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 +116 -234 5.9.0 → 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,
@@ -168,9 +167,9 @@
168 167 $settings = new Model_Audit_Logging();
169 168 $audit_report = new Audit_Report();
170 169 $audit = array(
171 170 'enabled' => $settings->is_active(),
172 - 'report' => $audit_report->status,
171 + 'report' => 'disabled',
173 172 'subscribers' => $this->change_subscriber_format( $audit_report ),
174 173 'frequency' => $audit_report->frequency,
175 174 'day' => $audit_report->day,
176 175 'day_n' => $audit_report->day_n,
@@ -178,14 +177,12 @@
178 177 // @since 2.7.0 We can remove it in the next version.
179 178 'dry_run' => false,
180 179 'storage_days' => $settings->storage_days,
181 180 );
182 - if ( ! $this->is_pro ) {
183 - $audit['enabled'] = false;
184 - }
185 181 } else {
186 182 $audit['enabled'] = false;
187 183 }
184 +
188 185 $settings_firewall = new Model_Firewall();
189 186 $settings_ll = new Model_Login_Lockout();
190 187 $settings_nl = new Model_Notfound_Lockout();
191 188 $settings_bl = new Model_Blacklist_Lockout();
@@ -266,10 +263,9 @@
266 263 );
267 264 if ( isset( $audit ) ) {
268 265 $ret['audit'] = $audit;
269 266 }
270 - // For Blocklist_Monitor.
271 - if ( $this->is_pro ) {
267 + if ( $this->has_hub_api_key ) {
272 268 $blocklist_monitor_class = wd_di()->get( Blocklist_Monitor::class );
273 269 $status = (string) $blocklist_monitor_class->get_status();
274 270 $ret['blocklist_monitor']['enabled'] = '1' === $status;
275 271 $ret['blocklist_monitor']['status'] = $status;
@@ -274,8 +270,9 @@
274 270 $ret['blocklist_monitor']['enabled'] = '1' === $status;
275 271 $ret['blocklist_monitor']['status'] = $status;
276 272 } else {
277 273 $ret['blocklist_monitor']['enabled'] = false;
274 + $ret['blocklist_monitor']['status'] = '-1';
278 275 }
279 276 // For Pwned passwords.
280 277 $pwned_password_model = wd_di()->get( Model_Password_Protection::class );
281 278 $ret['pwned_passwords']['enabled'] = $pwned_password_model->is_active();
@@ -286,18 +283,14 @@
286 283 $ret['force_strong_password']['enabled'] = $strong_password_model->is_active();
287 284 $ret['force_strong_password']['user_roles'] = $strong_password_model->user_roles;
288 285 $ret['force_strong_password']['message'] = $strong_password_model->get_message();
289 286 // For Session Protection.
290 - if ( $this->is_pro ) {
291 - $session_protection_model = wd_di()->get( Session_Protection_Model::class );
292 - $ret['session_protection']['enabled'] = $session_protection_model->enabled;
293 - $ret['session_protection']['user_roles'] = $session_protection_model->user_roles;
294 - $ret['session_protection']['lock_properties'] = $session_protection_model->lock_properties;
295 - $ret['session_protection']['idle_timeout'] = $session_protection_model->idle_timeout;
296 - $ret['session_protection']['login_duration'] = $session_protection_model->login_duration;
297 - } else {
298 - $ret['session_protection']['enabled'] = false;
299 - }
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;
300 293 // It's better to add Tweaks as the last key to eliminate unexpected behavior with possible user logout.
301 294 $ret['security_tweaks'] = $security_tweaks;
302 295
303 296 return $ret;
@@ -434,16 +427,18 @@
434 427 $default_ip_lockout_values = ( new Model_Blacklist_Lockout() )->get_default_values();
435 428 $default_ua_lockout_values = ( new Model_Ua_Lockout() )->get_default_values();
436 429 $default_password_protection_values = ( new Model_Password_Protection() )->get_default_values();
437 430 $default_2fa_values = ( new Model_Two_Fa() )->get_default_values();
431 + $default_scan_settings = wd_di()->get( Model_Scan::class );
432 +
438 433 // Total data.
439 - $data = array(
434 + $data = array(
440 435 'scan' => array(
441 436 'integrity_check' => true,
442 437 'check_core' => true,
443 438 'check_plugins' => true,
444 - 'check_known_vuln' => true,
445 - 'scan_malware' => true,
439 + 'check_known_vuln' => $default_scan_settings->check_known_vuln,
440 + 'scan_malware' => $default_scan_settings->scan_malware,
446 441 'check_abandoned_plugin' => true,
447 442 'filesize' => 3,
448 443 'report' => 'enabled',
449 444 'always_send' => false,
@@ -463,9 +458,8 @@
463 458 'email_subject_error' => $default_scan_notification_values['subject_error'],
464 459 'email_content_issue_found' => $default_scan_notification_values['content_issue_found'],
465 460 'email_content_issue_not_found' => $default_scan_notification_values['content_issue_not_found'],
466 461 'email_content_error' => $default_scan_notification_values['content_error'],
467 - // @since 2.7.0 move Scheduled options from Malware Scanning - Reporting to Malware settings.
468 462 // Values for frequency, day and time are above.
469 463 'scheduled_scanning' => true,
470 464 ),
471 465 'iplockout' => array(
@@ -583,54 +577,52 @@
583 577 'enabled' => false,
584 578 'user_roles' => $user_roles,
585 579 'message' => ( new Strong_Password_Model() )->get_message(),
586 580 ),
587 - );
588 - // Pro properties.
589 - if ( $this->is_pro ) {
590 - $data['audit'] = array(
591 - 'enabled' => true,
592 - 'report' => 'enabled',
593 - 'subscribers' => $default_recipients,
594 - 'frequency' => 'weekly',
595 - 'day' => 'sunday',
596 - 'day_n' => 1,
597 - 'time' => '4:00',
598 - // @since 2.7.0 We can remove it in the next version.
599 - 'dry_run' => false,
600 - 'storage_days' => '6 months',
601 - );
602 - $data['blocklist_monitor'] = array(
603 - // @since 2.7.0 Enable.
604 - 'enabled' => true,
605 - 'status' => '1',
606 - );
607 - $data['session_protection'] = array(
581 + 'session_protection' => array(
608 582 'enabled' => false,
609 583 'idle_timeout' => 1,
610 584 'login_duration' => ( new Session_Protection_Model() )->get_default_duration(),
611 585 'user_roles' => $user_roles,
612 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',
613 606 );
614 607 } else {
615 - $data['audit']['enabled'] = false;
616 - $data['blocklist_monitor']['enabled'] = false;
608 + $data['blocklist_monitor'] = array(
609 + 'enabled' => false,
610 + 'status' => '-1',
611 + );
617 612 }
618 613 // It's better to add Tweaks as the last key to eliminate unexpected behavior with possible user logout.
619 614 $data['security_tweaks'] = array(
620 - 'notification_repeat' => 'weekly',
621 - 'subscribers' => $default_recipients,
622 - 'notification' => 'enabled',
623 - 'automate' => true,
624 - 'data' => array(),
615 + 'notification' => 'disabled',
616 + 'data' => array(),
625 617 // @since 2.7.0 Specific values for 4 fixed, 0 ignored and 8 actioned tweaks. 12 tweaks in total.
626 - 'fixed' => array(
618 + 'fixed' => array(
627 619 'disable-xml-rpc',
628 620 'login-duration',
629 621 'disable-trackback',
630 622 'prevent-enum-users',
631 623 ),
632 - 'issues' => array(
624 + 'issues' => array(
633 625 'php-version',
634 626 'wp-version',
635 627 'prevent-php-executed',
636 628 'protect-information',
@@ -638,17 +630,18 @@
638 630 'security-key',
639 631 'disable-file-editor',
640 632 'hide-error',
641 633 ),
642 - 'ignore' => array(),
634 + 'ignore' => array(),
643 635 );
644 636
645 637 $configs['configs'] = $data;
646 - $configs['strings'] = $this->create_default_module_strings( $data, $this->is_pro );
638 + $configs['strings'] = $this->create_default_module_strings( $data );
647 639 $configs['name'] = esc_html__( 'Basic Config', 'defender-security' );
648 640 $configs['description'] = esc_html__( 'Recommended default protection for every site', 'defender-security' );
649 641 $configs['immortal'] = true;
650 642 $configs['is_removable'] = true;
643 + $configs['version'] = 2;
651 644 update_site_option( $key, $configs );
652 645 $this->index_key( $key );
653 646 }
654 647
@@ -777,22 +770,17 @@
777 770 // Reset all recipients before.
778 771 $scan_notification->in_house_recipients = array();
779 772 $scan_notification->out_house_recipients = array();
780 773 foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) {
781 - // @phpstan-ignore-next-line
782 - $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 + }
783 779 }
784 780 }
785 781 $scan_notification->save();
786 782 }
787 - // For Scan report.
788 - if (
789 - $this->is_pro
790 - && isset( $module_data['report'] )
791 - && $scan_report->status !== $module_data['report']
792 - ) {
793 - $scan_report->status = $module_data['report'];
794 - }
795 783 if ( isset( $module_data['always_send'] ) ) {
796 784 $scan_report->configs['always_send'] = $module_data['always_send'];
797 785 }
798 786 if ( isset( $module_data['report_subscribers'] ) && is_array( $module_data['report_subscribers'] ) && array() !== $module_data['report_subscribers'] ) {
@@ -799,17 +787,15 @@
799 787 // Reset all recipients before.
800 788 $scan_report->in_house_recipients = array();
801 789 $scan_report->out_house_recipients = array();
802 790 foreach ( $module_data['report_subscribers'] as $key => $subscribers ) {
803 - // @phpstan-ignore-next-line
804 - $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 + }
805 796 }
806 797 }
807 - // @since 2.7.0 Remove 'dry_run'-restoring.
808 - // @since 2.7.0 scheduled values. Step#1 if 'report'-key exists.
809 - if ( $this->is_pro && isset( $module_data['report'] ) ) {
810 - $scan_settings->scheduled_scanning = 'enabled' === $module_data['report'];
811 - }
812 798 // Step#2 if 'scheduled_scanning'-key exists.
813 799 if ( isset( $module_data['scheduled_scanning'] ) ) {
814 800 $scan_settings->scheduled_scanning = $module_data['scheduled_scanning'];
815 801 }
@@ -876,47 +862,18 @@
876 862 // Reset all recipients before.
877 863 $lockout_notification->in_house_recipients = array();
878 864 $lockout_notification->out_house_recipients = array();
879 865 foreach ( $module_data['notification_subscribers'] as $key => $subscribers ) {
880 - // @phpstan-ignore-next-line
881 - $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 + }
882 871 }
883 872 }
884 873
885 874 $lockout_notification->save();
886 875 }
887 - if ( $this->is_pro && isset( $module_data['report'] ) ) {
888 - $lockout_report = new Firewall_Report();
889 - if ( $lockout_report->status !== $module_data['report'] ) {
890 - $lockout_report->status = $module_data['report'];
891 - }
892 - if ( isset( $module_data['day'] ) ) {
893 - $lockout_report->day = $module_data['day'];
894 - }
895 - if ( isset( $module_data['report_frequency'] ) ) {
896 - $lockout_report->frequency = $module_data['report_frequency'];
897 - }
898 - if ( isset( $module_data['day_n'] ) ) {
899 - $lockout_report->day_n = (int) $module_data['day_n'];
900 - }
901 - if ( isset( $module_data['report_time'] ) ) {
902 - $lockout_report->time = $module_data['report_time'];
903 - }
904 - if ( isset( $module_data['report_subscribers'] ) && is_array( $module_data['report_subscribers'] ) && array() !== $module_data['report_subscribers'] ) {
905 - // Reset all recipients before.
906 - $lockout_report->in_house_recipients = array();
907 - $lockout_report->out_house_recipients = array();
908 - foreach ( $module_data['report_subscribers'] as $key => $subscribers ) {
909 - // @phpstan-ignore-next-line
910 - $lockout_report->$key = $subscribers;
911 - }
912 - }
913 - if ( isset( $module_data['last_sent'] ) ) {
914 - $lockout_report->last_sent = $module_data['last_sent'];
915 - }
916 - // @since 2.7.0 Remove 'dry_run'-restoring.
917 - $lockout_report->save();
918 - }
919 876 } else {
920 877 // Default data for lockout notification.
921 878 $lockout_notification = new Firewall_Notification();
922 879 $lockout_notification->status = 'disabled';
@@ -946,15 +903,8 @@
946 903 $controller->import_data( $module_data );
947 904 // Report.
948 905 $audit_report = new Audit_Report();
949 906 if ( is_array( $module_data ) && array() !== $module_data ) {
950 - if (
951 - $this->is_pro
952 - && isset( $module_data['report'] )
953 - && $audit_report->status !== $module_data['report']
954 - ) {
955 - $audit_report->status = $module_data['report'];
956 - }
957 907 if ( isset( $module_data['frequency'] ) ) {
958 908 $audit_report->frequency = $module_data['frequency'];
959 909 }
960 910 if ( isset( $module_data['day_n'] ) ) {
@@ -970,10 +920,13 @@
970 920 // Reset all recipients before.
971 921 $audit_report->in_house_recipients = array();
972 922 $audit_report->out_house_recipients = array();
973 923 foreach ( $module_data['subscribers'] as $key => $subscribers ) {
974 - // @phpstan-ignore-next-line
975 - $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 + }
976 929 }
977 930 }
978 931 if ( isset( $module_data['last_sent'] ) ) {
979 932 $audit_report->last_sent = $module_data['last_sent'];
@@ -995,13 +948,13 @@
995 948 * If 'blocklist_monitor' module is activated, 'enabled' set as true.
996 949 */
997 950 } elseif (
998 951 'blocklist_monitor' === $module
999 - && $this->is_pro
1000 - && isset( $module_data['status'] )
952 + && $this->has_hub_api_key
1001 953 ) {
1002 954 // No need to import data. Just change status.
1003 - ( new Blocklist_Monitor() )->change_status( $module_data['status'] );
955 + $blocklist_status = $module_data['status'] ?? '-1';
956 + ( new Blocklist_Monitor() )->change_status( $blocklist_status );
1004 957 } elseif (
1005 958 'pwned_passwords' === $module
1006 959 && isset( $module_data['custom_message'] )
1007 960 ) {
@@ -1007,9 +960,9 @@
1007 960 ) {
1008 961 $controller->import_data( $module_data );
1009 962 } elseif ( 'force_strong_password' === $module ) {
1010 963 $controller->import_data( $module_data );
1011 - } elseif ( 'session_protection' === $module && $this->is_pro ) {
964 + } elseif ( 'session_protection' === $module ) {
1012 965 $controller->import_data( $module_data );
1013 966 } elseif ( 'two_factor' === $module ) {
1014 967 $controller->import_data( $module_data );
1015 968 } elseif ( 'mask_login' === $module ) {
@@ -1032,48 +985,10 @@
1032 985 // For Tweak notification.
1033 986 if ( is_array( $module_data ) && array() !== $module_data && isset( $module_data['notification'] ) ) {
1034 987 $tweak_notification = new Tweak_Reminder();
1035 988 if ( $tweak_notification->status !== $module_data['notification'] ) {
1036 - $tweak_notification->status = $module_data['notification'];
989 + $tweak_notification->status = 'disabled';
1037 990 }
1038 -
1039 - if ( isset( $module_data['notification_repeat'] ) ) {
1040 - // Temporary check for older versions.
1041 - if ( is_bool( $module_data['notification_repeat'] ) ) {
1042 - $tweak_notification->configs['reminder'] = $module_data['notification_repeat']
1043 - ? 'daily'
1044 - : 'weekly';
1045 - } elseif (
1046 - is_string( $module_data['notification_repeat'] )
1047 - && in_array(
1048 - $module_data['notification_repeat'],
1049 - array(
1050 - 'daily',
1051 - 'weekly',
1052 - 'monthly',
1053 - ),
1054 - true
1055 - )
1056 - ) {
1057 - $tweak_notification->configs['reminder'] = $module_data['notification_repeat'];
1058 - } else {
1059 - $tweak_notification->configs['reminder'] = 'weekly';
1060 - }
1061 - } else {
1062 - $tweak_notification->configs['reminder'] = 'weekly';
1063 - }
1064 - if ( isset( $module_data['subscribers'] ) && is_array( $module_data['subscribers'] ) && array() !== $module_data['subscribers'] ) {
1065 - // Reset all recipients before.
1066 - $tweak_notification->in_house_recipients = array();
1067 - $tweak_notification->out_house_recipients = array();
1068 - foreach ( $module_data['subscribers'] as $key => $subscribers ) {
1069 - // @phpstan-ignore-next-line
1070 - $tweak_notification->$key = $subscribers;
1071 - }
1072 - }
1073 - if ( isset( $module_data['last_sent'] ) ) {
1074 - $tweak_notification->last_sent = $module_data['last_sent'];
1075 - }
1076 991 $tweak_notification->save();
1077 992 }
1078 993 }
1079 994 }
@@ -1175,9 +1090,10 @@
1175 1090 *
1176 1091 * @return bool Returns true if the new structure is used, otherwise false.
1177 1092 */
1178 1093 public function check_for_new_structure( array $configs ): bool {
1179 - 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'] ) );
1180 1096 }
1181 1097
1182 1098 /**
1183 1099 * Verifies the integrity of configuration data.
@@ -1209,45 +1125,36 @@
1209 1125 return array();
1210 1126 }
1211 1127
1212 1128 foreach ( $data['configs'] as $key => $config ) {
1213 - if (
1214 - 'security_tweaks' === $key
1215 - && 'enabled' === $config['notification']
1216 - && 1 === ( is_array( $data['strings']['security_tweaks'] )
1217 - || $data['strings']['security_tweaks'] instanceof Countable ? count( $data['strings']['security_tweaks'] ) : 0 )
1218 - ) {
1219 - $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 );
1220 1131 } elseif ( 'scan' === $key ) {
1221 - $data['strings']['scan'] = wd_di()->get( Controller_Scan::class )->config_strings(
1222 - $config,
1223 - $this->is_pro
1224 - );
1132 + $data['strings']['scan'] = wd_di()->get( Controller_Scan::class )->config_strings( $config );
1225 1133 } elseif ( 'iplockout' === $key ) {
1226 - $data['strings']['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings(
1227 - $config,
1228 - $this->is_pro
1229 - );
1134 + $data['strings']['iplockout'] = wd_di()->get( Controller_Firewall::class )->config_strings( $config );
1230 1135 } elseif ( 'audit' === $key ) {
1231 1136 // Additional check for Free version.
1232 1137 $config = is_array( $config ) ? $config : array();
1233 - $data['strings']['audit'] = wd_di()->get( Audit_Logging::class )->config_strings(
1234 - $config,
1235 - $this->is_pro
1236 - );
1138 + $data['strings']['audit'] = wd_di()->get( Audit_Logging::class )->config_strings( $config );
1237 1139 } elseif ( 'blocklist_monitor' === $key ) {
1238 1140 // Additional check for Free version.
1239 1141 $config = is_array( $config ) ? $config : array();
1240 - $data['strings']['blocklist_monitor'] = $this->format_blocklist_monitor_strings(
1241 - $config,
1242 - $this->is_pro
1243 - );
1142 + $data['strings']['blocklist_monitor'] = $this->format_blocklist_monitor_strings( $config );
1244 1143 } elseif ( 'pwned_passwords' === $key ) {
1245 - $data['strings']['pwned_passwords'] = wd_di()->get( Controller_Password_Protection::class )->config_strings(
1246 - $config,
1247 - $this->is_pro
1248 - );
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 );
1249 1155 }
1156 + // todo: display session_protection strings.
1250 1157 }
1251 1158
1252 1159 return $data['strings'];
1253 1160 }
@@ -1254,45 +1161,38 @@
1254 1161
1255 1162 /**
1256 1163 * Creates default module strings for the Basic configuration.
1257 1164 *
1258 - * @param array $configs The configuration data.
1259 - * @param bool $is_pro Whether the current installation is a pro version.
1165 + * @param array $configs The configuration data.
1260 1166 *
1261 1167 * @return array Returns an array of default module strings.
1262 1168 */
1263 - public function create_default_module_strings( array $configs, bool $is_pro ): array {
1169 + public function create_default_module_strings( array $configs ): array {
1264 1170 $strings = array();
1171 +
1265 1172 foreach ( $configs as $key => $config ) {
1266 1173 if ( 'security_tweaks' === $key ) {
1267 - $strings['security_tweaks'] = wd_di()->get( Controller_Security_Tweaks::class )->config_strings(
1268 - $config,
1269 - $is_pro
1270 - );
1174 + $strings['security_tweaks'] = wd_di()->get( Controller_Security_Tweaks::class )->config_strings( $config );
1271 1175 } elseif ( 'scan' === $key ) {
1272 - $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 );
1273 1177 } elseif ( 'iplockout' === $key ) {
1274 - $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 );
1275 1179 } elseif ( 'audit' === $key ) {
1276 - $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 );
1277 1181 } elseif ( 'two_factor' === $key ) {
1278 1182 $strings['two_factor'][] = esc_html__( 'Inactive', 'defender-security' );
1279 1183 } elseif ( 'mask_login' === $key ) {
1280 - $strings['mask_login'][] = esc_html__( 'Inactive', 'defender-security' );
1184 + $strings['mask_login'] = wd_di()->get( Controller_Mask_Login::class )->config_strings( $config );
1281 1185 } elseif ( 'security_headers' === $key ) {
1282 - $strings['security_headers'][] = esc_html__( 'Active', 'defender-security' );
1186 + $strings['security_headers'] = wd_di()->get( Security_Headers::class )->config_strings( $config );
1283 1187 } elseif ( 'blocklist_monitor' === $key ) {
1284 - $strings['blocklist_monitor'] = wd_di()->get( Blocklist_Monitor::class )->config_strings(
1285 - $config,
1286 - $is_pro
1287 - );
1188 + $strings['blocklist_monitor'] = wd_di()->get( Blocklist_Monitor::class )->config_strings( $config );
1288 1189 } elseif ( 'pwned_passwords' === $key ) {
1289 1190 $strings['pwned_passwords'][] = esc_html__( 'Inactive', 'defender-security' );
1290 1191 } elseif ( 'force_strong_password' === $key ) {
1291 1192 $strings['force_strong_password'][] = esc_html__( 'Inactive', 'defender-security' );
1292 - } elseif ( 'session_protection' === $key ) {
1293 - $strings['session_protection'][] = esc_html__( 'Inactive', 'defender-security' );
1294 1193 }
1194 + // todo: display session_protection strings.
1295 1195 }
1296 1196
1297 1197 return $strings;
1298 1198 }
@@ -1322,9 +1222,9 @@
1322 1222 * @return array
1323 1223 */
1324 1224 private function get_prev_settings(): array {
1325 1225 $arr = array();
1326 - if ( $this->is_pro ) {
1226 + if ( $this->has_hub_api_key ) {
1327 1227 $status = (string) wd_di()->get( Blocklist_Monitor::class )->get_status();
1328 1228 $arr['enabled'] = '1' === $status;
1329 1229 $arr['status'] = $status;
1330 1230 } else {
@@ -1355,11 +1255,11 @@
1355 1255 */
1356 1256 private function module_to_name( string $module ): string {
1357 1257 switch ( $module ) {
1358 1258 case 'security_tweaks':
1359 - return esc_html__( 'Security Recommendations', 'defender-security' );
1259 + return esc_html__( 'Hardening', 'defender-security' );
1360 1260 case 'scan':
1361 - return esc_html__( 'Malware Scanning', 'defender-security' );
1261 + return esc_html__( 'Issue', 'defender-security' );
1362 1262 case 'audit':
1363 1263 return Model_Audit_Logging::get_module_name();
1364 1264 case 'iplockout':
1365 1265 return esc_html__( 'Firewall', 'defender-security' );
@@ -1485,39 +1385,21 @@
1485 1385 );
1486 1386 }
1487 1387
1488 1388 /**
1489 - * Format strings of Block list Monitor config.
1389 + * Format strings of Blocklist Monitor config.
1490 1390 *
1491 1391 * @param array $config Saved config.
1492 - * @param bool $is_pro User membership status.
1493 1392 *
1494 1393 * @return array
1495 1394 */
1496 - private function format_blocklist_monitor_strings( array $config, bool $is_pro ): array {
1497 - // If Block list Monitor is enable.
1498 - if ( isset( $config['status'] ) && '1' === (string) $config['status'] ) {
1499 - if ( $is_pro ) {
1500 - $monitor = array( esc_html__( 'Active', 'defender-security' ) );
1501 - } else {
1502 - $monitor = array(
1503 - sprintf(
1504 - /* translators: %s: Html for Pro-tag. */
1505 - esc_html__( 'Active %s', 'defender-security' ),
1506 - '<span class="sui-tag sui-tag-pro">Pro</span>'
1507 - ),
1508 - );
1509 - }
1510 - } elseif ( $is_pro ) {
1511 - $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' ) );
1512 1400 } else {
1513 - $monitor = array(
1514 - sprintf(
1515 - /* translators: %s: Html for Pro-tag. */
1516 - esc_html__( 'Inactive %s', 'defender-security' ),
1517 - '<span class="sui-tag sui-tag-pro">Pro</span>'
1518 - ),
1519 - );
1401 + $monitor = array( esc_html__( 'Blocklist Monitor inactive', 'defender-security' ) );
1520 1402 }
1521 1403
1522 1404 return $monitor;
1523 1405 }