Rename wp-login.php - Version 2.0.1

Version Description

  • Prevents pretty redirects such as /login and /admin.
  • Simplifies some code.
  • Forces login page with trailing slash.
  • Replaces a wp_redirect with wp_safe_redirect.
  • Shows error message in the network admin if permalinks are not enabled for the main site.
Download this release

Release Info

Developer avryl
Plugin Icon 128x128 Rename wp-login.php
Version 2.0.1
Comparing to
See all releases

Code changes from version 2.0 to 2.0.1

Files changed (3) hide show
  1. readme.md +9 -1
  2. readme.txt +9 -1
  3. rename-wp-login.php +16 -35
readme.md CHANGED
@@ -4,7 +4,7 @@
4
  **Tags:** rename, login, wp-login, wp-login.php, brute force attacks, custom login url
5
  **Requires at least:** 3.8
6
  **Tested up to:** 3.8
7
- **Stable tag:** 2.0
8
  **License:** GPLv2 or later
9
  **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -62,6 +62,14 @@ Either go to your MySQL database and look for the value of `rwl_page` in the opt
62
 
63
  ## Changelog
64
 
 
 
 
 
 
 
 
 
65
  ### 2.0
66
 
67
  * This plugin can now be activated for a network and a networkwide default can be set.
4
  **Tags:** rename, login, wp-login, wp-login.php, brute force attacks, custom login url
5
  **Requires at least:** 3.8
6
  **Tested up to:** 3.8
7
+ **Stable tag:** 2.0.1
8
  **License:** GPLv2 or later
9
  **License URI:** http://www.gnu.org/licenses/gpl-2.0.html
10
 
62
 
63
  ## Changelog
64
 
65
+ ### 2.0.1
66
+
67
+ * Prevents pretty redirects such as /login and /admin.
68
+ * Simplifies some code.
69
+ * Forces login page with trailing slash.
70
+ * Replaces a wp_redirect with wp_safe_redirect.
71
+ * Shows error message in the network admin if permalinks are not enabled for the main site.
72
+
73
  ### 2.0
74
 
75
  * This plugin can now be activated for a network and a networkwide default can be set.
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: avryl
4
  Tags: rename, login, wp-login, wp-login.php, brute force attacks, custom login url
5
  Requires at least: 3.8
6
  Tested up to: 3.8
7
- Stable tag: 2.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -66,6 +66,14 @@ Either go to your MySQL database and look for the value of `rwl_page` in the opt
66
 
67
  == Changelog ==
68
 
 
 
 
 
 
 
 
 
69
  = 2.0 =
70
 
71
  * This plugin can now be activated for a network and a networkwide default can be set.
4
  Tags: rename, login, wp-login, wp-login.php, brute force attacks, custom login url
5
  Requires at least: 3.8
6
  Tested up to: 3.8
7
+ Stable tag: 2.0.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
66
 
67
  == Changelog ==
68
 
69
+ = 2.0.1 =
70
+
71
+ * Prevents pretty redirects such as /login and /admin.
72
+ * Simplifies some code.
73
+ * Forces login page with trailing slash.
74
+ * Replaces a wp_redirect with wp_safe_redirect.
75
+ * Shows error message in the network admin if permalinks are not enabled for the main site.
76
+
77
  = 2.0 =
78
 
79
  * This plugin can now be activated for a network and a networkwide default can be set.
rename-wp-login.php CHANGED
@@ -6,7 +6,7 @@ Plugin URI: http://wordpress.org/plugins/rename-wp-login/
6
  Description: Change wp-login.php to whatever you want. It can also prevent a lot of brute force attacks.
7
  Author: avryl
8
  Author URI: http://profiles.wordpress.org/avryl/
9
- Version: 2.0
10
  Text Domain: rename-wp-login
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -68,19 +68,7 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
68
 
69
  }
70
 
71
- public static function instance() {
72
-
73
- global $rwl;
74
-
75
- if ( ! $rwl ) {
76
-
77
- $rwl = new self;
78
-
79
- }
80
-
81
- }
82
-
83
- private function __construct() {
84
 
85
  global $wp_version;
86
 
@@ -130,6 +118,8 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
130
  add_filter( 'site_url', array( $this, 'site_url' ), 10, 2 );
131
  add_filter( 'network_site_url', array( $this, 'site_url' ), 10, 2 );
132
  add_filter( 'wp_redirect', array( $this, 'wp_redirect' ), 10, 2 );
 
 
133
 
134
  }
135
 
@@ -292,7 +282,7 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
292
 
293
  }
294
 
295
- wp_redirect( $redirect );
296
 
297
  die;
298
 
@@ -335,8 +325,7 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
335
 
336
  $out = '';
337
 
338
- if ( ! is_network_admin()
339
- && ! get_option( 'permalink_structure' ) ) {
340
 
341
  $out .= '<div class="error"><p><strong>Rename wp-login.php</strong> doesn’t work if you’re using the default permalink structure.<br>You must <a href="' . admin_url( 'options-permalink.php' ) . '">choose</a> another permalink structure for it to work.</p></div>';
342
 
@@ -391,31 +380,23 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
391
 
392
  }
393
 
394
- if ( strpos( $_SERVER['REQUEST_URI'], $this->new_login_slug() ) !== false ) {
395
 
396
- $home_url = parse_url( home_url() );
397
 
398
- $home_path = '';
399
- if ( isset( $home_url['path'] ) )
400
- $home_path = $home_url['path'];
401
- $home_path = trim( $home_path, '/' );
402
 
403
- $req_uri = $_SERVER['REQUEST_URI'];
404
- $req_uri_array = explode( '?', $req_uri );
405
- $req_uri = $req_uri_array[0];
406
- $req_uri = trim( $req_uri, '/' );
407
- $req_uri = preg_replace( "|^$home_path|i", '', $req_uri );
408
- $req_uri = trim( $req_uri, '/' );
409
 
410
- if ( $req_uri === $this->new_login_slug() ) {
411
 
412
- status_header( 200 );
413
 
414
- require_once( $this->path() . 'rwl-login.php' );
415
 
416
- die;
417
 
418
- }
419
 
420
  }
421
 
@@ -482,6 +463,6 @@ if ( ! class_exists( 'Rename_WP_Login' ) ) {
482
 
483
  }
484
 
485
- Rename_WP_Login::instance();
486
 
487
  }
6
  Description: Change wp-login.php to whatever you want. It can also prevent a lot of brute force attacks.
7
  Author: avryl
8
  Author URI: http://profiles.wordpress.org/avryl/
9
+ Version: 2.0.1
10
  Text Domain: rename-wp-login
11
  License: GPLv2 or later
12
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
68
 
69
  }
70
 
71
+ public function __construct() {
 
 
 
 
 
 
 
 
 
 
 
 
72
 
73
  global $wp_version;
74
 
118
  add_filter( 'site_url', array( $this, 'site_url' ), 10, 2 );
119
  add_filter( 'network_site_url', array( $this, 'site_url' ), 10, 2 );
120
  add_filter( 'wp_redirect', array( $this, 'wp_redirect' ), 10, 2 );
121
+
122
+ remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 );
123
 
124
  }
125
 
282
 
283
  }
284
 
285
+ wp_safe_redirect( $redirect );
286
 
287
  die;
288
 
325
 
326
  $out = '';
327
 
328
+ if ( ! get_option( 'permalink_structure' ) ) {
 
329
 
330
  $out .= '<div class="error"><p><strong>Rename wp-login.php</strong> doesn’t work if you’re using the default permalink structure.<br>You must <a href="' . admin_url( 'options-permalink.php' ) . '">choose</a> another permalink structure for it to work.</p></div>';
331
 
380
 
381
  }
382
 
383
+ $request = parse_url( $_SERVER['REQUEST_URI'] );
384
 
385
+ if ( $request['path'] === home_url( $this->new_login_slug(), 'relative' ) ) {
386
 
387
+ wp_safe_redirect( $this->new_login_url() );
 
 
 
388
 
389
+ die;
 
 
 
 
 
390
 
391
+ }
392
 
393
+ if ( untrailingslashit( $request['path'] ) === home_url( $this->new_login_slug(), 'relative' ) ) {
394
 
395
+ status_header( 200 );
396
 
397
+ require_once( $this->path() . 'rwl-login.php' );
398
 
399
+ die;
400
 
401
  }
402
 
463
 
464
  }
465
 
466
+ new Rename_WP_Login;
467
 
468
  }