'wpvr_item', 'post_status' => array( 'publish', 'draft', 'pending', 'private', 'future', 'trash' ), 'posts_per_page' => 1, 'fields' => 'ids', 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'wpvr_is_demo_tour', 'compare' => 'NOT EXISTS', ), array( 'key' => 'wpvr_is_demo_tour', 'value' => '1', 'compare' => '!=', ), ), ) ); if ( ! empty( $existing ) ) { update_option( self::OPT_HAS_EVER_CREATED, '1', false ); } } /* ----------------------------------------------------------------------- * Visibility check * --------------------------------------------------------------------- */ /** * Whether the notice should be rendered. * * @return bool */ private function should_show() { // 1. Listing page only. if ( ! $this->is_listing_page() ) { return false; } // 2. Admins only. if ( ! current_user_can( 'manage_options' ) ) { return false; } // 3. If a real tour was ever created on this site → never show. if ( get_option( self::OPT_HAS_EVER_CREATED ) ) { return false; } // 4. If the wizard was completed → never show. if ( get_option( self::OPT_WIZARD_DONE ) ) { return false; } // 5. If permanently dismissed → never show. if ( get_option( self::OPT_DISMISSED ) ) { return false; } return true; } /** * Check if current screen is the tour listing page. * * @return bool */ private function is_listing_page() { if ( ! is_admin() || ! function_exists( 'get_current_screen' ) ) { return false; } $screen = get_current_screen(); return $screen && 'edit-wpvr_item' === $screen->id; } /* ----------------------------------------------------------------------- * Rendering * --------------------------------------------------------------------- */ /** * Output the notice HTML + inline CSS + inline JS. */ public function render_notice() { if ( ! $this->should_show() ) { return; } $wizard_url = esc_url( admin_url( 'admin.php?page=rex-wpvr-setup-wizard' ) ); $nonce = wp_create_nonce( self::AJAX_DISMISS ); ?>

'Unauthorized' ), 403 ); return; } $nonce = isset( $_POST['nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['nonce'] ) ) : ''; if ( ! wp_verify_nonce( $nonce, self::AJAX_DISMISS ) ) { wp_send_json_error( array( 'message' => 'Invalid nonce' ), 400 ); return; } // Permanent dismiss — no expiry. update_option( self::OPT_DISMISSED, '1', false ); wp_send_json_success( array( 'message' => 'Dismissed' ) ); } }