PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.14
3.1.13 3.1.12 3.1.11 3.1.10 3.1.9 3.1.8 3.1.7 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 All 122 releases
firebox / Inc / Core / Admin / Includes / Library.php

Library.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.14, at Inc/Core/Admin/Includes/Library.php

136 lines 3.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FireBox
4 * @version 2.1.14 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2024 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 // set default post title
28 add_filter('default_title', [$this, 'presetPostTitle'], 100, 2);
29
30 // set default post content
31 add_filter('default_content', [$this, 'presetPostContent'], 200, 2);
32 }
33
34 /**
35 * Returns the library settings.
36 *
37 * @return array
38 */
39 private function getLibrarySettings()
40 {
41 return [
42 'id' => 'fbSelectTemplate',
43 'title' => firebox()->_('FB_CAMPAIGN_LIBRARY'),
44 'create_new_template_link' => admin_url('post-new.php?post_type=firebox'),
45 'main_category_label' => firebox()->_('FB_CAMPAIGN_TYPE'),
46 'plugin_license_settings_url' => admin_url('admin.php?page=firebox-settings#license_key'),
47 'plugin_dir' => FBOX_PLUGIN_DIR,
48 'plugin' => 'firebox',
49 'plugin_version' => FBOX_VERSION,
50 'plugin_license_type' => FBOX_LICENSE_TYPE,
51 'plugin_name' => firebox()->_('FB_PLUGIN_NAME'),
52
53 'license_key' => false,
54 'license_key_status' => false,
55
56
57 'blank_template_label' => fpframework()->_('FPF_BLANK_TEMPLATE'),
58 'template_use_url' => 'post-new.php?post_type=firebox&fpf_use_template=true&template='
59 ];
60 }
61
62 /**
63 * Old function used to find templates.
64 *
65 * @param string $template
66 *
67 * @deprecated 1.1.0
68 *
69 * @return null
70 */
71 public function find($template = '')
72 {
73 return;
74 }
75
76 /**
77 * Runs only on specific FireBox pages
78 *
79 * @return void
80 */
81 public function validate()
82 {
83 $current_screen = get_current_screen();
84
85 $allowed_pages = [
86 'toplevel_page_firebox',
87 'firebox_page_firebox-analytics',
88 'firebox_page_firebox-campaigns',
89 'firebox_page_firebox-submissions',
90 'firebox_page_firebox-settings',
91 'edit-firebox'
92 ];
93
94 if (!in_array($current_screen->id, $allowed_pages))
95 {
96 return false;
97 }
98
99 $this->init();
100 }
101
102 /**
103 * Set the default post title if we have selected a template via the Library
104 *
105 * @param string $post_title
106 * @param object $post
107 *
108 * @return string
109 */
110 public function presetPostTitle($post_title, $post)
111 {
112 if (!$template = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplateURL())
113 {
114 return $post_title;
115 }
116
117 return $template['template']['post_title'];
118 }
119
120 /**
121 * Sets the default post content if we have selected a template via the Library
122 *
123 * @param string
124 *
125 * @return string
126 */
127 public function presetPostContent($content)
128 {
129 if (!$template = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplateURL())
130 {
131 return $content;
132 }
133
134 return $template['template']['post_content'];
135 }
136 }