HC Custom WP-Admin URL - Version 1.2

Version Description

  • If WordPress for some reason haven't applied rewrite rules to .htaccess, default wp-admin url will work
Download this release

Release Info

Developer SomeWebMedia
Plugin Icon 128x128 HC Custom WP-Admin URL
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.2 to 1.2

Files changed (2) hide show
  1. hc-custom-wp-admin-url.php +28 -7
  2. readme.txt +6 -3
hc-custom-wp-admin-url.php CHANGED
@@ -1,7 +1,7 @@
1
  <?php
2
  /*
3
  Plugin Name: HC Custom WP-Admin URL
4
- Version: 1.1.2
5
  Plugin URI: http://wordpress.org/extend/plugins/hc-custom-wp-admin-url/
6
  Description: Small and simple plugin that allows you to change url of wp-admin
7
  Author: Some Web Media
@@ -91,7 +91,7 @@ if (!class_exists('hc_custom_wpadmin_url')) {
91
  $url = $this->get_url();
92
  // see referal url by the web client
93
  list($file, $arguments) = explode("?", $_SERVER['REQUEST_URI']);
94
- // if on localhost remove subdir
95
  $file = ($url['rewrite_base']) ? implode("", explode("/" . $url['rewrite_base'], $file)) : $file;
96
 
97
  if("/wp-login.php?loggedout=true" == $file . "?" . $arguments) {
@@ -111,7 +111,7 @@ if (!class_exists('hc_custom_wpadmin_url')) {
111
  exit();
112
  }
113
  }
114
-
115
  // return parsed url
116
  function get_url() {
117
  $url = array();
@@ -123,6 +123,30 @@ if (!class_exists('hc_custom_wpadmin_url')) {
123
  $url['query'] = $_SERVER['QUERY_STRING'];
124
  return $url;
125
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  $hc_custom_wpadmin_url = new hc_custom_wpadmin_url();
@@ -130,9 +154,6 @@ if (!class_exists('hc_custom_wpadmin_url')) {
130
  // add hooks
131
  add_filter('generate_rewrite_rules', array($hc_custom_wpadmin_url, 'rewrite_admin_url'));
132
  add_action('admin_init', array($hc_custom_wpadmin_url, 'custom_admin_url'));
 
133
 
134
- // check login page slug
135
- if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && (get_option('custom_wpadmin_slug') != false && get_option('custom_wpadmin_slug') != '')) {
136
- $hc_custom_wpadmin_url->custom_login();
137
- }
138
  }
1
  <?php
2
  /*
3
  Plugin Name: HC Custom WP-Admin URL
4
+ Version: 1.2
5
  Plugin URI: http://wordpress.org/extend/plugins/hc-custom-wp-admin-url/
6
  Description: Small and simple plugin that allows you to change url of wp-admin
7
  Author: Some Web Media
91
  $url = $this->get_url();
92
  // see referal url by the web client
93
  list($file, $arguments) = explode("?", $_SERVER['REQUEST_URI']);
94
+ // on localhost remove subdir
95
  $file = ($url['rewrite_base']) ? implode("", explode("/" . $url['rewrite_base'], $file)) : $file;
96
 
97
  if("/wp-login.php?loggedout=true" == $file . "?" . $arguments) {
111
  exit();
112
  }
113
  }
114
+
115
  // return parsed url
116
  function get_url() {
117
  $url = array();
123
  $url['query'] = $_SERVER['QUERY_STRING'];
124
  return $url;
125
  }
126
+
127
+ function check_login() {
128
+ // just chek if we are on the right place
129
+ if (in_array($GLOBALS['pagenow'], array('wp-login.php', 'wp-register.php')) && (get_option('custom_wpadmin_slug') != false && get_option('custom_wpadmin_slug') != '')) {
130
+
131
+ // inlcude file.php
132
+ $DS = DIRECTORY_SEPARATOR;
133
+ if (file_exists(dirname(__FILE__) . $DS . '..' . $DS . '..' . $DS . '..' . $DS . 'wp-admin' . $DS . 'includes' . $DS . 'file.php'))
134
+ include(dirname(__FILE__) . $DS . '..' . $DS . '..' . $DS . '..' . $DS . 'wp-admin' . $DS . 'includes' . $DS . 'file.php');
135
+ else
136
+ return; // if hierarchy is messed up, don't go further
137
+
138
+ // check if our plugin have written necesery line to .htaccess, sometimes WP doesn't write correctly so we don't want to disable login in that case
139
+ $markerdata = explode("\n", implode('', file(get_home_path() . '.htaccess')));
140
+ $found = false;
141
+ $url = $this->get_url();
142
+ foreach ($markerdata as $line) {
143
+ if (trim($line) == 'RewriteRule ^' . get_option('custom_wpadmin_slug') . '/?$ ' . ($url['rewrite_base'] ? '/'.$url['rewrite_base'] : '') . '/wp-login.php [QSA,L]')
144
+ $found = true;
145
+ }
146
+ if ($found)
147
+ $this->custom_login();
148
+ }
149
+ }
150
  }
151
 
152
  $hc_custom_wpadmin_url = new hc_custom_wpadmin_url();
154
  // add hooks
155
  add_filter('generate_rewrite_rules', array($hc_custom_wpadmin_url, 'rewrite_admin_url'));
156
  add_action('admin_init', array($hc_custom_wpadmin_url, 'custom_admin_url'));
157
+ add_action('login_init', array($hc_custom_wpadmin_url, 'check_login'));
158
 
 
 
 
 
159
  }
readme.txt CHANGED
@@ -1,9 +1,9 @@
1
  === HC Custom WP-Admin URL ===
2
  Contributors: SomeWebMedia
3
  Tags: plugin, administration, admin, custom url, login, security, wp-admin, wp-login
4
- Requires at least: 3.2.0
5
  Tested up to: 3.5.1
6
- Stable tag: 1.1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
@@ -37,7 +37,7 @@ Old WP Admin urls `http://yourdomain.com/wp-admin/` and `http://yourdomain.com/w
37
 
38
  = Anything important I should know? =
39
 
40
- Be careful if using this plugin with other which modify .htaccess file. Also if you are having trouble with your .htaccess file not being generated properly, try deleting it and re-saving Permalink options.
41
 
42
  == Screenshots ==
43
 
@@ -45,6 +45,9 @@ Be careful if using this plugin with other which modify .htaccess file. Also if
45
 
46
  == Changelog ==
47
 
 
 
 
48
  = 1.1.2 =
49
  * Fixed redirection bug when slug set to empty
50
 
1
  === HC Custom WP-Admin URL ===
2
  Contributors: SomeWebMedia
3
  Tags: plugin, administration, admin, custom url, login, security, wp-admin, wp-login
4
+ Requires at least: 3.2
5
  Tested up to: 3.5.1
6
+ Stable tag: 1.2
7
  License: GPLv2 or later
8
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
 
37
 
38
  = Anything important I should know? =
39
 
40
+ Be careful if using this plugin with other plugins which modify .htaccess file. Also if you are having trouble with your .htaccess file not being generated properly, try deleting it and re-saving Permalink options.
41
 
42
  == Screenshots ==
43
 
45
 
46
  == Changelog ==
47
 
48
+ = 1.2 =
49
+ * If WordPress for some reason haven't applied rewrite rules to .htaccess, default wp-admin url will work
50
+
51
  = 1.1.2 =
52
  * Fixed redirection bug when slug set to empty
53