| @@ -11,8 +11,9 @@ | ||
| 11 | 11 | use WP_Defender\Traits\IP; |
| 12 | 12 | use Calotes\Component\Request; |
| 13 | 13 | use Calotes\Component\Response; |
| 14 | 14 | use WP_Defender\Traits\Setting; |
| 15 | +use WP_Defender\Model\Lockout_Log; | |
| 15 | 16 | use WP_Defender\Component\Blacklist_Lockout; |
| 16 | 17 | use WP_Defender\Component\Config\Config_Hub_Helper; |
| 17 | 18 | use WP_Defender\Model\Setting\Login_Lockout as Model_Login_Lockout; |
| 18 | 19 | |
| @@ -69,9 +70,9 @@ | ||
| 69 | 70 | * @defender_route |
| 70 | 71 | */ |
| 71 | 72 | public function save_settings( Request $request ) { |
| 72 | 73 | $data = $request->get_data_by_model( $this->model ); |
| 73 | - $old_enabled = (bool) $this->model->enabled; | |
| 74 | + $old_enabled = $this->model->enabled; | |
| 74 | 75 | $prev_data = $this->model->export(); |
| 75 | 76 | |
| 76 | 77 | $this->model->import( $data ); |
| 77 | 78 | if ( $this->model->validate() ) { |
| @@ -117,9 +118,8 @@ | ||
| 117 | 118 | public function enqueue_assets() { |
| 118 | 119 | if ( ! $this->is_page_active() ) { |
| 119 | 120 | return; |
| 120 | 121 | } |
| 121 | - wp_localize_script( 'def-iplockout', 'login_lockout', $this->data_frontend() ); | |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | /** |
| 125 | 125 | * Provides data for the frontend. |
| @@ -130,10 +130,11 @@ | ||
| 130 | 130 | return array_merge( |
| 131 | 131 | array( |
| 132 | 132 | 'model' => $this->model->export(), |
| 133 | 133 | 'misc' => array( |
| 134 | - 'host' => defender_get_hostname(), | |
| 135 | - 'module_name' => Model_Login_Lockout::get_module_name(), | |
| 134 | + 'host' => defender_get_hostname(), | |
| 135 | + 'module_name' => Model_Login_Lockout::get_module_name(), | |
| 136 | + 'lockouts_24h' => (int) Lockout_Log::count( strtotime( '-24 hours' ), time(), Lockout_Log::AUTH_LOCK ), | |
| 136 | 137 | ), |
| 137 | 138 | ), |
| 138 | 139 | $this->dump_routes_and_nonces() |
| 139 | 140 | ); |
| @@ -190,9 +191,9 @@ | ||
| 190 | 191 | * |
| 191 | 192 | * @param array $data Data to be imported into the model. |
| 192 | 193 | */ |
| 193 | 194 | public function import_data( array $data ) { |
| 194 | - if ( ! empty( $data ) ) { | |
| 195 | + if ( array() !== $data ) { | |
| 195 | 196 | // Upgrade for old versions. |
| 196 | 197 | $data = $this->adapt_data( $data ); |
| 197 | 198 | $model = $this->model; |
| 198 | 199 | $model->import( $data ); |