` shell components here because they only ship inside the * desktop bundle, which is precisely *not* loaded on the classic admin * screens where this dialog is allowed to appear. * * @package Desktop_Mode * @since 0.18.5 */ defined( 'ABSPATH' ) || exit; /** Slug stored in `desktop_mode_seen_intros` for this dialog. */ const DESKTOP_MODE_WELCOME_INTRO_SLUG = 'activation-welcome'; /** * Decides whether the welcome dialog should render on the current request. * * Five gates: * * 1. We're inside `/wp-admin` (`is_admin()`). * 2. The user is logged in and can `read` (sanity gate — the dialog has * no destructive surface, but anonymous output makes no sense). * 3. The request is NOT chromeless — chromeless pages are iframes * rendering inside the desktop shell; the parent shell already shows * its own UX. * 4. The user has not already dismissed this intro. * 5. The `desktop_mode_show_welcome_dialog` filter returns truthy, so * sites can suppress the dialog entirely (e.g. managed-host onboarding * flows that ship their own). * * @since 0.18.5 * * @return bool */ function desktop_mode_should_show_welcome_dialog() { if ( ! is_admin() || ! is_user_logged_in() ) { return false; } if ( ! current_user_can( 'read' ) ) { return false; } if ( function_exists( 'desktop_mode_is_chromeless_request' ) && desktop_mode_is_chromeless_request() ) { return false; } $user_id = get_current_user_id(); if ( desktop_mode_has_seen_intro( $user_id, DESKTOP_MODE_WELCOME_INTRO_SLUG ) ) { return false; } /** * Filters whether the first-run welcome dialog should render for * the current user on the current request. All earlier gates * (admin context, capability, chromeless, seen-state) have * already passed by the time this filter fires. * * @since 0.18.5 * * @param bool $show Whether to render the dialog. Default true. * @param int $user_id Current user ID. */ return (bool) apply_filters( 'desktop_mode_show_welcome_dialog', true, $user_id ); } /** * Prints the welcome dialog markup, styles and dismiss script into * `admin_footer`. * * Self-contained on purpose: everything is scoped under the * `.desktop-mode-welcome` namespace so it cannot collide with the host * admin theme. The dismiss button POSTs to the seen-intros REST route, * which is exactly the same endpoint the in-shell intros use. * * @since 0.18.5 */ function desktop_mode_render_welcome_dialog() { if ( ! desktop_mode_should_show_welcome_dialog() ) { return; } $rest_url = esc_url_raw( rest_url( 'desktop-mode/v1/intros/seen' ) ); $rest_nonce = wp_create_nonce( 'wp_rest' ); $ajax_url = esc_url_raw( admin_url( 'admin-ajax.php' ) ); $ajax_nonce = wp_create_nonce( 'save-desktop-mode' ); $slug = DESKTOP_MODE_WELCOME_INTRO_SLUG; // All user-facing strings are passed through translation; the dialog // is keyboard-dismissible (Escape) and focus-trapped between the // close button and the "Got it" CTA. $title = __( 'Welcome to Desktop Mode', 'desktop-mode' ); $subtitle = __( 'A floating, window-based workspace for the WordPress admin — more like a real OS, less like a webpage.', 'desktop-mode' ); $body = __( 'Desktop Mode reimagines the WordPress admin as a true desktop environment. Open multiple admin screens side-by-side, drag and drop content between windows, and keep your work in view as you move between tasks.', 'desktop-mode' ); $cta = __( 'Got it', 'desktop-mode' ); $enable = __( 'Enable it now', 'desktop-mode' ); $enabling = __( 'Enabling…', 'desktop-mode' ); $close_a = __( 'Close', 'desktop-mode' ); $features = array( array( 'icon' => '🪟', 'title' => __( 'Multi-window workspace', 'desktop-mode' ), 'desc' => __( 'Open Posts, Media and Plugins in their own draggable, resizable windows. Tile, cascade or stack them however you work best.', 'desktop-mode' ), ), array( 'icon' => '⚡', 'title' => __( 'Native, table-driven apps', 'desktop-mode' ), 'desc' => __( 'Posts, Pages, Users and Plugins are reimplemented as fast native windows with sticky headers, bulk actions, multi-select and inline previews.', 'desktop-mode' ), ), array( 'icon' => '🎨', 'title' => __( 'Wallpapers, dock & themes', 'desktop-mode' ), 'desc' => __( 'Make it yours. Choose a wallpaper, pin your favorite screens to the dock, and switch accent colors — all from OS Settings.', 'desktop-mode' ), ), array( 'icon' => '🤖', 'title' => __( 'AI Copilot, built in', 'desktop-mode' ), 'desc' => __( 'Press ⌘K anywhere to ask the AI Assistant — it can run commands, navigate windows and answer questions about your site.', 'desktop-mode' ), ), ); ?>
' . esc_html__( 'Switch to Desktop Mode', 'desktop-mode' ) . '' ); ?>