*/ 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' ); ?>
'; $highlight_blocks = ''; echo wp_kses( sprintf( /* translators: 1: opening strong, 2: closing strong, 3: opening anchor to block editor, 4: closing anchor. */ __( '%1$sMeet the new Smart Post%2$s — gives you %3$s60+ Gutenberg Blocks%4$s and %5$s250+ Ready Patterns%6$s to design visually — see every change live.', 'post-carousel' ), '', '', $highlight_blocks, '', $highlight_open, '' ), array( 'strong' => array(), 'a' => array( 'class' => array(), 'href' => array(), 'target' => array(), 'rel' => array(), ), ) ); ?>
post_type || 'add' !== $screen->action ) { return; } if ( get_option( 'spsp_blocks_promo_modal_choice' ) ) { return; } $block_editor_url = admin_url( 'post-new.php?post_type=page&spblock_inserter=true' ); $nonce = wp_create_nonce( 'spsp_blocks_promo_modal' ); $modal_video_url = 'https://wpsmartpost.com/wp-content/uploads/2026/06/SP-Popup-V01_1.mp4'; ?> 'sp_post_carousel', 'posts_per_page' => 1, 'fields' => 'ids', 'post_status' => array( 'publish', 'draft', 'pending', 'private' ), ); $posts = get_posts( $args ); $has_posts = count( $posts ) > 0; $editor_preference = get_option( 'spsp_blocks_promo_modal_choice', '' ); $is_block_editor = 'block-editor' === $editor_preference; wp_send_json_success( array( 'has_posts' => $has_posts, 'is_block_editor' => $is_block_editor, ) ); } }