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-security-headers.php +26 -18 5.5.1 → 6.3.0 View file →
@@ -29,9 +29,8 @@
29 29 /**
30 30 * Initializes the model and service, registers routes, and sets up scheduled events if the model is active.
31 31 */
32 32 public function __construct() {
33 - add_filter( 'wp_defender_advanced_tools_data', array( $this, 'script_data' ) );
34 33 $this->model = wd_di()->get( \WP_Defender\Model\Setting\Security_Headers::class );
35 34 $this->init_headers();
36 35 $this->register_routes();
37 36 }
@@ -49,21 +48,8 @@
49 48 return new \WP_Defender\Model\Setting\Security_Headers();
50 49 }
51 50
52 51 /**
53 - * Provide data to the frontend via localized script.
54 - *
55 - * @param array $data Data collection is ready to passed.
56 - *
57 - * @return array Modified data array with added this controller data.
58 - */
59 - public function script_data( array $data ): array {
60 - $data['security_headers'] = $this->data_frontend();
61 -
62 - return $data;
63 - }
64 -
65 - /**
66 52 * Save settings.
67 53 *
68 54 * @param Request $request The request object containing new settings data.
69 55 *
@@ -84,9 +70,9 @@
84 70 $prev_data = $this->get_model()->get_old_settings();
85 71
86 72 $is_active_prev_data = false;
87 73
88 - if ( ! empty( $prev_data ) ) {
74 + if ( array() !== $prev_data ) {
89 75 $is_active_prev_data = true === $prev_data['sh_xframe'] || true === $prev_data['sh_xss_protection']
90 76 || true === $prev_data['sh_content_type_options'] || true === $prev_data['sh_feature_policy']
91 77 || true === $prev_data['sh_strict_transport'] || true === $prev_data['sh_referrer_policy'];
92 78 }
@@ -233,11 +219,33 @@
233 219 * @return array An array of strings.
234 220 */
235 221 public function export_strings(): array {
236 222 return array(
237 - $this->get_model()->is_any_activated() ? esc_html__( 'Active', 'defender-security' ) : esc_html__(
238 - 'Inactive',
223 + \WP_Defender\Model\Setting\Security_Headers::get_module_name() . ' '
224 + . ( $this->get_model()->is_any_activated() ? esc_html__( 'active', 'defender-security' ) : esc_html__(
225 + 'inactive',
239 226 'defender-security'
240 - ),
227 + ) ),
228 + );
229 + }
230 +
231 + /**
232 + * Generates configuration strings based on the provided configuration.
233 + *
234 + * @param array $config Configuration data.
235 + *
236 + * @return array Returns an array of configuration strings.
237 + */
238 + public function config_strings( array $config ): array {
239 + $active = ( isset( $config['sh_xframe'] ) && $config['sh_xframe'] )
240 + || ( isset( $config['sh_xss_protection'] ) && $config['sh_xss_protection'] )
241 + || ( isset( $config['sh_content_type_options'] ) && $config['sh_content_type_options'] )
242 + || ( isset( $config['sh_feature_policy'] ) && $config['sh_feature_policy'] )
243 + || ( isset( $config['sh_strict_transport'] ) && $config['sh_strict_transport'] )
244 + || ( isset( $config['sh_referrer_policy'] ) && $config['sh_referrer_policy'] );
245 +
246 + return array(
247 + \WP_Defender\Model\Setting\Security_Headers::get_module_name() . ' '
248 + . ( $active ? esc_html__( 'active', 'defender-security' ) : esc_html__( 'inactive', 'defender-security' ) ),
241 249 );
242 250 }
243 251 }