| @@ -93,8 +93,10 @@ | ||
| 93 | 93 | */ |
| 94 | 94 | function openstation_default_os_settings() { |
| 95 | 95 | return array( |
| 96 | 96 | 'wallpaper' => 'galaxy', |
| 97 | + // Pulse, the brand's signature. Mirrors `DEFAULTS` in | |
| 98 | + // `src/settings/constants.ts`. | |
| 97 | 99 | 'accent' => 'pulse', |
| 98 | 100 | // Only read when `accent` is `custom`. Seeded with Pulse so |
| 99 | 101 | // picking Custom before touching the wheel is a no-op rather |
| 100 | 102 | // than a jump to black. Mirrors `DEFAULTS` in |
| @@ -210,8 +212,13 @@ | ||
| 210 | 212 | // window (e.g. array( 'author', 'tags' )). Empty array means |
| 211 | 213 | // every column is visible. The sticky 'title' column is always |
| 212 | 214 | // shown — the UI prevents toggling it. |
| 213 | 215 | 'nativePostsHiddenColumns' => array(), |
| 216 | + // Per-user list of column keys hidden in the native Pages | |
| 217 | + // window (e.g. array( 'author', 'parent' )). Empty array means | |
| 218 | + // every column is visible. The sticky 'title' column is always | |
| 219 | + // shown — the UI prevents toggling it. | |
| 220 | + 'nativePagesHiddenColumns' => array(), | |
| 214 | 221 | // Per-user opt-IN for the native Pages window. Same posture as |
| 215 | 222 | // nativePostsEnabled — defaults OFF (Beta), users opt in to swap |
| 216 | 223 | // the classic `edit.php?post_type=page` iframe for the native UI. |
| 217 | 224 | 'nativePagesEnabled' => false, |
| @@ -234,21 +241,11 @@ | ||
| 234 | 241 | // (including any custom dashboard a plugin builds there) opens |
| 235 | 242 | // as a chromeless iframe until the user opts in via OS |
| 236 | 243 | // Settings → Features → Beta features. |
| 237 | 244 | '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, | |
| 245 | + // Performance enhancements are enabled unless explicitly disabled. | |
| 246 | + 'adminAssetCacheEnabled' => true, | |
| 247 | + 'windowPrewarmEnabled' => true, | |
| 251 | 248 | // When true, left-clicking the empty wallpaper triggers the |
| 252 | 249 | // "Show desktop" toggle (macOS-style) and the matching entry is |
| 253 | 250 | // hidden from the wallpaper context menu. When false (default), |
| 254 | 251 | // the entry stays in the menu and left clicks on the wallpaper |
| @@ -263,8 +260,10 @@ | ||
| 263 | 260 | // the wallpaper, settles onto nearby windows, and watches the |
| 264 | 261 | // pointer. Off by default; toggled from the wallpaper context |
| 265 | 262 | // menu. Per-user. See `docs/mio.md`. |
| 266 | 263 | 'mioEnabled' => false, |
| 264 | + 'mioApiEnabled' => false, | |
| 265 | + 'mioShowOnWallpaper' => true, | |
| 267 | 266 | // The user's own Mio, as built in "Make it yours": partial |
| 268 | 267 | // appearance + silhouette overrides, both empty until they |
| 269 | 268 | // touch a control. Stored per user rather than per browser |
| 270 | 269 | // because it is a preference about the person — ten minutes |
| @@ -343,14 +342,14 @@ | ||
| 343 | 342 | */ |
| 344 | 343 | function openstation_get_os_settings( $user_id ) { |
| 345 | 344 | $user_id = (int) $user_id; |
| 346 | 345 | if ( $user_id <= 0 ) { |
| 347 | - return openstation_default_os_settings(); | |
| 346 | + return openstation_sanitize_os_settings( array() ); | |
| 348 | 347 | } |
| 349 | 348 | |
| 350 | 349 | $raw = get_user_meta( $user_id, OPENSTATION_OS_SETTINGS_META_KEY, true ); |
| 351 | 350 | if ( ! is_array( $raw ) ) { |
| 352 | - return openstation_default_os_settings(); | |
| 351 | + return openstation_sanitize_os_settings( array() ); | |
| 353 | 352 | } |
| 354 | 353 | |
| 355 | 354 | return openstation_sanitize_os_settings( $raw ); |
| 356 | 355 | } |
| @@ -453,9 +452,9 @@ | ||
| 453 | 452 | function openstation_sanitize_os_settings( $raw ) { |
| 454 | 453 | $defaults = openstation_default_os_settings(); |
| 455 | 454 | |
| 456 | 455 | if ( ! is_array( $raw ) ) { |
| 457 | - return $defaults; | |
| 456 | + $raw = array(); | |
| 458 | 457 | } |
| 459 | 458 | |
| 460 | 459 | // Wallpaper — any non-empty string; registry membership is validated |
| 461 | 460 | // client-side at apply time. |
| @@ -786,8 +785,27 @@ | ||
| 786 | 785 | // user meta indefinitely. |
| 787 | 786 | $native_posts_hidden_columns = array_slice( array_values( array_unique( $native_posts_hidden_columns ) ), 0, 32 ); |
| 788 | 787 | } |
| 789 | 788 | |
| 789 | + $native_pages_hidden_columns = $defaults['nativePagesHiddenColumns']; | |
| 790 | + if ( isset( $raw['nativePagesHiddenColumns'] ) && is_array( $raw['nativePagesHiddenColumns'] ) ) { | |
| 791 | + $native_pages_hidden_columns = array(); | |
| 792 | + foreach ( $raw['nativePagesHiddenColumns'] as $col ) { | |
| 793 | + if ( ! is_string( $col ) || '' === $col ) { | |
| 794 | + continue; | |
| 795 | + } | |
| 796 | + $slug = sanitize_key( $col ); | |
| 797 | + if ( '' === $slug ) { | |
| 798 | + continue; | |
| 799 | + } | |
| 800 | + $native_pages_hidden_columns[] = $slug; | |
| 801 | + } | |
| 802 | + // Cap to a sane upper bound — far more than any plausible | |
| 803 | + // column count, but blocks a malicious payload from bloating | |
| 804 | + // user meta indefinitely. | |
| 805 | + $native_pages_hidden_columns = array_slice( array_values( array_unique( $native_pages_hidden_columns ) ), 0, 32 ); | |
| 806 | + } | |
| 807 | + | |
| 790 | 808 | $native_pages_enabled = isset( $raw['nativePagesEnabled'] ) |
| 791 | 809 | ? (bool) $raw['nativePagesEnabled'] |
| 792 | 810 | : $defaults['nativePagesEnabled']; |
| 793 | 811 | |
| @@ -806,16 +824,14 @@ | ||
| 806 | 824 | $station_home_enabled = isset( $raw['stationHomeEnabled'] ) |
| 807 | 825 | ? (bool) $raw['stationHomeEnabled'] |
| 808 | 826 | : $defaults['stationHomeEnabled']; |
| 809 | 827 | |
| 810 | - $admin_asset_cache_enabled = isset( $raw['adminAssetCacheEnabled'] ) | |
| 811 | - ? (bool) $raw['adminAssetCacheEnabled'] | |
| 812 | - : $defaults['adminAssetCacheEnabled']; | |
| 828 | + // Site-wide performance controls supersede the legacy per-user values. | |
| 829 | + // Keep the snapshot keys so existing window consumers can read them. | |
| 830 | + $extended_options = openstation_get_extended_options(); | |
| 831 | + $admin_asset_cache_enabled = $extended_options['admin_asset_cache']; | |
| 832 | + $window_prewarm_enabled = $extended_options['window_prewarm']; | |
| 813 | 833 | |
| 814 | - $window_prewarm_enabled = isset( $raw['windowPrewarmEnabled'] ) | |
| 815 | - ? (bool) $raw['windowPrewarmEnabled'] | |
| 816 | - : $defaults['windowPrewarmEnabled']; | |
| 817 | - | |
| 818 | 834 | $show_desktop_on_wallpaper_click = isset( $raw['showDesktopOnWallpaperClick'] ) |
| 819 | 835 | ? (bool) $raw['showDesktopOnWallpaperClick'] |
| 820 | 836 | : $defaults['showDesktopOnWallpaperClick']; |
| 821 | 837 | |
| @@ -824,9 +840,9 @@ | ||
| 824 | 840 | : $defaults['confirmCloseAllWindows']; |
| 825 | 841 | |
| 826 | 842 | $mio_enabled = isset( $raw['mioEnabled'] ) |
| 827 | 843 | ? (bool) $raw['mioEnabled'] |
| 828 | - : $defaults['mioEnabled']; | |
| 844 | + : ( isset( $raw['mioApiEnabled'] ) ? (bool) $raw['mioApiEnabled'] : $defaults['mioEnabled'] ); | |
| 829 | 845 | |
| 830 | 846 | // A missing key means "no look saved yet", which sanitizes to the |
| 831 | 847 | // same pair of empty arrays the defaults carry — so this needs no |
| 832 | 848 | // isset() branch of its own. |
| @@ -1012,8 +1028,9 @@ | ||
| 1012 | 1028 | 'heartbeatRate' => $heartbeat_rate, |
| 1013 | 1029 | 'nativePostsEnabled' => $native_posts_enabled, |
| 1014 | 1030 | 'nativePostsHiddenColumns' => $native_posts_hidden_columns, |
| 1015 | 1031 | 'nativePagesEnabled' => $native_pages_enabled, |
| 1032 | + 'nativePagesHiddenColumns' => $native_pages_hidden_columns, | |
| 1016 | 1033 | 'nativeUsersEnabled' => $native_users_enabled, |
| 1017 | 1034 | 'nativePluginsEnabled' => $native_plugins_enabled, |
| 1018 | 1035 | 'nativeCommentsEnabled' => $native_comments_enabled, |
| 1019 | 1036 | 'stationHomeEnabled' => $station_home_enabled, |
| @@ -1021,8 +1038,10 @@ | ||
| 1021 | 1038 | 'windowPrewarmEnabled' => $window_prewarm_enabled, |
| 1022 | 1039 | 'showDesktopOnWallpaperClick' => $show_desktop_on_wallpaper_click, |
| 1023 | 1040 | 'confirmCloseAllWindows' => $confirm_close_all_windows, |
| 1024 | 1041 | 'mioEnabled' => $mio_enabled, |
| 1042 | + 'mioApiEnabled' => $mio_enabled, | |
| 1043 | + 'mioShowOnWallpaper' => isset( $raw['mioShowOnWallpaper'] ) ? (bool) $raw['mioShowOnWallpaper'] : $defaults['mioShowOnWallpaper'], | |
| 1025 | 1044 | 'mioStyle' => $mio_style, |
| 1026 | 1045 | 'showPostStatusRibbons' => $show_post_status_ribbons, |
| 1027 | 1046 | 'developerModeEnabled' => $developer_mode_enabled, |
| 1028 | 1047 | 'foldersSharingEnabled' => $folders_sharing_enabled, |
| @@ -1130,8 +1149,13 @@ | ||
| 1130 | 1149 | // true of every path into this handler, not just the ones the |
| 1131 | 1150 | // schema happens to guard. |
| 1132 | 1151 | if ( ! is_array( $payload ) ) { |
| 1133 | 1152 | return rest_ensure_response( openstation_get_os_settings( $user_id ) ); |
| 1153 | + } | |
| 1154 | + | |
| 1155 | + // Normalize an alias-only patch before merging it with the saved master value. | |
| 1156 | + if ( ! array_key_exists( 'mioEnabled', $payload ) && array_key_exists( 'mioApiEnabled', $payload ) ) { | |
| 1157 | + $payload['mioEnabled'] = $payload['mioApiEnabled']; | |
| 1134 | 1158 | } |
| 1135 | 1159 | |
| 1136 | 1160 | openstation_save_os_settings( |
| 1137 | 1161 | $user_id, |