PluginProbe
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin / 1.1.10
OpenStation: Desktop Windows, Dock & Virtual Desktops for WP Admin v1.1.10
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 0.8.9 0.8.8 0.8.7 All 34 releases
← All changes | includes/ajax.php +27 -16 1.1.41.1.10 View file →
@@ -38,31 +38,42 @@
38 38 $enabled = ! empty( $_POST['enabled'] ) && '1' === $_POST['enabled'] ? '1' : '';
39 39
40 40 update_user_meta( get_current_user_id(), 'desktop_mode_mode', $enabled );
41 41
42 + // The first-run stamps and the enable / disable actions. One helper
43 + // shared with the portal's auto-enable so the two writers cannot
44 + // drift — see `includes/first-run/stamps.php`.
45 + if ( '1' === $enabled ) {
46 + openstation_record_user_enabled( get_current_user_id() );
47 + } else {
48 + openstation_record_user_disabled( get_current_user_id() );
49 + }
50 +
42 51 // Tell the client where to land.
43 52 //
44 - // Enabling from classic admin: land directly on the Dashboard with
45 - // the portal flag (`wp-admin/index.php?desktop_mode_portal=1`).
46 - // Previously this redirected through `/openstation/` so the
47 - // portal handler could pick a landing page (saved-session focused
48 - // window, `?target=`, or Dashboard fallback). That logic remains
49 - // in place for users who visit `/openstation/` directly — a
50 - // bookmark or shared link — but the explicit "Switch to Desktop
51 - // Mode" button is a deliberate user action that consistently
52 - // lands on the Dashboard, so users get a predictable starting
53 - // point regardless of what they did last session. The shell still
54 - // honours session restore and the user's default-window pref via
55 - // its own boot-time logic — the URL just provides a stable entry
56 - // point rather than a portal hop.
53 + // Enabling from classic admin: land on the shell screen with the
54 + // Dashboard as the page it opens first. The explicit "Switch to
55 + // Desktop Mode" button is a deliberate user action that
56 + // consistently lands on the Dashboard, so users get a predictable
57 + // starting point regardless of what they did last session; the
58 + // shell still honours session restore and the user's default-window
59 + // pref via its own boot-time logic. Going to the screen directly
60 + // rather than through `/openstation/` skips a hop the portal would
61 + // spend re-deciding what this URL already says.
57 62 //
58 63 // Disabling from the shell jumps to a plain admin URL — NOT the
59 64 // portal, which would auto-re-enable the mode via the
60 65 // `openstation_portal_auto_enable` filter and trap the user in a
61 66 // loop.
62 - $redirect = '1' === $enabled
63 - ? admin_url( 'index.php?' . OPENSTATION_PORTAL_FLAG . '=1' )
64 - : admin_url();
67 + // Which admin to land in. The toggle reports its own context, since
68 + // `is_network_admin()` is false on every `admin-ajax.php` request,
69 + // and we confirm the capability before honouring it — a client
70 + // cannot talk us into a screen the user can't open.
71 + $in_network = ! empty( $_POST['network'] ) && current_user_can( 'manage_network' );
72 + $admin = $in_network ? network_admin_url() : admin_url();
73 + $redirect = '1' === $enabled
74 + ? openstation_shell_url( $admin . 'index.php', false, $in_network )
75 + : $admin;
65 76
66 77 wp_send_json_success(
67 78 array(
68 79 'enabled' => $enabled,