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-session-protection.php +13 -38 5.3.1 → 6.3.0 View file →
@@ -12,9 +12,8 @@
12 12 use Calotes\Component\Request;
13 13 use Calotes\Component\Response;
14 14 use WP_Defender\Component\Session_Protection as Service;
15 15 use WP_Defender\Model\Setting\Session_Protection as Settings;
16 -use WP_Defender\Component\Breadcrumbs;
17 16
18 17 /**
19 18 * Handle session protection module.
20 19 */
@@ -40,9 +39,8 @@
40 39 */
41 40 public function __construct() {
42 41 $this->model = wd_di()->get( Settings::class );
43 42 $this->service = wd_di()->get( Service::class );
44 - add_filter( 'wp_defender_advanced_tools_data', array( $this, 'script_data' ) );
45 43 $this->register_routes();
46 44 if ( $this->model->enabled ) {
47 45 add_action( 'init', array( $this->service, 'handle_session_timeout' ) );
48 46 add_action( 'wp_enqueue_scripts', array( $this->service, 'enqueue_idle_scripts' ) );
@@ -61,34 +59,18 @@
61 59 }
62 60 }
63 61
64 62 /**
65 - * Provide data to the frontend via localized script.
66 - *
67 - * @param array $data Data collection is ready to passed.
68 - *
69 - * @return array Modified data array with added this controller data.
70 - */
71 - public function script_data( array $data ): array {
72 - $data['session_protection'] = $this->data_frontend();
73 -
74 - return $data;
75 - }
76 -
77 - /**
78 63 * All the variables that we will show on frontend, both in the main page, or dashboard widget.
79 64 *
80 65 * @return array
81 66 */
82 67 public function data_frontend(): array {
83 - $is_visited = wd_di()->get( Breadcrumbs::class )->get_meta_key();
84 -
85 68 return array_merge(
86 69 array(
87 - 'model' => $this->model->export(),
88 - 'properties' => $this->service::session_lock_properties(),
89 - 'show_feature_dot' => wd_di()->get( \WP_Defender\Behavior\WPMUDEV::class )->is_pro() && ! $is_visited,
90 - 'roles' => $this->get_all_editable_roles(),
70 + 'model' => $this->model->export(),
71 + 'properties' => $this->service::session_lock_properties(),
72 + 'roles' => $this->get_all_editable_roles(),
91 73 ),
92 74 $this->dump_routes_and_nonces()
93 75 );
94 76 }
@@ -110,12 +92,12 @@
110 92 // Changes for Hub.
111 93 \WP_Defender\Component\Config\Config_Hub_Helper::set_clear_active_flag();
112 94
113 95 // Maybe track if any settings have changed except user roles.
114 - if ( $this->maybe_track() && ! empty( $prev_data ) &&
96 + if ( $this->maybe_track() && array() !== $prev_data &&
115 97 (
116 98 ( $this->model->enabled !== $prev_data['enabled'] )
117 - || ! empty( array_diff( $this->model->lock_properties, $prev_data['lock_properties'] ) )
99 + || array() !== array_diff( $this->model->lock_properties, $prev_data['lock_properties'] )
118 100 || $this->model->idle_timeout !== $prev_data['idle_timeout']
119 101 )
120 102 ) {
121 103 $data = array(
@@ -164,18 +146,19 @@
164 146 /**
165 147 * Import the data of other source into this, it can be when HUB trigger the import, or user apply a preset.
166 148 *
167 149 * @param array $data Data from other source.
168 - *
169 - * @return null|void
170 150 */
171 151 public function import_data( array $data ) {
152 + $this->model->import( $data );
153 + if ( $this->model->validate() ) {
154 + $this->model->save();
155 + $this->service->update_last_activity();
156 + }
172 157 }
173 158
174 159 /**
175 160 * Remove all settings, configs generated in this container runtime.
176 - *
177 - * @return mixed
178 161 */
179 162 public function remove_settings() {
180 163 }
181 164
@@ -182,9 +165,8 @@
182 165 /**
183 166 * Remove all data.
184 167 */
185 168 public function remove_data() {
186 - wd_di()->get( Breadcrumbs::class )->delete_meta_key();
187 169 delete_site_transient( Service::LOGOUT_MSG_TRANSIENT_KEY );
188 170 }
189 171
190 172 /**
@@ -192,16 +174,9 @@
192 174 *
193 175 * @return array
194 176 */
195 177 public function export_strings() {
196 - return array();
197 - }
198 -
199 - /**
200 - * Provides data for the dashboard widget.
201 - *
202 - * @return array An array of dashboard widget data.
203 - */
204 - public function dashboard_widget(): array {
205 - return array( 'model' => $this->model->export() );
178 + return array(
179 + $this->model->is_active() ? esc_html__( 'Active', 'defender-security' ) : esc_html__( 'Inactive', 'defender-security' ),
180 + );
206 181 }
207 182 }