PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 2.1.23
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v2.1.23
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
← All changes | Inc/Core/Helpers/Plugin.php +13 -86 trunk2.1.23 View file →
@@ -1,12 +1,12 @@
1 1 <?php
2 2 /**
3 3 * @package FireBox
4 - * @version 3.1.13
4 + * @version 2.1.23
5 5 *
6 6 * @author FirePlugins <[email protected]>
7 7 * @link https://www.fireplugins.com
8 - * @copyright Copyright © 2026 FirePlugins All Rights Reserved
8 + * @copyright Copyright © 2024 FirePlugins All Rights Reserved
9 9 * @license GNU GPLv3 <http://www.gnu.org/licenses/gpl.html> or later
10 10 */
11 11
12 12 namespace FireBox\Core\Helpers;
@@ -34,9 +34,9 @@
34 34 try
35 35 {
36 36 $response_decoded = json_decode($response['body'], true);
37 37 }
38 - catch (\Exception $ex)
38 + catch (Exception $ex)
39 39 {
40 40 return;
41 41 }
42 42
@@ -113,61 +113,29 @@
113 113
114 114 return $content['install_date'];
115 115 }
116 116
117 - public static function getExtensionItemValue($key = null)
118 - {
119 - $path = self::getExtensionsDataFilePath();
120 -
121 - // If file does not exist, abort
122 - if (!file_exists($path))
123 - {
124 - return;
125 - }
126 -
127 - // If file exists, retrieve its contents
128 - // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
129 - $content = file_get_contents($path);
130 -
131 - // Decode it
132 - if (!$content = json_decode($content, true))
133 - {
134 - return;
135 - }
136 -
137 - // Ensure key exists
138 - if (!isset($content[$key]))
139 - {
140 - return;
141 - }
142 -
143 - return $content[$key];
144 - }
145 -
146 117 /**
147 - * Sets or updates a key-value pair in the extensions data file.
118 + * Sets the installation date.
148 119 *
149 - * @param string $key The key to set
150 - * @param mixed $value The value to set
151 - * @param bool $force_replace Whether to replace existing value regardless of age
152 - * @param int $max_age_days Maximum age in days before replacing existing value (only used if force_replace is false)
120 + * @param string $install_date
153 121 *
154 - * @return bool True if the value was set/updated, false if key already exists and no update was needed
122 + * @return bool
155 123 */
156 - public static function setExtensionData($key, $value, $force_replace = false, $max_age_days = 0)
124 + public static function setInstallationDate($install_date = null)
157 125 {
158 126 $path = self::getExtensionsDataFilePath();
159 127
160 - // If file does not exist, create it with the key-value pair
128 + // If file does not exist, abort
161 129 if (!file_exists($path))
162 130 {
163 131 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
164 132 file_put_contents($path, wp_json_encode(
165 133 [
166 - $key => $value
134 + 'install_date' => $install_date
167 135 ]
168 136 ));
169 - return true;
137 + return;
170 138 }
171 139
172 140 // If file exists, retrieve its contents
173 141 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
@@ -175,58 +143,17 @@
175 143
176 144 // Decode it
177 145 $content = json_decode($content, true);
178 146
179 - // If decoding failed, initialize as empty array
180 - if ($content === null)
147 + if (isset($content['install_date']))
181 148 {
182 - $content = [];
149 + return false;
183 150 }
184 151
185 - // Check if key already exists
186 - if (isset($content[$key]))
187 - {
188 - // If not forcing replacement, check age conditions
189 - if (!$force_replace)
190 - {
191 - // If max_age_days is 0, don't replace existing value
192 - if ($max_age_days <= 0)
193 - {
194 - return false;
195 - }
152 + $content['install_date'] = $install_date;
196 153
197 - // Check if file is older than max_age_days
198 - $file_modified_time = filemtime($path);
199 - $current_time = time();
200 - $age_in_seconds = $current_time - $file_modified_time;
201 - $age_in_days = floor($age_in_seconds / (60 * 60 * 24));
202 -
203 - // Only replace if file is older than max_age_days
204 - if ($age_in_days >= $max_age_days)
205 - {
206 - $content[$key] = $value;
207 - }
208 - else
209 - {
210 - return false;
211 - }
212 - }
213 - else
214 - {
215 - // Force replacement
216 - $content[$key] = $value;
217 - }
218 - }
219 - else
220 - {
221 - // Key doesn't exist, set it
222 - $content[$key] = $value;
223 - }
224 -
225 154 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
226 155 file_put_contents($path, wp_json_encode($content));
227 -
228 - return true;
229 156 }
230 157
231 158 /**
232 159 * The file path that stores all extensions data.