his->model->enabled && ! $this->model->enabled ) { /* translators: 1. tag open, 2. tag close */ $message = sprintf( esc_html__( '%1$s Session Protection %2$s deactivated successfully!', 'wpdef' ), '', '' ); } elseif ( ( $prev_data['enabled'] ?? false ) !== $this->model->enabled && $this->model->enabled ) { /* translators: 1. tag open, 2. tag close */ $message = sprintf( esc_html__( '%1$s Session Protection %2$s activated successfully!', 'wpdef' ), '', '' ); // Update last activity time to prevent instant logout. $this->service->update_last_activity(); } return new Response( true, array_merge( array( 'message' => $message, 'auto_close' => true, ), $this->data_frontend() ) ); } return new Response( false, array( 'message' => $this->model->get_formatted_errors() ) ); } /** * Export the data of this module, we will use this for export to HUB, create a preset etc. * * @return array */ public function to_array() { return array(); } /** * Import the data of other source into this, it can be when HUB trigger the import, or user apply a preset. * * @param array $data Data from other source. */ public function import_data( array $data ) { $this->model->import( $data ); if ( $this->model->validate() ) { $this->model->save(); $this->service->update_last_activity(); } } /** * Remove all settings, configs generated in this container runtime. */ public function remove_settings() { } /** * Remove all data. */ public function remove_data() { delete_site_transient( Service::LOGOUT_MSG_TRANSIENT_KEY ); } /** * Export strings. * * @return array */ public function export_strings() { return array( $this->model->is_active() ? esc_html__( 'Active', 'wpdef' ) : esc_html__( 'Inactive', 'wpdef' ), ); } /** * Provides data for the dashboard widget. * * @return array An array of dashboard widget data. */ public function dashboard_widget(): array { return array( 'model' => $this->model->export() ); } }his->model->enabled && ! $this->model->enabled ) { /* translators: 1. tag open, 2. tag close */ $message = sprintf( esc_html__( '%1$s Session Protection %2$s deactivated successfully!', 'wpdef' ), '', '' ); } elseif ( ( $prev_data['enabled'] ?? false ) !== $this->model->enabled && $this->model->enabled ) { /* translators: 1. tag open, 2. tag close */ $message = sprintf( esc_html__( '%1$s Session Protection %2$s activated successfully!', 'wpdef' ), '', '' ); // Update last activity time to prevent instant logout. $this->service->update_last_activity(); } return new Response( true, array_merge( array( 'message' => $message, 'auto_close' => true, ), $this->data_frontend() ) ); } return new Response( false, array( 'message' => $this->model->get_formatted_errors() ) ); } /** * Export the data of this module, we will use this for export to HUB, create a preset etc. * * @return array */ public function to_array() { return array(); } /** * Import the data of other source into this, it can be when HUB trigger the import, or user apply a preset. * * @param array $data Data from other source. */ public function import_data( array $data ) { $this->model->import( $data ); if ( $this->model->validate() ) { $this->model->save(); $this->service->update_last_activity(); } } /** * Remove all settings, configs generated in this container runtime. */ public function remove_settings() { } /** * Remove all data. */ public function remove_data() { delete_site_transient( Service::LOGOUT_MSG_TRANSIENT_KEY ); } /** * Export strings. * * @return array */ public function export_strings() { return array( $this->model->is_active() ? esc_html__( 'Active', 'wpdef' ) : esc_html__( 'Inactive', 'wpdef' ), ); } /** * Provides data for the dashboard widget. * * @return array An array of dashboard widget data. */ public function dashboard_widget(): array { return array( 'model' => $this->model->export() ); } }