is_allowed_page( $screen ) ) { return; } // For common pages (dashboard, plugins), check priority FIRST $is_common_page = in_array( $screen->id, [ 'dashboard', 'plugins' ], true ); if ( $is_common_page ) { $current_priority = get_option( '_wpdeveloper_plugin_pointer_priority', 999 ); // If priority is greater than 4, update it to 4 if ( $current_priority > 4 ) { update_option( '_wpdeveloper_plugin_pointer_priority', 4 ); $current_priority = 4; } // If priority is not 4, don't display on common pages if ( $current_priority != 4 ) { return; } } // Check basic conditions if ( ! self::is_user_allowed() || self::is_dismissed() || ! self::is_campaign_time() || self::has_pro() ) { return; } $this->enqueue_dependencies(); $pointer_content = '
' . esc_html__( 'Create a high-converting knowledge base & FAQ powered by AI with Instant Answers, Advanced Analytics & more.', 'betterdocs' ) . '
'; $pointer_content .= sprintf( '', self::PROMOTION_URL, esc_html__( 'Claim Offer', 'betterdocs' ) ); $allowed_tags = [ 'h3' => [], 'p' => [], 'a' => [ 'class' => [], 'target' => [ '_blank' ], 'href' => [], ], ]; ?> id === 'dashboard' || $screen->id === 'plugins' ) { return true; } // BetterDocs admin pages $betterdocs_screens = [ 'toplevel_page_betterdocs-dashboard', 'betterdocs_page_betterdocs-admin', 'betterdocs_page_betterdocs-settings', 'betterdocs_page_betterdocs-analytics', 'betterdocs_page_betterdocs-glossaries', 'betterdocs_page_betterdocs-faq', 'betterdocs_page_betterdocs-ai-chatbot', 'edit-doc_category', 'edit-doc_tag', 'edit-knowledge_base', ]; return in_array( $screen->id, $betterdocs_screens, true ); } private static function is_user_allowed(): bool { return current_user_can( 'manage_options' ) || current_user_can( 'edit_docs' ); } private static function is_campaign_time() { $start = new \DateTime( '2025-11-25 12:00:00', new \DateTimeZone( 'UTC' ) ); $end = new \DateTime( '2025-12-04 23:59:59', new \DateTimeZone( 'UTC' ) ); $now = new \DateTime( 'now', new \DateTimeZone( 'UTC' ) ); return $now >= $start && $now <= $end; } private function enqueue_dependencies() { wp_enqueue_script( 'wp-pointer' ); wp_enqueue_style( 'wp-pointer' ); } private static function is_dismissed(): bool { return self::get_introduction_meta( self::DISMISS_ACTION_KEY ); } /** * Get introduction meta for the current user * * @param string|null $key Optional. Specific key to retrieve. * @return mixed */ public static function get_introduction_meta( $key = null ) { $user_id = get_current_user_id(); $introduction_meta = get_user_meta( $user_id, self::USER_META_KEY, true ); if ( ! is_array( $introduction_meta ) ) { $introduction_meta = []; } if ( $key ) { return isset( $introduction_meta[ $key ] ) ? $introduction_meta[ $key ] : false; } return $introduction_meta; } /** * Set introduction meta for the current user * * @param string $key The introduction key to set. * @return void */ public static function set_introduction_viewed( $key ) { $user_id = get_current_user_id(); $introduction_meta = self::get_introduction_meta(); $introduction_meta[ $key ] = true; update_user_meta( $user_id, self::USER_META_KEY, $introduction_meta ); } private static function has_pro(): bool { return is_plugin_active( 'betterdocs-pro/betterdocs-pro.php' ); } }