| @@ -1,9 +1,9 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -namespace PXLBSAdminify\Inc\Admin\Frames; | |
| 3 | +namespace WPAdminify\Inc\Admin\Frames; | |
| 4 | 4 | |
| 5 | -use PXLBSAdminify\Inc\Utils; | |
| 5 | +use WPAdminify\Inc\Utils; | |
| 6 | 6 | |
| 7 | 7 | // no direct access allowed |
| 8 | 8 | if (!defined('ABSPATH')) { |
| 9 | 9 | exit; |
| @@ -28,44 +28,24 @@ | ||
| 28 | 28 | add_filter("language_attributes", [$this, "page_attribute"]); |
| 29 | 29 | add_action('admin_enqueue_scripts', [$this, 'load_scripts']); |
| 30 | 30 | |
| 31 | 31 | // Reload the page after plugin activation/deactivation |
| 32 | - // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change. | |
| 33 | 32 | if ( isset( $_GET['activate'] ) || isset( $_GET['activate-multi'] ) || isset( $_GET['deactivate'] ) || isset( $_GET['deactivate-multi'] ) ) { |
| 34 | - add_action('admin_footer', [$this, 'render_reload_script']); | |
| 33 | + self::custom_plugin_change_reload(); | |
| 35 | 34 | } |
| 36 | 35 | } |
| 37 | 36 | |
| 38 | - public static function render_reload_script() { | |
| 39 | - self::custom_plugin_change_reload(); | |
| 37 | + static function custom_plugin_change_reload() { | |
| 38 | + ?> | |
| 39 | + <script type="text/javascript"> | |
| 40 | + parent.location.reload(); | |
| 41 | + </script> | |
| 42 | + <?php | |
| 40 | 43 | } |
| 41 | 44 | |
| 42 | - /** | |
| 43 | - * Break the current page out of the Adminify UI iframe. | |
| 44 | - * | |
| 45 | - * @param string|null $actual_link Optional. URL to send the parent window to. | |
| 46 | - * When null, the parent simply reloads. | |
| 47 | - * @return void | |
| 48 | - */ | |
| 49 | - public static function custom_plugin_change_reload( $actual_link = null ) { | |
| 50 | - if ( null !== $actual_link ) { | |
| 51 | - // wp_json_encode(), not esc_js(): esc_js() turns "&" into "&", | |
| 52 | - // which a classic <script> does not decode, breaking query args. | |
| 53 | - echo '<script>parent.location.replace(' . wp_json_encode( | |
| 54 | - esc_url_raw( $actual_link ), | |
| 55 | - JSON_HEX_TAG | JSON_HEX_AMP | JSON_HEX_APOS | JSON_HEX_QUOT | |
| 56 | - ) . ');</script>'; | |
| 57 | - | |
| 58 | - // The reload() below would abort the replace() navigation above. | |
| 59 | - return; | |
| 60 | - } | |
| 61 | - | |
| 62 | - echo '<script>parent.location.reload();</script>'; | |
| 63 | - } | |
| 64 | - | |
| 65 | 45 | public function load_scripts() |
| 66 | 46 | { |
| 67 | - wp_enqueue_style('frame-adminify--frame', PXLBSADMINIFY_ASSETS . 'admin/css/frame' . Utils::assets_ext('.css'), [], PXLBSADMINIFY_VER); | |
| 47 | + wp_enqueue_style('frame-adminify--frame', WP_ADMINIFY_ASSETS . 'admin/css/frame' . Utils::assets_ext('.css'), [], WP_ADMINIFY_VER); | |
| 68 | 48 | } |
| 69 | 49 | |
| 70 | 50 | public function page_attribute($attr) |
| 71 | 51 | { |