PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.13
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.13
1.1.13 1.1.12 1.1.11 1.1.10 1.1.9 1.1.8 1.1.7 1.1.6 1.1.5 1.1.4 1.1.3 1.1.2 1.1.1 1.1.0 1.0.1 1.0.0 0.9.8 0.9.7 0.9.6 0.9.4 0.9.5 0.9.3 0.9.2 0.9.1 0.9.0 All 37 releases
← All changes | includes/os-settings.php +67 -27 1.1.7 → 1.1.13 View file →
@@ -30,8 +30,11 @@
30 30
31 31 /** Valid window-radius IDs — mirrors the TS `WINDOW_RADII` constant. */
32 32 const OPENSTATION_OS_SETTINGS_WINDOW_RADII = array( 'sharp', 'default', 'round' );
33 33
34 +/** How a newly opened window lands — mirrors the TS `OPEN_WINDOWS_AS` constant. */
35 +const OPENSTATION_OS_SETTINGS_OPEN_WINDOWS_AS = array( 'default', 'maximized', 'focused' );
36 +
34 37 /**
35 38 * Valid admin-bar mode IDs — mirrors the TS `ADMIN_BAR_MODES` constant.
36 39 *
37 40 * `static` keeps the WordPress admin bar pinned above the shell (the
@@ -93,8 +96,10 @@
93 96 */
94 97 function openstation_default_os_settings() {
95 98 return array(
96 99 'wallpaper' => 'galaxy',
100 + // Pulse, the brand's signature. Mirrors `DEFAULTS` in
101 + // `src/settings/constants.ts`.
97 102 'accent' => 'pulse',
98 103 // Only read when `accent` is `custom`. Seeded with Pulse so
99 104 // picking Custom before touching the wheel is a no-op rather
100 105 // than a jump to black. Mirrors `DEFAULTS` in
@@ -108,8 +113,9 @@
108 113 // `src/settings/constants.ts` — PHP seeds the first load and JS
109 114 // owns every paint after it, so a mismatch shows up as the
110 115 // corners changing shape a moment after the shell boots.
111 116 'windowRadius' => 'round',
117 + 'openWindowsAs' => 'default',
112 118 // How the WordPress admin bar presents above the shell.
113 119 // `hidden` ships as the default so a fresh desktop has ONE
114 120 // navigation surface: everything the user can open lives on the
115 121 // dock, and the dock's "Exit OpenStation" tile is the way back
@@ -210,8 +216,13 @@
210 216 // window (e.g. array( 'author', 'tags' )). Empty array means
211 217 // every column is visible. The sticky 'title' column is always
212 218 // shown — the UI prevents toggling it.
213 219 'nativePostsHiddenColumns' => array(),
220 + // Per-user list of column keys hidden in the native Pages
221 + // window (e.g. array( 'author', 'parent' )). Empty array means
222 + // every column is visible. The sticky 'title' column is always
223 + // shown — the UI prevents toggling it.
224 + 'nativePagesHiddenColumns' => array(),
214 225 // Per-user opt-IN for the native Pages window. Same posture as
215 226 // nativePostsEnabled — defaults OFF (Beta), users opt in to swap
216 227 // the classic `edit.php?post_type=page` iframe for the native UI.
217 228 'nativePagesEnabled' => false,
@@ -234,21 +245,11 @@
234 245 // (including any custom dashboard a plugin builds there) opens
235 246 // as a chromeless iframe until the user opts in via OS
236 247 // Settings → Features → Beta features.
237 248 'stationHomeEnabled' => false,
238 - // Per-user opt-IN for the service worker's shared admin-asset
239 - // cache (Experimental). Defaults OFF. The value feeds the
240 - // `openstation_pwa_admin_asset_cache` filter's default via
241 - // `openstation_pwa_admin_asset_cache_enabled()` and reaches the
242 - // SW inside the served `sw.js` bytes, so a change applies via a
243 - // normal SW update on the user's next reload.
244 - 'adminAssetCacheEnabled' => false,
245 - // Per-user opt-IN for hover-intent window prewarming
246 - // (Experimental). Defaults OFF. When on, a sustained mouse
247 - // hover on a dock tile speculatively builds that page's window
248 - // hidden so it appears already rendered on click. Read live by
249 - // the dock JS; no server-side behavior attaches to it.
250 - 'windowPrewarmEnabled' => false,
249 + // Performance enhancements are enabled unless explicitly disabled.
250 + 'adminAssetCacheEnabled' => true,
251 + 'windowPrewarmEnabled' => true,
251 252 // When true, left-clicking the empty wallpaper triggers the
252 253 // "Show desktop" toggle (macOS-style) and the matching entry is
253 254 // hidden from the wallpaper context menu. When false (default),
254 255 // the entry stays in the menu and left clicks on the wallpaper
@@ -263,8 +264,10 @@
263 264 // the wallpaper, settles onto nearby windows, and watches the
264 265 // pointer. Off by default; toggled from the wallpaper context
265 266 // menu. Per-user. See `docs/mio.md`.
266 267 'mioEnabled' => false,
268 + 'mioApiEnabled' => false,
269 + 'mioShowOnWallpaper' => true,
267 270 // The user's own Mio, as built in "Make it yours": partial
268 271 // appearance + silhouette overrides, both empty until they
269 272 // touch a control. Stored per user rather than per browser
270 273 // because it is a preference about the person — ten minutes
@@ -343,14 +346,14 @@
343 346 */
344 347 function openstation_get_os_settings( $user_id ) {
345 348 $user_id = (int) $user_id;
346 349 if ( $user_id <= 0 ) {
347 - return openstation_default_os_settings();
350 + return openstation_sanitize_os_settings( array() );
348 351 }
349 352
350 353 $raw = get_user_meta( $user_id, OPENSTATION_OS_SETTINGS_META_KEY, true );
351 354 if ( ! is_array( $raw ) ) {
352 - return openstation_default_os_settings();
355 + return openstation_sanitize_os_settings( array() );
353 356 }
354 357
355 358 return openstation_sanitize_os_settings( $raw );
356 359 }
@@ -453,16 +456,22 @@
453 456 function openstation_sanitize_os_settings( $raw ) {
454 457 $defaults = openstation_default_os_settings();
455 458
456 459 if ( ! is_array( $raw ) ) {
457 - return $defaults;
460 + $raw = array();
458 461 }
459 462
460 463 // Wallpaper — any non-empty string; registry membership is validated
461 464 // client-side at apply time.
462 - $wallpaper = isset( $raw['wallpaper'] ) && is_string( $raw['wallpaper'] ) && '' !== $raw['wallpaper']
463 - ? sanitize_key( $raw['wallpaper'] )
464 - : $defaults['wallpaper'];
465 + // Key-clean per `/` segment: a desktop theme's wallpapers are
466 + // registered as `desktop-theme/<theme>/<id>`, and a flat
467 + // `sanitize_key()` would fold that into an id nothing answers to.
468 + $wallpaper = isset( $raw['wallpaper'] ) && is_string( $raw['wallpaper'] )
469 + ? implode( '/', array_filter( array_map( 'sanitize_key', explode( '/', $raw['wallpaper'] ) ) ) )
470 + : '';
471 + if ( '' === $wallpaper ) {
472 + $wallpaper = $defaults['wallpaper'];
473 + }
465 474
466 475 // Accent — non-empty string; swatch validity is enforced in the picker.
467 476 $accent = isset( $raw['accent'] ) && is_string( $raw['accent'] ) && '' !== $raw['accent']
468 477 ? sanitize_key( $raw['accent'] )
@@ -487,8 +496,13 @@
487 496 $window_radius = isset( $raw['windowRadius'] ) && in_array( $raw['windowRadius'], OPENSTATION_OS_SETTINGS_WINDOW_RADII, true )
488 497 ? (string) $raw['windowRadius']
489 498 : $defaults['windowRadius'];
490 499
500 + // How a newly opened window lands — one of the three known values.
501 + $open_windows_as = isset( $raw['openWindowsAs'] ) && in_array( $raw['openWindowsAs'], OPENSTATION_OS_SETTINGS_OPEN_WINDOWS_AS, true )
502 + ? (string) $raw['openWindowsAs']
503 + : $defaults['openWindowsAs'];
504 +
491 505 // Admin-bar mode — must be one of the three known values.
492 506 $admin_bar_mode = isset( $raw['adminBarMode'] )
493 507 && in_array( $raw['adminBarMode'], OPENSTATION_OS_SETTINGS_ADMIN_BAR_MODES, true )
494 508 ? (string) $raw['adminBarMode']
@@ -786,8 +800,27 @@
786 800 // user meta indefinitely.
787 801 $native_posts_hidden_columns = array_slice( array_values( array_unique( $native_posts_hidden_columns ) ), 0, 32 );
788 802 }
789 803
804 + $native_pages_hidden_columns = $defaults['nativePagesHiddenColumns'];
805 + if ( isset( $raw['nativePagesHiddenColumns'] ) && is_array( $raw['nativePagesHiddenColumns'] ) ) {
806 + $native_pages_hidden_columns = array();
807 + foreach ( $raw['nativePagesHiddenColumns'] as $col ) {
808 + if ( ! is_string( $col ) || '' === $col ) {
809 + continue;
810 + }
811 + $slug = sanitize_key( $col );
812 + if ( '' === $slug ) {
813 + continue;
814 + }
815 + $native_pages_hidden_columns[] = $slug;
816 + }
817 + // Cap to a sane upper bound — far more than any plausible
818 + // column count, but blocks a malicious payload from bloating
819 + // user meta indefinitely.
820 + $native_pages_hidden_columns = array_slice( array_values( array_unique( $native_pages_hidden_columns ) ), 0, 32 );
821 + }
822 +
790 823 $native_pages_enabled = isset( $raw['nativePagesEnabled'] )
791 824 ? (bool) $raw['nativePagesEnabled']
792 825 : $defaults['nativePagesEnabled'];
793 826
@@ -806,16 +839,14 @@
806 839 $station_home_enabled = isset( $raw['stationHomeEnabled'] )
807 840 ? (bool) $raw['stationHomeEnabled']
808 841 : $defaults['stationHomeEnabled'];
809 842
810 - $admin_asset_cache_enabled = isset( $raw['adminAssetCacheEnabled'] )
811 - ? (bool) $raw['adminAssetCacheEnabled']
812 - : $defaults['adminAssetCacheEnabled'];
843 + // Site-wide performance controls supersede the legacy per-user values.
844 + // Keep the snapshot keys so existing window consumers can read them.
845 + $extended_options = openstation_get_extended_options();
846 + $admin_asset_cache_enabled = $extended_options['admin_asset_cache'];
847 + $window_prewarm_enabled = $extended_options['window_prewarm'];
813 848
814 - $window_prewarm_enabled = isset( $raw['windowPrewarmEnabled'] )
815 - ? (bool) $raw['windowPrewarmEnabled']
816 - : $defaults['windowPrewarmEnabled'];
817 -
818 849 $show_desktop_on_wallpaper_click = isset( $raw['showDesktopOnWallpaperClick'] )
819 850 ? (bool) $raw['showDesktopOnWallpaperClick']
820 851 : $defaults['showDesktopOnWallpaperClick'];
821 852
@@ -824,9 +855,9 @@
824 855 : $defaults['confirmCloseAllWindows'];
825 856
826 857 $mio_enabled = isset( $raw['mioEnabled'] )
827 858 ? (bool) $raw['mioEnabled']
828 - : $defaults['mioEnabled'];
859 + : ( isset( $raw['mioApiEnabled'] ) ? (bool) $raw['mioApiEnabled'] : $defaults['mioEnabled'] );
829 860
830 861 // A missing key means "no look saved yet", which sanitizes to the
831 862 // same pair of empty arrays the defaults carry — so this needs no
832 863 // isset() branch of its own.
@@ -987,8 +1018,9 @@
987 1018 'accent' => $accent,
988 1019 'customAccent' => $custom_accent,
989 1020 'dockSize' => $dock_size,
990 1021 'windowRadius' => $window_radius,
1022 + 'openWindowsAs' => $open_windows_as,
991 1023 'adminBarMode' => $admin_bar_mode,
992 1024 'desktopLayout' => $desktop_layout,
993 1025 'dockPlacement' => $dock_placement,
994 1026 'dockBehavior' => $dock_behavior,
@@ -1012,8 +1044,9 @@
1012 1044 'heartbeatRate' => $heartbeat_rate,
1013 1045 'nativePostsEnabled' => $native_posts_enabled,
1014 1046 'nativePostsHiddenColumns' => $native_posts_hidden_columns,
1015 1047 'nativePagesEnabled' => $native_pages_enabled,
1048 + 'nativePagesHiddenColumns' => $native_pages_hidden_columns,
1016 1049 'nativeUsersEnabled' => $native_users_enabled,
1017 1050 'nativePluginsEnabled' => $native_plugins_enabled,
1018 1051 'nativeCommentsEnabled' => $native_comments_enabled,
1019 1052 'stationHomeEnabled' => $station_home_enabled,
@@ -1021,8 +1054,10 @@
1021 1054 'windowPrewarmEnabled' => $window_prewarm_enabled,
1022 1055 'showDesktopOnWallpaperClick' => $show_desktop_on_wallpaper_click,
1023 1056 'confirmCloseAllWindows' => $confirm_close_all_windows,
1024 1057 'mioEnabled' => $mio_enabled,
1058 + 'mioApiEnabled' => $mio_enabled,
1059 + 'mioShowOnWallpaper' => isset( $raw['mioShowOnWallpaper'] ) ? (bool) $raw['mioShowOnWallpaper'] : $defaults['mioShowOnWallpaper'],
1025 1060 'mioStyle' => $mio_style,
1026 1061 'showPostStatusRibbons' => $show_post_status_ribbons,
1027 1062 'developerModeEnabled' => $developer_mode_enabled,
1028 1063 'foldersSharingEnabled' => $folders_sharing_enabled,
@@ -1130,8 +1165,13 @@
1130 1165 // true of every path into this handler, not just the ones the
1131 1166 // schema happens to guard.
1132 1167 if ( ! is_array( $payload ) ) {
1133 1168 return rest_ensure_response( openstation_get_os_settings( $user_id ) );
1169 + }
1170 +
1171 + // Normalize an alias-only patch before merging it with the saved master value.
1172 + if ( ! array_key_exists( 'mioEnabled', $payload ) && array_key_exists( 'mioApiEnabled', $payload ) ) {
1173 + $payload['mioEnabled'] = $payload['mioApiEnabled'];
1134 1174 }
1135 1175
1136 1176 openstation_save_os_settings(
1137 1177 $user_id,