PluginProbe
QuadMenu – Mega Menu / 3.3.8
QuadMenu – Mega Menu v3.3.8
3.3.8 3.3.7 3.3.6 trunk 1.8.4 1.8.5 1.8.7 1.8.8 1.8.9 1.9.0 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 88 releases
quadmenu / redux / ReduxCore / inc / class.redux_functions.php

class.redux_functions.php in QuadMenu – Mega Menu 3.3.8, at redux/ReduxCore/inc/class.redux_functions.php

276 lines 8.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Redux Framework Private Functions Container Class
5 *
6 * @package Redux_Framework
7 * @subpackage Core
8 */
9
10 // Exit if accessed directly
11 if ( ! defined( 'ABSPATH' ) ) {
12 exit;
13 }
14
15 // Don't duplicate me!
16 if ( ! class_exists( 'ReduxLegacy_Functions' ) ) {
17
18 /**
19 * Redux Functions Class
20 * Class of useful functions that can/should be shared among all Redux files.
21 *
22 * @since 1.0.0
23 */
24 class ReduxLegacy_Functions {
25
26 public static $_parent;
27
28 public static function isMin() {
29 $min = '';
30
31 if ( false == self::$_parent->args['dev_mode'] ) {
32 $min = '.min';
33 }
34
35 return $min;
36 }
37
38 /**
39 * Sets a cookie.
40 * Do nothing if unit testing.
41 *
42 * @since 3.5.4
43 * @access public
44 * @return void
45 *
46 * @param string $name The cookie name.
47 * @param string $value The cookie value.
48 * @param integer $expire Expiry time.
49 * @param string $path The cookie path.
50 * @param string $domain The cookie domain.
51 * @param boolean $secure HTTPS only.
52 * @param boolean $httponly Only set cookie on HTTP calls.
53 */
54 public static function setCookie( $name, $value, $expire = 0, $path = '', $domain = null, $secure = false, $httponly = false ) {
55 if ( ! defined( 'WP_TESTS_DOMAIN' ) ) {
56 setcookie( $name, $value, $expire, $path, $domain, $secure, $httponly );
57 }
58 }
59
60 /**
61 * Parse CSS from output/compiler array
62 *
63 * @since 3.2.8
64 * @access private
65 * @return $css CSS string
66 */
67 public static function parseCSS( $cssArray = array(), $style = '', $value = '' ) {
68
69 // Something wrong happened
70 if ( count( $cssArray ) == 0 ) {
71 return;
72 } else { // if ( count( $cssArray ) >= 1 ) {
73 $css = '';
74
75 foreach ( $cssArray as $element => $selector ) {
76
77 // The old way
78 if ( $element === 0 ) {
79 $css = self::theOldWay( $cssArray, $style );
80
81 return $css;
82 }
83
84 // New way continued
85 $cssStyle = $element . ':' . $value . ';';
86
87 $css .= $selector . '{' . $cssStyle . '}';
88 }
89 }
90
91 return $css;
92 }
93
94 private static function theOldWay( $cssArray, $style ) {
95 $keys = implode( ',', $cssArray );
96 $css = $keys . '{' . $style . '}';
97
98 return $css;
99 }
100
101 /**
102 * initWpFilesystem - Initialized the WordPress filesystem, if it already isn't.
103 *
104 * @since 3.2.3
105 * @access public
106 * @return void
107 */
108 public static function initWpFilesystem() {
109 global $wp_filesystem;
110
111 // Initialize the WordPress filesystem, no more using file_put_contents function
112 if ( empty( $wp_filesystem ) ) {
113 require_once ABSPATH . '/wp-includes/pluggable.php';
114 require_once ABSPATH . '/wp-admin/includes/file.php';
115 WP_Filesystem();
116 }
117 }
118
119 /**
120 * verFromGit - Retrives latest Redux version from GIT
121 *
122 * @since 3.2.0
123 * @access private
124 * @return string $ver
125 */
126 private static function verFromGit() {
127 // Get the raw framework.php from github
128 $gitpage = wp_remote_get(
129 'https://raw.github.com/ReduxFrameworkLegacy/redux-framework/master/ReduxCore/framework.php',
130 array(
131 'headers' => array(
132 'Accept-Encoding' => '',
133 ),
134 'sslverify' => true,
135 'timeout' => 300,
136 )
137 );
138
139 // Is the response code the corect one?
140 if ( ! is_wp_error( $gitpage ) ) {
141 if ( isset( $gitpage['body'] ) ) {
142 // Get the page text.
143 $body = $gitpage['body'];
144
145 // Find version line in framework.php
146 $needle = 'public static $_version =';
147 $pos = strpos( $body, $needle );
148
149 // If it's there, continue. We don't want errors if $pos = 0.
150 if ( $pos > 0 ) {
151
152 // Look for the semi-colon at the end of the version line
153 $semi = strpos( $body, ';', $pos );
154
155 // Error avoidance. If the semi-colon is there, continue.
156 if ( $semi > 0 ) {
157
158 // Extract the version line
159 $text = substr( $body, $pos, ( $semi - $pos ) );
160
161 // Find the first quote around the veersion number.
162 $quote = strpos( $body, "'", $pos );
163
164 // Extract the version number
165 $ver = substr( $body, $quote, ( $semi - $quote ) );
166
167 // Strip off quotes.
168 $ver = str_replace( "'", '', $ver );
169
170 return $ver;
171 }
172 }
173 }
174 }
175 }
176
177 /**
178 * updateCheck - Checks for updates to Redux Framework
179 *
180 * @since 3.2.0
181 * @access public
182 *
183 * @param string $curVer Current version of Redux Framework
184 *
185 * @return void - Admin notice is diaplyed if new version is found
186 */
187 public static function updateCheck( $parent, $curVer ) {
188
189 // If no cookie, check for new ver
190 if ( ! isset( $_COOKIE['redux_update_check'] ) ) { // || 1 == strcmp($_COOKIE['redux_update_check'], self::$_version)) {
191 // actual ver number from git repo
192 $ver = self::verFromGit();
193
194 // hour long cookie.
195 setcookie( 'redux_update_check', $ver, time() + 3600, '/' );
196 } else {
197
198 // saved value from cookie. If it's different from current ver
199 // we can still show the update notice.
200 $ver = $_COOKIE['redux_update_check'];
201 }
202
203 // Set up admin notice on new version
204 // if ( 1 == strcmp( $ver, $curVer ) ) {
205 if ( version_compare( $ver, $curVer, '>' ) ) {
206 $msg = '<strong>A new build of Redux is now available!</strong><br/><br/>Your version: <strong>' . $curVer . '</strong><br/>New version: <strong><span style="color: red;">' . $ver . '</span></strong><br/><br/><em>If you are not a developer, your theme/plugin author shipped with <code>dev_mode</code> on. Contact them to fix it, but in the meantime you can use our <a href="' . 'https://' . 'wordpress.org/plugins/redux-developer-mode-disabler/" target="_blank">dev_mode disabler</a>.</em><br /><br /><a href="' . 'https://' . 'github.com/ReduxFrameworkLegacy/redux-framework">Get it now</a>&nbsp;&nbsp;|';
207
208 $data = array(
209 'parent' => $parent,
210 'type' => 'updated',
211 'msg' => $msg,
212 'id' => 'dev_notice_' . $ver,
213 'dismiss' => true,
214 );
215
216 ReduxLegacy_Admin_Notices::set_notice( $data );
217 }
218 }
219
220 public static function tru( $string, $opt_name ) {
221 $redux = ReduxFrameworkInstancesLegacy::get_instance( $opt_name );
222 $check = get_user_option( 'r_tru_u_x', array() );
223 if ( ! empty( $check ) && ( isset( $check['expires'] ) < time() ) ) {
224 $check = array();
225 }
226
227 // if ( isset( $redux->args['dev_mode'] ) && $redux->args['dev_mode'] == true && ! ( isset( $redux->args['forced_dev_mode_off'] ) && $redux->args['forced_dev_mode_off'] == true ) ) {
228 if ( isset( $redux->args['dev_mode'] ) && $redux->args['dev_mode'] == true ) {
229 update_user_option(
230 get_current_user_id(),
231 'r_tru_u_x',
232 array(
233 'id' => '',
234 'expires' => 60 * 60 * 24,
235 )
236 );
237 return apply_filters( 'redux/' . $opt_name . '/aURL_filter', '<span data-id="1" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $string . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>' );
238 } else {
239
240 if ( empty( $check ) ) {
241 $check = @wp_remote_get( 'http://look.redux.io/status.php?p=' . ReduxFrameworkLegacy::$_is_plugin );
242 $check = json_decode( wp_remote_retrieve_body( $check ), true );
243
244 if ( ! empty( $check ) && isset( $check['id'] ) ) {
245 update_user_option( get_current_user_id(), 'r_tru_u_x', $check );
246 }
247 }
248 $check = isset( $check['id'] ) ? $check['id'] : $check;
249 if ( ! empty( $check ) ) {
250 return apply_filters( 'redux/' . $opt_name . '/aURL_filter', '<span data-id="' . $check . '" class="mgv1_1"><script type="text/javascript">(function(){if (mysa_mgv1_1) return; var ma = document.createElement("script"); ma.type = "text/javascript"; ma.async = true; ma.src = "' . $string . '"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ma, s) })();var mysa_mgv1_1=true;</script></span>' );
251 } else {
252 return '';
253 }
254 }
255 }
256
257 public static function dat( $fname, $opt_name ) {
258 $name = apply_filters( 'redux/' . $opt_name . '/aDBW_filter', $fname );
259
260 return $name;
261 }
262
263 public static function bub( $fname, $opt_name ) {
264 $name = apply_filters( 'redux/' . $opt_name . '/aNF_filter', $fname );
265
266 return $name;
267 }
268
269 public static function yo( $fname, $opt_name ) {
270 $name = apply_filters( 'redux/' . $opt_name . '/aNFM_filter', $fname );
271
272 return $name;
273 }
274 }
275 }
276