WPS Hide Login - Version 1.2

Version Description

  • Enhancement: Prevent redirection to login URL when accessing /wp-admin/customize.php directly
  • Enhancement: Redirect to admin URL when already logged-in and accessing login URL without the action query string
Download this release

Release Info

Developer tabrisrp
Plugin Icon 128x128 WPS Hide Login
Version 1.2
Comparing to
See all releases

Code changes from version 1.1.7 to 1.2

Files changed (2) hide show
  1. readme.txt +5 -1
  2. wps-hide-login.php +16 -3
readme.txt CHANGED
@@ -4,7 +4,7 @@ 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.8
7
- Stable tag: 1.1.7
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
10
 
@@ -64,6 +64,10 @@ First step is to check your .htaccess file and compare it to a regular one, to s
64
 
65
  == Changelog ==
66
 
 
 
 
 
67
  = 1.1.7 =
68
  * Fix: change fake 404 on wp-admin when not logged-in to a 403 forbidden to prevent fatal errors with various themes & plugins
69
 
4
  Tags: rename, login, wp-login, wp-login.php, custom login url
5
  Requires at least: 4.1
6
  Tested up to: 4.8
7
+ Stable tag: 1.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 =
68
+ * Enhancement: Prevent redirection to login URL when accessing /wp-admin/customize.php directly
69
+ * Enhancement: Redirect to admin URL when already logged-in and accessing login URL without the action query string
70
+
71
  = 1.1.7 =
72
  * Fix: change fake 404 on wp-admin when not logged-in to a 403 forbidden to prevent fatal errors with various themes & plugins
73
 
wps-hide-login.php CHANGED
@@ -5,7 +5,7 @@ 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.1.7
9
  Text Domain: wps-hide-login
10
  License: GPLv2 or later
11
  License URI: http://www.gnu.org/licenses/gpl-2.0.html
@@ -154,6 +154,7 @@ if ( defined( 'ABSPATH' )
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
 
158
  add_filter( 'plugin_action_links_' . $this->basename(), array( $this, 'plugin_action_links' ) );
159
  add_filter( 'site_url', array( $this, 'site_url' ), 10, 4 );
@@ -383,6 +384,14 @@ if ( defined( 'ABSPATH' )
383
 
384
  }
385
 
 
 
 
 
 
 
 
 
386
  public function wp_loaded() {
387
 
388
  global $pagenow;
@@ -429,8 +438,12 @@ if ( defined( 'ABSPATH' )
429
  $this->wp_template_loader();
430
 
431
  } elseif ( $pagenow === 'wp-login.php' ) {
432
-
433
  global $error, $interim_login, $action, $user_login;
 
 
 
 
 
434
 
435
  @require_once ABSPATH . 'wp-login.php';
436
 
@@ -509,4 +522,4 @@ if ( defined( 'ABSPATH' )
509
  }
510
 
511
  add_action( 'plugins_loaded', array( 'WPS_Hide_Login', 'get_instance' ), 1 );
512
- }
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
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
  add_filter( 'plugin_action_links_' . $this->basename(), array( $this, 'plugin_action_links' ) );
160
  add_filter( 'site_url', array( $this, 'site_url' ), 10, 4 );
384
 
385
  }
386
 
387
+ public function setup_theme() {
388
+ global $pagenow;
389
+
390
+ if ( ! is_user_logged_in() && 'customize.php' === $pagenow ) {
391
+ wp_die( __( 'This has been disabled', 'wps-hide-login' ), 403 );
392
+ }
393
+ }
394
+
395
  public function wp_loaded() {
396
 
397
  global $pagenow;
438
  $this->wp_template_loader();
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();
446
+ }
447
 
448
  @require_once ABSPATH . 'wp-login.php';
449
 
522
  }
523
 
524
  add_action( 'plugins_loaded', array( 'WPS_Hide_Login', 'get_instance' ), 1 );
525
+ }