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-rate.php +41 -15 5.7.1 → 6.3.0 View file →
@@ -9,9 +9,8 @@
9 9
10 10 use Calotes\Base\Component;
11 11 use WP_Defender\Model\Setting\Security_Tweaks;
12 12 use WP_Defender\Traits\Defender_Bootstrap;
13 -use WP_Defender\Helper\Analytics\Rate as Rate_Analytics;
14 13
15 14 /**
16 15 * Handles the functionality related to user ratings and notifications.
17 16 *
@@ -119,11 +118,9 @@
119 118 *
120 119 * @return int The count of scans.
121 120 */
122 121 protected static function get_count_scans( $slug ): int {
123 - $scan_count = get_site_option( $slug, false );
124 -
125 - return empty( $scan_count ) ? 0 : (int) $scan_count;
122 + return (int) get_site_option( $slug, 0 );
126 123 }
127 124
128 125 /**
129 126 * Get a button label to rate.
@@ -204,9 +201,9 @@
204 201 case 'completed_scans':
205 202 default:
206 203 $text = '<p class="notice-header">' . sprintf(
207 204 /* translators: %d - Number of completed scans. */
208 - esc_html__( '🎉 Nice work — %d scans completed!', 'defender-security' ),
205 + esc_html__( 'Nice work — %d scans completed!', 'defender-security' ),
209 206 self::NUMBER_COMPLETED_SCANS
210 207 );
211 208 $text .= '</p><p class="notice-body">';
212 209 $text .= esc_html__(
@@ -244,9 +241,9 @@
244 241
245 242 case 'ua_lockouts':
246 243 $text = '<p class="notice-header">' . sprintf(
247 244 /* translators: %d - Number of UA lockouts. */
248 - esc_html__( '🤖 Defender has blocked %d malicious bots!', 'defender-security' ),
245 + esc_html__( 'Defender has blocked %d malicious bots!', 'defender-security' ),
249 246 self::NUMBER_UA_LOCKOUTS
250 247 );
251 248 $text .= '</p><p class="notice-body">';
252 249 $text .= sprintf(
@@ -262,9 +259,9 @@
262 259
263 260 case 'ip_lockouts':
264 261 $text = '<p class="notice-header">' . sprintf(
265 262 /* translators: %d - Number of IP lockouts. */
266 - esc_html__( '🚫 Defender has blocked %d suspicious IPs!', 'defender-security' ),
263 + esc_html__( 'Defender has blocked %d suspicious IPs!', 'defender-security' ),
267 264 self::NUMBER_IP_LOCKOUTS
268 265 );
269 266 $text .= '</p><p class="notice-body">';
270 267 $text .= sprintf(
@@ -389,8 +386,9 @@
389 386 * 4) UA lockouts,
390 387 * 5) IP lockouts,
391 388 * 6) default one after 7 days installed.
392 389 * Note: items #1-5 are without waiting for 7 days.
390 + * No uses in v6.0 but it'll will be implemented in the future.
393 391 *
394 392 * @return array
395 393 */
396 394 public static function is_achievement_displayed(): array {
@@ -416,9 +414,9 @@
416 414 $res['slug'] = 'fixed_scans';
417 415 } else {
418 416 $tweak_arr = wd_di()->get( Security_Tweaks::class )->get_tweak_types();
419 417 $total_tweaks = $tweak_arr['count_fixed'] + $tweak_arr['count_ignored'] + $tweak_arr['count_issues'];
420 - if ( $tweak_arr['count_fixed'] === $total_tweaks ) {
418 + if ( $tweak_arr['count_fixed'] === $total_tweaks && $total_tweaks > 0 ) {
421 419 $res['slug'] = 'resolved_tweaks';
422 420 } elseif ( self::get_count_scans( self::SLUG_UA_LOCKOUTS ) >= self::NUMBER_UA_LOCKOUTS ) {
423 421 $res['slug'] = 'ua_lockouts';
424 422 } elseif ( self::get_count_scans( self::SLUG_IP_LOCKOUTS ) >= self::NUMBER_IP_LOCKOUTS ) {
@@ -439,17 +437,47 @@
439 437 return $res;
440 438 }
441 439
442 440 /**
441 + * Display the rating notice on the Issues page if all malware scans are resolved.
442 + *
443 + * @param int $count_scan_issues Count of Scan issues.
444 + *
445 + * @return bool
446 + * @since 6.0
447 + */
448 + public static function is_displayed_in_redesigned_version( int $count_scan_issues ): bool {
449 + if ( self::was_rate_request() ) {
450 + return false;
451 + }
452 + // Check by required page.
453 + if ( 'wdf-scan' !== defender_get_current_page() ) {
454 + return false;
455 + }
456 + if ( self::was_postponed_request() ) {
457 + return false;
458 + }
459 +
460 + return 0 === $count_scan_issues;
461 + }
462 +
463 + /**
443 464 * Have there already been clicks on the Rate or Dismiss buttons?
444 465 *
445 466 * @return bool
446 467 */
447 468 private static function was_rate_request(): bool {
448 - if ( get_site_option( self::SLUG_FOR_BUTTON_RATE, (bool) apply_filters( 'wd_display_rating', false ) ) ) {
469 + $display_rating = apply_filters( 'wd_display_rating', false );
470 + $display_rating = is_bool( $display_rating ) ? $display_rating : (bool) $display_rating;
471 + // Avoid case with '1'.
472 + if ( true === (bool) get_site_option( self::SLUG_FOR_BUTTON_RATE, $display_rating ) ) {
449 473 return true;
450 474 }
451 - if ( get_site_option( self::SLUG_FOR_BUTTON_THANKS, (bool) apply_filters( 'wd_dismiss_rating', false ) ) ) {
475 +
476 + $dismiss_rating = apply_filters( 'wd_dismiss_rating', false );
477 + $dismiss_rating = is_bool( $dismiss_rating ) ? $dismiss_rating : (bool) $dismiss_rating;
478 + // Avoid case with '1'.
479 + if ( true === (bool) get_site_option( self::SLUG_FOR_BUTTON_THANKS, $dismiss_rating ) ) {
452 480 return true;
453 481 }
454 482
455 483 return false;
@@ -471,9 +499,9 @@
471 499 *
472 500 * @return bool
473 501 */
474 502 protected static function is_required_page(): bool {
475 - $arr = array(
503 + $arr = array(
476 504 'wdf-hardener',
477 505 'wdf-scan',
478 506 'wdf-logging',
479 507 'wdf-ip-lockout',
@@ -480,13 +508,11 @@
480 508 'wdf-2fa',
481 509 'wdf-advanced-tools',
482 510 'wdf-notification',
483 511 'wdf-setting',
512 + // Dashboard and Setup Wizard have the same page slug.
513 + 'wp-defender',
484 514 );
485 - $_this = new self();
486 - if ( ! $_this->is_onboarding() ) {
487 - $arr[] = 'wp-defender';
488 - }
489 515
490 516 return in_array( defender_get_current_page(), $arr, true );
491 517 }
492 518 }