| @@ -20,15 +20,15 @@ | ||
| 20 | 20 | public function __construct( $core ) { |
| 21 | 21 | parent::__construct( $core ); |
| 22 | 22 | |
| 23 | 23 | // Add admin and network notices. |
| 24 | - add_action( 'admin_notices', array( $this, 'file_error_notice' ) ); | |
| 25 | - add_action( 'network_admin_notices', array( $this, 'file_error_notice' ) ); | |
| 24 | + add_action( 'admin_notices', [ $this, 'file_error_notice' ] ); | |
| 25 | + add_action( 'network_admin_notices', [ $this, 'file_error_notice' ] ); | |
| 26 | 26 | |
| 27 | - add_action( 'wp_loaded', array( $this, 'update_rules' ) ); | |
| 28 | - add_action( 'update_option_siteurl', array( $this, 'update_option_url' ), 10, 2 ); | |
| 29 | - add_action( 'admin_init', array( $this, 'alter_ips' ) ); | |
| 30 | - add_action( 'admin_init', array( $this, 'enable_settings' ) ); | |
| 27 | + add_action( 'wp_loaded', [ $this, 'update_rules' ] ); | |
| 28 | + add_action( 'update_option_siteurl', [ $this, 'update_option_url' ], 10, 2 ); | |
| 29 | + add_action( 'admin_init', [ $this, 'alter_ips' ] ); | |
| 30 | + add_action( 'admin_init', [ $this, 'enable_settings' ] ); | |
| 31 | 31 | |
| 32 | 32 | // If the firewall or whitelist rules do not exist, attempt to pull fresh. |
| 33 | 33 | $token = get_option( 'patchstack_api_token', false ); |
| 34 | 34 | if ( ! empty( $token ) && ( get_option( 'patchstack_firewall_rules', '' ) == '' || get_option( 'patchstack_whitelist_keys_rules' ) == '' ) && get_option( 'patchstack_license_free', 0 ) != 1 ) { |
| @@ -47,9 +47,9 @@ | ||
| 47 | 47 | return; |
| 48 | 48 | } |
| 49 | 49 | |
| 50 | 50 | // Check root .htaccess file and data folder writability. |
| 51 | - $files = array(); | |
| 51 | + $files = []; | |
| 52 | 52 | if ( file_exists( ABSPATH . '.htaccess' ) && ! wp_is_writable( ABSPATH . '.htaccess' ) ) { |
| 53 | 53 | array_push( $files, ABSPATH . '.htaccess' ); |
| 54 | 54 | } |
| 55 | 55 | |
| @@ -85,9 +85,9 @@ | ||
| 85 | 85 | $token = $this->plugin->api->get_access_token(); |
| 86 | 86 | |
| 87 | 87 | // Update the firewall status. |
| 88 | 88 | if ( ! empty( $token ) ) { |
| 89 | - $this->plugin->api->update_firewall_status( array( 'status' => $this->get_option( 'patchstack_basic_firewall' ) == 1 ) ); | |
| 89 | + $this->plugin->api->update_firewall_status( [ 'status' => $this->get_option( 'patchstack_basic_firewall' ) == 1 ] ); | |
| 90 | 90 | } |
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
| @@ -100,9 +100,9 @@ | ||
| 100 | 100 | * @return void |
| 101 | 101 | */ |
| 102 | 102 | public function update_option_url( $old_value, $new_value ) { |
| 103 | 103 | if ( $old_value != $new_value ) { |
| 104 | - $this->plugin->api->update_url( array( 'plugin_url' => $new_value ) ); | |
| 104 | + $this->plugin->api->update_url( [ 'plugin_url' => $new_value ] ); | |
| 105 | 105 | } |
| 106 | 106 | } |
| 107 | 107 | |
| 108 | 108 | /** |
| @@ -111,9 +111,9 @@ | ||
| 111 | 111 | * |
| 112 | 112 | * @return void |
| 113 | 113 | */ |
| 114 | 114 | public function alter_ips() { |
| 115 | - if ( ! isset( $_GET['action'], $_GET['PatchstackNonce'] ) || ! wp_verify_nonce( $_GET['PatchstackNonce'], 'patchstack-nonce-alter-ips' ) || ! current_user_can( 'administrator' ) || ! in_array( $_GET['action'], array( 'patchstack_unblock', 'patchstack_unblock_whitelist', 'patchstack_whitelist' ) ) ) { | |
| 115 | + if ( ! isset( $_GET['action'], $_GET['PatchstackNonce'] ) || ! wp_verify_nonce( $_GET['PatchstackNonce'], 'patchstack-nonce-alter-ips' ) || ! current_user_can( 'administrator' ) || ! in_array( $_GET['action'], [ 'patchstack_unblock', 'patchstack_unblock_whitelist', 'patchstack_whitelist' ] ) ) { | |
| 116 | 116 | return; |
| 117 | 117 | } |
| 118 | 118 | |
| 119 | 119 | global $wpdb; |
| @@ -121,15 +121,15 @@ | ||
| 121 | 121 | // Unblock the IP; delete the logs of the IP. |
| 122 | 122 | if ( $_GET['action'] == 'patchstack_unblock' && isset( $_GET['id'] ) && ctype_digit( $_GET['id'] ) ) { |
| 123 | 123 | // First get the IP address to unblock. |
| 124 | 124 | $result = $wpdb->get_results( |
| 125 | - $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', array( (int) $_GET['id'] ) ) | |
| 125 | + $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', [ (int) $_GET['id'] ] ) | |
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | 128 | // Unblock the IP address. |
| 129 | 129 | if ( isset( $result[0], $result[0]->ip ) ) { |
| 130 | 130 | $wpdb->query( |
| 131 | - $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', array( $result[0]->ip ) ) | |
| 131 | + $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', [ $result[0]->ip ] ) | |
| 132 | 132 | ); |
| 133 | 133 | } |
| 134 | 134 | } |
| 135 | 135 | |
| @@ -136,9 +136,9 @@ | ||
| 136 | 136 | // Unblock and whitelist the IP. |
| 137 | 137 | if ( $_GET['action'] == 'patchstack_unblock_whitelist' && isset( $_GET['id'] ) && ctype_digit( $_GET['id'] ) ) { |
| 138 | 138 | // First get the IP address to whitelist. |
| 139 | 139 | $result = $wpdb->get_results( |
| 140 | - $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', array( (int) $_GET['id'] ) ) | |
| 140 | + $wpdb->prepare( 'SELECT ip FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE id = %d', [ (int) $_GET['id'] ] ) | |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | 143 | // Whitelist and unblock the IP address. |
| 144 | 144 | if ( isset( $result[0], $result[0]->ip ) && filter_var( $result[0]->ip, FILTER_VALIDATE_IP ) ) { |
| @@ -143,9 +143,9 @@ | ||
| 143 | 143 | // Whitelist and unblock the IP address. |
| 144 | 144 | if ( isset( $result[0], $result[0]->ip ) && filter_var( $result[0]->ip, FILTER_VALIDATE_IP ) ) { |
| 145 | 145 | update_option( 'patchstack_login_whitelist', $this->get_option( 'patchstack_login_whitelist', '' ) . "\n" . $result[0]->ip ); |
| 146 | 146 | $wpdb->query( |
| 147 | - $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', array( $result[0]->ip ) ) | |
| 147 | + $wpdb->prepare( 'DELETE FROM ' . $wpdb->prefix . 'patchstack_event_log WHERE ip = %s', [ $result[0]->ip ] ) | |
| 148 | 148 | ); |
| 149 | 149 | } |
| 150 | 150 | } |
| 151 | 151 | |
| @@ -172,8 +172,8 @@ | ||
| 172 | 172 | // Turn it on. |
| 173 | 173 | update_option( 'patchstack_show_settings', 1 ); |
| 174 | 174 | |
| 175 | 175 | // Redirect the user back to the license page. |
| 176 | - wp_safe_redirect( admin_url( 'admin.php?page=' . $this->plugin->name . '&tab=license' ) ); | |
| 176 | + wp_safe_redirect( admin_url( 'admin.php?page=' . $this->plugin->name ) ); | |
| 177 | 177 | exit; |
| 178 | 178 | } |
| 179 | 179 | } |