PluginProbe
Adminify – White Label, Admin Menu Editor, Login Customizer / 4.2.18
Adminify – White Label, Admin Menu Editor, Login Customizer v4.2.18
4.3.1 4.3.0 4.2.26 4.2.25 4.2.24 4.2.23 4.2.22 4.2.21 4.2.20 4.2.19 4.2.18 4.2.17 4.2.16 4.2.15 4.2.14 4.2.13 4.2.12 4.2.11 4.2.10 4.2.9 4.2.8 4.2.7 4.2.6 4.2.5 4.1.17 All 164 releases
adminify / Inc / Admin / Frames / Frames.php

Frames.php in Adminify – White Label, Admin Menu Editor, Login Customizer 4.2.18, at Inc/Admin/Frames/Frames.php

79 lines 2.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace PXLBSAdminify\Inc\Admin\Frames;
4
5 use PXLBSAdminify\Inc\Utils;
6
7 // no direct access allowed
8 if (!defined('ABSPATH')) {
9 exit;
10 }
11 /**
12 * WP Adminify
13 * Frames Class
14 *
15 * @author Jewel Theme <support@jeweltheme.com>
16 */
17
18 if (!class_exists('Frames')) {
19 class Frames
20 {
21 public function __construct()
22 {
23 $this->init_hooks();
24 }
25
26 private function init_hooks()
27 {
28 add_filter("language_attributes", [$this, "page_attribute"]);
29 add_action('admin_enqueue_scripts', [$this, 'load_scripts']);
30
31 // Reload the page after plugin activation/deactivation
32 // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- read-only check, no state change.
33 if ( isset( $_GET['activate'] ) || isset( $_GET['activate-multi'] ) || isset( $_GET['deactivate'] ) || isset( $_GET['deactivate-multi'] ) ) {
34 add_action('admin_footer', [$this, 'render_reload_script']);
35 }
36 }
37
38 public static function render_reload_script() {
39 self::custom_plugin_change_reload();
40 }
41
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 "&amp;",
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 public function load_scripts()
66 {
67 wp_enqueue_style('frame-adminify--frame', PXLBSADMINIFY_ASSETS . 'admin/css/frame' . Utils::assets_ext('.css'), [], PXLBSADMINIFY_VER);
68 }
69
70 public function page_attribute($attr)
71 {
72 $attrs = [$attr];
73 $attrs[] = 'frame-adminify-iframe="true"';
74 return implode(' ', $attrs);
75 }
76 }
77
78 }
79