Skip to content

Instantly share code, notes, and snippets.

@mondalaci
Created January 11, 2026 20:37
Show Gist options
  • Select an option

  • Save mondalaci/5d60a23914baf1ed3b6db55b42b556a2 to your computer and use it in GitHub Desktop.

Select an option

Save mondalaci/5d60a23914baf1ed3b6db55b42b556a2 to your computer and use it in GitHub Desktop.
--- a/classes/plugin.php
+++ b/classes/plugin.php
@@ -60,6 +60,7 @@ class Plugin {
add_action( 'admin_init', array( $this, 'admin_init' ) );
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 9999 );
+ add_action( 'init', array( $this, 'init_block_access' ) );
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
@@ -490,14 +491,6 @@ class Plugin {
global $pagenow;
- if ( ! is_multisite()
- && ( strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-signup' ) !== false
- || strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-activate' ) !== false ) && apply_filters( 'wps_hide_login_signup_enable', false ) === false ) {
-
- wp_die( __( 'This feature is not enabled.', 'wps-hide-login' ) );
-
- }
-
$request = parse_url( rawurldecode( $_SERVER['REQUEST_URI'] ) );
if ( ( strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-login.php' ) !== false
@@ -536,6 +529,19 @@ class Plugin {
}
}
+ /**
+ * Block access to wp-signup.php and wp-activate.php on non-multisite installations.
+ * This runs on 'init' hook to ensure translations are loaded.
+ */
+ public function init_block_access() {
+ if ( ! is_multisite()
+ && ( strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-signup' ) !== false
+ || strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-activate' ) !== false ) && apply_filters( 'wps_hide_login_signup_enable', false ) === false ) {
+
+ wp_die( __( 'This feature is not enabled.', 'wps-hide-login' ) );
+
+ }
+ }
+
public function wp_loaded() {
global $pagenow;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment