| @@ -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\Model\Setting\Notfound_Lockout; |
| 17 | 18 | use WP_Defender\Component\Config\Config_Hub_Helper; |
| 18 | 19 | |
| @@ -67,9 +68,8 @@ | ||
| 67 | 68 | public function enqueue_assets() { |
| 68 | 69 | if ( ! $this->is_page_active() ) { |
| 69 | 70 | return; |
| 70 | 71 | } |
| 71 | - wp_localize_script( 'def-iplockout', 'nf_lockout', $this->data_frontend() ); | |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | /** |
| 75 | 75 | * Save settings. |
| @@ -80,9 +80,9 @@ | ||
| 80 | 80 | * @defender_route |
| 81 | 81 | */ |
| 82 | 82 | public function save_settings( Request $request ) { |
| 83 | 83 | $data = $request->get_data( $this->request_filter_rules() ); |
| 84 | - $old_enabled = (bool) $this->model->enabled; | |
| 84 | + $old_enabled = $this->model->enabled; | |
| 85 | 85 | $prev_data = $this->model->export(); |
| 86 | 86 | |
| 87 | 87 | $this->model->import( $data ); |
| 88 | 88 | if ( $this->model->validate() ) { |
| @@ -126,12 +126,18 @@ | ||
| 126 | 126 | * |
| 127 | 127 | * @return array An array of data for the frontend. |
| 128 | 128 | */ |
| 129 | 129 | public function data_frontend(): array { |
| 130 | + $summary = Lockout_Log::get_summary(); | |
| 131 | + | |
| 130 | 132 | return array_merge( |
| 131 | 133 | array( |
| 132 | 134 | 'model' => $this->model->export(), |
| 133 | - 'misc' => array( 'module_name' => Notfound_Lockout::get_module_name() ), | |
| 135 | + 'misc' => array( | |
| 136 | + 'module_name' => Notfound_Lockout::get_module_name(), | |
| 137 | + 'hits_today' => (int) ( $summary['lockout_404_today'] ?? 0 ), | |
| 138 | + 'lockouts_today' => (int) ( $summary['lockout_404_today'] ?? 0 ), | |
| 139 | + ), | |
| 134 | 140 | ), |
| 135 | 141 | $this->dump_routes_and_nonces() |
| 136 | 142 | ); |
| 137 | 143 | } |
| @@ -193,9 +199,9 @@ | ||
| 193 | 199 | * |
| 194 | 200 | * @param array $data Data to be imported into the model. |
| 195 | 201 | */ |
| 196 | 202 | public function import_data( array $data ) { |
| 197 | - if ( ! empty( $data ) ) { | |
| 203 | + if ( array() !== $data ) { | |
| 198 | 204 | $data = $this->adapt_data( $data ); |
| 199 | 205 | $model = $this->model; |
| 200 | 206 | $model->import( $data ); |
| 201 | 207 | if ( $model->validate() ) { |