| @@ -2,8 +2,9 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace WP_Defender; |
| 4 | 4 | |
| 5 | 5 | use WP_Defender\Traits\Defender_Bootstrap; |
| 6 | +use WP_Defender\Component\Rate; | |
| 6 | 7 | |
| 7 | 8 | /** |
| 8 | 9 | * Class Bootstrap |
| 9 | 10 | * |
| @@ -25,11 +26,15 @@ | ||
| 25 | 26 | * |
| 26 | 27 | * @since 2.4 |
| 27 | 28 | */ |
| 28 | 29 | protected function set_free_installation_timestamp(): void { |
| 29 | - // It's for both cases because don’t have a Pro checking during plugin activation. | |
| 30 | - if ( empty( get_site_option( 'defender_free_install_date' ) ) ) { | |
| 31 | - update_site_option( 'defender_free_install_date', time() ); | |
| 30 | + // Let's equate the plugin installation and postponed notice dates. This will simplify future checks. | |
| 31 | + $install_date = (int) get_site_option( Rate::SLUG_FREE_INSTALL_DATE, 0 ); | |
| 32 | + if ( 0 === $install_date ) { | |
| 33 | + update_site_option( Rate::SLUG_FREE_INSTALL_DATE, time() ); | |
| 34 | + update_site_option( Rate::SLUG_POSTPONED_NOTICE_DATE, time() ); | |
| 35 | + } else { | |
| 36 | + update_site_option( Rate::SLUG_POSTPONED_NOTICE_DATE, $install_date ); | |
| 32 | 37 | } |
| 33 | 38 | } |
| 34 | 39 | |
| 35 | 40 | /** |
| @@ -35,57 +40,17 @@ | ||
| 35 | 40 | /** |
| 36 | 41 | * Load all modules. |
| 37 | 42 | */ |
| 38 | 43 | public function init_modules(): void { |
| 44 | + add_action( 'admin_init', array( $this, 'maybe_redirect_after_activation' ), 1 ); | |
| 39 | 45 | $this->init_modules_common(); |
| 40 | - $this->init_free_dashboard(); | |
| 41 | 46 | } |
| 42 | 47 | |
| 43 | 48 | /** |
| 44 | - * Load Free Dashboard module. | |
| 49 | + * Deactivation clears only free version cron hooks. | |
| 45 | 50 | */ |
| 46 | - public function init_free_dashboard(): void { | |
| 47 | - $file_path = defender_path( 'extra/free-dashboard/module.php' ); | |
| 48 | - if ( file_exists( $file_path ) ) { | |
| 49 | - require_once $file_path; | |
| 50 | - | |
| 51 | - add_filter( 'wdev_email_message_' . DEFENDER_PLUGIN_BASENAME, array( $this, 'defender_ads_message' ) ); | |
| 52 | - | |
| 53 | - $screen_prefix = 'defender'; | |
| 54 | - $screen_suffix = is_multisite() ? '-network' : ''; | |
| 55 | - | |
| 56 | - $free_install_date = get_site_option( 'defender_free_install_date', false ); | |
| 57 | - | |
| 58 | - do_action( | |
| 59 | - 'wpmudev_register_notices', | |
| 60 | - 'defender', | |
| 61 | - array( | |
| 62 | - 'basename' => DEFENDER_PLUGIN_BASENAME, | |
| 63 | - 'title' => 'Defender', | |
| 64 | - 'wp_slug' => 'defender-security', | |
| 65 | - 'cta_email' => __( 'Get Secure!', 'defender-security' ), | |
| 66 | - 'installed_on' => $free_install_date ?: time(), | |
| 67 | - 'screens' => array( | |
| 68 | - 'toplevel_page_wp-defender' . $screen_suffix, | |
| 69 | - $screen_prefix . '_page_wdf-hardener' . $screen_suffix, | |
| 70 | - $screen_prefix . '_page_wdf-scan' . $screen_suffix, | |
| 71 | - $screen_prefix . '_page_wdf-logging' . $screen_suffix, | |
| 72 | - $screen_prefix . '_page_wdf-ip-lockout' . $screen_suffix, | |
| 73 | - $screen_prefix . '_page_wdf-waf' . $screen_suffix, | |
| 74 | - $screen_prefix . '_page_wdf-2fa' . $screen_suffix, | |
| 75 | - $screen_prefix . '_page_wdf-advanced-tools' . $screen_suffix, | |
| 76 | - $screen_prefix . '_page_wdf-notification' . $screen_suffix, | |
| 77 | - $screen_prefix . '_page_wdf-setting' . $screen_suffix, | |
| 78 | - $screen_prefix . '_page_wdf-tutorial' . $screen_suffix, | |
| 79 | - ), | |
| 80 | - ) | |
| 81 | - ); | |
| 82 | - } | |
| 83 | - } | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * @return string | |
| 87 | - */ | |
| 88 | - public function defender_ads_message(): string { | |
| 89 | - return __( "You're awesome for installing Defender! Are you interested in how to make the most of this plugin? We've collected all the best security resources we know in a single email - just for users of Defender!", 'defender-security' ); | |
| 51 | + public function deactivation_hook(): void { | |
| 52 | + $this->deactivation_hook_common(); | |
| 53 | + wp_clear_scheduled_hook( 'audit_clean_up_logs' ); | |
| 54 | + wp_clear_scheduled_hook( 'wpdef_quarantine_delete_expired' ); | |
| 90 | 55 | } |
| 91 | 56 | } |