PluginProbe
QuadMenu – Mega Menu / 1.9.0
QuadMenu – Mega Menu v1.9.0
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 2.0.7 All 87 releases
quadmenu / lib / ReduxCore / inc / class.redux_functions.php

class.redux_functions.php in QuadMenu – Mega Menu 1.9.0, at lib/ReduxCore/inc/class.redux_functions.php

270 lines 11.2 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( 'Redux_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 Redux_Functions {
25
26 static public $_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/ReduxFramework/redux-framework/master/ReduxCore/framework.php', array(
130 'headers' => array(
131 'Accept-Encoding' => ''
132 ),
133 'sslverify' => true,
134 'timeout' => 300
135 ) );
136
137 // Is the response code the corect one?
138 if ( ! is_wp_error( $gitpage ) ) {
139 if ( isset( $gitpage['body'] ) ) {
140 // Get the page text.
141 $body = $gitpage['body'];
142
143 // Find version line in framework.php
144 $needle = 'public static $_version =';
145 $pos = strpos( $body, $needle );
146
147 // If it's there, continue. We don't want errors if $pos = 0.
148 if ( $pos > 0 ) {
149
150 // Look for the semi-colon at the end of the version line
151 $semi = strpos( $body, ";", $pos );
152
153 // Error avoidance. If the semi-colon is there, continue.
154 if ( $semi > 0 ) {
155
156 // Extract the version line
157 $text = substr( $body, $pos, ( $semi - $pos ) );
158
159 // Find the first quote around the veersion number.
160 $quote = strpos( $body, "'", $pos );
161
162 // Extract the version number
163 $ver = substr( $body, $quote, ( $semi - $quote ) );
164
165 // Strip off quotes.
166 $ver = str_replace( "'", '', $ver );
167
168 return $ver;
169 }
170 }
171 }
172 }
173 }
174
175 /**
176 * updateCheck - Checks for updates to Redux Framework
177 *
178 * @since 3.2.0
179 * @access public
180 *
181 * @param string $curVer Current version of Redux Framework
182 *
183 * @return void - Admin notice is diaplyed if new version is found
184 */
185 public static function updateCheck( $parent, $curVer ) {
186
187 // If no cookie, check for new ver
188 if ( ! isset( $_COOKIE['redux_update_check'] ) ) { // || 1 == strcmp($_COOKIE['redux_update_check'], self::$_version)) {
189 // actual ver number from git repo
190 $ver = self::verFromGit();
191
192 // hour long cookie.
193 setcookie( "redux_update_check", $ver, time() + 3600, '/' );
194 } else {
195
196 // saved value from cookie. If it's different from current ver
197 // we can still show the update notice.
198 $ver = $_COOKIE['redux_update_check'];
199 }
200
201 // Set up admin notice on new version
202 //if ( 1 == strcmp( $ver, $curVer ) ) {
203 if ( version_compare( $ver, $curVer, '>' ) ) {
204 $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/ReduxFramework/redux-framework">Get it now</a>&nbsp;&nbsp;|';
205
206 $data = array(
207 'parent' => $parent,
208 'type' => 'updated',
209 'msg' => $msg,
210 'id' => 'dev_notice_' . $ver,
211 'dismiss' => true
212 );
213
214 Redux_Admin_Notices::set_notice($data);
215 }
216 }
217
218 public static function tru( $string, $opt_name ) {
219 $redux = ReduxFrameworkInstances::get_instance( $opt_name );
220 $check = get_user_option( 'r_tru_u_x', array() );
221 if ( ! empty( $check ) && ( isset( $check['expires'] ) < time() ) ) {
222 $check = array();
223 }
224
225 //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 ) ) {
226 if ( isset( $redux->args['dev_mode'] ) && $redux->args['dev_mode'] == true ) {
227 update_user_option( get_current_user_id(), 'r_tru_u_x', array(
228 'id' => '',
229 'expires' => 60 * 60 * 24
230 ) );
231 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>' );
232 } else {
233
234 if ( empty( $check ) ) {
235 $check = @wp_remote_get( 'http://look.redux.io/status.php?p=' . ReduxFramework::$_is_plugin );
236 $check = json_decode( wp_remote_retrieve_body( $check ), true );
237
238 if ( ! empty( $check ) && isset( $check['id'] ) ) {
239 update_user_option( get_current_user_id(), 'r_tru_u_x', $check );
240 }
241 }
242 $check = isset( $check['id'] ) ? $check['id'] : $check;
243 if ( ! empty( $check ) ) {
244 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>' );
245 } else {
246 return "";
247 }
248 }
249 }
250
251 public static function dat($fname, $opt_name){
252 $name = apply_filters('redux/' . $opt_name . '/aDBW_filter', $fname);
253
254 return $name;
255 }
256
257 public static function bub($fname, $opt_name){
258 $name = apply_filters('redux/' . $opt_name . '/aNF_filter', $fname);
259
260 return $name;
261 }
262
263 public static function yo($fname, $opt_name){
264 $name = apply_filters('redux/' . $opt_name . '/aNFM_filter', $fname);
265
266 return $name;
267 }
268 }
269 }
270