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
firebox / Inc / Framework / Inc / Helpers / Responsive.php

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

144 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.2.6
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 class Responsive
20 {
21 /**
22 * Renders the given CSS.
23 *
24 * @param array $css
25 * @param string $namespace
26 *
27 * @return string
28 */
29 public static function renderResponsiveCSS($css, $namespace = '')
30 {
31 $output = '';
32
33 foreach (Controls\Responsive::$breakpoints as $breakpoint)
34 {
35 if (!isset($css[$breakpoint]) || empty($css[$breakpoint]))
36 {
37 continue;
38 }
39
40 /**
41 * If we were given an array of strings of CSS, transform them to a string so we can output it.
42 *
43 * i.e. transform
44 * [
45 * 'color: #fff;',
46 * 'background: #000;'
47 * ]
48 *
49 * to:
50 *
51 * 'color: #fff;background: #000;'
52 */
53 if (!is_string($css[$breakpoint]))
54 {
55 $css[$breakpoint] = implode(' ', $css[$breakpoint]);
56 }
57
58 $function = 'get' . ucfirst($breakpoint) . 'Output';
59 if (!$output .= self::$function($css[$breakpoint], $namespace))
60 {
61 continue;
62 }
63 }
64
65 return $output;
66 }
67
68 /**
69 * Returns the desktop CSS.
70 *
71 * @param string $css
72 * @param string $namespace
73 *
74 * @return string
75 */
76 public static function getDesktopOutput($css, $namespace)
77 {
78 return self::getGenericTemplate($css, '', $namespace);
79 }
80
81 /**
82 * Returns the tablet CSS.
83 *
84 * @param string $css
85 * @param string $namespace
86 *
87 * @return string
88 */
89 public static function getTabletOutput($css, $namespace)
90 {
91 return self::getGenericTemplate($css, '(max-width: 991px)', $namespace);
92 }
93
94 /**
95 * Returns the mobile CSS.
96 *
97 * @param string $css
98 * @param string $namespace
99 *
100 * @return string
101 */
102 public static function getMobileOutput($css, $namespace)
103 {
104 return self::getGenericTemplate($css, '(max-width: 575px)', $namespace);
105 }
106
107 /**
108 * Returns the responsive output of a specific media query size.
109 *
110 * @param string $css
111 * @param string $size
112 * @param string $namespace
113 *
114 * @return string
115 */
116 public static function getGenericTemplate($css, $size = '', $namespace = '')
117 {
118 if (!is_string($css) || !is_string($size) || !is_string($namespace))
119 {
120 return '';
121 }
122
123 if (empty($css))
124 {
125 return '';
126 }
127
128 $namespace_prefix = $namespace_suffix = $size_prefix = $size_suffix = '';
129
130 if (!empty($size))
131 {
132 $size_prefix = '@media screen and ' . $size . ' { ';
133 $size_suffix = ' }';
134 }
135
136 if (!empty($namespace))
137 {
138 $namespace_prefix = $namespace . ' { ';
139 $namespace_suffix = ' }';
140 }
141
142 return $size_prefix . $namespace_prefix . $css . $namespace_suffix . $size_suffix;
143 }
144 }