PluginProbe
Defender Security – Malware Scanner, Login Security & Firewall / 6.3.0
Defender Security – Malware Scanner, Login Security & Firewall v6.3.0
6.3.0 6.2.3 6.2.4 6.2.0 6.2.1 6.2.2 6.1.0 5.3.1 5.4.0 5.4.1 5.5.0 5.5.1 5.6.0 5.6.1 5.6.2 5.7.0 5.7.1 5.7.2 5.8.0 5.8.1 5.9.0 6.0.0 6.0.1 3.0.1 3.1.0 All 141 releases
← All changes | src/controller/class-nf-lockout.php +10 -4 5.6.0 → 6.3.0 View file →
@@ -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() ) {