display_last_modal( self::FEATURE_SLUG ); $current_user = wp_get_current_user(); return array( 'show_welcome_modal' => $is_displayed, ); } /** * Display modal if: * plugin version has important changes, * plugin settings have been reset before -> this is not fresh install, * Whitelabel > Documentation, Tutorials and What’s New Modal > checked Show tab OR Whitelabel is disabled. * * @param string $key The feature slug to check. * * @return bool */ protected function display_last_modal( $key ): bool { $info = defender_white_label_status(); return (bool) get_site_option( $key ) && ! $info['hide_doc_link']; } /** * Upgrades site options related to feature modals based on the database version. */ public function upgrade_site_options(): void { $db_version = get_site_option( 'wd_db_version' ); $feature_slugs = array( // Important slugs to display Onboarding, e.g. after the click on Reset settings. array( 'slug' => 'wp_defender_shown_activator', 'vers' => '2.4.0', ), array( 'slug' => 'wp_defender_is_free_activated', 'vers' => '2.4.0', ), // The latest feature. array( 'slug' => 'wd_show_feature_turnstile', 'vers' => '5.7.0', ), // The current feature. array( 'slug' => self::FEATURE_SLUG, 'vers' => self::FEATURE_VERSION, ), ); foreach ( $feature_slugs as $feature ) { if ( version_compare( $db_version, $feature['vers'], '==' ) ) { // The current feature. update_site_option( $feature['slug'], true ); } else { // Old one. delete_site_option( $feature['slug'] ); } } } /** * Get additional text. * * @return string */ private function additional_text(): string { return ''; } /** * Enable the welcome modal only when the installed plugin version matches the exact * release the modal belongs to, so it does not re-appear on later patches/minors * (e.g. 6.0.1, 6.1) that share the same DB version. * * @return void */ public static function maybe_enable_welcome_modal(): void { if ( defined( 'DEFENDER_VERSION' ) && version_compare( DEFENDER_VERSION, self::FEATURE_VERSION, '==' ) ) { update_site_option( self::FEATURE_SLUG, true ); } } /** * Delete welcome modal key. * * @return void */ public static function delete_modal_key(): void { delete_site_option( self::FEATURE_SLUG ); } }