| @@ -61,8 +61,30 @@ | ||
| 61 | 61 | |
| 62 | 62 | echo '<script>parent.location.reload();</script>'; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | + /** | |
| 66 | + * Break out of the Adminify UI iframe, decided by the browser. | |
| 67 | + * | |
| 68 | + * Same job as custom_plugin_change_reload(), for requests that could not | |
| 69 | + * be classified server-side because the environment strips Fetch Metadata | |
| 70 | + * headers (see Utils::has_fetch_metadata()). The script checks the frame | |
| 71 | + * it actually runs in, so a genuine top-level load is left alone. | |
| 72 | + * | |
| 73 | + * @param string $actual_link URL to send the parent window to. | |
| 74 | + * @return void | |
| 75 | + */ | |
| 76 | + public static function maybe_break_out_of_frame( $actual_link ) { | |
| 77 | + $url = wp_json_encode( | |
| 78 | + esc_url_raw( $actual_link ), | |
| 79 | + JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | |
| 80 | + ); | |
| 81 | + | |
| 82 | + echo '<script>(function(){var f;try{f=window.frameElement;}catch(e){return;}' | |
| 83 | + . 'if(!f||f.id!=="frame-adminify-app--iframe")return;' | |
| 84 | + . 'parent.location.replace(' . $url . ');})();</script>'; | |
| 85 | + } | |
| 86 | + | |
| 65 | 87 | public function load_scripts() |
| 66 | 88 | { |
| 67 | 89 | wp_enqueue_style('frame-adminify--frame', PXLBSADMINIFY_ASSETS . 'admin/css/frame' . Utils::assets_ext('.css'), [], PXLBSADMINIFY_VER); |
| 68 | 90 | } |