PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.1.1
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.1.1
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 1.1.1, at Inc/Core/Admin/Includes/Library.php

128 lines 2.8 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 1.1.1 Free
5 *
6 * @author FirePlugins <info@fireplugins.com>
7 * @link https://www.fireplugins.com
8 * @copyright Copyright © 2022 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' => 'FB_POPUP_LIBRARY',
44 'create_new_template_link' => admin_url('post-new.php?post_type=firebox'),
45 'main_category_label' => firebox()->_('FB_POPUP_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 'blank_template_label' => firebox()->_('FB_BLANK_POPUP'),
54 'template_use_url' => 'post-new.php?post_type=firebox&fpf_use_template=true&template='
55 ];
56 }
57
58 /**
59 * Old function used to find templates.
60 *
61 * @param string $template
62 *
63 * @deprecated 1.1.0
64 *
65 * @return null
66 */
67 public function find($template = '')
68 {
69 return;
70 }
71
72 /**
73 * Runs only on specific FireBox pages
74 *
75 * @return void
76 */
77 public function validate()
78 {
79 $current_screen = get_current_screen();
80
81 $allowed_pages = [
82 'toplevel_page_firebox',
83 'edit-firebox'
84 ];
85
86 if (!in_array($current_screen->id, $allowed_pages))
87 {
88 return false;
89 }
90
91 $this->init();
92 }
93
94 /**
95 * Set the default post title if we have selected a template via the Library
96 *
97 * @param string $post_title
98 * @param object $post
99 *
100 * @return string
101 */
102 public function presetPostTitle($post_title, $post)
103 {
104 if (!$template = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplateURL())
105 {
106 return;
107 }
108
109 return $template['template']['post_title'];
110 }
111
112 /**
113 * Sets the default post content if we have selected a template via the Library
114 *
115 * @param string
116 *
117 * @return string
118 */
119 public function presetPostContent($content)
120 {
121 if (!$template = \FireBox\Core\Helpers\BoxHelper::getBoxFromTemplateURL())
122 {
123 return;
124 }
125
126 return $template['template']['post_content'];
127 }
128 }