= OPENSTATION_ACTIVATION_NUDGE_MAX_AGE_DAYS ) { return false; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( ! $screen || ! in_array( $screen->id, openstation_activation_nudge_screens(), true ) ) { return false; } if ( openstation_is_chromeless_request() ) { return false; } $user_id = get_current_user_id(); if ( openstation_has_seen_intro( $user_id, OPENSTATION_ACTIVATION_NUDGE_INTRO_SLUG ) ) { return false; } // Asked of the dialog's own gate rather than of its seen-slug: a // site that filters the dialog off never records the slug, and the // nudge would then wait for a dismissal that cannot happen. if ( function_exists( 'openstation_should_show_welcome_dialog' ) && openstation_should_show_welcome_dialog() ) { return false; } /** * Filters whether the activation nudge renders for the current * user on the current request. Every earlier gate (capability, * site never enabled, install age, screen, seen-state, no welcome * dialog on this request) has already passed when this fires. * * @param bool $show Whether to render the notice. Default true. * @param int $user_id Current user ID. */ return (bool) apply_filters( 'openstation_show_activation_nudge', true, $user_id ); } /** * The notice's inner markup: one sentence and two actions. * * @return string HTML. */ function openstation_activation_nudge_markup() { $portal_url = openstation_portal_url(); $message = sprintf( '%s %s', esc_html__( 'OpenStation is installed but not turned on.', 'desktop-mode' ), esc_html__( 'It changes wp-admin only for the people who turn it on.', 'desktop-mode' ) ); $actions = sprintf( '

%2$s

', esc_url( $portal_url ), esc_html__( 'Turn on OpenStation', 'desktop-mode' ), esc_html__( 'Not now', 'desktop-mode' ) ); return '

' . $message . '

' . $actions; } /** * Prints the nudge on `admin_notices` / `network_admin_notices`. * * `wp_admin_notice()` when Core has it; the same `div.notice` markup * by hand on older versions (the plugin supports 6.0). The "Not now" * button carries a small inline script that POSTs the slug to the * seen-intros route and removes the notice, exactly as the welcome * dialog does. * * @return void */ function openstation_render_activation_nudge() { if ( ! openstation_should_show_activation_nudge() ) { return; } $markup = openstation_activation_nudge_markup(); if ( function_exists( 'wp_admin_notice' ) ) { wp_admin_notice( $markup, array( 'type' => 'info', 'id' => 'os-activation-nudge', 'additional_classes' => array( 'os-activation-nudge' ), 'paragraph_wrap' => false, ) ); } else { echo '
' . $markup . '
'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- built from escaped parts in openstation_activation_nudge_markup(). } $rest_url = esc_url_raw( rest_url( 'desktop-mode/v1/intros/seen' ) ); $rest_nonce = wp_create_nonce( 'wp_rest' ); ?>