base, \WpSecurityAuditLog::get_plugin_screens_array(), true ) ) { $notice_upgrade = Settings_Helper::get_boolean_option_value( Abstract_Migration::UPGRADE_NOTICE, false ); if ( $notice_upgrade ) { Settings_Helper::delete_option_value( self::EBOOK_NOTICE ); self::display_notice_upgrade(); } // if ( 'free' === \WpSecurityAuditLog::get_plugin_version() ) { // $ebook = Settings_Helper::get_boolean_option_value( self::EBOOK_NOTICE, false ); // if ( ! $ebook ) { // self::display_ebook_notice(); // } // } // $survey_2025 = Settings_Helper::get_boolean_option_value( 'survey-2025', false ); // if ( ! $survey_2025 ) { // self::display_yearly_security_survey(); // } $learndash_update_notice = Settings_Helper::get_boolean_option_value( self::LEARNDASH_UPDATE_NOTICE, false ); if ( ! $learndash_update_notice && self::is_learndash_active() ) { self::display_learndash_update_notice(); } elseif ( self::should_show_melapress_survey() ) { self::display_melapress_product_survey(); } // @free:start if ( self::should_show_black_friday_notice() ) { self::display_black_friday(); } // @free:end } } /** * Responsible for initializing the AJAX hooks for the notifications * * @return void * * @since 4.6.0 */ public static function init_ajax_hooks() { $notice_upgrade = Settings_Helper::get_boolean_option_value( Abstract_Migration::UPGRADE_NOTICE, false ); if ( $notice_upgrade ) { \add_action( 'wp_ajax_wsal_dismiss_upgrade_notice', array( __CLASS__, 'dismiss_upgrade_notice' ) ); ++self::$number_of_notices; } // ! \WpSecurityAuditLog::get_plugin_version() does not work in this hook action, do not use it. // if ( 'free' === \WpSecurityAuditLog::get_plugin_version() ) { // $ebook = Settings_Helper::get_boolean_option_value( self::EBOOK_NOTICE, false ); // if ( ! $ebook ) { // ++self::$number_of_notices; // \add_action( 'wp_ajax_wsal_dismiss_ebook_notice', array( __CLASS__, 'dismiss_ebook_notice' ) ); // } // } // $survey_2025 = Settings_Helper::get_boolean_option_value( 'survey-2025', false ); // if ( ! $survey_2025 ) { // \add_action( 'wp_ajax_dismiss_yearly_survey', array( __CLASS__, 'dismiss_yearly_survey' ) ); // ++self::$number_of_notices; // } $learndash_update_notice = Settings_Helper::get_boolean_option_value( self::LEARNDASH_UPDATE_NOTICE, false ); if ( ! $learndash_update_notice && self::is_learndash_active() ) { \add_action( 'wp_ajax_dismiss_learndash_update_notice', array( __CLASS__, 'dismiss_learndash_update_notice' ) ); ++self::$number_of_notices; } elseif ( self::should_show_melapress_survey() ) { \add_action( 'wp_ajax_dismiss_melapress_survey', array( __CLASS__, 'dismiss_melapress_survey' ) ); \add_action( 'wp_ajax_take_melapress_survey', array( __CLASS__, 'take_melapress_survey' ) ); ++self::$number_of_notices; } // @free:start if ( self::should_show_black_friday_notice() ) { \add_action( 'wp_ajax_dismiss_black_friday', array( __CLASS__, 'dismiss_black_friday' ) ); ++self::$number_of_notices; } // @free:end } /** * Display upgrade notice. * * @since 5.1.0 */ public static function display_notice_upgrade() { include_once WSAL_BASE_DIR . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Free' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'plugin-update-card.php'; } /** * Display upgrade notice. * * @since 5.1.1 */ public static function display_ebook_notice() { include_once WSAL_BASE_DIR . DIRECTORY_SEPARATOR . 'classes' . DIRECTORY_SEPARATOR . 'Free' . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'wsal-ebook-card.php'; } /** * Method: Ajax request handler to dismiss upgrade notice. * * @since 5.1.0 */ public static function dismiss_upgrade_notice() { if ( ! Settings_Helper::current_user_can( 'edit' ) ) { \wp_send_json_error(); } if ( ! array_key_exists( 'nonce', $_POST ) || ! wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['nonce'] ) ), 'dismiss_upgrade_notice' ) ) { \wp_send_json_error( \esc_html_e( 'nonce is not provided or incorrect', 'wp-security-audit-log' ) ); } Settings_Helper::delete_option_value( Abstract_Migration::UPGRADE_NOTICE ); \wp_send_json_success(); } /** * Method: Ajax request handler to dismiss ebook notice. * * @since 5.1.1 */ public static function dismiss_ebook_notice() { if ( ! Settings_Helper::current_user_can( 'edit' ) ) { \wp_send_json_error(); } if ( ! array_key_exists( 'nonce', $_POST ) || ! wp_verify_nonce( \sanitize_text_field( \wp_unslash( $_POST['nonce'] ) ), 'dismiss_ebook_notice' ) ) { \wp_send_json_error( \esc_html_e( 'nonce is not provided or incorrect', 'wp-security-audit-log' ) ); } Settings_Helper::set_option_value( self::EBOOK_NOTICE, true ); \wp_send_json_success(); } /** * Returns the number of notifications we have to show. * * @return int * * @since 5.2.2 */ public static function get_number_of_notices(): int { return self::$number_of_notices; } /** * Ajax request handler to dismiss the yearly survey notice. * * @return void * * @since 5.5.1 */ public static function dismiss_yearly_survey() { if ( ! Settings_Helper::current_user_can( 'edit' ) || ! \current_user_can( 'manage_options' ) ) { \wp_send_json_error(); } $nonce_check = \check_ajax_referer( 'dismiss_yearly_survey', 'nonce' ); if ( ! $nonce_check ) { \wp_send_json_error( \esc_html_e( 'nonce is not provided or incorrect', 'wp-security-audit-log' ) ); } $update_yr_setting = Settings_Helper::set_option_value( 'survey-2025', true ); if ( ! $update_yr_setting ) { \wp_send_json_error( \esc_html__( 'Failed to dismiss the survey. Please try again.', 'wp-security-audit-log' ) ); } \wp_send_json_success(); } /** * Ajax request handler to dismiss the melapress survey notice (X button). * * @return void * * @since 5.5.3 * @since 5.6.1 - Changed to temporary dismissal that resets on plugin upgrade. */ public static function dismiss_melapress_survey() { if ( ! Settings_Helper::current_user_can( 'edit' ) || ! \current_user_can( 'manage_options' ) ) { \wp_send_json_error(); } \check_ajax_referer( 'dismiss_melapress_survey', 'nonce' ); $update_setting = Settings_Helper::set_boolean_option_value( 'melapress-survey-dismissed', true ); if ( ! $update_setting ) { \wp_send_json_error( \esc_html__( 'Failed to dismiss the survey. Please try again.', 'wp-security-audit-log' ) ); } \wp_send_json_success(); } /** * Ajax request handler when the user clicks "Take the survey". * Sets a permanent flag that persists across upgrades. * * @return void * * @since 5.6.1 */ public static function take_melapress_survey() { if ( ! Settings_Helper::current_user_can( 'edit' ) || ! \current_user_can( 'manage_options' ) ) { \wp_send_json_error(); } \check_ajax_referer( 'take_melapress_survey', 'nonce' ); $update_setting = Settings_Helper::set_boolean_option_value( 'melapress-survey-taken', true ); if ( ! $update_setting ) { \wp_send_json_error( \esc_html__( 'Failed to save the survey preference. Please try again.', 'wp-security-audit-log' ) ); } \wp_send_json_success(); } /** * Ajax request handler to dismiss the LearnDash update notice. * * @return void * * @since 5.6.0 */ public static function dismiss_learndash_update_notice() { if ( ! Settings_Helper::current_user_can( 'edit' ) || ! \current_user_can( 'manage_options' ) ) { \wp_send_json_error(); } \check_ajax_referer( 'dismiss_learndash_update_notice', 'nonce' ); $update_setting = Settings_Helper::set_option_value( self::LEARNDASH_UPDATE_NOTICE, true ); if ( ! $update_setting ) { \wp_send_json_error( \esc_html__( 'Failed to dismiss the notice. Please try again.', 'wp-security-audit-log' ) ); } \wp_send_json_success(); } /** * Display the 2025 MelaPress survey admin notice * * @since 5.5.1 */ public static function display_yearly_security_survey() { // Show only to admins. if ( ! \current_user_can( 'manage_options' ) ) { return; } $survey_url = \esc_url( \add_query_arg( array( 'utm_source' => 'plugin', 'utm_medium' => 'wsal', 'utm_campaign' => 'survey+promo+banner', ), 'https://melapress.com/wordpress-security-survey-2025/' ) ); ?>

format( 'Y-m-d' ); } /** * Check if the Black Friday campaign is currently active. * * @return bool * * @since 5.5.4 */ public static function is_black_friday_campaign_active(): bool { $current_date = self::get_current_date(); // Campaign runs from November 21 to December 1. return $current_date >= '2025-11-21' && $current_date <= '2025-12-01'; } /** * Check if the Melapress survey banner should be displayed. * * @return bool * * @since 5.6.1 */ public static function should_show_melapress_survey(): bool { // Permanent dismissal: user already took the survey. if ( Settings_Helper::get_boolean_option_value( 'melapress-survey-taken', false ) ) { return false; } // Temporary dismissal: user clicked X (resets on next upgrade). if ( Settings_Helper::get_boolean_option_value( 'melapress-survey-dismissed', false ) ) { return false; } // Don't show during Black Friday. if ( self::is_black_friday_campaign_active() ) { return false; } // On new installs, wait 15 days before showing. $installed_at = Settings_Helper::get_option_value( 'plugin-installed-at', false ); if ( false !== $installed_at && ( time() - (int) $installed_at ) < 15 * DAY_IN_SECONDS ) { return false; } return true; } /** * Check if the Black Friday notice should be displayed. * * @return bool * * @since 5.5.4 */ public static function should_show_black_friday_notice(): bool { // Check if we're within the campaign period. if ( ! self::is_black_friday_campaign_active() ) { return false; } $current_date = self::get_current_date(); // Check dismissal status. $first_dismissal = Settings_Helper::get_option_value( 'black-friday-first-dismiss', '' ); // If permanently dismissed (second time), never show again. if ( Settings_Helper::get_boolean_option_value( 'black-friday', false ) ) { return false; } // Black Friday date (November 28, 2025). $black_friday_date = '2025-11-28'; // If first dismissal exists and we're before Black Friday, don't show. if ( ! empty( $first_dismissal ) && $current_date < $black_friday_date ) { return false; } // If first dismissal exists and we're on or after Black Friday, show again. if ( ! empty( $first_dismissal ) && $current_date >= $black_friday_date ) { return true; } // No dismissal yet, show the notice. return true; } /** * Ajax request handler to dismiss the Black Friday notice. * * @return void * * @since 5.5.4 */ public static function dismiss_black_friday() { if ( ! Settings_Helper::current_user_can( 'edit' ) || ! \current_user_can( 'manage_options' ) ) { \wp_send_json_error(); } $nonce_check = \check_ajax_referer( 'dismiss_black_friday', 'nonce' ); if ( ! $nonce_check ) { \wp_send_json_error( \esc_html__( 'nonce is not provided or incorrect', 'wp-security-audit-log' ) ); } $current_date = self::get_current_date(); // Check if this is the first or second dismissal. $first_dismissal = Settings_Helper::get_option_value( 'black-friday-first-dismiss', '' ); if ( empty( $first_dismissal ) ) { // First dismissal - save the date. $update_setting = Settings_Helper::set_option_value( 'black-friday-first-dismiss', $current_date ); } else { // Second dismissal (on or after Black Friday) - permanently dismiss. $update_setting = Settings_Helper::set_option_value( 'black-friday', true ); } if ( ! $update_setting ) { \wp_send_json_error( \esc_html__( 'Failed to dismiss the notice. Please try again.', 'wp-security-audit-log' ) ); } \wp_send_json_success(); } /** * Display the Black Friday admin notice. * * @return void * * @since 5.5.4 */ public static function display_black_friday() { if ( ! \current_user_can( 'manage_options' ) ) { return; } $offer_url = 'https://melapress.com/black-friday-cyber-monday/?utm_source=plugin&utm_medium=wsal&utm_campaign=BFCM2025'; ?>
Black Friday Sale