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/model/setting/class-scan.php +16 -34 5.6.0 → 6.3.0 View file →
@@ -6,12 +6,9 @@
6 6 */
7 7
8 8 namespace WP_Defender\Model\Setting;
9 9
10 -use DateTime;
11 -use Exception;
12 10 use Calotes\Model\Setting;
13 -use function wp_timezone;
14 11
15 12 /**
16 13 * Model for scan settings.
17 14 */
@@ -86,9 +83,9 @@
86 83 * @var string
87 84 * @defender_property
88 85 * @rule in[daily,weekly,monthly]
89 86 */
90 - public $frequency;
87 + public $frequency = 'weekly';
91 88
92 89 /**
93 90 * The day of scheduled scan.
94 91 *
@@ -95,15 +92,14 @@
95 92 * @var string
96 93 * @defender_property
97 94 * @sanitize_text_field
98 95 */
99 - public $day;
96 + public $day = '';
100 97
101 98 /**
102 99 * This is for when user select scheduled scan as monthly, we will have the day number, instead of text.
103 100 *
104 101 * @var int
105 - * @sanitize_text_field
106 102 * @defender_property
107 103 */
108 104 public int $day_n = 1;
109 105
@@ -113,9 +109,9 @@
113 109 * @var string
114 110 * @defender_property
115 111 * @sanitize_text_field
116 112 */
117 - public $time;
113 + public $time = '';
118 114
119 115 /**
120 116 * Quarantine file deletion/expiration cron schedule.
121 117 *
@@ -177,9 +173,9 @@
177 173 *
178 174 * @return void
179 175 */
180 176 protected function after_validate(): void {
181 - // Case#1: all child types of File change detection are unchecked BUT parent type is checked.
177 + // Case#1: all child types of File change detection are unchecked BUT the parent type is checked.
182 178 if ( $this->integrity_check && ! $this->check_core && ! $this->check_plugins ) {
183 179 $this->errors[] = sprintf(
184 180 /* translators: %s: File change detection. */
185 181 esc_html__( 'You have not selected a scan type for the %s. Please choose at least one and save the settings again.', 'defender-security' ),
@@ -184,10 +180,10 @@
184 180 /* translators: %s: File change detection. */
185 181 esc_html__( 'You have not selected a scan type for the %s. Please choose at least one and save the settings again.', 'defender-security' ),
186 182 '<strong>' . esc_html__( 'File change detection', 'defender-security' ) . '</strong>'
187 183 );
188 - // Case#2: all scan types are unchecked and Scheduled Scanning is checked.
189 - } elseif ( ! $this->is_enabled_any_scan_type() && $this->scheduled_scanning ) {
184 + // Case#2: all scan types are unchecked.
185 + } elseif ( ! $this->is_enabled_any_scan_type() ) {
190 186 $this->errors[] = esc_html__(
191 187 'You have not selected a scan type. Please enable at least one scan type and save the settings again.',
192 188 'defender-security'
193 189 );
@@ -194,36 +190,13 @@
194 190 }
195 191 }
196 192
197 193 /**
198 - * Initializes the object by setting default values for the frequency, day, day_n, and time properties based on the
199 - * current day and time.
194 + * Initializes the object by setting default values.
200 195 *
201 196 * @return void
202 - * @throws Exception Emits Exception in case of an error.
203 - * @since 4.7.1 Implement Dynamic Scan Scheduling to avoid event spikes on MP.
204 197 */
205 198 protected function before_load(): void {
206 - // Get current day and time.
207 - $date = new DateTime( 'now', wp_timezone() );
208 - $result = explode( '--', $date->format( 'l--H--i' ) );
209 - $day = strtolower( $result[0] );
210 - $current_hours = (int) $result[1];
211 - $current_mins = (int) $result[2];
212 - // We have a 30 minute span, so XX:00-15 => XX:00, XX:16-45 => XX:30, XX:46-59 => (XX+1):00.
213 - if ( $current_mins > 15 && $current_mins <= 45 ) {
214 - $mins = '30';
215 - } elseif ( $current_mins >= 0 && $current_mins < 16 ) {
216 - $mins = '00';
217 - } else {
218 - ++$current_hours;
219 - $mins = '00';
220 - }
221 -
222 - $this->frequency = 'weekly';
223 - $this->day = $day;
224 - $this->day_n = 1;
225 - $this->time = $current_hours . ':' . $mins;
226 199 }
227 200
228 201 /**
229 202 * Is enabled any scan type at least?
@@ -234,6 +207,15 @@
234 207 return $this->integrity_check
235 208 || $this->check_known_vuln
236 209 || $this->scan_malware
237 210 || $this->check_abandoned_plugin;
211 + }
212 +
213 + /**
214 + * Is enabled Scheduled Scanning?
215 + *
216 + * @return bool
217 + */
218 + public function is_enabled_scheduled_scanning(): bool {
219 + return false;
238 220 }
239 221 }