| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.9 Free |
| 5 |
* |
| 6 |
* @author FirePlugins <info@fireplugins.com> |
| 7 |
* @link https://www.fireplugins.com |
| 8 |
* @copyright Copyright © 2026 FirePlugins All Rights Reserved |
| 9 |
* @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later |
| 10 |
*/ |
| 11 |
|
| 12 |
namespace FireBox\Core\Admin\Includes; |
| 13 |
|
| 14 |
if (!defined('ABSPATH')) |
| 15 |
{ |
| 16 |
exit; // Exit if accessed directly. |
| 17 |
} |
| 18 |
|
| 19 |
class UpgradeToPlanModal |
| 20 |
{ |
| 21 |
/** |
| 22 |
* The Modal ID. |
| 23 |
* |
| 24 |
* @var String |
| 25 |
*/ |
| 26 |
const modal_id = 'fireboxUpgradeToPlan'; |
| 27 |
|
| 28 |
static $run = false; |
| 29 |
|
| 30 |
public function __construct() |
| 31 |
{ |
| 32 |
add_action('admin_footer', [$this, 'addModal'], 13); |
| 33 |
} |
| 34 |
|
| 35 |
/** |
| 36 |
* Adds Upgrade to Plan Modal to the page |
| 37 |
* |
| 38 |
* @return void |
| 39 |
*/ |
| 40 |
public function addModal() |
| 41 |
{ |
| 42 |
if (self::$run) |
| 43 |
{ |
| 44 |
return; |
| 45 |
} |
| 46 |
|
| 47 |
if (!function_exists('get_current_screen')) |
| 48 |
{ |
| 49 |
return; |
| 50 |
} |
| 51 |
|
| 52 |
$current_screen = get_current_screen(); |
| 53 |
|
| 54 |
// Don't load within the block editor |
| 55 |
$isBlockEditor = $current_screen->is_block_editor && $current_screen->post_type === 'firebox'; |
| 56 |
if ($isBlockEditor) |
| 57 |
{ |
| 58 |
return; |
| 59 |
} |
| 60 |
|
| 61 |
$isPluginPage = strpos($current_screen->id, 'firebox') !== false; |
| 62 |
|
| 63 |
if (!$isPluginPage) |
| 64 |
{ |
| 65 |
return; |
| 66 |
} |
| 67 |
|
| 68 |
self::$run = true; |
| 69 |
|
| 70 |
wp_register_style( |
| 71 |
'fpframework-pro-modal', |
| 72 |
FPF_MEDIA_URL . 'admin/css/fpf_pro_modal.css', |
| 73 |
[], |
| 74 |
FPF_VERSION, |
| 75 |
false |
| 76 |
); |
| 77 |
wp_enqueue_style('fpframework-pro-modal'); |
| 78 |
|
| 79 |
// JS |
| 80 |
wp_register_script( |
| 81 |
'firebox-upgrade-to-plan-modal', |
| 82 |
FBOX_MEDIA_URL . 'admin/js/upgrade_to_plan_modal.js', |
| 83 |
[], |
| 84 |
FBOX_VERSION, |
| 85 |
false |
| 86 |
); |
| 87 |
wp_enqueue_script('firebox-upgrade-to-plan-modal'); |
| 88 |
|
| 89 |
$content = firebox()->renderer->admin->render('modals/upgrade_to_plan', [], true); |
| 90 |
|
| 91 |
$payload = [ |
| 92 |
'id' => self::modal_id, |
| 93 |
'class' => ['upgrade-to-plan', 'upgrade-pro-modal'], |
| 94 |
'content' => $content, |
| 95 |
'width' => '480px', |
| 96 |
'overlay_click' => false |
| 97 |
]; |
| 98 |
|
| 99 |
// render modal |
| 100 |
\FPFramework\Helpers\HTML::renderModal($payload); |
| 101 |
} |
| 102 |
} |