| @@ -424,8 +424,28 @@ | ||
| 424 | 424 | return '1' === sanitize_text_field( wp_unslash( $_GET[ OPENSTATION_CLASSIC_FLAG ] ) ); |
| 425 | 425 | } |
| 426 | 426 | |
| 427 | 427 | /** |
| 428 | + * Whether the request came from a classic-override page. A navigation | |
| 429 | + * a page starts from script (`location.href = …`, as "Edit with | |
| 430 | + * Elementor" does) carries no flag, but its Referer still does. | |
| 431 | + * | |
| 432 | + * @return bool | |
| 433 | + */ | |
| 434 | +function openstation_is_classic_referer() { | |
| 435 | + if ( empty( $_SERVER['HTTP_REFERER'] ) ) { | |
| 436 | + return false; | |
| 437 | + } | |
| 438 | + $referer = esc_url_raw( wp_unslash( $_SERVER['HTTP_REFERER'] ) ); | |
| 439 | + $query = wp_parse_url( $referer, PHP_URL_QUERY ); | |
| 440 | + if ( ! openstation_url_is_same_admin( $referer ) || ! is_string( $query ) ) { | |
| 441 | + return false; | |
| 442 | + } | |
| 443 | + parse_str( $query, $args ); | |
| 444 | + return isset( $args[ OPENSTATION_CLASSIC_FLAG ] ) && '1' === $args[ OPENSTATION_CLASSIC_FLAG ]; | |
| 445 | +} | |
| 446 | + | |
| 447 | +/** | |
| 428 | 448 | * Checks whether the browser is fetching this request as a |
| 429 | 449 | * sub-resource of some page rather than navigating to it. |
| 430 | 450 | * |
| 431 | 451 | * Admin URLs serve more than pages. Jetpack's admin-bar sparkline is |