| @@ -94,8 +94,25 @@ | ||
| 94 | 94 | return openstation_is_shell_screen_request() && ! empty( $_GET[ OPENSTATION_SHELL_OVERVIEW_ARG ] ); |
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | /** |
| 98 | + * The side this shell slides its desk in from, when it was reached by a | |
| 99 | + * switch from another origin: `next`, `prev`, or ''. A one-shot boot | |
| 100 | + * arg like the two above (`openstation_hop_from`), because the hint a | |
| 101 | + * same-origin switch leaves in sessionStorage never crosses origins. | |
| 102 | + * | |
| 103 | + * @return string | |
| 104 | + */ | |
| 105 | +function openstation_shell_arrival_direction() { | |
| 106 | + if ( ! openstation_is_shell_screen_request() ) { | |
| 107 | + return ''; | |
| 108 | + } | |
| 109 | + // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only routing flag. | |
| 110 | + $from = isset( $_GET[ OPENSTATION_NETWORK_HOP_FROM_ARG ] ) && is_scalar( $_GET[ OPENSTATION_NETWORK_HOP_FROM_ARG ] ) ? sanitize_key( wp_unslash( $_GET[ OPENSTATION_NETWORK_HOP_FROM_ARG ] ) ) : ''; | |
| 111 | + return in_array( $from, array( 'next', 'prev' ), true ) ? $from : ''; | |
| 112 | +} | |
| 113 | + | |
| 114 | +/** | |
| 98 | 115 | * Builds the shell screen URL, optionally carrying a target. |
| 99 | 116 | * |
| 100 | 117 | * `$target` is an absolute same-origin admin URL or a request-URI-shaped |
| 101 | 118 | * path (`/wp-admin/edit.php?post_type=page`). Either way only its path |