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/component/class-backup-settings.php +118 -228 5.8.1 → 6.3.0 View file →
@@ -63,13 +63,13 @@
63 63
64 64 public const KEY = 'defender_last_settings', INDEXER = 'defender_config_indexer';
65 65
66 66 /**
67 - * Indicates whether the current installation is a pro version.
67 + * Indicates whether the site has a HUB API key (true for both free and pro with Hub connected).
68 68 *
69 69 * @var bool
70 70 */
71 - private $is_pro;
71 + private $has_hub_api_key;
72 72
73 73 /**
74 74 * Constructor for the Backup_Settings class.
75 75 * It initializes the class and sets whether the current installation is a pro version.
@@ -74,9 +74,10 @@
74 74 * Constructor for the Backup_Settings class.
75 75 * It initializes the class and sets whether the current installation is a pro version.
76 76 */
77 77 public function __construct() {
78 - $this->is_pro = ( new WPMUDEV() )->is_pro();
78 + $wpmudev = wd_di()->get( WPMUDEV::class );
79 + $this->has_hub_api_key = $wpmudev->is_apikey_available();
79 80 }
80 81
81 82 /**
82 83 * Changes the format of subscribers in a notification object to an array format.
@@ -119,10 +120,8 @@
119 120 $tweak_class->refresh_tweaks_status();
120 121 $settings = new Model_Security_Tweaks();
121 122 $tweak_notification = new Tweak_Reminder();
122 123 $security_tweaks = array(
123 - 'notification_repeat' => $tweak_notification->configs['reminder'],
124 - 'subscribers' => $this->change_subscriber_format( $tweak_notification ),
125 124 'notification' => $tweak_notification->status,
126 125 'data' => $settings->data,
127 126 'fixed' => $settings->fixed,
128 127 'issues' => $settings->issues,
@@ -140,8 +139,9 @@
140 139 'check_plugins' => $settings->check_plugins,
141 140 'check_known_vuln' => $settings->check_known_vuln,
142 141 'scan_malware' => $settings->scan_malware,
143 142 'filesize' => $settings->filesize,
143 + 'check_abandoned_plugin' => $settings->check_abandoned_plugin,
144 144 // @since 2.7.0 changes for Scheduled options.
145 145 'scheduled_scanning' => $settings->scheduled_scanning,
146 146 'day' => $settings->day,
147 147 'day_n' => $settings->day_n,
@@ -167,9 +167,9 @@
167 167 $settings = new Model_Audit_Logging();
168 168 $audit_report = new Audit_Report();
169 169 $audit = array(
170 170 'enabled' => $settings->is_active(),
171 - 'report' => $audit_report->status,
171 + 'report' => 'disabled',
172 172 'subscribers' => $this->change_subscriber_format( $audit_report ),
173 173 'frequency' => $audit_report->frequency,
174 174 'day' => $audit_report->day,
175 175 'day_n' => $audit_report->day_n,
@@ -177,14 +177,12 @@
177 177 // @since 2.7.0 We can remove it in the next version.
178 178 'dry_run' => false,
179 179 'storage_days' => $settings->storage_days,
180 180 );
181 - if ( ! $this->is_pro ) {
182 - $audit['enabled'] = false;
183 - }
184 181 } else {
185 182 $audit['enabled'] = false;
186 183 }
184 +
187 185 $settings_firewall = new Model_Firewall();
188 186 $settings_ll = new Model_Login_Lockout();
189 187 $settings_nl = new Model_Notfound_Lockout();
190 188 $settings_bl = new Model_Blacklist_Lockout();
@@ -265,10 +263,9 @@
265 263 );
266 264 if ( isset( $audit ) ) {
267 265 $ret['audit'] = $audit;
268 266 }
269 - // For Blocklist_Monitor.
270 - if ( $this->is_pro ) {
267 + if ( $this->has_hub_api_key ) {
271 268 $blocklist_monitor_class = wd_di()->get( Blocklist_Monitor::class );
272 269 $status = (string) $blocklist_monitor_class->get_status();
273 270 $ret['blocklist_monitor']['enabled'] = '1' === $status;
274 271 $ret['blocklist_monitor']['status'] = $status;
@@ -273,8 +270,9 @@
273 270 $ret['blocklist_monitor']['enabled'] = '1' === $status;
274 271 $ret['blocklist_monitor']['status'] = $status;
275 272 } else {
276 273 $ret['blocklist_monitor']['enabled'] = false;
274 + $ret['blocklist_monitor']['status'] = '-1';
277 275 }
278 276 // For Pwned passwords.
279 277 $pwned_password_model = wd_di()->get( Model_Password_Protection::class );
280 278 $ret['pwned_passwords']['enabled'] = $pwned_password_model->is_active();
@@ -285,18 +283,14 @@
285 283 $ret['force_strong_password']['enabled'] = $strong_password_model->is_active();
286 284 $ret['force_strong_password']['user_roles'] = $strong_password_model->user_roles;
287 285 $ret['force_strong_password']['message'] = $strong_password_model->get_message();
288 286 // For Session Protection.
289 - if ( $this->is_pro ) {
290 - $session_protection_model = wd_di()->get( Session_Protection_Model::class );
291 - $ret['session_protection']['enabled'] = $session_protection_model->enabled;
292 - $ret['session_protection']['user_roles'] = $session_protection_model->user_roles;
293 - $ret['session_protection']['lock_properties'] = $session_protection_model->lock_properties;
294 - $ret['session_protection']['idle_timeout'] = $session_protection_model->idle_timeout;
295 - $ret['session_protection']['login_duration'] = $session_protection_model->login_duration;
296 - } else {
297 - $ret['session_protection']['enabled'] = false;
298 - }
287 + $session_protection_model = wd_di()->get( Session_Protection_Model::class );
288 + $ret['session_protection']['enabled'] = $session_protection_model->enabled;
289 + $ret['session_protection']['user_roles'] = $session_protection_model->user_roles;
290 + $ret['session_protection']['lock_properties'] = $session_protection_model->lock_properties;
291 + $ret['session_protection']['idle_timeout'] = $session_protection_model->idle_timeout;
292 + $ret['session_protection']['login_duration'] = $session_protection_model->login_duration;
299 293 // It's better to add Tweaks as the last key to eliminate unexpected behavior with possible user logout.
300 294 $ret['security_tweaks'] = $security_tweaks;
301 295
302 296 return $ret;
@@ -433,16 +427,19 @@
433 427 $default_ip_lockout_values = ( new Model_Blacklist_Lockout() )->get_default_values();
434 428 $default_ua_lockout_values = ( new Model_Ua_Lockout() )->get_default_values();
435 429 $default_password_protection_values = ( new Model_Password_Protection() )->get_default_values();
436 430 $default_2fa_values = ( new Model_Two_Fa() )->get_default_values();
431 + $default_scan_settings = wd_di()->get( Model_Scan::class );
432 +
437 433 // Total data.
438 - $data = array(
434 + $data = array(
439 435 'scan' => array(
440 436 'integrity_check' => true,
441 437 'check_core' => true,
442 438 'check_plugins' => true,
443 - 'check_known_vuln' => true,
444 - 'scan_malware' => true,
439 + 'check_known_vuln' => $default_scan_settings->check_known_vuln,
440 + 'scan_malware' => $default_scan_settings->scan_malware,
441 + 'check_abandoned_plugin' => true,
445 442 'filesize' => 3,
446 443 'report' => 'enabled',
447 444 'always_send' => false,
448 445 'report_subscribers' => $default_recipients,
@@ -461,9 +458,8 @@
461 458 'email_subject_error' => $default_scan_notification_values['subject_error'],
462 459 'email_content_issue_found' => $default_scan_notification_values['content_issue_found'],
463 460 'email_content_issue_not_found' => $default_scan_notification_values['content_issue_not_found'],
464 461 'email_content_error' => $default_scan_notification_values['content_error'],
465 - // @since 2.7.0 move Scheduled options from Malware Scanning - Reporting to Malware settings.
466 462 // Values for frequency, day and time are above.
467 463 'scheduled_scanning' => true,
468 464 ),
469 465 'iplockout' => array(
@@ -581,54 +577,52 @@
581 577 'enabled' => false,
582 578 'user_roles' => $user_roles,
583 579 'message' => ( new Strong_Password_Model() )->get_message(),
584 580 ),
585 - );
586 - // Pro properties.
587 - if ( $this->is_pro ) {
588 - $data['audit'] = array(
589 - 'enabled' => true,
590 - 'report' => 'enabled',
591 - 'subscribers' => $default_recipients,
592 - 'frequency' => 'weekly',
593 - 'day' => 'sunday',
594 - 'day_n' => 1,
595 - 'time' => '4:00',
596 - // @since 2.7.0 We can remove it in the next version.
597 - 'dry_run' => false,
598 - 'storage_days' => '6 months',
599 - );
600 - $data['blocklist_monitor'] = array(
601 - // @since 2.7.0 Enable.
602 - 'enabled' => true,
603 - 'status' => '1',
604 - );
605 - $data['session_protection'] = array(
581 + 'session_protection' => array(
606 582 'enabled' => false,
607 583 'idle_timeout' => 1,
608 584 'login_duration' => ( new Session_Protection_Model() )->get_default_duration(),
609 585 'user_roles' => $user_roles,
610 586 'lock_properties' => array(),
587 + ),
588 + );
589 + $data['audit'] = array(
590 + 'enabled' => true,
591 + 'report' => 'disabled',
592 + 'subscribers' => $default_recipients,
593 + 'frequency' => 'weekly',
594 + 'day' => 'sunday',
595 + 'day_n' => 1,
596 + 'time' => '4:00',
597 + // @since 2.7.0 We can remove it in the next version.
598 + 'dry_run' => false,
599 + 'storage_days' => '6 months',
600 + );
601 + if ( $this->has_hub_api_key ) {
602 + $data['blocklist_monitor'] = array(
603 + // @since 2.7.0 Enable.
604 + 'enabled' => true,
605 + 'status' => '1',
611 606 );
612 607 } else {
613 - $data['audit']['enabled'] = false;
614 - $data['blocklist_monitor']['enabled'] = false;
608 + $data['blocklist_monitor'] = array(
609 + 'enabled' => false,
610 + 'status' => '-1',
611 + );
615 612 }
616 613 // It's better to add Tweaks as the last key to eliminate unexpected behavior with possible user logout.
617 614 $data['security_tweaks'] = array(
618 - 'notification_repeat' => 'weekly',
619 - 'subscribers' => $default_recipients,
620 - 'notification' => 'enabled',
621 - 'automate' => true,
622 - 'data' => array(),
615 + 'notification' => 'disabled',
616 + 'data' => array(),
623 617 // @since 2.7.0 Specific values for 4 fixed, 0 ignored and 8 actioned tweaks. 12 tweaks in total.
624 - 'fixed' => array(
618 + 'fixed' => array(
625 619 'disable-xml-rpc',
626 620 'login-duration',
627 621 'disable-trackback',
628 622 'prevent-enum-users',
629 623 ),
630 - 'issues' => array(
624 + 'issues' => array(
631 625 'php-version',
632 626 'wp-version',
633 627 'prevent-php-executed',
634 628 'protect-information',
@@ -636,17 +630,18 @@
636 630 'security-key',
637 631 'disable-file-editor',
638 632 'hide-error',
639 633 ),
640 - 'ignore' => array(),
634 + 'ignore' => array(),
641 635 );
642 636
643 637 $configs['configs'] = $data;
644 - $configs['strings'] = $this->create_default_module_strings( $data, $this->is_pro );
638 + $configs['strings'] = $this->create_default_module_strings( $data );
645 639 $configs['name'] = esc_html__( 'Basic Config', 'defender-security' );
646 640 $configs['description'] = esc_html__( 'Recommended default protection for every site', 'defender-security' );
647 641 $configs['immortal'] = true;
648 642 $configs['is_removable'] = true;
643 + $configs['version'] = 2;
649 644 update_site_option( $key, $configs );
650 645 $this->index_key( $key );
651 646 }
652 647
@@ -775,21 +770,17 @@
775 770 // Reset all recipients before.
776 771 $scan_notification->in_house_recipients = array();
777 772 $scan_notification->out_house_recipients = array();
778 773 foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) {
779 - $scan_notification->$key = $subscribers;
774 + if ( 'in_house_recipients' === $key ) {
775 + $scan_notification->in_house_recipients = $subscribers;
776 + } elseif ( 'out_house_recipients' === $key ) {
777 + $scan_notification->out_house_recipients = $subscribers;
778 + }
780 779 }
781 780 }
782 781 $scan_notification->save();
783 782 }
784 - // For Scan report.
785 - if (
786 - $this->is_pro
787 - && isset( $module_data['report'] )
788 - && $scan_report->status !== $module_data['report']
789 - ) {
790 - $scan_report->status = $module_data['report'];
791 - }
792 783 if ( isset( $module_data['always_send'] ) ) {
793 784 $scan_report->configs['always_send'] = $module_data['always_send'];
794 785 }
795 786 if ( isset( $module_data['report_subscribers'] ) && is_array( $module_data['report_subscribers'] ) && array() !== $module_data['report_subscribers'] ) {
@@ -796,16 +787,15 @@
796 787 // Reset all recipients before.
797 788 $scan_report->in_house_recipients = array();
798 789 $scan_report->out_house_recipients = array();
799 790 foreach ( $module_data['report_subscribers'] as $key => $subscribers ) {
800 - $scan_report->$key = $subscribers;
791 + if ( 'in_house_recipients' === $key ) {
792 + $scan_report->in_house_recipients = $subscribers;
793 + } elseif ( 'out_house_recipients' === $key ) {
794 + $scan_report->out_house_recipients = $subscribers;
795 + }
801 796 }
802 797 }
803 - // @since 2.7.0 Remove 'dry_run'-restoring.
804 - // @since 2.7.0 scheduled values. Step#1 if 'report'-key exists.
805 - if ( $this->is_pro && isset( $module_data['report'] ) ) {
806 - $scan_settings->scheduled_scanning = 'enabled' === $module_data['report'];
807 - }
808 798 // Step#2 if 'scheduled_scanning'-key exists.
809 799 if ( isset( $module_data['scheduled_scanning'] ) ) {
810 800 $scan_settings->scheduled_scanning = $module_data['scheduled_scanning'];
811 801 }
@@ -872,45 +862,18 @@
872 862 // Reset all recipients before.
873 863 $lockout_notification->in_house_recipients = array();
874 864 $lockout_notification->out_house_recipients = array();
875 865 foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) {
876 - $lockout_notification->$key = $subscribers;
866 + if ( 'in_house_recipients' === $key ) {
867 + $lockout_notification->in_house_recipients = $subscribers;
868 + } elseif ( 'out_house_recipients' === $key ) {
869 + $lockout_notification->out_house_recipients = $subscribers;
870 + }
877 871 }
878 872 }
879 873
880 874 $lockout_notification->save();
881 875 }
882 - if ( $this->is_pro && isset( $module_data['report'] ) ) {
883 - $lockout_report = new Firewall_Report();
884 - if ( $lockout_report->status !== $module_data['report'] ) {
885 - $lockout_report->status = $module_data['report'];
886 - }
887 - if ( isset( $module_data['day'] ) ) {
888 - $lockout_report->day = $module_data['day'];
889 - }
890 - if ( isset( $module_data['report_frequency'] ) ) {
891 - $lockout_report->frequency = $module_data['report_frequency'];
892 - }
893 - if ( isset( $module_data['day_n'] ) ) {
894 - $lockout_report->day_n = (int) $module_data['day_n'];
895 - }
896 - if ( isset( $module_data['report_time'] ) ) {
897 - $lockout_report->time = $module_data['report_time'];
898 - }
899 - if ( isset( $module_data['report_subscribers'] ) && is_array( $module_data['report_subscribers'] ) && array() !== $module_data['report_subscribers'] ) {
900 - // Reset all recipients before.
901 - $lockout_report->in_house_recipients = array();
902 - $lockout_report->out_house_recipients = array();
903 - foreach ( $module_data['report_subscribers'] as $key => $subscribers ) {
904 - $lockout_report->$key = $subscribers;
905 - }
906 - }
907 - if ( isset( $module_data['last_sent'] ) ) {
908 - $lockout_report->last_sent = $module_data['last_sent'];
909 - }
910 - // @since 2.7.0 Remove 'dry_run'-restoring.
911 - $lockout_report->save();
912 - }
913 876 } else {
914 877 // Default data for lockout notification.
915 878 $lockout_notification = new Firewall_Notification();
916 879 $lockout_notification->status = 'disabled';
@@ -940,15 +903,8 @@
940 903 $controller->import_data( $module_data );
941 904 // Report.
942 905 $audit_report = new Audit_Report();
943 906 if ( is_array( $module_data ) && array() !== $module_data ) {
944 - if (
945 - $this->is_pro
946 - && isset( $module_data['report'] )
947 - && $audit_report->status !== $module_data['report']
948 - ) {
949 - $audit_report->status = $module_data['report'];
950 - }
951 907 if ( isset( $module_data['frequency'] ) ) {
952 908 $audit_report->frequency = $module_data['frequency'];
953 909 }
954 910 if ( isset( $module_data['day_n'] ) ) {
@@ -964,9 +920,13 @@
964 920 // Reset all recipients before.
965 921 $audit_report->in_house_recipients = array();
966 922 $audit_report->out_house_recipients = array();
967 923 foreach ( $module_data['subscribers'] as $key => $subscribers ) {
968 - $audit_report->$key = $subscribers;
924 + if ( 'in_house_recipients' === $key ) {
925 + $audit_report->in_house_recipients = $subscribers;
926 + } elseif ( 'out_house_recipients' === $key ) {
927 + $audit_report->out_house_recipients = $subscribers;
928 + }
969 929 }
970 930 }
971 931 if ( isset( $module_data['last_sent'] ) ) {
972 932 $audit_report->last_sent = $module_data['last_sent'];
@@ -988,13 +948,13 @@
988 948 * If 'blocklist_monitor' module is activated, 'enabled' set as true.
989 949 */
990 950 } elseif (
991 951 'blocklist_monitor' === $module
992 - && $this->is_pro
993 - && isset( $module_data['status'] )
952 + && $this->has_hub_api_key
994 953 ) {
995 954 // No need to import data. Just change status.
996 - ( new Blocklist_Monitor() )->change_status( $module_data['status'] );
955 + $blocklist_status = $module_data['status'] ?? '-1';
956 + ( new Blocklist_Monitor() )->change_status( $blocklist_status );
997 957 } elseif (
998 958 'pwned_passwords' === $module
999 959 && isset( $module_data['custom_message'] )
1000 960 ) {
@@ -1000,9 +960,9 @@
1000 960 ) {
1001 961 $controller->import_data( $module_data );
1002 962 } elseif ( 'force_strong_password' === $module ) {
1003 963 $controller->import_data( $module_data );
1004 - } elseif ( 'session_protection' === $module && $this->is_pro ) {
964 + } elseif ( 'session_protection' === $module ) {
1005 965 $controller->import_data( $module_data );
1006 966 } elseif ( 'two_factor' === $module ) {
1007 967 $controller->import_data( $module_data );
1008 968 } elseif ( 'mask_login' === $module ) {
@@ -1025,47 +985,10 @@
1025 985 // For Tweak notification.
1026 986 if ( is_array( $module_data ) && array() !== $module_data && isset( $module_data['notification'] ) ) {
1027 987 $tweak_notification = new Tweak_Reminder();
1028 988 if ( $tweak_notification->status !== $module_data['notification'] ) {
1029 - $tweak_notification->status = $module_data['notification'];
989 + $tweak_notification->status = 'disabled';
1030 990 }
1031 -
1032 - if ( isset( $module_data['notification_repeat'] ) ) {
1033 - // Temporary check for older versions.
1034 - if ( is_bool( $module_data['notification_repeat'] ) ) {
1035 - $tweak_notification->configs['reminder'] = $module_data['notification_repeat']
1036 - ? 'daily'
1037 - : 'weekly';
1038 - } elseif (
1039 - is_string( $module_data['notification_repeat'] )
1040 - && in_array(
1041 - $module_data['notification_repeat'],
1042 - array(
1043 - 'daily',
1044 - 'weekly',
1045 - 'monthly',
1046 - ),
1047 - true
1048 - )
1049 - ) {
1050 - $tweak_notification->configs['reminder'] = $module_data['notification_repeat'];
1051 - } else {
1052 - $tweak_notification->configs['reminder'] = 'weekly';
1053 - }
1054 - } else {
1055 - $tweak_notification->configs['reminder'] = 'weekly';
1056 - }
1057 - if ( isset( $module_data['subscribers'] ) && is_array( $module_data['subscribers'] ) && array() !== $module_data['subscribers'] ) {
1058 - // Reset all recipients before.
1059 - $tweak_notification->in_house_recipients = array();
1060 - $tweak_notification->out_house_recipients = array();
1061 - foreach ( $module_data['subscribers'] as $key => $subscribers ) {
1062 - $tweak_notification->$key = $subscribers;
1063 - }
1064 - }
1065 - if ( isset( $module_data['last_sent'] ) ) {
1066 - $tweak_notification->last_sent = $module_data['last_sent'];
1067 - }
1068 991 $tweak_notification->save();
1069 992 }
1070 993 }
1071 994 }
@@ -1167,9 +1090,10 @@
1167 1090 *
1168 1091 * @return bool Returns true if the new structure is used, otherwise false.
1169 1092 */
1170 1093 public function check_for_new_structure( array $configs ): bool {
1171 - return array_key_exists( 'subscribers', $configs['security_tweaks'] );
1094 + return isset( $configs['version'] ) ||
1095 + ( isset( $configs['security_tweaks'] ) && array_key_exists( 'enabled_user_enums', $configs['security_tweaks'] ) );
1172 1096 }
1173 1097
1174 1098 /**
1175 1099 * Verifies the integrity of configuration data.
@@ -1201,45 +1125,36 @@
1201 1125 return array();
1202 1126 }
1203 1127
1204 1128 foreach ( $data['configs'] as $key => $config ) {
1205 - if (
1206 - 'security_tweaks' === $key
1207 - && 'enabled' === $config['notification']
1208 - && 1 === ( is_array( $data['strings']['security_tweaks'] )
1209 - || $data['strings']['security_tweaks'] instanceof Countable ? count( $data['strings']['security_tweaks'] ) : 0 )
1210 - ) {
1211 - $data['strings']['security_tweaks'][] = esc_html__( 'Email notifications active', 'defender-security' );
1129 + if ( 'security_tweaks' === $key ) {
1130 + $data['strings']['security_tweaks'] = wd_di()->get( Controller_Security_Tweaks::class )->config_strings( $config );
1212 1131 } elseif ( 'scan' === $key ) {
1213 - $data['strings']['scan'] = wd_di()->get( Controller_Scan::class )->config_strings(
1214 - $config,
1215 - $this->is_pro
1216 - );
1132 + $data['strings']['scan'] = wd_di()->get( Controller_Scan::class )->config_strings( $config );
1217 1133 } elseif ( 'iplockout' === $key ) {
1218 - $data['strings']['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings(
1219 - $config,
1220 - $this->is_pro
1221 - );
1134 + $data['strings']['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings( $config );
1222 1135 } elseif ( 'audit' === $key ) {
1223 1136 // Additional check for Free version.
1224 1137 $config = is_array( $config ) ? $config : array();
1225 - $data['strings']['audit'] = wd_di()->get( Audit_Logging::class )->config_strings(
1226 - $config,
1227 - $this->is_pro
1228 - );
1138 + $data['strings']['audit'] = wd_di()->get( Audit_Logging::class )->config_strings( $config );
1229 1139 } elseif ( 'blocklist_monitor' === $key ) {
1230 1140 // Additional check for Free version.
1231 1141 $config = is_array( $config ) ? $config : array();
1232 - $data['strings']['blocklist_monitor'] = $this->format_blocklist_monitor_strings(
1233 - $config,
1234 - $this->is_pro
1235 - );
1142 + $data['strings']['blocklist_monitor'] = $this->format_blocklist_monitor_strings( $config );
1236 1143 } elseif ( 'pwned_passwords' === $key ) {
1237 - $data['strings']['pwned_passwords'] = wd_di()->get( Controller_Password_Protection::class )->config_strings(
1238 - $config,
1239 - $this->is_pro
1240 - );
1144 + $data['strings']['pwned_passwords'] = wd_di()->get( Controller_Password_Protection::class )->config_strings( $config );
1145 + } elseif ( 'mask_login' === $key ) {
1146 + $data['strings']['mask_login'] = wd_di()->get( Controller_Mask_Login::class )->config_strings( $config );
1147 + } elseif ( 'security_headers' === $key ) {
1148 + $config = is_array( $config ) ? $config : array();
1149 + $data['strings']['security_headers'] = wd_di()->get( Security_Headers::class )->config_strings( $config );
1150 + } elseif ( 'two_factor' === $key ) {
1151 + // Two-Factor is available on both Free and Pro.
1152 + $data['strings']['two_factor'] = wd_di()->get( Two_Factor::class )->config_strings( $config );
1153 + } elseif ( 'force_strong_password' === $key ) {
1154 + $data['strings']['force_strong_password'] = wd_di()->get( Strong_Password_Controller::class )->config_strings( $config );
1241 1155 }
1156 + // todo: display session_protection strings.
1242 1157 }
1243 1158
1244 1159 return $data['strings'];
1245 1160 }
@@ -1246,45 +1161,38 @@
1246 1161
1247 1162 /**
1248 1163 * Creates default module strings for the Basic configuration.
1249 1164 *
1250 - * @param array $configs The configuration data.
1251 - * @param bool $is_pro Whether the current installation is a pro version.
1165 + * @param array $configs The configuration data.
1252 1166 *
1253 1167 * @return array Returns an array of default module strings.
1254 1168 */
1255 - public function create_default_module_strings( array $configs, bool $is_pro ): array {
1169 + public function create_default_module_strings( array $configs ): array {
1256 1170 $strings = array();
1171 +
1257 1172 foreach ( $configs as $key => $config ) {
1258 1173 if ( 'security_tweaks' === $key ) {
1259 - $strings['security_tweaks'] = wd_di()->get( Controller_Security_Tweaks::class )->config_strings(
1260 - $config,
1261 - $is_pro
1262 - );
1174 + $strings['security_tweaks'] = wd_di()->get( Controller_Security_Tweaks::class )->config_strings( $config );
1263 1175 } elseif ( 'scan' === $key ) {
1264 - $strings['scan'] = wd_di()->get( Controller_Scan::class )->config_strings( $config, $is_pro );
1176 + $strings['scan'] = wd_di()->get( Controller_Scan::class )->config_strings( $config );
1265 1177 } elseif ( 'iplockout' === $key ) {
1266 - $strings['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings( $config, $is_pro );
1178 + $strings['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings( $config );
1267 1179 } elseif ( 'audit' === $key ) {
1268 - $strings['audit'] = wd_di()->get( Audit_Logging::class )->config_strings( $config, $is_pro );
1180 + $strings['audit'] = wd_di()->get( Audit_Logging::class )->config_strings( $config );
1269 1181 } elseif ( 'two_factor' === $key ) {
1270 1182 $strings['two_factor'][] = esc_html__( 'Inactive', 'defender-security' );
1271 1183 } elseif ( 'mask_login' === $key ) {
1272 - $strings['mask_login'][] = esc_html__( 'Inactive', 'defender-security' );
1184 + $strings['mask_login'] = wd_di()->get( Controller_Mask_Login::class )->config_strings( $config );
1273 1185 } elseif ( 'security_headers' === $key ) {
1274 - $strings['security_headers'][] = esc_html__( 'Active', 'defender-security' );
1186 + $strings['security_headers'] = wd_di()->get( Security_Headers::class )->config_strings( $config );
1275 1187 } elseif ( 'blocklist_monitor' === $key ) {
1276 - $strings['blocklist_monitor'] = wd_di()->get( Blocklist_Monitor::class )->config_strings(
1277 - $config,
1278 - $is_pro
1279 - );
1188 + $strings['blocklist_monitor'] = wd_di()->get( Blocklist_Monitor::class )->config_strings( $config );
1280 1189 } elseif ( 'pwned_passwords' === $key ) {
1281 1190 $strings['pwned_passwords'][] = esc_html__( 'Inactive', 'defender-security' );
1282 1191 } elseif ( 'force_strong_password' === $key ) {
1283 1192 $strings['force_strong_password'][] = esc_html__( 'Inactive', 'defender-security' );
1284 - } elseif ( 'session_protection' === $key ) {
1285 - $strings['session_protection'][] = esc_html__( 'Inactive', 'defender-security' );
1286 1193 }
1194 + // todo: display session_protection strings.
1287 1195 }
1288 1196
1289 1197 return $strings;
1290 1198 }
@@ -1314,9 +1222,9 @@
1314 1222 * @return array
1315 1223 */
1316 1224 private function get_prev_settings(): array {
1317 1225 $arr = array();
1318 - if ( $this->is_pro ) {
1226 + if ( $this->has_hub_api_key ) {
1319 1227 $status = (string) wd_di()->get( Blocklist_Monitor::class )->get_status();
1320 1228 $arr['enabled'] = '1' === $status;
1321 1229 $arr['status'] = $status;
1322 1230 } else {
@@ -1347,11 +1255,11 @@
1347 1255 */
1348 1256 private function module_to_name( string $module ): string {
1349 1257 switch ( $module ) {
1350 1258 case 'security_tweaks':
1351 - return esc_html__( 'Security Recommendations', 'defender-security' );
1259 + return esc_html__( 'Hardening', 'defender-security' );
1352 1260 case 'scan':
1353 - return esc_html__( 'Malware Scanning', 'defender-security' );
1261 + return esc_html__( 'Issue', 'defender-security' );
1354 1262 case 'audit':
1355 1263 return Model_Audit_Logging::get_module_name();
1356 1264 case 'iplockout':
1357 1265 return esc_html__( 'Firewall', 'defender-security' );
@@ -1477,39 +1385,21 @@
1477 1385 );
1478 1386 }
1479 1387
1480 1388 /**
1481 - * Format strings of Block list Monitor config.
1389 + * Format strings of Blocklist Monitor config.
1482 1390 *
1483 1391 * @param array $config Saved config.
1484 - * @param bool $is_pro User membership status.
1485 1392 *
1486 1393 * @return array
1487 1394 */
1488 - private function format_blocklist_monitor_strings( array $config, bool $is_pro ): array {
1489 - // If Block list Monitor is enable.
1490 - if ( isset( $config['status'] ) && '1' === (string) $config['status'] ) {
1491 - if ( $is_pro ) {
1492 - $monitor = array( esc_html__( 'Active', 'defender-security' ) );
1493 - } else {
1494 - $monitor = array(
1495 - sprintf(
1496 - /* translators: %s: Html for Pro-tag. */
1497 - esc_html__( 'Active %s', 'defender-security' ),
1498 - '<span class="sui-tag sui-tag-pro">Pro</span>'
1499 - ),
1500 - );
1501 - }
1502 - } elseif ( $is_pro ) {
1503 - $monitor = array( esc_html__( 'Inactive', 'defender-security' ) );
1395 + private function format_blocklist_monitor_strings( array $config ): array {
1396 + if ( $this->has_hub_api_key ) {
1397 + $monitor = isset( $config['status'] ) && '1' === (string) $config['status']
1398 + ? array( esc_html__( 'Blocklist Monitor active', 'defender-security' ) )
1399 + : array( esc_html__( 'Blocklist Monitor inactive', 'defender-security' ) );
1504 1400 } else {
1505 - $monitor = array(
1506 - sprintf(
1507 - /* translators: %s: Html for Pro-tag. */
1508 - esc_html__( 'Inactive %s', 'defender-security' ),
1509 - '<span class="sui-tag sui-tag-pro">Pro</span>'
1510 - ),
1511 - );
1401 + $monitor = array( esc_html__( 'Blocklist Monitor inactive', 'defender-security' ) );
1512 1402 }
1513 1403
1514 1404 return $monitor;
1515 1405 }