| @@ -149,8 +149,11 @@ | ||
| 149 | 149 | // Site). Off-origin hits still redirect into admin so shared |
| 150 | 150 | // links keep working; they just don't silently mutate user-meta. |
| 151 | 151 | if ( $auto_enable && openstation_portal_is_same_origin_navigation() && '1' !== get_user_meta( $user_id, 'desktop_mode_mode', true ) ) { |
| 152 | 152 | update_user_meta( $user_id, 'desktop_mode_mode', '1' ); |
| 153 | + // Same stamps + action as the AJAX toggle; the portal is the | |
| 154 | + // second of the two paths that turn a user on. | |
| 155 | + openstation_record_user_enabled( $user_id ); | |
| 153 | 156 | } |
| 154 | 157 | |
| 155 | 158 | // Pick the page the shell opens first. An explicit `target` query |
| 156 | 159 | // arg — a same-origin wp-admin URL — is how |
| @@ -352,10 +355,10 @@ | ||
| 352 | 355 | } |
| 353 | 356 | |
| 354 | 357 | // The "Detach to new tab" button tags its URL with this flag so the |
| 355 | 358 | // user can view one admin page classically without disabling desktop |
| 356 | - // mode account-wide. Only affects the single request — subsequent | |
| 357 | - // navigations inside the tab lose the flag and follow normal rules. | |
| 359 | + // mode account-wide. Navigations inside that tab keep it (see the | |
| 360 | + // Referer check below). | |
| 358 | 361 | if ( ! empty( $_GET[ OPENSTATION_CLASSIC_FLAG ] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended |
| 359 | 362 | return; |
| 360 | 363 | } |
| 361 | 364 | |
| @@ -393,8 +396,15 @@ | ||
| 393 | 396 | */ |
| 394 | 397 | $redirect = apply_filters( 'openstation_admin_redirect_to_portal', true, get_current_user_id() ); |
| 395 | 398 | if ( ! $redirect ) { |
| 396 | 399 | return; |
| 400 | + } | |
| 401 | + | |
| 402 | + // A navigation out of a classic tab that lost the flag stays classic, | |
| 403 | + // with the flag back in the URL for the next navigation's Referer. | |
| 404 | + if ( '' !== $target && openstation_is_classic_referer() ) { | |
| 405 | + wp_safe_redirect( add_query_arg( OPENSTATION_CLASSIC_FLAG, '1', $target ) ); | |
| 406 | + exit; | |
| 397 | 407 | } |
| 398 | 408 | |
| 399 | 409 | // Route 1: straight to the shell screen. |
| 400 | 410 | if ( openstation_portal_forward_is_redundant( $target ) ) { |