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
firebox / Inc / Core / Helpers / Plugin.php

Plugin.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 2.1.23, at Inc/Core/Helpers/Plugin.php

167 lines 3.2 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.23
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\Helpers;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Plugin
20 {
21 public static function getLatestVersionData()
22 {
23 $url = FPF_GET_LICENSE_VERSION_URL . 'firebox';
24
25 $response = wp_remote_get($url);
26
27 if (!is_array($response))
28 {
29 return;
30 }
31
32 $response_decoded = null;
33
34 try
35 {
36 $response_decoded = json_decode($response['body'], true);
37 }
38 catch (Exception $ex)
39 {
40 return;
41 }
42
43 if (!isset($response_decoded['version']))
44 {
45 return;
46 }
47
48 return $response_decoded;
49 }
50
51 /**
52 * Checks whether the plugin is outdated.
53 *
54 * @param int $days_old
55 *
56 * @return bool
57 */
58 public static function isOutdated($days_old = 120)
59 {
60 if (!defined('FBOX_RELEASE_DATE'))
61 {
62 return false;
63 }
64
65 if (!$then = strtotime(FBOX_RELEASE_DATE))
66 {
67 return false;
68 }
69
70 $days_old = (int) $days_old;
71 $now = time();
72 $diff = $now - $then;
73 $days_diff = round($diff / (60 * 60 * 24));
74
75 if ($days_diff <= $days_old)
76 {
77 return false;
78 }
79
80 return true;
81 }
82
83 /**
84 * Returns the installation date.
85 *
86 * @return string
87 */
88 public static function getInstallationDate()
89 {
90 $path = self::getExtensionsDataFilePath();
91
92 // If file does not exist, abort
93 if (!file_exists($path))
94 {
95 return;
96 }
97
98 // If file exists, retrieve its contents
99 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
100 $content = file_get_contents($path);
101
102 // Decode it
103 if (!$content = json_decode($content, true))
104 {
105 return;
106 }
107
108 // Ensure install date exists
109 if (!isset($content['install_date']))
110 {
111 return;
112 }
113
114 return $content['install_date'];
115 }
116
117 /**
118 * Sets the installation date.
119 *
120 * @param string $install_date
121 *
122 * @return bool
123 */
124 public static function setInstallationDate($install_date = null)
125 {
126 $path = self::getExtensionsDataFilePath();
127
128 // If file does not exist, abort
129 if (!file_exists($path))
130 {
131 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
132 file_put_contents($path, wp_json_encode(
133 [
134 'install_date' => $install_date
135 ]
136 ));
137 return;
138 }
139
140 // If file exists, retrieve its contents
141 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_get_contents_file_get_contents
142 $content = file_get_contents($path);
143
144 // Decode it
145 $content = json_decode($content, true);
146
147 if (isset($content['install_date']))
148 {
149 return false;
150 }
151
152 $content['install_date'] = $install_date;
153
154 // phpcs:ignore WordPress.WP.AlternativeFunctions.file_system_operations_file_put_contents
155 file_put_contents($path, wp_json_encode($content));
156 }
157
158 /**
159 * The file path that stores all extensions data.
160 *
161 * @return string
162 */
163 public static function getExtensionsDataFilePath()
164 {
165 return \FPFramework\Helpers\WPHelper::getPluginUploadsDirectory('firebox') . '/data.json';
166 }
167 }