PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.7
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.7
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 / FireBoxFormHelper.php

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

139 lines 2.3 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.1.146
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 FireBoxFormHelper
23 {
24 /**
25 * FireBoxForm Provider
26 *
27 * @var FireBoxFormProvider
28 */
29 private $provider;
30
31 public function __construct($provider = null)
32 {
33 if (!$provider)
34 {
35 $provider = new \FPFramework\Helpers\DataProviders\FireBoxFormProvider();
36 }
37
38 $this->provider = $provider;
39 }
40
41 /**
42 * Parses and returns forms data
43 *
44 * @param array $forms
45 *
46 * @return array
47 */
48 public static function _parseData($forms)
49 {
50 if (empty($forms))
51 {
52 return [];
53 }
54
55 $forms_parsed = [];
56
57 foreach ($forms as $id => $label)
58 {
59 $forms_parsed[] = [
60 'id' => $id,
61 'title' => $label
62 ];
63 }
64
65 return $forms_parsed;
66 }
67
68 /**
69 * Returns items based on offset and limit
70 *
71 * @param integer $offset
72 * @param integer $limit
73 *
74 * @return array
75 */
76 public function getItems($offset = 0, $limit = SearchDropdownHelper::SELECTION_ITEMS)
77 {
78 if (!is_int($offset))
79 {
80 return [];
81 }
82
83 if (!is_int($limit))
84 {
85 return [];
86 }
87
88 $limit = 9999999;
89
90 return $this->provider->getItems($offset, $limit);
91 }
92
93 /**
94 * Gets Boxes from the Selected Items
95 *
96 * @param array $items
97 *
98 * @return array
99 */
100 public function getSelectedItems($items)
101 {
102 if (is_object($items))
103 {
104 $items = (array) $items;
105 }
106
107 if (empty($items) || !is_array($items))
108 {
109 return [];
110 }
111
112 return $this->provider->getSelectedItems($items);
113 }
114
115 /**
116 * Searches the boxes and returns an array of items
117 *
118 * @param string $name
119 * @param array $no_ids List of already added items
120 *
121 * @return array
122 */
123 public function getSearchItems($name, $no_ids = null)
124 {
125 if (!is_string($name))
126 {
127 return [];
128 }
129
130 $name = trim($name);
131
132 if (empty($name))
133 {
134 return [];
135 }
136
137 return $this->provider->getSearchItems($name, $no_ids);
138 }
139 }