401 ) ); } if ( ! desktop_mode_is_enabled() ) { return new WP_Error( 'rest_forbidden', __( 'Desktop mode is not enabled for your account.', 'desktop-mode' ), array( 'status' => 403 ) ); } return true; } // Chromeless / classic admin-bar suppression and the `wp_redirect` // flag-preservation filter pair were moved to // `includes/core/routing.php` in 0.8.1. The functions and the // add_filter / add_action hookings live there now; this file // remains the home of `desktop_mode_is_chromeless_request()` and // `desktop_mode_is_classic_request()` (called from the routing // helpers at hook-fire time), which is why // `desktop-mode.php` requires routing.php BEFORE helpers.php. /** * `desktop_mode_is_chromeless_request()` and `desktop_mode_is_classic_request()` * were moved to `includes/core/routing.php` in 0.8.1 — see that * file for the canonical definitions. The function names didn't * change; PHP looks them up by name at call time, so every * existing caller (helpers, render, hooks) keeps working. */ /** * Returns the default wallpaper id used when a user has no saved * selection (or their saved selection was unregistered by a plugin * deactivation). * * Exposed as a filter so themes/plugins can set a site-wide default * without forking the TS build. * * ```php * add_filter( 'desktop_mode_default_wallpaper', function () { * return 'my-plugin/brand'; * } ); * ``` * * The returned string is passed through `sanitize_key()` so a filter * that returns an invalid slug degrades to the empty string (and the * shell falls back to its hard-coded `'dark'` preset). * * @since 0.11.0 * * @return string Wallpaper id. Empty string if the filter returns * an invalid value. */ function desktop_mode_get_default_wallpaper() { /** * Filters the wallpaper id loaded on first boot / new user. * * @since 0.11.0 * * @param string $id Default wallpaper slug. */ $id = apply_filters( 'desktop_mode_default_wallpaper', 'dark' ); if ( ! is_string( $id ) ) { return ''; } return sanitize_key( $id ); } /** * Build a `WP_Error` for a desktop-mode registration failure. * * Centralises the error-code vocabulary used by every * `desktop_mode_register_*()` function so plugin authors see a * consistent contract. The canonical error-code list lives in * `docs/hooks-reference.md`. * * @since 0.11.0 * * @param string $code Short error slug (e.g. `desktop_mode_missing_title`). * @param string $message Human-readable message. Should be translated. * @param array $data Optional extra context attached to the error. * @return WP_Error */ function desktop_mode_registration_error( $code, $message, $data = array() ) { return new WP_Error( (string) $code, (string) $message, is_array( $data ) ? $data : array() ); } // `desktop_mode_url_is_same_admin()`, // `desktop_mode_resolve_admin_target()` and // `desktop_mode_admin_target_allowlist()` were moved to // `includes/core/routing.php` in 0.8.1 — see that file for the // canonical definitions. Function names didn't change; PHP's // runtime resolution finds them across the module split. // Dock building, menu / native-windows payload assembly and the // script/style handle resolvers were moved to // `includes/core/payload.php` in 0.8.1. Function names didn't // change; existing callers find them via PHP's runtime function // resolution. desktop-mode.php loads payload.php right after // helpers.php so the foundational helpers (desktop_mode_is_enabled // etc.) are present when payload functions are invoked.