| @@ -52,8 +52,28 @@ | ||
| 52 | 52 | */ |
| 53 | 53 | const OPENSTATION_OS_SETTINGS_DOCK_PLACEMENTS = array( 'bottom', 'left', 'right' ); |
| 54 | 54 | |
| 55 | 55 | /** |
| 56 | + * Valid dock-behavior IDs — mirrors the TS `DOCK_BEHAVIORS` constant. | |
| 57 | + * | |
| 58 | + * `static` keeps the dock always on screen (the default); `dynamic` | |
| 59 | + * parks it off its edge behind a peek strip that reveals when the | |
| 60 | + * pointer reaches that edge or something on it takes keyboard focus, | |
| 61 | + * and releases the band it floats over from the work area. | |
| 62 | + */ | |
| 63 | +const OPENSTATION_OS_SETTINGS_DOCK_BEHAVIORS = array( 'static', 'dynamic' ); | |
| 64 | + | |
| 65 | +/** | |
| 66 | + * `mobileLayout` — which experience the shell renders. `auto` | |
| 67 | + * follows the viewport; the other two force it either way. | |
| 68 | + * Mirrors `OsModePreference` in `src/mode/index.ts`. | |
| 69 | + */ | |
| 70 | +const OPENSTATION_OS_SETTINGS_MOBILE_LAYOUTS = array( 'auto', 'desktop', 'mobile' ); | |
| 71 | + | |
| 72 | +/** `mobileTabs` — at most this many ids pinned to the phone tab bar. */ | |
| 73 | +const OPENSTATION_OS_SETTINGS_MOBILE_TABS_MAX = 3; | |
| 74 | + | |
| 75 | +/** | |
| 56 | 76 | * Playable range for the window-reveal duration override, in ms. |
| 57 | 77 | * Mirrors `MIN_REVEAL_DURATION_MS` / `MAX_REVEAL_DURATION_MS` in |
| 58 | 78 | * `src/reveals/registry.ts`. |
| 59 | 79 | * |
| @@ -73,8 +93,10 @@ | ||
| 73 | 93 | */ |
| 74 | 94 | function openstation_default_os_settings() { |
| 75 | 95 | return array( |
| 76 | 96 | 'wallpaper' => 'galaxy', |
| 97 | + // Pulse, the brand's signature. Mirrors `DEFAULTS` in | |
| 98 | + // `src/settings/constants.ts`. | |
| 77 | 99 | 'accent' => 'pulse', |
| 78 | 100 | // Only read when `accent` is `custom`. Seeded with Pulse so |
| 79 | 101 | // picking Custom before touching the wheel is a no-op rather |
| 80 | 102 | // than a jump to black. Mirrors `DEFAULTS` in |
| @@ -95,8 +117,14 @@ | ||
| 95 | 117 | // dock, and the dock's "Exit OpenStation" tile is the way back |
| 96 | 118 | // to classic admin. `static` (vanilla behavior) and `dynamic` |
| 97 | 119 | // are one pick away in OpenStation Preferences → Appearance. |
| 98 | 120 | 'adminBarMode' => 'hidden', |
| 121 | + // Always on screen. `dynamic` (auto-hide behind a peek strip) | |
| 122 | + // is one pick away in OpenStation Preferences → Appearance. | |
| 123 | + 'dockBehavior' => 'static', | |
| 124 | + // The Split layout's sidebar answers for itself: a folded | |
| 125 | + // sidebar over a static bottom dock is a valid desk. | |
| 126 | + 'sideDockBehavior' => 'static', | |
| 99 | 127 | // One dock holding every menu, with the system tiles grouped |
| 100 | 128 | // behind a hairline. `classic` (side bar for core menus + bottom |
| 101 | 129 | // dock for plugins) is the other option; it is no longer what a |
| 102 | 130 | // first-run desktop looks like. |
| @@ -184,8 +212,13 @@ | ||
| 184 | 212 | // window (e.g. array( 'author', 'tags' )). Empty array means |
| 185 | 213 | // every column is visible. The sticky 'title' column is always |
| 186 | 214 | // shown — the UI prevents toggling it. |
| 187 | 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(), | |
| 188 | 221 | // Per-user opt-IN for the native Pages window. Same posture as |
| 189 | 222 | // nativePostsEnabled — defaults OFF (Beta), users opt in to swap |
| 190 | 223 | // the classic `edit.php?post_type=page` iframe for the native UI. |
| 191 | 224 | 'nativePagesEnabled' => false, |
| @@ -202,8 +235,17 @@ | ||
| 202 | 235 | // Per-user opt-IN for the native Comments window. Defaults OFF |
| 203 | 236 | // (Beta); the server-side cap gate (`edit_posts`) means the |
| 204 | 237 | // toggle only matters for users who could see the Comments tile. |
| 205 | 238 | 'nativeCommentsEnabled' => false, |
| 239 | + // Per-user opt-IN for Station Home, the native Dashboard | |
| 240 | + // window. Defaults OFF: the ordinary `index.php` Dashboard | |
| 241 | + // (including any custom dashboard a plugin builds there) opens | |
| 242 | + // as a chromeless iframe until the user opts in via OS | |
| 243 | + // Settings → Features → Beta features. | |
| 244 | + 'stationHomeEnabled' => false, | |
| 245 | + // Performance enhancements are enabled unless explicitly disabled. | |
| 246 | + 'adminAssetCacheEnabled' => true, | |
| 247 | + 'windowPrewarmEnabled' => true, | |
| 206 | 248 | // When true, left-clicking the empty wallpaper triggers the |
| 207 | 249 | // "Show desktop" toggle (macOS-style) and the matching entry is |
| 208 | 250 | // hidden from the wallpaper context menu. When false (default), |
| 209 | 251 | // the entry stays in the menu and left clicks on the wallpaper |
| @@ -208,13 +250,20 @@ | ||
| 208 | 250 | // hidden from the wallpaper context menu. When false (default), |
| 209 | 251 | // the entry stays in the menu and left clicks on the wallpaper |
| 210 | 252 | // do nothing. Per-user. |
| 211 | 253 | 'showDesktopOnWallpaperClick' => false, |
| 254 | + // Whether the close-all-windows shortcut (Alt+Cmd/Ctrl+W) asks | |
| 255 | + // before it closes. The dialog's "Don't ask again" checkbox is | |
| 256 | + // what writes false; OpenStation Preferences -> Windows is what | |
| 257 | + // turns it back on. Per-user. | |
| 258 | + 'confirmCloseAllWindows' => true, | |
| 212 | 259 | // Mio — a soft-body companion that floats over |
| 213 | 260 | // the wallpaper, settles onto nearby windows, and watches the |
| 214 | 261 | // pointer. Off by default; toggled from the wallpaper context |
| 215 | 262 | // menu. Per-user. See `docs/mio.md`. |
| 216 | 263 | 'mioEnabled' => false, |
| 264 | + 'mioApiEnabled' => false, | |
| 265 | + 'mioShowOnWallpaper' => true, | |
| 217 | 266 | // The user's own Mio, as built in "Make it yours": partial |
| 218 | 267 | // appearance + silhouette overrides, both empty until they |
| 219 | 268 | // touch a control. Stored per user rather than per browser |
| 220 | 269 | // because it is a preference about the person — ten minutes |
| @@ -231,11 +280,12 @@ | ||
| 231 | 280 | // a glance. Per-user. |
| 232 | 281 | 'showPostStatusRibbons' => true, |
| 233 | 282 | // Unlocks developer-facing surfaces meant for plugin |
| 234 | 283 | // authors: the Starter Widget appears in the add-widget |
| 235 | - // picker, and the OS Settings → Components tab runs its | |
| 236 | - // intentional missing-import-warner demo. Off by default. | |
| 237 | - // Per-user. | |
| 284 | + // picker, the OS Settings → Components tab runs its | |
| 285 | + // intentional missing-import-warner demo, and the Code Blue | |
| 286 | + // error-log reader registers (icon, window, REST routes). | |
| 287 | + // Off by default. Per-user. | |
| 238 | 288 | 'developerModeEnabled' => false, |
| 239 | 289 | // Per-user opt-OUT for the folder-sharing feature. Defaults |
| 240 | 290 | // ON. When false: |
| 241 | 291 | // - The Share button, share-settings modal, "Leave shared |
| @@ -264,8 +314,14 @@ | ||
| 264 | 314 | // Per-user ordering, flat across every dock/sidebar zone. Ids |
| 265 | 315 | // not in the list keep their registration order and render |
| 266 | 316 | // after the listed ones. Unknown ids are tolerated. |
| 267 | 317 | 'navOrder' => array(), |
| 318 | + // Which experience the shell renders: 'auto' follows the | |
| 319 | + // viewport, 'desktop' / 'mobile' force it. See `includes/mobile.php`. | |
| 320 | + 'mobileLayout' => 'auto', | |
| 321 | + // Ids pinned to the phone tab bar, at most three. Empty means | |
| 322 | + // the server default (`openstation_mobile_tab_bar`). | |
| 323 | + 'mobileTabs' => array(), | |
| 268 | 324 | // Persisted desktop position for every item the user has |
| 269 | 325 | // promoted to the wallpaper via `navPlacement[id]=desktop|both`. |
| 270 | 326 | // Keyed by item id, value is `{ x: int, y: int }`. The JS |
| 271 | 327 | // synthesizer reads this when building a synthetic placement so |
| @@ -286,14 +342,14 @@ | ||
| 286 | 342 | */ |
| 287 | 343 | function openstation_get_os_settings( $user_id ) { |
| 288 | 344 | $user_id = (int) $user_id; |
| 289 | 345 | if ( $user_id <= 0 ) { |
| 290 | - return openstation_default_os_settings(); | |
| 346 | + return openstation_sanitize_os_settings( array() ); | |
| 291 | 347 | } |
| 292 | 348 | |
| 293 | 349 | $raw = get_user_meta( $user_id, OPENSTATION_OS_SETTINGS_META_KEY, true ); |
| 294 | 350 | if ( ! is_array( $raw ) ) { |
| 295 | - return openstation_default_os_settings(); | |
| 351 | + return openstation_sanitize_os_settings( array() ); | |
| 296 | 352 | } |
| 297 | 353 | |
| 298 | 354 | return openstation_sanitize_os_settings( $raw ); |
| 299 | 355 | } |
| @@ -396,9 +452,9 @@ | ||
| 396 | 452 | function openstation_sanitize_os_settings( $raw ) { |
| 397 | 453 | $defaults = openstation_default_os_settings(); |
| 398 | 454 | |
| 399 | 455 | if ( ! is_array( $raw ) ) { |
| 400 | - return $defaults; | |
| 456 | + $raw = array(); | |
| 401 | 457 | } |
| 402 | 458 | |
| 403 | 459 | // Wallpaper — any non-empty string; registry membership is validated |
| 404 | 460 | // client-side at apply time. |
| @@ -436,8 +492,19 @@ | ||
| 436 | 492 | && in_array( $raw['adminBarMode'], OPENSTATION_OS_SETTINGS_ADMIN_BAR_MODES, true ) |
| 437 | 493 | ? (string) $raw['adminBarMode'] |
| 438 | 494 | : $defaults['adminBarMode']; |
| 439 | 495 | |
| 496 | + // Dock behavior — must be one of the two known values. One answer | |
| 497 | + // per rail: the dock, and the Split layout's sidebar. | |
| 498 | + $dock_behavior = isset( $raw['dockBehavior'] ) | |
| 499 | + && in_array( $raw['dockBehavior'], OPENSTATION_OS_SETTINGS_DOCK_BEHAVIORS, true ) | |
| 500 | + ? (string) $raw['dockBehavior'] | |
| 501 | + : $defaults['dockBehavior']; | |
| 502 | + $side_dock_behavior = isset( $raw['sideDockBehavior'] ) | |
| 503 | + && in_array( $raw['sideDockBehavior'], OPENSTATION_OS_SETTINGS_DOCK_BEHAVIORS, true ) | |
| 504 | + ? (string) $raw['sideDockBehavior'] | |
| 505 | + : $defaults['sideDockBehavior']; | |
| 506 | + | |
| 440 | 507 | // Desktop layout — must be one of the known values (`classic`, |
| 441 | 508 | // `unified`). Default `unified`. |
| 442 | 509 | $desktop_layout = isset( $raw['desktopLayout'] ) |
| 443 | 510 | && in_array( $raw['desktopLayout'], OPENSTATION_OS_SETTINGS_DESKTOP_LAYOUTS, true ) |
| @@ -718,8 +785,27 @@ | ||
| 718 | 785 | // user meta indefinitely. |
| 719 | 786 | $native_posts_hidden_columns = array_slice( array_values( array_unique( $native_posts_hidden_columns ) ), 0, 32 ); |
| 720 | 787 | } |
| 721 | 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 | + | |
| 722 | 808 | $native_pages_enabled = isset( $raw['nativePagesEnabled'] ) |
| 723 | 809 | ? (bool) $raw['nativePagesEnabled'] |
| 724 | 810 | : $defaults['nativePagesEnabled']; |
| 725 | 811 | |
| @@ -734,15 +820,29 @@ | ||
| 734 | 820 | $native_comments_enabled = isset( $raw['nativeCommentsEnabled'] ) |
| 735 | 821 | ? (bool) $raw['nativeCommentsEnabled'] |
| 736 | 822 | : $defaults['nativeCommentsEnabled']; |
| 737 | 823 | |
| 824 | + $station_home_enabled = isset( $raw['stationHomeEnabled'] ) | |
| 825 | + ? (bool) $raw['stationHomeEnabled'] | |
| 826 | + : $defaults['stationHomeEnabled']; | |
| 827 | + | |
| 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']; | |
| 833 | + | |
| 738 | 834 | $show_desktop_on_wallpaper_click = isset( $raw['showDesktopOnWallpaperClick'] ) |
| 739 | 835 | ? (bool) $raw['showDesktopOnWallpaperClick'] |
| 740 | 836 | : $defaults['showDesktopOnWallpaperClick']; |
| 741 | 837 | |
| 838 | + $confirm_close_all_windows = isset( $raw['confirmCloseAllWindows'] ) | |
| 839 | + ? (bool) $raw['confirmCloseAllWindows'] | |
| 840 | + : $defaults['confirmCloseAllWindows']; | |
| 841 | + | |
| 742 | 842 | $mio_enabled = isset( $raw['mioEnabled'] ) |
| 743 | 843 | ? (bool) $raw['mioEnabled'] |
| 744 | - : $defaults['mioEnabled']; | |
| 844 | + : ( isset( $raw['mioApiEnabled'] ) ? (bool) $raw['mioApiEnabled'] : $defaults['mioEnabled'] ); | |
| 745 | 845 | |
| 746 | 846 | // A missing key means "no look saved yet", which sanitizes to the |
| 747 | 847 | // same pair of empty arrays the defaults carry — so this needs no |
| 748 | 848 | // isset() branch of its own. |
| @@ -757,8 +857,35 @@ | ||
| 757 | 857 | $developer_mode_enabled = isset( $raw['developerModeEnabled'] ) |
| 758 | 858 | ? (bool) $raw['developerModeEnabled'] |
| 759 | 859 | : $defaults['developerModeEnabled']; |
| 760 | 860 | |
| 861 | + // mobileLayout — the phone/desktop override. | |
| 862 | + $mobile_layout = isset( $raw['mobileLayout'] ) | |
| 863 | + && in_array( $raw['mobileLayout'], OPENSTATION_OS_SETTINGS_MOBILE_LAYOUTS, true ) | |
| 864 | + ? (string) $raw['mobileLayout'] | |
| 865 | + : $defaults['mobileLayout']; | |
| 866 | + | |
| 867 | + // mobileTabs — ordered nav ids pinned to the phone tab bar. Same | |
| 868 | + // id grammar as navOrder, capped at the tab bar's slot count. | |
| 869 | + $mobile_tabs = array(); | |
| 870 | + if ( isset( $raw['mobileTabs'] ) && is_array( $raw['mobileTabs'] ) ) { | |
| 871 | + $seen_tabs = array(); | |
| 872 | + foreach ( $raw['mobileTabs'] as $id ) { | |
| 873 | + if ( ! is_string( $id ) || '' === $id ) { | |
| 874 | + continue; | |
| 875 | + } | |
| 876 | + $slug = sanitize_key( openstation_canonical_nav_id( $id ) ); | |
| 877 | + if ( '' === $slug || isset( $seen_tabs[ $slug ] ) ) { | |
| 878 | + continue; | |
| 879 | + } | |
| 880 | + $seen_tabs[ $slug ] = true; | |
| 881 | + $mobile_tabs[] = $slug; | |
| 882 | + if ( count( $mobile_tabs ) >= OPENSTATION_OS_SETTINGS_MOBILE_TABS_MAX ) { | |
| 883 | + break; | |
| 884 | + } | |
| 885 | + } | |
| 886 | + } | |
| 887 | + | |
| 761 | 888 | $folders_sharing_enabled = isset( $raw['foldersSharingEnabled'] ) |
| 762 | 889 | ? (bool) $raw['foldersSharingEnabled'] |
| 763 | 890 | : $defaults['foldersSharingEnabled']; |
| 764 | 891 | |
| @@ -879,8 +1006,10 @@ | ||
| 879 | 1006 | 'windowRadius' => $window_radius, |
| 880 | 1007 | 'adminBarMode' => $admin_bar_mode, |
| 881 | 1008 | 'desktopLayout' => $desktop_layout, |
| 882 | 1009 | 'dockPlacement' => $dock_placement, |
| 1010 | + 'dockBehavior' => $dock_behavior, | |
| 1011 | + 'sideDockBehavior' => $side_dock_behavior, | |
| 883 | 1012 | 'dockRailRenderer' => $dock_rail_renderer, |
| 884 | 1013 | 'desktopTheme' => $desktop_theme, |
| 885 | 1014 | 'appliedThemeRecommendations' => $applied_theme_recommendations, |
| 886 | 1015 | 'unfocusEffect' => $unfocus_effect, |
| @@ -899,13 +1028,20 @@ | ||
| 899 | 1028 | 'heartbeatRate' => $heartbeat_rate, |
| 900 | 1029 | 'nativePostsEnabled' => $native_posts_enabled, |
| 901 | 1030 | 'nativePostsHiddenColumns' => $native_posts_hidden_columns, |
| 902 | 1031 | 'nativePagesEnabled' => $native_pages_enabled, |
| 1032 | + 'nativePagesHiddenColumns' => $native_pages_hidden_columns, | |
| 903 | 1033 | 'nativeUsersEnabled' => $native_users_enabled, |
| 904 | 1034 | 'nativePluginsEnabled' => $native_plugins_enabled, |
| 905 | 1035 | 'nativeCommentsEnabled' => $native_comments_enabled, |
| 1036 | + 'stationHomeEnabled' => $station_home_enabled, | |
| 1037 | + 'adminAssetCacheEnabled' => $admin_asset_cache_enabled, | |
| 1038 | + 'windowPrewarmEnabled' => $window_prewarm_enabled, | |
| 906 | 1039 | 'showDesktopOnWallpaperClick' => $show_desktop_on_wallpaper_click, |
| 1040 | + 'confirmCloseAllWindows' => $confirm_close_all_windows, | |
| 907 | 1041 | 'mioEnabled' => $mio_enabled, |
| 1042 | + 'mioApiEnabled' => $mio_enabled, | |
| 1043 | + 'mioShowOnWallpaper' => isset( $raw['mioShowOnWallpaper'] ) ? (bool) $raw['mioShowOnWallpaper'] : $defaults['mioShowOnWallpaper'], | |
| 908 | 1044 | 'mioStyle' => $mio_style, |
| 909 | 1045 | 'showPostStatusRibbons' => $show_post_status_ribbons, |
| 910 | 1046 | 'developerModeEnabled' => $developer_mode_enabled, |
| 911 | 1047 | 'foldersSharingEnabled' => $folders_sharing_enabled, |
| @@ -910,8 +1046,10 @@ | ||
| 910 | 1046 | 'developerModeEnabled' => $developer_mode_enabled, |
| 911 | 1047 | 'foldersSharingEnabled' => $folders_sharing_enabled, |
| 912 | 1048 | 'navPlacement' => $nav_placement, |
| 913 | 1049 | 'navOrder' => $nav_order, |
| 1050 | + 'mobileLayout' => $mobile_layout, | |
| 1051 | + 'mobileTabs' => $mobile_tabs, | |
| 914 | 1052 | 'dockPromotedPositions' => $dock_promoted_positions, |
| 915 | 1053 | ); |
| 916 | 1054 | } |
| 917 | 1055 | |
| @@ -1011,8 +1149,13 @@ | ||
| 1011 | 1149 | // true of every path into this handler, not just the ones the |
| 1012 | 1150 | // schema happens to guard. |
| 1013 | 1151 | if ( ! is_array( $payload ) ) { |
| 1014 | 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']; | |
| 1015 | 1158 | } |
| 1016 | 1159 | |
| 1017 | 1160 | openstation_save_os_settings( |
| 1018 | 1161 | $user_id, |