id, [ 'dashboard', 'plugins' ], true ) ) { return false; } // 7. Check if GatePass plugin is installed or active if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $all_plugins = get_plugins(); if ( isset( $all_plugins['gatepass-password-protection/gatepass-password-protection.php'] ) ) { return false; } if ( is_plugin_active( 'gatepass-password-protection/gatepass-password-protection.php' ) ) { return false; } // 8. Check if user permanently dismissed the notice $user_id = get_current_user_id(); $permanently_dismissed = get_user_meta( $user_id, 'ame_gatepass_notice_permanently_dismissed', true ); if ( 'true' === $permanently_dismissed ) { return false; } // 9. Check if first dismissal timestamp is within the 21-day cool-down period $first_dismiss = get_user_meta( $user_id, 'ame_gatepass_notice_first_dismiss', true ); if ( $first_dismiss ) { $days_elapsed = ( time() - intval( $first_dismiss ) ) / DAY_IN_SECONDS; if ( $days_elapsed < 21 ) { return false; } } return true; } /** * Enqueue CSS and JS assets only if the GatePass promotional notice is visible. * * @param string $hook_suffix The current admin page hook. */ function ame_enqueue_gatepass_promo_assets( $hook_suffix ) { if ( ! ame_should_display_gatepass_notice() ) { return; } // Enqueue general admin styles wp_enqueue_style( 'ame-admin-style', plugin_dir_url( dirname( __FILE__ ) ) . 'assets/css/admin.css', [], '1.0.0' ); // Enqueue general admin script wp_enqueue_script( 'ame-admin-script', plugin_dir_url( dirname( __FILE__ ) ) . 'assets/js/admin.js', [ 'jquery' ], '1.0.0', true ); // Localize AJAX parameters for security and execution wp_localize_script( 'ame-admin-script', 'ameGatePassPromo', [ 'ajax_url' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'ame_gatepass_promo_nonce' ), 'action' => 'ame_dismiss_gatepass_notice', ] ); } add_action( 'admin_enqueue_scripts', 'ame_enqueue_gatepass_promo_assets' ); /** * Render the promotional notice HTML markup. */ function ame_render_gatepass_promo_notice() { if ( ! ame_should_display_gatepass_notice() ) { return; } ?>

esc_html__( 'Permission denied.', 'advanced-marquee-effect' ) ] ); } $user_id = get_current_user_id(); // Check if first dismiss has already been recorded $first_dismiss = get_user_meta( $user_id, 'ame_gatepass_notice_first_dismiss', true ); if ( ! $first_dismiss ) { // First dismiss: Save the dismissal timestamp $updated = update_user_meta( $user_id, 'ame_gatepass_notice_first_dismiss', time() ); if ( $updated ) { wp_send_json_success( [ 'dismiss_type' => 'first' ] ); } else { wp_send_json_error( [ 'message' => esc_html__( 'Failed to update user meta.', 'advanced-marquee-effect' ) ] ); } } else { // Second dismiss: Set permanent dismissal flag $updated = update_user_meta( $user_id, 'ame_gatepass_notice_permanently_dismissed', 'true' ); if ( $updated ) { wp_send_json_success( [ 'dismiss_type' => 'permanent' ] ); } else { wp_send_json_error( [ 'message' => esc_html__( 'Failed to update user meta.', 'advanced-marquee-effect' ) ] ); } } } add_action( 'wp_ajax_ame_dismiss_gatepass_notice', 'ame_dismiss_gatepass_notice_handler' );