WPS Hide Login - Version 1.8

Version Description

  • Fix multisite subdomain for website menu (Thanks Eric Celeste)
Download this release

Release Info

Developer NicolasKulka
Plugin Icon 128x128 WPS Hide Login
Version 1.8
Comparing to
See all releases

Code changes from version 1.7 to 1.8

Files changed (3) hide show
  1. classes/plugin.php +41 -7
  2. readme.txt +4 -1
  3. wps-hide-login.php +2 -2
classes/plugin.php CHANGED
@@ -55,6 +55,10 @@ class Plugin {
55
  ) );
56
  }
57
 
 
 
 
 
58
  add_action( 'admin_init', array( $this, 'admin_init' ) );
59
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 9999 );
60
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
@@ -126,13 +130,43 @@ class Plugin {
126
 
127
  }
128
 
129
- private function new_login_slug() {
130
- if ( $slug = get_option( 'whl_page' ) ) {
131
- return $slug;
132
- } else if ( ( is_multisite() && is_plugin_active_for_network( WPS_HIDE_LOGIN_BASENAME ) && ( $slug = get_site_option( 'whl_page', 'login' ) ) ) ) {
133
- return $slug;
134
- } else if ( $slug = 'login' ) {
135
- return $slug;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
  }
137
  }
138
 
55
  ) );
56
  }
57
 
58
+ if ( is_multisite() ) {
59
+ add_action( 'wp_before_admin_bar_render', array( $this, 'modify_mysites_menu' ), 999 );
60
+ }
61
+
62
  add_action( 'admin_init', array( $this, 'admin_init' ) );
63
  add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 9999 );
64
  add_action( 'admin_notices', array( $this, 'admin_notices' ) );
130
 
131
  }
132
 
133
+ public function modify_mysites_menu() {
134
+ global $wp_admin_bar;
135
+
136
+ $all_toolbar_nodes = $wp_admin_bar->get_nodes();
137
+
138
+ foreach ( $all_toolbar_nodes as $node ) {
139
+ if ( preg_match( '/^blog-(\d+)(.*)/', $node->id, $matches ) ) {
140
+ $blog_id = $matches[1];
141
+ if ( $login_slug = $this->new_login_slug( $blog_id ) ) {
142
+ if ( ! $matches[2] || '-d' === $matches[2] ) {
143
+ $args = $node;
144
+ $old_href = $args->href;
145
+ $args->href = preg_replace( '/wp-admin\/$/', "$login_slug/", $old_href );
146
+ if ( $old_href !== $arg->href ) {
147
+ $wp_admin_bar->add_node( $args );
148
+ }
149
+ } elseif ( strpos( $node->href, '/wp-admin/' ) !== false ) {
150
+ $wp_admin_bar->remove_node( $node->id );
151
+ }
152
+ }
153
+ }
154
+ }
155
+ }
156
+
157
+ private function new_login_slug( $blog_id = '' ) {
158
+ if ( $blog_id ) {
159
+ if ( $slug = get_blog_option( $blog_id, 'whl_page' ) ) {
160
+ return $slug;
161
+ }
162
+ } else {
163
+ if ( $slug = get_option( 'whl_page' ) ) {
164
+ return $slug;
165
+ } else if ( ( is_multisite() && is_plugin_active_for_network( WPS_HIDE_LOGIN_BASENAME ) && ( $slug = get_site_option( 'whl_page', 'login' ) ) ) ) {
166
+ return $slug;
167
+ } else if ( $slug = 'login' ) {
168
+ return $slug;
169
+ }
170
  }
171
  }
172
 
readme.txt CHANGED
@@ -6,7 +6,7 @@ Tags: rename, login, wp-login, wp-login.php, custom login url, jetpack, wpserveu
6
  Requires at least: 4.1
7
  Tested up to: 5.6
8
  Requires PHP: 7.0
9
- Stable tag: 1.7
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
@@ -148,6 +148,9 @@ La première étape consiste à vérifier votre fichier .htaccess et à le compa
148
 
149
  == Changelog ==
150
 
 
 
 
151
  = 1.7 =
152
  * Fix vulnerability (Thanks Sebastian Schmitt) : Posting "post_password" with arbitrary content to /wp-login.php reveals the normal wordpress login page.
153
 
6
  Requires at least: 4.1
7
  Tested up to: 5.6
8
  Requires PHP: 7.0
9
+ Stable tag: 1.8
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
12
 
148
 
149
  == Changelog ==
150
 
151
+ = 1.8 =
152
+ * Fix multisite subdomain for website menu (Thanks Eric Celeste)
153
+
154
  = 1.7 =
155
  * Fix vulnerability (Thanks Sebastian Schmitt) : Posting "post_password" with arbitrary content to /wp-login.php reveals the normal wordpress login page.
156
 
wps-hide-login.php CHANGED
@@ -5,7 +5,7 @@ Description: Protect your website by changing the login URL and preventing acces
5
  Donate link: https://www.paypal.me/donateWPServeur
6
  Author: WPServeur, NicolasKulka, wpformation
7
  Author URI: https://wpserveur.net
8
- Version: 1.7
9
  Requires at least: 4.1
10
  Tested up to: 5.6
11
  Requires PHP: 7.0
@@ -21,7 +21,7 @@ if ( ! defined( 'ABSPATH' ) ) {
21
  }
22
 
23
  // Plugin constants
24
- define( 'WPS_HIDE_LOGIN_VERSION', '1.7' );
25
  define( 'WPS_HIDE_LOGIN_FOLDER', 'wps-hide-login' );
26
 
27
  define( 'WPS_HIDE_LOGIN_URL', plugin_dir_url( __FILE__ ) );
5
  Donate link: https://www.paypal.me/donateWPServeur
6
  Author: WPServeur, NicolasKulka, wpformation
7
  Author URI: https://wpserveur.net
8
+ Version: 1.8
9
  Requires at least: 4.1
10
  Tested up to: 5.6
11
  Requires PHP: 7.0
21
  }
22
 
23
  // Plugin constants
24
+ define( 'WPS_HIDE_LOGIN_VERSION', '1.8' );
25
  define( 'WPS_HIDE_LOGIN_FOLDER', 'wps-hide-login' );
26
 
27
  define( 'WPS_HIDE_LOGIN_URL', plugin_dir_url( __FILE__ ) );