| 1 |
<?php |
| 2 |
/** |
| 3 |
* Desktop Mode — Built-in wallpaper presets. |
| 4 |
* |
| 5 |
* The five gradient / solid presets that ship with the plugin, each |
| 6 |
* registered through the same public API third-party plugins use |
| 7 |
* (`desktop_mode_register_wallpaper()`). Dogfooding the registration |
| 8 |
* surface for the built-ins is how we discover whether the API is |
| 9 |
* expressive enough for plugin authors — if we couldn't describe our |
| 10 |
* own presets through it, the API is broken. |
| 11 |
* |
| 12 |
* Hooked on `init` priority 5 so the presets land in the registry |
| 13 |
* before the shell config is built (shell render runs on |
| 14 |
* `admin_enqueue_scripts`, which fires after `init`), and before any |
| 15 |
* late third-party plugin that wants to react via the |
| 16 |
* `desktop_mode_wallpaper_registered` action. |
| 17 |
* |
| 18 |
* @package WPDesktopMode |
| 19 |
* @since 0.11.0 |
| 20 |
*/ |
| 21 |
|
| 22 |
defined( 'ABSPATH' ) || exit; |
| 23 |
|
| 24 |
/** |
| 25 |
* Registers the five built-in wallpaper presets. |
| 26 |
* |
| 27 |
* @since 0.11.0 |
| 28 |
*/ |
| 29 |
function desktop_mode_register_builtin_wallpapers() { |
| 30 |
$presets = array( |
| 31 |
array( |
| 32 |
'id' => 'dark', |
| 33 |
'label' => __( 'Graphite', 'desktop-mode' ), |
| 34 |
'value' => 'linear-gradient(135deg, #1d2327 0%, #2c3338 50%, #1d2327 100%)', |
| 35 |
), |
| 36 |
array( |
| 37 |
'id' => 'aurora', |
| 38 |
'label' => __( 'Aurora', 'desktop-mode' ), |
| 39 |
'value' => 'linear-gradient(135deg, #1a2980 0%, #26d0ce 100%)', |
| 40 |
), |
| 41 |
array( |
| 42 |
'id' => 'sunset', |
| 43 |
'label' => __( 'Sunset', 'desktop-mode' ), |
| 44 |
'value' => 'linear-gradient(135deg, #ff512f 0%, #dd2476 100%)', |
| 45 |
), |
| 46 |
array( |
| 47 |
'id' => 'forest', |
| 48 |
'label' => __( 'Forest', 'desktop-mode' ), |
| 49 |
'value' => 'linear-gradient(135deg, #134e5e 0%, #71b280 100%)', |
| 50 |
), |
| 51 |
array( |
| 52 |
'id' => 'mono', |
| 53 |
'label' => __( 'Mono', 'desktop-mode' ), |
| 54 |
'value' => '#1d2327', |
| 55 |
), |
| 56 |
); |
| 57 |
|
| 58 |
foreach ( $presets as $preset ) { |
| 59 |
desktop_mode_register_wallpaper( $preset['id'], array( |
| 60 |
'label' => $preset['label'], |
| 61 |
'preview' => $preset['value'], |
| 62 |
'value' => $preset['value'], |
| 63 |
'type' => 'css', |
| 64 |
) ); |
| 65 |
} |
| 66 |
|
| 67 |
// Animated WordPress Logo — built-in PixiJS canvas wallpaper. |
| 68 |
// Moved out of `desktop.min.js` in 0.8.4. Same registration |
| 69 |
// surface third-party canvas wallpapers use: `script` is an |
| 70 |
// enqueued handle (registered in `includes/assets.php`); the |
| 71 |
// shell's wallpaper sync injects its URL when the wallpaper |
| 72 |
// def is needed (selected, or shown in the OS Settings picker). |
| 73 |
desktop_mode_register_wallpaper( 'wp-animated-logo', array( |
| 74 |
'label' => __( 'Animated WordPress Logo', 'desktop-mode' ), |
| 75 |
'preview' => 'radial-gradient(circle at 50% 50%, #1e3a8a 0%, #0b0f25 100%)', |
| 76 |
'type' => 'canvas', |
| 77 |
'script' => 'desktop-mode-animated-logo-wallpaper', |
| 78 |
) ); |
| 79 |
} |
| 80 |
add_action( 'init', 'desktop_mode_register_builtin_wallpapers', 5 ); |
| 81 |
|