*/ namespace SmartPostShow\Admin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly. } /** * This class is responsible for all kinds of admin facing notices. */ class Admin_Notices { /** * Initialize the class and set its properties. */ public function __construct() { add_action( 'admin_notices', array( $this, 'render_all_admin_notices' ) ); add_action( 'in_admin_header', array( $this, 'render_blocks_promo_modal' ) ); add_action( 'wp_ajax_spsp_dismiss_blocks_promo_notice', array( $this, 'dismiss_blocks_promo_notice' ) ); add_action( 'wp_ajax_spsp_dismiss_blocks_promo_modal', array( $this, 'dismiss_blocks_promo_modal' ) ); add_action( 'wp_ajax_check_sp_post_carousel_posts', array( $this, 'check_sp_post_carousel_posts' ) ); } /** * Display all admin notice for backend. * * @return void */ public function render_all_admin_notices() { $this->render_blocks_promo_notice(); } /** * Render the "Meet the new Smart Post" promo banner that surfaces * the block editor + ready patterns on the classic sp_post_carousel edit * screens. Dismissed per-user via user_meta. * * @return void */ public function render_blocks_promo_notice() { if ( ! current_user_can( 'edit_posts' ) ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || 'sp_post_carousel' !== $screen->post_type ) { return; } if ( 'post' !== $screen->base ) { return; } if ( get_option( 'spsp_blocks_promo_notice_dismissed' ) ) { return; } $block_editor_url = admin_url( 'post-new.php?post_type=page&spblock_inserter=true' ); $nonce = wp_create_nonce( 'spsp_blocks_promo_notice' ); ?>