Rename wp-login.php - Version 1.3

Version Description

  • Prevents the plugin from working when there is no permalink structure.
Download this release

Release Info

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

Code changes from version 1.1 to 1.3

Files changed (2) hide show
  1. readme.txt +12 -4
  2. rename-wp-login.php +54 -33
readme.txt CHANGED
@@ -1,4 +1,4 @@
1
- === Plugin Name ===
2
  Contributors: avryl
3
  Tags: rename, login, wp-login, wp-login.php, brute force, attacks
4
  Requires at least: 3.6
@@ -14,7 +14,7 @@ Change wp-login.php to whatever you want. It can also prevent a lot of brute for
14
  = What it does =
15
 
16
  This plugin renames wp-login.php to whatever you want. The default is example.com/**login**/ if no such page already exists. Otherwise it will append a number, e.g. login-1.
17
- You can change this under SettingsPermalinksLogin’.
18
  Please remember what you changed your login page to, accessing wp-login.php or wp-admin/ will not work and will return a 404 not found status.
19
 
20
  = Compatibility =
@@ -50,6 +50,14 @@ While you could use this plugin to prevent a lot of brute force attacks, it does
50
 
51
  == Changelog ==
52
 
 
 
 
 
 
 
 
 
53
  = 1.1 =
54
 
55
  * Blocked access to wp-admin/ to prevent a redirect the the new login page.
@@ -60,6 +68,6 @@ While you could use this plugin to prevent a lot of brute force attacks, it does
60
 
61
  == Upgrade Notice ==
62
 
63
- = 1.1 =
64
 
65
- * Always immediately update this plugin please!
1
+ === Rename wp-login.php ===
2
  Contributors: avryl
3
  Tags: rename, login, wp-login, wp-login.php, brute force, attacks
4
  Requires at least: 3.6
14
  = What it does =
15
 
16
  This plugin renames wp-login.php to whatever you want. The default is example.com/**login**/ if no such page already exists. Otherwise it will append a number, e.g. login-1.
17
+ You can change this under Settings › Permalinks › Login.
18
  Please remember what you changed your login page to, accessing wp-login.php or wp-admin/ will not work and will return a 404 not found status.
19
 
20
  = Compatibility =
50
 
51
  == Changelog ==
52
 
53
+ = 1.3 =
54
+
55
+ * Prevents the plugin from working when there is no permalink structure.
56
+
57
+ = 1.2 =
58
+
59
+ * Fixed status code custom login page.
60
+
61
  = 1.1 =
62
 
63
  * Blocked access to wp-admin/ to prevent a redirect the the new login page.
68
 
69
  == Upgrade Notice ==
70
 
71
+ = 1.3 =
72
 
73
+ Always immediately update this plugin please!
rename-wp-login.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /*
3
- Plugin Name: Rename wp-login
4
  Plugin URI: http://wordpress.org/plugins/rename-wp-login/
5
  Description: Change wp-login.php to whatever you want. It can also prevent a lot of brute force attacks.
6
  Author: avryl
7
  Author URI: http://profiles.wordpress.org/avryl/
8
- Version: 1.1
9
  Text Domain: rename-wp-login
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -24,6 +24,57 @@ function rwl_activation() {
24
  add_option('rwl_page', wp_unique_post_slug('login', 0, 'publish', 'page', 0));
25
  }
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  add_action('wp_loaded', 'rwl_wp_loaded');
28
  function rwl_wp_loaded() {
29
  if (is_admin() && !is_user_logged_in() && !defined('DOING_AJAX') && get_option('rwl_admin') != '1') {
@@ -58,6 +109,7 @@ add_action('wp', 'rwl_wp');
58
  function rwl_wp() {
59
  global $wp_query, $post, $wp;
60
  if ($wp_query->is_404 && $wp->request == get_option('rwl_page')) {
 
61
  $post = new stdClass();
62
  $post->ID = 0;
63
  $wp_query->queried_object = $post;
@@ -74,37 +126,6 @@ function rwl_wp() {
74
  }
75
  }
76
 
77
- add_action('admin_init', 'rwl_admin_init');
78
- function rwl_admin_init() {
79
- add_settings_section('rename-wp-login-section', 'Login', '__return_false', 'permalink');
80
- add_settings_field('rwl-page', '<label for="rwl-page-input">Rename wp-login.php</label>', 'rwl_page', 'permalink', 'rename-wp-login-section');
81
- add_settings_field('rwl-admin', '<label for="rwl-admin-input">Redirect wp-admin/ to new login page (not recommended)</label>', 'rwl_admin', 'permalink', 'rename-wp-login-section');
82
- if ($_SERVER['REQUEST_METHOD'] == 'POST') {
83
- if (!empty($_POST['rwl_page'])) {
84
- update_option('rwl_page', wp_unique_post_slug($_POST['rwl_page'], 0, 'publish', 'page', 0));
85
- }
86
- update_option('rwl_admin', isset($_POST['rwl_admin']) ? $_POST['rwl_admin'] : '0');
87
- }
88
- if (get_option('rwl_redirect') == '1') {
89
- delete_option('rwl_redirect');
90
- wp_redirect(admin_url('options-permalink.php#rwl-page-input'));
91
- }
92
- }
93
-
94
- function rwl_page() {
95
- echo '<code>' . site_url() . '/</code> <input id="rwl-page-input" type="text" name="rwl_page" value="' . get_option('rwl_page') . '" /> <code>/</code>';
96
- }
97
-
98
- function rwl_admin() {
99
- echo '<input id="rwl-admin-input" type="checkbox" name="rwl_admin" value="1" ' . checked(get_option('rwl_admin'), true, false) . ' />';
100
- }
101
-
102
- add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'rwl_plugin_action_links');
103
- function rwl_plugin_action_links($links) {
104
- array_unshift($links, '<a href="options-permalink.php#rwl-page-input">Settings</a>');
105
- return $links;
106
- }
107
-
108
  add_filter('site_url', 'rwl_filter_site_url', 10, 4);
109
  function rwl_filter_site_url($url, $path, $scheme, $blog_id) {
110
  return (strpos($path, 'wp-login.php') !== false && $scheme == 'login_post') ? site_url() . '/' . get_option('rwl_page') . '/' . str_replace('wp-login.php', '', $path) : $url;
1
  <?php
2
  /*
3
+ Plugin Name: Rename wp-login.php
4
  Plugin URI: http://wordpress.org/plugins/rename-wp-login/
5
  Description: Change wp-login.php to whatever you want. It can also prevent a lot of brute force attacks.
6
  Author: avryl
7
  Author URI: http://profiles.wordpress.org/avryl/
8
+ Version: 1.3
9
  Text Domain: rename-wp-login
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
24
  add_option('rwl_page', wp_unique_post_slug('login', 0, 'publish', 'page', 0));
25
  }
26
 
27
+ add_action('admin_init', 'rwl_admin_init');
28
+ function rwl_admin_init() {
29
+ add_settings_section('rename-wp-login-section', 'Login', '__return_false', 'permalink');
30
+ add_settings_field('rwl-page', '<label for="rwl-page-input">Rename wp-login.php</label>', 'rwl_page', 'permalink', 'rename-wp-login-section');
31
+ add_settings_field('rwl-admin', '<label for="rwl-admin-input">Redirect wp-admin/ to new login page (not recommended)</label>', 'rwl_admin', 'permalink', 'rename-wp-login-section');
32
+ if ($_SERVER['REQUEST_METHOD'] == 'POST') {
33
+ if (!empty($_POST['rwl_page'])) {
34
+ update_option('rwl_page', wp_unique_post_slug(sanitize_title_with_dashes($_POST['rwl_page']), 0, 'publish', 'page', 0));
35
+ }
36
+ update_option('rwl_admin', isset($_POST['rwl_admin']) ? $_POST['rwl_admin'] : '0');
37
+ }
38
+ if (get_option('rwl_redirect') == '1') {
39
+ delete_option('rwl_redirect');
40
+ wp_redirect(admin_url('options-permalink.php#rwl-page-input'));
41
+ }
42
+ }
43
+
44
+ function rwl_page() {
45
+ echo '<code>' . site_url() . '/</code> <input id="rwl-page-input" type="text" name="rwl_page" value="' . get_option('rwl_page') . '" /> <code>/</code>';
46
+ }
47
+
48
+ function rwl_admin() {
49
+ echo '<input id="rwl-admin-input" type="checkbox" name="rwl_admin" value="1" ' . checked(get_option('rwl_admin'), true, false) . ' />';
50
+ }
51
+
52
+ add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'rwl_plugin_action_links');
53
+ function rwl_plugin_action_links($links) {
54
+ array_unshift($links, '<a href="options-permalink.php#rwl-page-input">Settings</a>');
55
+ return $links;
56
+ }
57
+
58
+ add_action('admin_notices', 'rwl_admin_notices');
59
+ function rwl_admin_notices() {
60
+ if (!get_option('permalink_structure')) {
61
+ ?>
62
+ <div class="error">
63
+ <p><strong>Rename wp-login.php</strong> doesn't work if you’re using the default permalink structure.<br>You must choose another permalink structure for it to work.</p>
64
+ </div>
65
+ <?php
66
+ } elseif ($_GET['settings-updated'] == true) {
67
+ ?>
68
+ <div class="updated">
69
+ <p>Your login page is now here: <a href="<?php echo site_url(); ?>/<?php echo get_option('rwl_page'); ?>/"><?php echo site_url(); ?>/<strong><?php echo get_option('rwl_page'); ?></strong>/</a>. Bookmark this page!</p>
70
+ </div>
71
+ <?php
72
+ }
73
+ }
74
+
75
+ if (!get_option('permalink_structure'))
76
+ return;
77
+
78
  add_action('wp_loaded', 'rwl_wp_loaded');
79
  function rwl_wp_loaded() {
80
  if (is_admin() && !is_user_logged_in() && !defined('DOING_AJAX') && get_option('rwl_admin') != '1') {
109
  function rwl_wp() {
110
  global $wp_query, $post, $wp;
111
  if ($wp_query->is_404 && $wp->request == get_option('rwl_page')) {
112
+ status_header(200);
113
  $post = new stdClass();
114
  $post->ID = 0;
115
  $wp_query->queried_object = $post;
126
  }
127
  }
128
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
129
  add_filter('site_url', 'rwl_filter_site_url', 10, 4);
130
  function rwl_filter_site_url($url, $path, $scheme, $blog_id) {
131
  return (strpos($path, 'wp-login.php') !== false && $scheme == 'login_post') ? site_url() . '/' . get_option('rwl_page') . '/' . str_replace('wp-login.php', '', $path) : $url;