Version Description
- Enhancement: Compatibility 4.9.x
Download this release
Release Info
Developer | NicolasKulka |
Plugin | WPS Hide Login |
Version | 1.2.2 |
Comparing to | |
See all releases |
Code changes from version 1.2.1 to 1.2.2
- readme.txt +6 -3
- uninstall.php +6 -6
- wps-hide-login.php +118 -113
readme.txt
CHANGED
@@ -1,10 +1,10 @@
|
|
1 |
=== WPS Hide Login ===
|
2 |
|
3 |
-
Contributors: tabrisrp, WPServeur
|
4 |
Tags: rename, login, wp-login, wp-login.php, custom login url
|
5 |
Requires at least: 4.1
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.2.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -64,6 +64,9 @@ First step is to check your .htaccess file and compare it to a regular one, to s
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
|
|
|
|
|
|
67 |
= 1.2.1 =
|
68 |
* Enhancement: Prevent access to the login page by using the URL encoded version of wp-login.php
|
69 |
|
1 |
=== WPS Hide Login ===
|
2 |
|
3 |
+
Contributors: tabrisrp, WPServeur, nicolaskulka
|
4 |
Tags: rename, login, wp-login, wp-login.php, custom login url
|
5 |
Requires at least: 4.1
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 1.2.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 1.2.2 =
|
68 |
+
* Enhancement: Compatibility 4.9.x
|
69 |
+
|
70 |
= 1.2.1 =
|
71 |
* Enhancement: Prevent access to the login page by using the URL encoded version of wp-login.php
|
72 |
|
uninstall.php
CHANGED
@@ -19,23 +19,23 @@ global $wpdb;
|
|
19 |
if ( is_multisite() ) {
|
20 |
|
21 |
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
|
22 |
-
|
23 |
|
24 |
if ( $blogs ) {
|
25 |
|
26 |
-
|
27 |
switch_to_blog( $blog['blog_id'] );
|
28 |
-
delete_option('whl_page');
|
29 |
|
30 |
//info: optimize table
|
31 |
-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `"
|
32 |
restore_current_blog();
|
33 |
}
|
34 |
}
|
35 |
|
36 |
} else {
|
37 |
-
delete_option('whl_page');
|
38 |
|
39 |
//info: optimize table
|
40 |
-
$GLOBALS['wpdb']->query("OPTIMIZE TABLE `"
|
41 |
}
|
19 |
if ( is_multisite() ) {
|
20 |
|
21 |
$blogs = $wpdb->get_results( "SELECT blog_id FROM {$wpdb->blogs}", ARRAY_A );
|
22 |
+
delete_site_option( 'whl_page' );
|
23 |
|
24 |
if ( $blogs ) {
|
25 |
|
26 |
+
foreach ( $blogs as $blog ) {
|
27 |
switch_to_blog( $blog['blog_id'] );
|
28 |
+
delete_option( 'whl_page' );
|
29 |
|
30 |
//info: optimize table
|
31 |
+
$GLOBALS['wpdb']->query( "OPTIMIZE TABLE `" . $GLOBALS['wpdb']->prefix . "options`" );
|
32 |
restore_current_blog();
|
33 |
}
|
34 |
}
|
35 |
|
36 |
} else {
|
37 |
+
delete_option( 'whl_page' );
|
38 |
|
39 |
//info: optimize table
|
40 |
+
$GLOBALS['wpdb']->query( "OPTIMIZE TABLE `" . $GLOBALS['wpdb']->prefix . "options`" );
|
41 |
}
|
wps-hide-login.php
CHANGED
@@ -5,27 +5,28 @@ Plugin URI: https://github.com/Tabrisrp/wps-hide-login
|
|
5 |
Description: Protect your website by changing the login URL and preventing access to wp-login.php page and wp-admin directory while not logged-in
|
6 |
Author: Remy Perona for WPServeur
|
7 |
Author URI: http://profiles.wordpress.org/tabrisrp/
|
8 |
-
Version: 1.2.
|
|
|
|
|
9 |
Text Domain: wps-hide-login
|
10 |
License: GPLv2 or later
|
11 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
12 |
*/
|
13 |
|
14 |
-
if ( defined( 'ABSPATH' )
|
15 |
-
&& ! class_exists( 'WPS_Hide_Login' ) ) {
|
16 |
|
17 |
class WPS_Hide_Login {
|
18 |
|
19 |
private $wp_login_php;
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
|
30 |
private function basename() {
|
31 |
|
@@ -41,15 +42,13 @@ if ( defined( 'ABSPATH' )
|
|
41 |
|
42 |
private function use_trailing_slashes() {
|
43 |
|
44 |
-
return ( '/' === substr( get_option( 'permalink_structure' ), -1, 1 ) );
|
45 |
|
46 |
}
|
47 |
|
48 |
private function user_trailingslashit( $string ) {
|
49 |
|
50 |
-
return $this->use_trailing_slashes()
|
51 |
-
? trailingslashit( $string )
|
52 |
-
: untrailingslashit( $string );
|
53 |
|
54 |
}
|
55 |
|
@@ -84,9 +83,9 @@ if ( defined( 'ABSPATH' )
|
|
84 |
if ( $slug = get_option( 'whl_page' ) ) {
|
85 |
return $slug;
|
86 |
} else if ( ( is_multisite() && is_plugin_active_for_network( $this->basename() ) && ( $slug = get_site_option( 'whl_page', 'login' ) ) ) ) {
|
87 |
-
|
88 |
} else if ( $slug = 'login' ) {
|
89 |
-
|
90 |
}
|
91 |
|
92 |
}
|
@@ -106,57 +105,63 @@ if ( defined( 'ABSPATH' )
|
|
106 |
}
|
107 |
|
108 |
public function __construct() {
|
109 |
-
|
110 |
|
111 |
global $wp_version;
|
112 |
|
113 |
if ( version_compare( $wp_version, '4.0-RC1-src', '<' ) ) {
|
114 |
add_action( 'admin_notices', array( $this, 'admin_notices_incompatible' ) );
|
115 |
add_action( 'network_admin_notices', array( $this, 'admin_notices_incompatible' ) );
|
|
|
116 |
return;
|
117 |
}
|
118 |
|
119 |
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
}
|
124 |
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
142 |
|
143 |
register_activation_hook( $this->basename(), array( $this, 'activate' ) );
|
144 |
|
145 |
if ( is_multisite() && is_plugin_active_for_network( $this->basename() ) ) {
|
146 |
-
|
147 |
add_action( 'update_wpmu_options', array( $this, 'update_wpmu_options' ) );
|
148 |
|
149 |
-
add_filter( 'network_admin_plugin_action_links_' . $this->basename(), array(
|
|
|
|
|
|
|
150 |
}
|
151 |
|
152 |
-
|
153 |
-
|
154 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
155 |
add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
|
156 |
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
|
157 |
add_action( 'setup_theme', array( $this, 'setup_theme' ), 1 );
|
158 |
|
159 |
-
|
160 |
add_filter( 'site_url', array( $this, 'site_url' ), 10, 4 );
|
161 |
add_filter( 'network_site_url', array( $this, 'network_site_url' ), 10, 3 );
|
162 |
add_filter( 'wp_redirect', array( $this, 'wp_redirect' ), 10, 2 );
|
@@ -166,37 +171,37 @@ if ( defined( 'ABSPATH' )
|
|
166 |
|
167 |
}
|
168 |
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
|
186 |
public function admin_notices_incompatible() {
|
187 |
|
188 |
-
echo '<div class="error notice is-dismissible"><p>' . __( 'Please upgrade to the latest version of WordPress to activate', 'wps-hide-login') . ' <strong>' . __( 'WPS Hide Login', 'wps-hide-login') . '</strong>.</p></div>';
|
189 |
|
190 |
}
|
191 |
|
192 |
-
|
193 |
|
194 |
-
echo '<div class="error notice is-dismissible"><p>' . __( 'WPS Hide Login could not be activated because you already have Rename wp-login.php active. Please uninstall rename wp-login.php to use WPS Hide Login', 'wps-hide-login') . '</p></div>';
|
195 |
|
196 |
}
|
197 |
|
198 |
public function activate() {
|
199 |
-
|
200 |
add_option( 'whl_redirect', '1' );
|
201 |
|
202 |
delete_option( 'whl_admin' );
|
@@ -207,14 +212,14 @@ if ( defined( 'ABSPATH' )
|
|
207 |
|
208 |
$out = '';
|
209 |
|
210 |
-
$out .= '<h3>' . __( 'WPS Hide Login', 'wps-hide-login') . '</h3>';
|
211 |
$out .= '<p>' . __( 'This option allows you to set a networkwide default, which can be overridden by individual sites. Simply go to to the site’s permalink settings to change the url.', 'wps-hide-login' ) . '</p>';
|
212 |
$out .= '<p>' . sprintf( __( 'Need help? Try the <a href="%1$s" target="_blank">support forum</a>. This plugin is kindly brought to you by <a href="%2$s" target="_blank">WPServeur</a>.', 'wps-hide-login' ), 'http://wordpress.org/support/plugin/wps-hide-login/', 'https://www.wpserveur.net' ) . '</p>';
|
213 |
$out .= '<table class="form-table">';
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
$out .= '</table>';
|
219 |
|
220 |
echo $out;
|
@@ -222,15 +227,15 @@ if ( defined( 'ABSPATH' )
|
|
222 |
}
|
223 |
|
224 |
public function update_wpmu_options() {
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
}
|
235 |
|
236 |
public function admin_init() {
|
@@ -251,7 +256,7 @@ if ( defined( 'ABSPATH' )
|
|
251 |
'general',
|
252 |
'wps-hide-login-section'
|
253 |
);
|
254 |
-
|
255 |
register_setting( 'general', 'whl_page', 'sanitize_title_with_dashes' );
|
256 |
|
257 |
if ( get_option( 'whl_redirect' ) ) {
|
@@ -259,8 +264,8 @@ if ( defined( 'ABSPATH' )
|
|
259 |
delete_option( 'whl_redirect' );
|
260 |
|
261 |
if ( is_multisite()
|
262 |
-
|
263 |
-
|
264 |
|
265 |
$redirect = network_admin_url( 'settings.php#whl-page-input' );
|
266 |
|
@@ -283,15 +288,15 @@ if ( defined( 'ABSPATH' )
|
|
283 |
$out = '';
|
284 |
|
285 |
if ( ! is_multisite()
|
286 |
-
|
287 |
|
288 |
$out .= '<p>' . sprintf( __( 'Need help? Try the <a href="%1$s" target="_blank">support forum</a>. This plugin is kindly brought to you by <a href="%2$s" target="_blank">WPServeur</a>.', 'wps-hide-login' ), 'http://wordpress.org/support/plugin/wps-hide-login/', 'https://www.wpserveur.net' ) . '</p>';
|
289 |
|
290 |
}
|
291 |
|
292 |
if ( is_multisite()
|
293 |
-
|
294 |
-
|
295 |
|
296 |
$out .= '<p>' . sprintf( __( 'To set a networkwide default, go to <a href="%s">Network Settings</a>.', 'wps-hide-login' ), network_admin_url( 'settings.php#whl-page-input' ) ) . '</p>';
|
297 |
|
@@ -305,11 +310,11 @@ if ( defined( 'ABSPATH' )
|
|
305 |
|
306 |
if ( get_option( 'permalink_structure' ) ) {
|
307 |
|
308 |
-
echo '<code>' . trailingslashit( home_url() ) . '</code> <input id="whl_page" type="text" name="whl_page" value="' . $this->new_login_slug()
|
309 |
|
310 |
} else {
|
311 |
|
312 |
-
echo '<code>' . trailingslashit( home_url() ) . '?</code> <input id="whl_page" type="text" name="whl_page" value="' . $this->new_login_slug()
|
313 |
|
314 |
}
|
315 |
|
@@ -322,9 +327,9 @@ if ( defined( 'ABSPATH' )
|
|
322 |
$out = '';
|
323 |
|
324 |
if ( ! is_network_admin()
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
|
329 |
echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( 'Your login page is now here: <strong><a href="%1$s">%2$s</a></strong>. Bookmark this page!', 'wps-hide-login' ), $this->new_login_url(), $this->new_login_url() ) . '</p></div>';
|
330 |
|
@@ -335,7 +340,7 @@ if ( defined( 'ABSPATH' )
|
|
335 |
public function plugin_action_links( $links ) {
|
336 |
|
337 |
if ( is_network_admin()
|
338 |
-
|
339 |
|
340 |
array_unshift( $links, '<a href="' . network_admin_url( 'settings.php#whl-page-input' ) . '">' . __( 'Settings', 'wps-hide-login' ) . '</a>' );
|
341 |
|
@@ -354,8 +359,8 @@ if ( defined( 'ABSPATH' )
|
|
354 |
global $pagenow;
|
355 |
|
356 |
if ( ! is_multisite()
|
357 |
-
|
358 |
-
|
359 |
|
360 |
wp_die( __( 'This feature is not enabled.', 'wps-hide-login' ) );
|
361 |
|
@@ -364,8 +369,8 @@ if ( defined( 'ABSPATH' )
|
|
364 |
$request = parse_url( $_SERVER['REQUEST_URI'] );
|
365 |
|
366 |
if ( ( strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-login.php' ) !== false
|
367 |
-
|
368 |
-
|
369 |
|
370 |
$this->wp_login_php = true;
|
371 |
|
@@ -374,9 +379,9 @@ if ( defined( 'ABSPATH' )
|
|
374 |
$pagenow = 'index.php';
|
375 |
|
376 |
} elseif ( untrailingslashit( $request['path'] ) === home_url( $this->new_login_slug(), 'relative' )
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
|
381 |
$pagenow = 'wp-login.php';
|
382 |
|
@@ -397,38 +402,38 @@ if ( defined( 'ABSPATH' )
|
|
397 |
global $pagenow;
|
398 |
|
399 |
if ( is_admin() && ! is_user_logged_in() && ! defined( 'DOING_AJAX' ) && $pagenow !== 'admin-post.php' ) {
|
400 |
-
|
401 |
}
|
402 |
|
403 |
$request = parse_url( $_SERVER['REQUEST_URI'] );
|
404 |
|
405 |
if ( $pagenow === 'wp-login.php'
|
406 |
-
|
407 |
-
|
408 |
|
409 |
wp_safe_redirect( $this->user_trailingslashit( $this->new_login_url() )
|
410 |
-
|
411 |
|
412 |
die;
|
413 |
|
414 |
} elseif ( $this->wp_login_php ) {
|
415 |
|
416 |
if ( ( $referer = wp_get_referer() )
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
|
421 |
parse_str( $referer['query'], $referer );
|
422 |
|
423 |
if ( ! empty( $referer['key'] )
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
|
429 |
wp_safe_redirect( $this->new_login_url()
|
430 |
-
|
431 |
-
|
432 |
die;
|
433 |
|
434 |
}
|
@@ -439,7 +444,7 @@ if ( defined( 'ABSPATH' )
|
|
439 |
|
440 |
} elseif ( $pagenow === 'wp-login.php' ) {
|
441 |
global $error, $interim_login, $action, $user_login;
|
442 |
-
|
443 |
if ( is_user_logged_in() && ! isset( $_REQUEST['action'] ) ) {
|
444 |
wp_safe_redirect( admin_url() );
|
445 |
die();
|
@@ -515,9 +520,9 @@ if ( defined( 'ABSPATH' )
|
|
515 |
|
516 |
}
|
517 |
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
|
522 |
}
|
523 |
|
5 |
Description: Protect your website by changing the login URL and preventing access to wp-login.php page and wp-admin directory while not logged-in
|
6 |
Author: Remy Perona for WPServeur
|
7 |
Author URI: http://profiles.wordpress.org/tabrisrp/
|
8 |
+
Version: 1.2.2
|
9 |
+
Requires at least: 4.1
|
10 |
+
Tested up to: 4.9
|
11 |
Text Domain: wps-hide-login
|
12 |
License: GPLv2 or later
|
13 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
14 |
*/
|
15 |
|
16 |
+
if ( defined( 'ABSPATH' ) && ! class_exists( 'WPS_Hide_Login' ) ) {
|
|
|
17 |
|
18 |
class WPS_Hide_Login {
|
19 |
|
20 |
private $wp_login_php;
|
21 |
|
22 |
+
/**
|
23 |
+
* Instance of this class.
|
24 |
+
*
|
25 |
+
* @since 1.0.0
|
26 |
+
*
|
27 |
+
* @var object
|
28 |
+
*/
|
29 |
+
protected static $instance = null;
|
30 |
|
31 |
private function basename() {
|
32 |
|
42 |
|
43 |
private function use_trailing_slashes() {
|
44 |
|
45 |
+
return ( '/' === substr( get_option( 'permalink_structure' ), - 1, 1 ) );
|
46 |
|
47 |
}
|
48 |
|
49 |
private function user_trailingslashit( $string ) {
|
50 |
|
51 |
+
return $this->use_trailing_slashes() ? trailingslashit( $string ) : untrailingslashit( $string );
|
|
|
|
|
52 |
|
53 |
}
|
54 |
|
83 |
if ( $slug = get_option( 'whl_page' ) ) {
|
84 |
return $slug;
|
85 |
} else if ( ( is_multisite() && is_plugin_active_for_network( $this->basename() ) && ( $slug = get_site_option( 'whl_page', 'login' ) ) ) ) {
|
86 |
+
return $slug;
|
87 |
} else if ( $slug = 'login' ) {
|
88 |
+
return $slug;
|
89 |
}
|
90 |
|
91 |
}
|
105 |
}
|
106 |
|
107 |
public function __construct() {
|
108 |
+
add_action( 'plugins_loaded', array( $this, 'whl_load_textdomain' ), 9 );
|
109 |
|
110 |
global $wp_version;
|
111 |
|
112 |
if ( version_compare( $wp_version, '4.0-RC1-src', '<' ) ) {
|
113 |
add_action( 'admin_notices', array( $this, 'admin_notices_incompatible' ) );
|
114 |
add_action( 'network_admin_notices', array( $this, 'admin_notices_incompatible' ) );
|
115 |
+
|
116 |
return;
|
117 |
}
|
118 |
|
119 |
|
120 |
+
if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) || ! function_exists( 'is_plugin_active' ) ) {
|
121 |
+
require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
|
122 |
+
|
123 |
}
|
124 |
|
125 |
+
if ( is_plugin_active_for_network( 'rename-wp-login/rename-wp-login.php' ) ) {
|
126 |
+
deactivate_plugins( plugin_basename( __FILE__ ) );
|
127 |
+
add_action( 'network_admin_notices', array( $this, 'admin_notices_plugin_conflict' ) );
|
128 |
+
if ( isset( $_GET['activate'] ) ) {
|
129 |
+
unset( $_GET['activate'] );
|
130 |
+
}
|
131 |
+
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
if ( is_plugin_active( 'rename-wp-login/rename-wp-login.php' ) ) {
|
136 |
+
deactivate_plugins( plugin_basename( __FILE__ ) );
|
137 |
+
add_action( 'admin_notices', array( $this, 'admin_notices_plugin_conflict' ) );
|
138 |
+
if ( isset( $_GET['activate'] ) ) {
|
139 |
+
unset( $_GET['activate'] );
|
140 |
+
}
|
141 |
+
|
142 |
+
return;
|
143 |
+
}
|
144 |
|
145 |
register_activation_hook( $this->basename(), array( $this, 'activate' ) );
|
146 |
|
147 |
if ( is_multisite() && is_plugin_active_for_network( $this->basename() ) ) {
|
148 |
+
add_action( 'wpmu_options', array( $this, 'wpmu_options' ) );
|
149 |
add_action( 'update_wpmu_options', array( $this, 'update_wpmu_options' ) );
|
150 |
|
151 |
+
add_filter( 'network_admin_plugin_action_links_' . $this->basename(), array(
|
152 |
+
$this,
|
153 |
+
'plugin_action_links'
|
154 |
+
) );
|
155 |
}
|
156 |
|
157 |
+
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
158 |
+
add_action( 'plugins_loaded', array( $this, 'plugins_loaded' ), 2 );
|
159 |
add_action( 'admin_notices', array( $this, 'admin_notices' ) );
|
160 |
add_action( 'network_admin_notices', array( $this, 'admin_notices' ) );
|
161 |
add_action( 'wp_loaded', array( $this, 'wp_loaded' ) );
|
162 |
add_action( 'setup_theme', array( $this, 'setup_theme' ), 1 );
|
163 |
|
164 |
+
add_filter( 'plugin_action_links_' . $this->basename(), array( $this, 'plugin_action_links' ) );
|
165 |
add_filter( 'site_url', array( $this, 'site_url' ), 10, 4 );
|
166 |
add_filter( 'network_site_url', array( $this, 'network_site_url' ), 10, 3 );
|
167 |
add_filter( 'wp_redirect', array( $this, 'wp_redirect' ), 10, 2 );
|
171 |
|
172 |
}
|
173 |
|
174 |
+
/**
|
175 |
+
* Return an instance of this class.
|
176 |
+
*
|
177 |
+
* @since 1.0.0
|
178 |
+
*
|
179 |
+
* @return object A single instance of this class.
|
180 |
+
*/
|
181 |
+
public static function get_instance() {
|
182 |
+
|
183 |
+
// If the single instance hasn't been set, set it now.
|
184 |
+
if ( null == self::$instance ) {
|
185 |
+
self::$instance = new self;
|
186 |
+
}
|
187 |
+
|
188 |
+
return self::$instance;
|
189 |
+
}
|
190 |
|
191 |
public function admin_notices_incompatible() {
|
192 |
|
193 |
+
echo '<div class="error notice is-dismissible"><p>' . __( 'Please upgrade to the latest version of WordPress to activate', 'wps-hide-login' ) . ' <strong>' . __( 'WPS Hide Login', 'wps-hide-login' ) . '</strong>.</p></div>';
|
194 |
|
195 |
}
|
196 |
|
197 |
+
public function admin_notices_plugin_conflict() {
|
198 |
|
199 |
+
echo '<div class="error notice is-dismissible"><p>' . __( 'WPS Hide Login could not be activated because you already have Rename wp-login.php active. Please uninstall rename wp-login.php to use WPS Hide Login', 'wps-hide-login' ) . '</p></div>';
|
200 |
|
201 |
}
|
202 |
|
203 |
public function activate() {
|
204 |
+
|
205 |
add_option( 'whl_redirect', '1' );
|
206 |
|
207 |
delete_option( 'whl_admin' );
|
212 |
|
213 |
$out = '';
|
214 |
|
215 |
+
$out .= '<h3>' . __( 'WPS Hide Login', 'wps-hide-login' ) . '</h3>';
|
216 |
$out .= '<p>' . __( 'This option allows you to set a networkwide default, which can be overridden by individual sites. Simply go to to the site’s permalink settings to change the url.', 'wps-hide-login' ) . '</p>';
|
217 |
$out .= '<p>' . sprintf( __( 'Need help? Try the <a href="%1$s" target="_blank">support forum</a>. This plugin is kindly brought to you by <a href="%2$s" target="_blank">WPServeur</a>.', 'wps-hide-login' ), 'http://wordpress.org/support/plugin/wps-hide-login/', 'https://www.wpserveur.net' ) . '</p>';
|
218 |
$out .= '<table class="form-table">';
|
219 |
+
$out .= '<tr valign="top">';
|
220 |
+
$out .= '<th scope="row"><label for="whl_page">' . __( 'Networkwide default', 'wps-hide-login' ) . '</label></th>';
|
221 |
+
$out .= '<td><input id="whl_page" type="text" name="whl_page" value="' . esc_attr( get_site_option( 'whl_page', 'login' ) ) . '"></td>';
|
222 |
+
$out .= '</tr>';
|
223 |
$out .= '</table>';
|
224 |
|
225 |
echo $out;
|
227 |
}
|
228 |
|
229 |
public function update_wpmu_options() {
|
230 |
+
if ( check_admin_referer( 'siteoptions' ) ) {
|
231 |
+
if ( ( $whl_page = sanitize_title_with_dashes( $_POST['whl_page'] ) )
|
232 |
+
&& strpos( $whl_page, 'wp-login' ) === false
|
233 |
+
&& ! in_array( $whl_page, $this->forbidden_slugs() ) ) {
|
234 |
+
|
235 |
+
update_site_option( 'whl_page', $whl_page );
|
236 |
+
|
237 |
+
}
|
238 |
+
}
|
239 |
}
|
240 |
|
241 |
public function admin_init() {
|
256 |
'general',
|
257 |
'wps-hide-login-section'
|
258 |
);
|
259 |
+
|
260 |
register_setting( 'general', 'whl_page', 'sanitize_title_with_dashes' );
|
261 |
|
262 |
if ( get_option( 'whl_redirect' ) ) {
|
264 |
delete_option( 'whl_redirect' );
|
265 |
|
266 |
if ( is_multisite()
|
267 |
+
&& is_super_admin()
|
268 |
+
&& is_plugin_active_for_network( $this->basename() ) ) {
|
269 |
|
270 |
$redirect = network_admin_url( 'settings.php#whl-page-input' );
|
271 |
|
288 |
$out = '';
|
289 |
|
290 |
if ( ! is_multisite()
|
291 |
+
|| is_super_admin() ) {
|
292 |
|
293 |
$out .= '<p>' . sprintf( __( 'Need help? Try the <a href="%1$s" target="_blank">support forum</a>. This plugin is kindly brought to you by <a href="%2$s" target="_blank">WPServeur</a>.', 'wps-hide-login' ), 'http://wordpress.org/support/plugin/wps-hide-login/', 'https://www.wpserveur.net' ) . '</p>';
|
294 |
|
295 |
}
|
296 |
|
297 |
if ( is_multisite()
|
298 |
+
&& is_super_admin()
|
299 |
+
&& is_plugin_active_for_network( $this->basename() ) ) {
|
300 |
|
301 |
$out .= '<p>' . sprintf( __( 'To set a networkwide default, go to <a href="%s">Network Settings</a>.', 'wps-hide-login' ), network_admin_url( 'settings.php#whl-page-input' ) ) . '</p>';
|
302 |
|
310 |
|
311 |
if ( get_option( 'permalink_structure' ) ) {
|
312 |
|
313 |
+
echo '<code>' . trailingslashit( home_url() ) . '</code> <input id="whl_page" type="text" name="whl_page" value="' . $this->new_login_slug() . '">' . ( $this->use_trailing_slashes() ? ' <code>/</code>' : '' );
|
314 |
|
315 |
} else {
|
316 |
|
317 |
+
echo '<code>' . trailingslashit( home_url() ) . '?</code> <input id="whl_page" type="text" name="whl_page" value="' . $this->new_login_slug() . '">';
|
318 |
|
319 |
}
|
320 |
|
327 |
$out = '';
|
328 |
|
329 |
if ( ! is_network_admin()
|
330 |
+
&& $pagenow === 'options-general.php'
|
331 |
+
&& isset( $_GET['settings-updated'] )
|
332 |
+
&& ! isset( $_GET['page'] ) ) {
|
333 |
|
334 |
echo '<div class="updated notice is-dismissible"><p>' . sprintf( __( 'Your login page is now here: <strong><a href="%1$s">%2$s</a></strong>. Bookmark this page!', 'wps-hide-login' ), $this->new_login_url(), $this->new_login_url() ) . '</p></div>';
|
335 |
|
340 |
public function plugin_action_links( $links ) {
|
341 |
|
342 |
if ( is_network_admin()
|
343 |
+
&& is_plugin_active_for_network( $this->basename() ) ) {
|
344 |
|
345 |
array_unshift( $links, '<a href="' . network_admin_url( 'settings.php#whl-page-input' ) . '">' . __( 'Settings', 'wps-hide-login' ) . '</a>' );
|
346 |
|
359 |
global $pagenow;
|
360 |
|
361 |
if ( ! is_multisite()
|
362 |
+
&& ( strpos( $_SERVER['REQUEST_URI'], 'wp-signup' ) !== false
|
363 |
+
|| strpos( $_SERVER['REQUEST_URI'], 'wp-activate' ) ) !== false ) {
|
364 |
|
365 |
wp_die( __( 'This feature is not enabled.', 'wps-hide-login' ) );
|
366 |
|
369 |
$request = parse_url( $_SERVER['REQUEST_URI'] );
|
370 |
|
371 |
if ( ( strpos( rawurldecode( $_SERVER['REQUEST_URI'] ), 'wp-login.php' ) !== false
|
372 |
+
|| untrailingslashit( $request['path'] ) === site_url( 'wp-login', 'relative' ) )
|
373 |
+
&& ! is_admin() ) {
|
374 |
|
375 |
$this->wp_login_php = true;
|
376 |
|
379 |
$pagenow = 'index.php';
|
380 |
|
381 |
} elseif ( untrailingslashit( $request['path'] ) === home_url( $this->new_login_slug(), 'relative' )
|
382 |
+
|| ( ! get_option( 'permalink_structure' )
|
383 |
+
&& isset( $_GET[ $this->new_login_slug() ] )
|
384 |
+
&& empty( $_GET[ $this->new_login_slug() ] ) ) ) {
|
385 |
|
386 |
$pagenow = 'wp-login.php';
|
387 |
|
402 |
global $pagenow;
|
403 |
|
404 |
if ( is_admin() && ! is_user_logged_in() && ! defined( 'DOING_AJAX' ) && $pagenow !== 'admin-post.php' ) {
|
405 |
+
wp_die( __( 'This has been disabled', 'wps-hide-login' ), 403 );
|
406 |
}
|
407 |
|
408 |
$request = parse_url( $_SERVER['REQUEST_URI'] );
|
409 |
|
410 |
if ( $pagenow === 'wp-login.php'
|
411 |
+
&& $request['path'] !== $this->user_trailingslashit( $request['path'] )
|
412 |
+
&& get_option( 'permalink_structure' ) ) {
|
413 |
|
414 |
wp_safe_redirect( $this->user_trailingslashit( $this->new_login_url() )
|
415 |
+
. ( ! empty( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '' ) );
|
416 |
|
417 |
die;
|
418 |
|
419 |
} elseif ( $this->wp_login_php ) {
|
420 |
|
421 |
if ( ( $referer = wp_get_referer() )
|
422 |
+
&& strpos( $referer, 'wp-activate.php' ) !== false
|
423 |
+
&& ( $referer = parse_url( $referer ) )
|
424 |
+
&& ! empty( $referer['query'] ) ) {
|
425 |
|
426 |
parse_str( $referer['query'], $referer );
|
427 |
|
428 |
if ( ! empty( $referer['key'] )
|
429 |
+
&& ( $result = wpmu_activate_signup( $referer['key'] ) )
|
430 |
+
&& is_wp_error( $result )
|
431 |
+
&& ( $result->get_error_code() === 'already_active'
|
432 |
+
|| $result->get_error_code() === 'blog_taken' ) ) {
|
433 |
|
434 |
wp_safe_redirect( $this->new_login_url()
|
435 |
+
. ( ! empty( $_SERVER['QUERY_STRING'] ) ? '?' . $_SERVER['QUERY_STRING'] : '' ) );
|
436 |
+
|
437 |
die;
|
438 |
|
439 |
}
|
444 |
|
445 |
} elseif ( $pagenow === 'wp-login.php' ) {
|
446 |
global $error, $interim_login, $action, $user_login;
|
447 |
+
|
448 |
if ( is_user_logged_in() && ! isset( $_REQUEST['action'] ) ) {
|
449 |
wp_safe_redirect( admin_url() );
|
450 |
die();
|
520 |
|
521 |
}
|
522 |
|
523 |
+
public function whl_load_textdomain() {
|
524 |
+
load_plugin_textdomain( 'wps-hide-login', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' );
|
525 |
+
}
|
526 |
|
527 |
}
|
528 |
|