PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.13
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.13
3.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 All 123 releases
firebox / Inc / Framework / Inc / Helpers / FireBoxHelper.php

FireBoxHelper.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 3.1.13, at Inc/Framework/Inc/Helpers/FireBoxHelper.php

172 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package FirePlugins Framework
4 * @version 1.2.5
5 *
6 * @author FirePlugins <[email protected]>
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 FPFramework\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 use FPFramework\Libs\Registry;
20 use FPFramework\Helpers\SearchDropdownHelper;
21
22 class FireBoxHelper
23 {
24 /**
25 * FireBox Provider
26 *
27 * @var FireBoxProvider
28 */
29 private $provider;
30
31 public function __construct($provider = null)
32 {
33 // add current box ID we are manipulating to the noids list
34 add_filter('fpframework/fields/searchdropdown/filter_get_search_items_ids', [$this, 'addBoxOnNoIDsList'], 1, 2);
35
36 if (!$provider)
37 {
38 $provider = new \FPFramework\Helpers\DataProviders\FireBoxProvider();
39 }
40
41 $this->provider = $provider;
42 }
43
44 /**
45 * Parses and returns boxes data
46 *
47 * @param array $boxes
48 *
49 * @return array
50 */
51 public static function _parseData($boxes)
52 {
53 $boxes = (array) $boxes;
54
55 if (empty($boxes))
56 {
57 return [];
58 }
59
60 $boxes_parsed = [];
61
62 foreach ($boxes as $key => $p)
63 {
64 $p = (object) $p;
65
66 $boxes_parsed[] = [
67 'id' => $p->ID,
68 'title' => $p->post_title
69 ];
70 }
71
72 return $boxes_parsed;
73 }
74
75 /**
76 * Adds the current box we are manipulating to the noids list
77 *
78 * @param mixed $noids
79 * @param int $post_id
80 *
81 * @return array
82 */
83 public function addBoxOnNoIDsList($noids, $post_id)
84 {
85 // search boxes except a given ID
86 if (is_null($post_id))
87 {
88 return $noids;
89 }
90
91 if (empty($noids))
92 {
93 $noids = [ $post_id ];
94 }
95 else
96 {
97 $noids[] = $post_id;
98 }
99
100 return $noids;
101 }
102
103 /**
104 * Returns items based on offset and limit
105 *
106 * @param integer $offset
107 * @param integer $limit
108 *
109 * @return array
110 */
111 public function getItems($offset = 0, $limit = SearchDropdownHelper::SELECTION_ITEMS)
112 {
113 if (!is_int($offset))
114 {
115 return [];
116 }
117
118 if (!is_int($limit))
119 {
120 return [];
121 }
122
123 return $this->provider->getItems($offset, $limit);
124 }
125
126 /**
127 * Gets Boxes from the Selected Items
128 *
129 * @param array $items
130 *
131 * @return array
132 */
133 public function getSelectedItems($items)
134 {
135 if (is_object($items))
136 {
137 $items = (array) $items;
138 }
139
140 if (empty($items) || !is_array($items))
141 {
142 return [];
143 }
144
145 return $this->provider->getSelectedItems($items);
146 }
147
148 /**
149 * Searches the boxes and returns an array of items
150 *
151 * @param string $name
152 * @param array $no_ids List of already added items
153 *
154 * @return array
155 */
156 public function getSearchItems($name, $no_ids = null)
157 {
158 if (!is_string($name))
159 {
160 return [];
161 }
162
163 $name = trim($name);
164
165 if (empty($name))
166 {
167 return [];
168 }
169
170 return $this->provider->getSearchItems($name, $no_ids);
171 }
172 }