| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package FireBox |
| 4 |
* @version 3.1.8 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 Library extends \FPFramework\Admin\Library\Library |
| 20 |
{ |
| 21 |
public function __construct() |
| 22 |
{ |
| 23 |
parent::__construct($this->getLibrarySettings()); |
| 24 |
|
| 25 |
add_action('current_screen', [$this, 'validate']); |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* Returns the library settings. |
| 30 |
* |
| 31 |
* @return array |
| 32 |
*/ |
| 33 |
private function getLibrarySettings() |
| 34 |
{ |
| 35 |
return [ |
| 36 |
'id' => 'fbSelectTemplate', |
| 37 |
'title' => firebox()->_('FB_CAMPAIGN_LIBRARY'), |
| 38 |
'create_new_template_link' => admin_url('post-new.php?post_type=firebox'), |
| 39 |
'main_category_label' => firebox()->_('FB_CAMPAIGN_TYPE'), |
| 40 |
'plugin_license_settings_url' => admin_url('admin.php?page=firebox-settings#license_key'), |
| 41 |
'plugin_dir' => FBOX_PLUGIN_DIR, |
| 42 |
'plugin' => 'firebox', |
| 43 |
'plugin_version' => FBOX_VERSION, |
| 44 |
'plugin_license_type' => FBOX_LICENSE_TYPE, |
| 45 |
'plugin_name' => firebox()->_('FB_PLUGIN_NAME'), |
| 46 |
|
| 47 |
'license_key' => false, |
| 48 |
'license_key_status' => false, |
| 49 |
|
| 50 |
|
| 51 |
'blank_template_label' => fpframework()->_('FPF_BLANK_TEMPLATE'), |
| 52 |
'template_use_url' => 'post.php?action=edit&post=' |
| 53 |
]; |
| 54 |
} |
| 55 |
|
| 56 |
/** |
| 57 |
* Old function used to find templates. |
| 58 |
* |
| 59 |
* @param string $template |
| 60 |
* |
| 61 |
* @deprecated 1.1.0 |
| 62 |
* |
| 63 |
* @return null |
| 64 |
*/ |
| 65 |
public function find($template = '') |
| 66 |
{ |
| 67 |
return; |
| 68 |
} |
| 69 |
|
| 70 |
/** |
| 71 |
* Runs only on specific FireBox pages |
| 72 |
* |
| 73 |
* @return void |
| 74 |
*/ |
| 75 |
public function validate() |
| 76 |
{ |
| 77 |
$current_screen = get_current_screen(); |
| 78 |
|
| 79 |
$allowed_pages = [ |
| 80 |
'toplevel_page_firebox', |
| 81 |
'firebox_page_firebox-analytics', |
| 82 |
'firebox_page_firebox-campaigns', |
| 83 |
'firebox_page_firebox-submissions', |
| 84 |
'firebox_page_firebox-settings', |
| 85 |
'edit-firebox' |
| 86 |
]; |
| 87 |
|
| 88 |
if (!in_array($current_screen->id, $allowed_pages)) |
| 89 |
{ |
| 90 |
return false; |
| 91 |
} |
| 92 |
|
| 93 |
$this->init(); |
| 94 |
} |
| 95 |
} |