| @@ -39,9 +39,8 @@ | ||
| 39 | 39 | */ |
| 40 | 40 | public function __construct() { |
| 41 | 41 | $this->model = wd_di()->get( Settings::class ); |
| 42 | 42 | $this->service = wd_di()->get( Service::class ); |
| 43 | - add_filter( 'wp_defender_advanced_tools_data', array( $this, 'script_data' ) ); | |
| 44 | 43 | $this->register_routes(); |
| 45 | 44 | if ( $this->model->enabled ) { |
| 46 | 45 | add_action( 'init', array( $this->service, 'handle_session_timeout' ) ); |
| 47 | 46 | add_action( 'wp_enqueue_scripts', array( $this->service, 'enqueue_idle_scripts' ) ); |
| @@ -60,21 +59,8 @@ | ||
| 60 | 59 | } |
| 61 | 60 | } |
| 62 | 61 | |
| 63 | 62 | /** |
| 64 | - * Provide data to the frontend via localized script. | |
| 65 | - * | |
| 66 | - * @param array $data Data collection is ready to passed. | |
| 67 | - * | |
| 68 | - * @return array Modified data array with added this controller data. | |
| 69 | - */ | |
| 70 | - public function script_data( array $data ): array { | |
| 71 | - $data['session_protection'] = $this->data_frontend(); | |
| 72 | - | |
| 73 | - return $data; | |
| 74 | - } | |
| 75 | - | |
| 76 | - /** | |
| 77 | 63 | * All the variables that we will show on frontend, both in the main page, or dashboard widget. |
| 78 | 64 | * |
| 79 | 65 | * @return array |
| 80 | 66 | */ |
| @@ -106,12 +92,12 @@ | ||
| 106 | 92 | // Changes for Hub. |
| 107 | 93 | \WP_Defender\Component\Config\Config_Hub_Helper::set_clear_active_flag(); |
| 108 | 94 | |
| 109 | 95 | // Maybe track if any settings have changed except user roles. |
| 110 | - if ( $this->maybe_track() && ! empty( $prev_data ) && | |
| 96 | + if ( $this->maybe_track() && array() !== $prev_data && | |
| 111 | 97 | ( |
| 112 | 98 | ( $this->model->enabled !== $prev_data['enabled'] ) |
| 113 | - || ! empty( array_diff( $this->model->lock_properties, $prev_data['lock_properties'] ) ) | |
| 99 | + || array() !== array_diff( $this->model->lock_properties, $prev_data['lock_properties'] ) | |
| 114 | 100 | || $this->model->idle_timeout !== $prev_data['idle_timeout'] |
| 115 | 101 | ) |
| 116 | 102 | ) { |
| 117 | 103 | $data = array( |
| @@ -160,10 +146,8 @@ | ||
| 160 | 146 | /** |
| 161 | 147 | * Import the data of other source into this, it can be when HUB trigger the import, or user apply a preset. |
| 162 | 148 | * |
| 163 | 149 | * @param array $data Data from other source. |
| 164 | - * | |
| 165 | - * @return null|void | |
| 166 | 150 | */ |
| 167 | 151 | public function import_data( array $data ) { |
| 168 | 152 | $this->model->import( $data ); |
| 169 | 153 | if ( $this->model->validate() ) { |
| @@ -168,16 +152,13 @@ | ||
| 168 | 152 | $this->model->import( $data ); |
| 169 | 153 | if ( $this->model->validate() ) { |
| 170 | 154 | $this->model->save(); |
| 171 | 155 | $this->service->update_last_activity(); |
| 172 | - return; | |
| 173 | 156 | } |
| 174 | 157 | } |
| 175 | 158 | |
| 176 | 159 | /** |
| 177 | 160 | * Remove all settings, configs generated in this container runtime. |
| 178 | - * | |
| 179 | - * @return mixed | |
| 180 | 161 | */ |
| 181 | 162 | public function remove_settings() { |
| 182 | 163 | } |
| 183 | 164 | |
| @@ -196,15 +177,6 @@ | ||
| 196 | 177 | public function export_strings() { |
| 197 | 178 | return array( |
| 198 | 179 | $this->model->is_active() ? esc_html__( 'Active', 'defender-security' ) : esc_html__( 'Inactive', 'defender-security' ), |
| 199 | 180 | ); |
| 200 | - } | |
| 201 | - | |
| 202 | - /** | |
| 203 | - * Provides data for the dashboard widget. | |
| 204 | - * | |
| 205 | - * @return array An array of dashboard widget data. | |
| 206 | - */ | |
| 207 | - public function dashboard_widget(): array { | |
| 208 | - return array( 'model' => $this->model->export() ); | |
| 209 | 181 | } |
| 210 | 182 | } |