PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 1.0.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v1.0.14
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 / Libs / Functions.php

Functions.php in FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment 1.0.14, at Inc/Framework/Inc/Libs/Functions.php

126 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.0.27
5 *
6 * @author FirePlugins <[email protected]>
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 FPFramework\Libs;
13
14 if (!defined('ABSPATH'))
15 {
16 exit; // Exit if accessed directly.
17 }
18
19 class Functions {
20 /**
21 * Tries to fix date based on its syntax. Sets it to null if incorrect.
22 *
23 * @param string $date
24 *
25 * @return void
26 */
27 public static function fixDate(&$date)
28 {
29 if (!$date)
30 {
31 $date = null;
32
33 return;
34 }
35
36 $date = trim($date);
37
38 // Check if date has correct syntax: 00-00-00 00:00:00
39 if (preg_match('#^[0-9]+-[0-9]+-[0-9]+( [0-9][0-9]:[0-9][0-9]:[0-9][0-9])$#', $date))
40 {
41 return;
42 }
43
44 // Check if date has syntax: 00-00-00 00:00
45 // If so, add :00 (seconds)
46 if (preg_match('#^[0-9]+-[0-9]+-[0-9]+ [0-9][0-9]:[0-9][0-9]$#', $date))
47 {
48 $date .= ':00';
49
50 return;
51 }
52
53 // Check if date has a prepending date syntax: 00-00-00 ...
54 // If so, add 00:00:00 (hours:mins;secs)
55 if (preg_match('#^([0-9]+-[0-9]+-[0-9]+)#', $date, $match))
56 {
57 $date = $match[1] . ' 00:00:00';
58
59 return;
60 }
61
62 // Date format is not correct, so return null
63 $date = null;
64 }
65
66 /**
67 * Fixes date by adding offset
68 *
69 * @param string $date
70 *
71 * @return void
72 */
73 public static function fixDateOffset(&$date)
74 {
75 if ($date <= 0)
76 {
77 $date = 0;
78
79 return;
80 }
81
82 $factory = new \FPFramework\Base\Factory();
83
84 $date = $factory->getDate($date, \FPFramework\Base\Factory::getConfig()->get('offset'));
85 $date->setTimezone(new \DateTimeZone('UTC'));
86
87 $date = $date->format('Y-m-d H:i:s', true, false);
88 }
89
90 /**
91 * Returns current date
92 *
93 * @return string
94 */
95 public static function dateTimeNow()
96 {
97 $factory = new \FPFramework\Base\Factory();
98 return $factory->getDate()->format("Y-m-d H:i:s");
99 }
100
101 /**
102 * Increments the session
103 *
104 * @return void
105 */
106 public static function incrementSession()
107 {
108 $factory = new \FPFramework\Base\Factory();
109 $session = $factory->getSession();
110
111 if(!$session->get('fpf.session.counter'))
112 {
113 $session->set('fpf.session.counter', 1);
114 }
115 else
116 {
117 $counter = $session->get('fpf.session.counter') + 1;
118 $session->set('fpf.session.counter', $counter);
119 }
120 }
121
122 public static function getLicenseKey()
123 {
124 return get_option('fpf_license_key');
125 }
126 }