| @@ -17,9 +17,9 @@ | ||
| 17 | 17 | */ |
| 18 | 18 | public function __construct( $core ) { |
| 19 | 19 | parent::__construct( $core ); |
| 20 | 20 | |
| 21 | - if ( $this->get_option( 'patchstack_license_free', 0 ) == 1 ) { | |
| 21 | + if ( $this->get_option( 'patchstack_license_free', 0 ) == 1 || $this->is_community() ) { | |
| 22 | 22 | return; |
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | // Update the renamed login page if it's set to our hardcoded one. |
| @@ -32,10 +32,10 @@ | ||
| 32 | 32 | return; |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | // Register the filters and actions for the functionality. |
| 36 | - add_action( 'init', array( $this, 'init' ) ); | |
| 37 | - add_action( 'wp_logout', array( $this, 'wp_logout' ) ); | |
| 36 | + add_action( 'init', [ $this, 'init' ] ); | |
| 37 | + add_action( 'wp_logout', [ $this, 'wp_logout' ] ); | |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | /** |
| 41 | 41 | * Deny access to wp-login.php if the login page rename feature is enabled. |
| @@ -48,9 +48,13 @@ | ||
| 48 | 48 | return; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | // Determine if the user is whitelisted. |
| 52 | - if ( ( stripos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false || $GLOBALS['pagenow'] === 'wp-login.php' || $_SERVER['PHP_SELF'] === '/wp-login.php' ) && !$this->is_whitelisted() ) { | |
| 52 | + if ( ( stripos( $_SERVER['REQUEST_URI'], 'wp-login.php' ) !== false || $GLOBALS['pagenow'] === 'wp-login.php' || $_SERVER['PHP_SELF'] === '/wp-login.php' ) && ! $this->is_whitelisted() ) { | |
| 53 | + if ( isset( $_REQUEST['action'] ) && in_array( $_REQUEST['action'], ['confirm_admin_email', 'postpass', 'lostpassword', 'retrievepassword', 'resetpass', 'rp', 'register', 'checkemail', 'confirmaction'] ) ) { | |
| 54 | + return; | |
| 55 | + } | |
| 56 | + | |
| 53 | 57 | $this->plugin->firewall_base->display_error_page( 'login' ); |
| 54 | 58 | } |
| 55 | 59 | |
| 56 | 60 | // If the current page is the renamed login page we give the user access for 10 minutes to the login page. |
| @@ -76,10 +80,10 @@ | ||
| 76 | 80 | * @return boolean |
| 77 | 81 | */ |
| 78 | 82 | private function is_whitelisted() { |
| 79 | 83 | // Process the whitelist, and remove old ones. |
| 80 | - $whitelist = get_site_option( 'patchstack_rename_wp_login_whitelist', array() ); | |
| 81 | - $new_whitelist = array(); | |
| 84 | + $whitelist = get_site_option( 'patchstack_rename_wp_login_whitelist', [] ); | |
| 85 | + $new_whitelist = []; | |
| 82 | 86 | $allow = false; |
| 83 | 87 | |
| 84 | 88 | // Only continue if there are actually any whitelist entries. |
| 85 | 89 | if ( is_array( $whitelist ) && count( $whitelist ) != 0 ){ |
| @@ -108,10 +112,10 @@ | ||
| 108 | 112 | * |
| 109 | 113 | * @return void |
| 110 | 114 | */ |
| 111 | 115 | private function whitelist_ip() { |
| 112 | - $whitelist = get_site_option( 'patchstack_rename_wp_login_whitelist', array() ); | |
| 113 | - $new_whitelist = array(); | |
| 116 | + $whitelist = get_site_option( 'patchstack_rename_wp_login_whitelist', [] ); | |
| 117 | + $new_whitelist = []; | |
| 114 | 118 | |
| 115 | 119 | // If the IP address is already whitelisted, reset the timestamp. |
| 116 | 120 | if ( is_array( $whitelist ) && count( $whitelist ) != 0 ) { |
| 117 | 121 | $ip = $this->get_ip(); |
| @@ -118,9 +122,9 @@ | ||
| 118 | 122 | $whitelisted = false; |
| 119 | 123 | foreach ( $whitelist as $entry ) { |
| 120 | 124 | // Determine if we should extend the whitelist time or ignore if already whitelisted. |
| 121 | 125 | if ( $ip === $entry[0] ) { |
| 122 | - $new_whitelist[] = array( $ip, time() ); | |
| 126 | + $new_whitelist[] = [ $ip, time() ]; | |
| 123 | 127 | $whitelisted = true; |
| 124 | 128 | } else { |
| 125 | 129 | $new_whitelist[] = $entry; |
| 126 | 130 | } |
| @@ -127,13 +131,13 @@ | ||
| 127 | 131 | } |
| 128 | 132 | |
| 129 | 133 | // Whitelist the IP address. |
| 130 | 134 | if ( ! $whitelisted ) { |
| 131 | - $new_whitelist[] = array( $ip, time() ); | |
| 135 | + $new_whitelist[] = [ $ip, time() ]; | |
| 132 | 136 | } |
| 133 | 137 | |
| 134 | 138 | update_site_option( 'patchstack_rename_wp_login_whitelist', $new_whitelist ); |
| 135 | 139 | } else { |
| 136 | - update_site_option( 'patchstack_rename_wp_login_whitelist', array( array( $this->get_ip(), time() ) ) ); | |
| 140 | + update_site_option( 'patchstack_rename_wp_login_whitelist', [ [ $this->get_ip(), time() ] ] ); | |
| 137 | 141 | } |
| 138 | 142 | } |
| 139 | 143 | } |