← All changes
|
Inc/Framework/Inc/Admin/Includes/UpgradeProModal.php
+37
-38
1.0.8
→
3.1.14
View file →
| @@ -1,12 +1,12 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * @package FirePlugins Framework |
| 4 | - * @version 1.0.20 | |
| 4 | + * @version 1.2.6 | |
| 5 | 5 | * |
| 6 | 6 | * @author FirePlugins <[email protected]> |
| 7 | 7 | * @link https://www.fireplugins.com |
| 8 | - * @copyright Copyright © 2021 FirePlugins All Rights Reserved | |
| 8 | + * @copyright Copyright © 2026 FirePlugins All Rights Reserved | |
| 9 | 9 | * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | 12 | namespace FPFramework\Admin\Includes; |
| @@ -37,8 +37,10 @@ | ||
| 37 | 37 | * |
| 38 | 38 | * @var string |
| 39 | 39 | */ |
| 40 | 40 | private $plugin_name; |
| 41 | + | |
| 42 | + static $run = false; | |
| 41 | 43 | |
| 42 | 44 | public function __construct($plugin_slug = null, $plugin_name = null) |
| 43 | 45 | { |
| 44 | 46 | $this->plugin_slug = $plugin_slug; |
| @@ -43,60 +45,46 @@ | ||
| 43 | 45 | { |
| 44 | 46 | $this->plugin_slug = $plugin_slug; |
| 45 | 47 | $this->plugin_name = $plugin_name; |
| 46 | 48 | |
| 47 | - add_action( 'current_screen', [$this, 'validate'] ); | |
| 49 | + add_action('admin_footer', [$this, 'addModal'], 13); | |
| 48 | 50 | } |
| 49 | 51 | |
| 50 | 52 | /** |
| 51 | - * Runs only on given plugin | |
| 53 | + * Adds Upgrade to Pro Modal to the page | |
| 52 | 54 | * |
| 53 | 55 | * @return void |
| 54 | 56 | */ |
| 55 | - public function validate() | |
| 57 | + public function addModal() | |
| 56 | 58 | { |
| 57 | - if (!is_admin()) | |
| 59 | + if (self::$run) | |
| 58 | 60 | { |
| 59 | 61 | return; |
| 60 | 62 | } |
| 63 | + | |
| 64 | + if (!function_exists('get_current_screen')) | |
| 65 | + { | |
| 66 | + return; | |
| 67 | + } | |
| 61 | 68 | |
| 62 | 69 | $current_screen = get_current_screen(); |
| 63 | - if (strpos($current_screen->id, $this->plugin_slug) === false) | |
| 70 | + | |
| 71 | + // Don't load within the block editor | |
| 72 | + $isBlockEditor = $current_screen->is_block_editor && $current_screen->post_type === $this->plugin_slug; | |
| 73 | + if ($isBlockEditor) | |
| 64 | 74 | { |
| 65 | 75 | return; |
| 66 | 76 | } |
| 67 | 77 | |
| 68 | - $this->run(); | |
| 69 | - } | |
| 78 | + $isPluginPage = strpos($current_screen->id, $this->plugin_slug) !== false; | |
| 79 | + | |
| 80 | + if (!$isPluginPage) | |
| 81 | + { | |
| 82 | + return; | |
| 83 | + } | |
| 70 | 84 | |
| 71 | - /** | |
| 72 | - * Run module | |
| 73 | - * | |
| 74 | - * @return void | |
| 75 | - */ | |
| 76 | - private function run() | |
| 77 | - { | |
| 78 | - add_action('admin_footer', [$this, 'addModal'], 13); | |
| 79 | - } | |
| 85 | + self::$run = true; | |
| 80 | 86 | |
| 81 | - /** | |
| 82 | - * Adds Upgrade to Pro Modal to the page | |
| 83 | - * | |
| 84 | - * @return void | |
| 85 | - */ | |
| 86 | - public function addModal() | |
| 87 | - { | |
| 88 | - // get smart tags table layout | |
| 89 | - $content = fpframework()->renderer->admin->render('upgrade_pro', ['plugin_name' => $this->plugin_name], true); | |
| 90 | - | |
| 91 | - $payload = [ | |
| 92 | - 'id' => self::modal_id, | |
| 93 | - 'class' => ['upgrade-pro'], | |
| 94 | - 'content' => $content, | |
| 95 | - 'width' => '480px', | |
| 96 | - 'overlay_click' => false | |
| 97 | - ]; | |
| 98 | - | |
| 99 | 87 | // CSS |
| 100 | 88 | wp_register_style( |
| 101 | 89 | 'fpframework-pro-modal', |
| 102 | 90 | FPF_MEDIA_URL . 'admin/css/fpf_pro_modal.css', |
| @@ -103,9 +91,9 @@ | ||
| 103 | 91 | [], |
| 104 | 92 | FPF_VERSION, |
| 105 | 93 | false |
| 106 | 94 | ); |
| 107 | - wp_enqueue_style( 'fpframework-pro-modal' ); | |
| 95 | + wp_enqueue_style('fpframework-pro-modal'); | |
| 108 | 96 | |
| 109 | 97 | // JS |
| 110 | 98 | wp_register_script( |
| 111 | 99 | 'fpframework-pro-modal', |
| @@ -113,10 +101,21 @@ | ||
| 113 | 101 | [], |
| 114 | 102 | FPF_VERSION, |
| 115 | 103 | false |
| 116 | 104 | ); |
| 117 | - wp_enqueue_script( 'fpframework-pro-modal' ); | |
| 105 | + wp_enqueue_script('fpframework-pro-modal'); | |
| 118 | 106 | |
| 107 | + // get smart tags table layout | |
| 108 | + $content = fpframework()->renderer->admin->render('upgrade_pro', ['plugin_name' => $this->plugin_name], true); | |
| 109 | + | |
| 110 | + $payload = [ | |
| 111 | + 'id' => self::modal_id, | |
| 112 | + 'class' => ['upgrade-pro', 'upgrade-pro-modal'], | |
| 113 | + 'content' => $content, | |
| 114 | + 'width' => '480px', | |
| 115 | + 'overlay_click' => false | |
| 116 | + ]; | |
| 117 | + | |
| 119 | 118 | // render a pro modal |
| 120 | 119 | \FPFramework\Helpers\HTML::renderModal($payload); |
| 121 | 120 | } |
| 122 | 121 | } |