PluginProbe
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment / 3.1.14
FireBox – WooCommerce Popup Builder, Exit Intent Popup, Email Optin & Cart Abandonment v3.1.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
← All changes | Inc/Framework/Inc/Base/WebClient.php +63 -20 3.1.8 → 3.1.14 View file →
@@ -1,8 +1,8 @@
1 1 <?php
2 2 /**
3 3 * @package FirePlugins Framework
4 - * @version 1.1.146
4 + * @version 1.2.6
5 5 *
6 6 * @author FirePlugins <[email protected]>
7 7 * @link https://www.fireplugins.com
8 8 * @copyright Copyright © 2026 FirePlugins All Rights Reserved
@@ -27,10 +27,24 @@
27 27 */
28 28 public static $client;
29 29
30 30 /**
31 + * Per-request memoized results of getDeviceType()/getOS()/getBrowser(), keyed by UA string.
32 + *
33 + * @var array
34 + */
35 + private static $resultCache = array();
36 +
37 + /**
38 + * Memoized constants from JApplicationWebClient, keyed by class name.
39 + *
40 + * @var array
41 + */
42 + private static $constantsCache = array();
43 +
44 + /**
31 45 * Get visitor's Device Type
32 - *
46 + *
33 47 * @param string $ua User Agent string, if null use the implicit one from the server's enviroment
34 48 *
35 49 * @return string The client's device type. Can be: tablet, mobile, desktop
36 50 */
@@ -35,11 +49,18 @@
35 49 * @return string The client's device type. Can be: tablet, mobile, desktop
36 50 */
37 51 public static function getDeviceType($ua = null)
38 52 {
53 + $cacheKey = 'deviceType_' . ($ua === null ? '' : $ua);
54 +
55 + if (isset(self::$resultCache[$cacheKey]))
56 + {
57 + return self::$resultCache[$cacheKey];
58 + }
59 +
39 60 $detect = new Mobile_Detect(null, $ua);
40 61
41 - return ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'mobile') : 'desktop');
62 + return (self::$resultCache[$cacheKey] = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'mobile') : 'desktop'));
42 63 }
43 64
44 65 /**
45 66 * Get visitor's Operating System
@@ -44,47 +65,55 @@
44 65 /**
45 66 * Get visitor's Operating System
46 67 *
47 68 * @param string $ua User Agent string, if null use the implicit one from the server's enviroment
48 - *
49 - * @return string Possible values: any of JApplicationWebClient's OS constants (except 'iphone' and 'ipad'),
69 + *
70 + * @return string Possible values: any of JApplicationWebClient's OS constants (except 'iphone' and 'ipad'),
50 71 * 'ios', 'chromeos'
51 72 */
52 73 public static function getOS($ua = null)
53 74 {
75 + $cacheKey = 'os_' . ($ua === null ? '' : $ua);
76 +
77 + if (isset(self::$resultCache[$cacheKey]))
78 + {
79 + return self::$resultCache[$cacheKey];
80 + }
81 +
54 82 // detect iOS and CromeOS (not handled by JApplicationWebClient)
55 - $ua = self::getClient($ua)->userAgent;
83 + $client = self::getClient($ua);
84 + $userAgent = $client->userAgent;
56 85
57 - if (!$ua)
86 + if (!$userAgent)
58 87 {
59 88 return;
60 89 }
61 -
90 +
62 91 $ios_regex = '/iPhone|iPad|iPod/i';
63 - if (preg_match($ios_regex, $ua))
92 + if (preg_match($ios_regex, $userAgent))
64 93 {
65 - return 'ios';
94 + return (self::$resultCache[$cacheKey] = 'ios');
66 95 }
67 96
68 97 $chromeos_regex = '/CrOS/i';
69 - if (preg_match($chromeos_regex, $ua))
98 + if (preg_match($chromeos_regex, $userAgent))
70 99 {
71 - return 'chromeos';
100 + return (self::$resultCache[$cacheKey] = 'chromeos');
72 101 }
73 102
74 103 // use JApplicationWebClient for OS detection
75 - $platformInt = self::getClient($ua)->platform;
104 + $platformInt = $client->platform;
76 105 $constants = self::getClientConstants();
77 -
106 +
78 107 if (isset($constants[$platformInt]))
79 108 {
80 - return strtolower($constants[$platformInt]);
109 + return (self::$resultCache[$cacheKey] = strtolower($constants[$platformInt]));
81 110 }
82 111 }
83 112
84 113 /**
85 114 * Get visitor's Browser name / version
86 - *
115 + *
87 116 * @param string $ua User Agent string, if null use the implicit one from the server's enviroment
88 117 *
89 118 * @return array
90 119 */
@@ -89,8 +118,15 @@
89 118 * @return array
90 119 */
91 120 public static function getBrowser($ua = null)
92 121 {
122 + $cacheKey = 'browser_' . ($ua === null ? '' : $ua);
123 +
124 + if (isset(self::$resultCache[$cacheKey]))
125 + {
126 + return self::$resultCache[$cacheKey];
127 + }
128 +
93 129 $client = self::getClient($ua);
94 130 $browserInt = $client->browser;
95 131 $constants = self::getClientConstants();
96 132
@@ -95,12 +131,12 @@
95 131 $constants = self::getClientConstants();
96 132
97 133 if (isset($constants[$browserInt]))
98 134 {
99 - return array(
135 + return (self::$resultCache[$cacheKey] = array(
100 136 'name' => strtolower($constants[$browserInt]),
101 137 'version' => $client->browserVersion
102 - );
138 + ));
103 139 }
104 140 }
105 141
106 142 /**
@@ -109,13 +145,20 @@
109 145 * @return array
110 146 */
111 147 private static function getClientConstants()
112 148 {
113 - $r = new \ReflectionClass('\\FPFramework\\Helpers\\Vendors\\WebClient');
149 + $class = '\\FPFramework\\Helpers\\Vendors\\WebClient';
150 +
151 + if (isset(self::$constantsCache[$class]))
152 + {
153 + return self::$constantsCache[$class];
154 + }
155 +
156 + $r = new \ReflectionClass($class);
114 157 $constantsArray = $r->getConstants();
115 158
116 159 // flip the associative array
117 - return array_flip($constantsArray);
160 + return (self::$constantsCache[$class] = array_flip($constantsArray));
118 161 }
119 162
120 163 /**
121 164 * Get the Application Client helper