| 1 |
<?php |
| 2 |
/** |
| 3 |
* OpenStation — Built-in wallpaper presets. |
| 4 |
* |
| 5 |
* The built-in wallpapers that ship with the plugin — five gradient / |
| 6 |
* solid CSS presets plus the Animated WordPress Logo canvas wallpaper — |
| 7 |
* each registered through the same public API third-party plugins use |
| 8 |
* (`openstation_register_wallpaper()`). Dogfooding the registration |
| 9 |
* surface for the built-ins is how we discover whether the API is |
| 10 |
* expressive enough for plugin authors — if we couldn't describe our |
| 11 |
* own presets through it, the API is broken. |
| 12 |
* |
| 13 |
* Hooked on `init` priority 5 so the presets land in the registry |
| 14 |
* before the shell config is built (shell render runs on |
| 15 |
* `admin_enqueue_scripts`, which fires after `init`), and before any |
| 16 |
* late third-party plugin that wants to react via the |
| 17 |
* `openstation_wallpaper_registered` action. |
| 18 |
* |
| 19 |
* @package OpenStation |
| 20 |
*/ |
| 21 |
|
| 22 |
defined( 'ABSPATH' ) || exit; |
| 23 |
|
| 24 |
/** |
| 25 |
* Registers the built-in wallpapers: five gradient / solid CSS presets |
| 26 |
* plus the Animated WordPress Logo canvas wallpaper. |
| 27 |
*/ |
| 28 |
function openstation_register_builtin_wallpapers() { |
| 29 |
/* |
| 30 |
* The four brand surfaces, straight from the OpenStation brand |
| 31 |
* guidelines. Registered as `css` wallpapers pointing at the |
| 32 |
* vector artwork the plugin ships: an SVG scales to any desk at |
| 33 |
* any DPI for a few kilobytes, which no raster wallpaper can do. |
| 34 |
* |
| 35 |
* `cover` on a 3:2 artboard, `center` so the composition's focal |
| 36 |
* point survives a crop on either axis, `fixed` so the desk does |
| 37 |
* not shift under a window drag. |
| 38 |
* |
| 39 |
* Galaxy is the default desk — see the `wallpaper` default in |
| 40 |
* `openstation_default_os_settings()`. |
| 41 |
*/ |
| 42 |
$brand = array( |
| 43 |
array( |
| 44 |
'id' => 'galaxy', |
| 45 |
'label' => __( 'Galaxy', 'desktop-mode' ), |
| 46 |
'file' => 'galaxy.svg', |
| 47 |
'description' => __( 'The station seen from outside: a Void sky with soft Nebula glows and a Starlight starfield drifting through it.', 'desktop-mode' ), |
| 48 |
), |
| 49 |
array( |
| 50 |
'id' => 'space', |
| 51 |
'label' => __( 'Space', 'desktop-mode' ), |
| 52 |
'file' => 'space.svg', |
| 53 |
'description' => __( 'Deep space, quietly. One long gradient from near-black to a faint violet horizon — the calmest desk in the set, and the one that asks least of your eyes.', 'desktop-mode' ), |
| 54 |
), |
| 55 |
array( |
| 56 |
'id' => 'holomesh', |
| 57 |
'label' => __( 'Holomesh', 'desktop-mode' ), |
| 58 |
'file' => 'holomesh.svg', |
| 59 |
'description' => __( 'The holographic mesh: lavender, pink, cyan and mint pooling into each other like light through a prism.', 'desktop-mode' ), |
| 60 |
), |
| 61 |
array( |
| 62 |
'id' => 'pulsemesh', |
| 63 |
'label' => __( 'Pulsemesh', 'desktop-mode' ), |
| 64 |
'file' => 'pulsemesh.svg', |
| 65 |
'description' => __( 'The pulsar mesh: magenta and violet burning through a white core, the brightest surface the brand has.', 'desktop-mode' ), |
| 66 |
), |
| 67 |
); |
| 68 |
|
| 69 |
foreach ( $brand as $wallpaper ) { |
| 70 |
$css = 'url( ' . OPENSTATION_URL . 'assets/wallpapers/' . $wallpaper['file'] . ' ) center center / cover no-repeat fixed'; |
| 71 |
openstation_register_wallpaper( |
| 72 |
$wallpaper['id'], |
| 73 |
array( |
| 74 |
'label' => $wallpaper['label'], |
| 75 |
'type' => 'css', |
| 76 |
// The swatch is the same artwork, sized to the chip rather |
| 77 |
// than the desk: `cover` on a 40px square would crop to a |
| 78 |
// meaningless corner of the composition. |
| 79 |
'preview' => 'url( ' . OPENSTATION_URL . 'assets/wallpapers/' . $wallpaper['file'] . ' ) center center / cover no-repeat', |
| 80 |
'value' => $css, |
| 81 |
'description' => $wallpaper['description'], |
| 82 |
) |
| 83 |
); |
| 84 |
} |
| 85 |
|
| 86 |
$presets = array( |
| 87 |
array( |
| 88 |
'id' => 'dark', |
| 89 |
'label' => __( 'Graphite', 'desktop-mode' ), |
| 90 |
'value' => 'linear-gradient(135deg, #1d2327 0%, #2c3338 50%, #1d2327 100%)', |
| 91 |
'description' => __( 'A quiet charcoal gradient that keeps every eye on your windows — the classic dark desk WordPress admins know by heart.', 'desktop-mode' ), |
| 92 |
), |
| 93 |
array( |
| 94 |
'id' => 'aurora', |
| 95 |
'label' => __( 'Aurora', 'desktop-mode' ), |
| 96 |
'value' => 'linear-gradient(135deg, #1a2980 0%, #26d0ce 100%)', |
| 97 |
'description' => __( 'Deep indigo melting into arctic teal — northern lights over a midnight horizon.', 'desktop-mode' ), |
| 98 |
), |
| 99 |
array( |
| 100 |
'id' => 'sunset', |
| 101 |
'label' => __( 'Sunset', 'desktop-mode' ), |
| 102 |
'value' => 'linear-gradient(135deg, #ff512f 0%, #dd2476 100%)', |
| 103 |
'description' => __( 'A warm blaze from ember orange to magenta — golden hour, frozen mid-fade.', 'desktop-mode' ), |
| 104 |
), |
| 105 |
array( |
| 106 |
'id' => 'forest', |
| 107 |
'label' => __( 'Forest', 'desktop-mode' ), |
| 108 |
'value' => 'linear-gradient(135deg, #134e5e 0%, #71b280 100%)', |
| 109 |
'description' => __( 'Cool pine greens for calm, unhurried work under the canopy.', 'desktop-mode' ), |
| 110 |
), |
| 111 |
array( |
| 112 |
'id' => 'mono', |
| 113 |
'label' => __( 'Mono', 'desktop-mode' ), |
| 114 |
'value' => '#1d2327', |
| 115 |
'description' => __( 'One flat graphite tone. No gradient, no noise — nothing but your work.', 'desktop-mode' ), |
| 116 |
), |
| 117 |
); |
| 118 |
|
| 119 |
foreach ( $presets as $preset ) { |
| 120 |
openstation_register_wallpaper( |
| 121 |
$preset['id'], |
| 122 |
array( |
| 123 |
'label' => $preset['label'], |
| 124 |
'preview' => $preset['value'], |
| 125 |
'value' => $preset['value'], |
| 126 |
'type' => 'css', |
| 127 |
'description' => $preset['description'], |
| 128 |
) |
| 129 |
); |
| 130 |
} |
| 131 |
|
| 132 |
// Animated WordPress Logo — built-in PixiJS canvas wallpaper. |
| 133 |
// Moved out of `desktop.min.js`. Same registration |
| 134 |
// surface third-party canvas wallpapers use: `script` is an |
| 135 |
// enqueued handle (registered in `includes/assets.php`); the |
| 136 |
// shell's wallpaper sync injects its URL when the wallpaper |
| 137 |
// def is needed (selected, or shown in the OS Settings picker). |
| 138 |
openstation_register_wallpaper( |
| 139 |
'wp-animated-logo', |
| 140 |
array( |
| 141 |
'label' => __( 'Animated WordPress Logo', 'desktop-mode' ), |
| 142 |
'preview' => 'radial-gradient(circle at 50% 50%, #1e3a8a 0%, #0b0f25 100%)', |
| 143 |
'type' => 'canvas', |
| 144 |
'script' => 'os-animated-logo-wallpaper', |
| 145 |
'description' => __( 'Thousands of luminous particles holding the shape of the WordPress W. Sweep your cursor through and they scatter like sand, then drift home again.', 'desktop-mode' ), |
| 146 |
) |
| 147 |
); |
| 148 |
|
| 149 |
// Snow — built-in PixiJS canvas wallpaper. The preview gradient |
| 150 |
// must match the default backdrop the JS side paints behind the |
| 151 |
// canvas (`backdropCss()` in `src/plugins/snow-wallpaper/settings.ts`) |
| 152 |
// — the swatch renders before the wallpaper script has ever |
| 153 |
// loaded, so a mismatch would show one sky in the picker and a |
| 154 |
// different one once selected. First built-in wallpaper with a |
| 155 |
// `renderConfig` settings dialog (wind, snowflake count, flake |
| 156 |
// size, background colour). |
| 157 |
openstation_register_wallpaper( |
| 158 |
'wp-snow', |
| 159 |
array( |
| 160 |
'label' => __( 'Snow', 'desktop-mode' ), |
| 161 |
'preview' => 'linear-gradient(180deg, #0c1a36 0%, #1d355e 55%, #425d8a 100%)', |
| 162 |
'type' => 'canvas', |
| 163 |
'script' => 'os-snow-wallpaper', |
| 164 |
'description' => __( 'Snow falling over a midnight sky. Flakes settle on the top edge of every window, pile into little drifts, then quietly melt away. Open the wallpaper settings to tune the wind, the snowfall, the flake size, and the colour of the night.', 'desktop-mode' ), |
| 165 |
) |
| 166 |
); |
| 167 |
} |
| 168 |
add_action( 'init', 'openstation_register_builtin_wallpapers', 5 ); |
| 169 |
|