| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* @package Redux_Tracking |
| 5 |
*/ |
| 6 |
if ( ! class_exists( 'ReduxFramework' ) ) { |
| 7 |
return; |
| 8 |
} |
| 9 |
|
| 10 |
/** |
| 11 |
* Class that creates the tracking functionality for Redux, as the core class might be used in more plugins, |
| 12 |
* it's checked for existence first. |
| 13 |
* NOTE: this functionality is opt-in. Disabling the tracking in the settings or saying no when asked will cause |
| 14 |
* this file to not even be loaded. |
| 15 |
*/ |
| 16 |
if ( ! class_exists( 'Redux_Tracking' ) ) { |
| 17 |
|
| 18 |
/** |
| 19 |
* Class Redux_Tracking |
| 20 |
*/ |
| 21 |
class Redux_Tracking { |
| 22 |
|
| 23 |
public $options = array(); |
| 24 |
public $parent; |
| 25 |
|
| 26 |
/** Refers to a single instance of this class. */ |
| 27 |
private static $instance = null; |
| 28 |
|
| 29 |
/** |
| 30 |
* Creates or returns an instance of this class. |
| 31 |
* |
| 32 |
* @return Redux_Tracking A single instance of this class. |
| 33 |
*/ |
| 34 |
public static function get_instance() { |
| 35 |
|
| 36 |
if ( null == self::$instance ) { |
| 37 |
self::$instance = new self; |
| 38 |
} |
| 39 |
|
| 40 |
return self::$instance; |
| 41 |
} |
| 42 |
// end get_instance; |
| 43 |
|
| 44 |
/** |
| 45 |
* Class constructor |
| 46 |
*/ |
| 47 |
|
| 48 |
function __construct() { |
| 49 |
|
| 50 |
|
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @param ReduxFramework $parent |
| 55 |
*/ |
| 56 |
public function load( $parent ) { |
| 57 |
$this->parent = $parent; |
| 58 |
|
| 59 |
|
| 60 |
$this->options = get_option( 'redux-framework-tracking' ); |
| 61 |
$this->options['dev_mode'] = $parent->args['dev_mode']; |
| 62 |
|
| 63 |
|
| 64 |
if ( ! isset( $this->options['hash'] ) || ! $this->options['hash'] || empty( $this->options['hash'] ) ) { |
| 65 |
$this->options['hash'] = md5( network_site_url() . '-' . $_SERVER['REMOTE_ADDR'] ); |
| 66 |
update_option( 'redux-framework-tracking', $this->options ); |
| 67 |
} |
| 68 |
|
| 69 |
if ( isset( $_GET['redux_framework_disable_tracking'] ) && ! empty( $_GET['redux_framework_disable_tracking'] ) ) { |
| 70 |
$this->options['allow_tracking'] = 'no'; |
| 71 |
update_option( 'redux-framework-tracking', $this->options ); |
| 72 |
} |
| 73 |
|
| 74 |
if ( isset( $_GET['redux_framework_enable_tracking'] ) && ! empty( $_GET['redux_framework_enable_tracking'] ) ) { |
| 75 |
$this->options['allow_tracking'] = 'yes'; |
| 76 |
update_option( 'redux-framework-tracking', $this->options ); |
| 77 |
} |
| 78 |
|
| 79 |
if ( isset( $_GET['page'] ) && $_GET['page'] == $this->parent->args['page_slug'] ) { |
| 80 |
if ( ! isset( $this->options['allow_tracking'] ) ) { |
| 81 |
add_action( 'admin_enqueue_scripts', array( $this, '_enqueue_tracking' ) ); |
| 82 |
} else if ( ! isset( $this->options['tour'] ) && ( $this->parent->args['dev_mode'] == "true" || $this->parent->args['page_slug'] == "redux_demo" ) ) { |
| 83 |
add_action( 'admin_enqueue_scripts', array( $this, '_enqueue_newsletter' ) ); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
$hash = md5( trailingslashit( network_site_url() ) . '-redux' ); |
| 88 |
add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'tracking_arg' ) ); |
| 89 |
add_action( 'wp_ajax_' . $hash, array( $this, 'tracking_arg' ) ); |
| 90 |
|
| 91 |
$hash = md5( md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' ) . '-support' ); |
| 92 |
add_action( 'wp_ajax_nopriv_' . $hash, array( $this, 'support_args' ) ); |
| 93 |
add_action( 'wp_ajax_' . $hash, array( $this, 'support_args' ) ); |
| 94 |
|
| 95 |
if ( isset( $this->options['allow_tracking'] ) && $this->options['allow_tracking'] == 'yes' ) { |
| 96 |
// The tracking checks daily, but only sends new data every 7 days. |
| 97 |
if ( ! wp_next_scheduled( 'redux_tracking' ) ) { |
| 98 |
wp_schedule_event( time(), 'daily', 'redux_tracking' ); |
| 99 |
} |
| 100 |
add_action( 'redux_tracking', array( $this, 'tracking' ) ); |
| 101 |
} |
| 102 |
} |
| 103 |
|
| 104 |
function _enqueue_tracking() { |
| 105 |
wp_enqueue_style( 'wp-pointer' ); |
| 106 |
wp_enqueue_script( 'jquery' ); |
| 107 |
wp_enqueue_script( 'jquery-ui' ); |
| 108 |
wp_enqueue_script( 'wp-pointer' ); |
| 109 |
wp_enqueue_script( 'utils' ); |
| 110 |
add_action( 'admin_print_footer_scripts', array( $this, 'tracking_request' ) ); |
| 111 |
} |
| 112 |
|
| 113 |
function _enqueue_newsletter() { |
| 114 |
wp_enqueue_style( 'wp-pointer' ); |
| 115 |
wp_enqueue_script( 'jquery' ); |
| 116 |
wp_enqueue_script( 'jquery-ui' ); |
| 117 |
wp_enqueue_script( 'wp-pointer' ); |
| 118 |
wp_enqueue_script( 'utils' ); |
| 119 |
add_action( 'admin_print_footer_scripts', array( $this, 'newsletter_request' ) ); |
| 120 |
} |
| 121 |
|
| 122 |
/** |
| 123 |
* Shows a popup that asks for permission to allow tracking. |
| 124 |
*/ |
| 125 |
function tracking_request() { |
| 126 |
$id = '#wpadminbar'; |
| 127 |
$nonce = wp_create_nonce( 'redux_activate_tracking' ); |
| 128 |
|
| 129 |
$content = '<h3>' . esc_html__( 'Help improve Our Panel', 'redux-framework' ) . '</h3>'; |
| 130 |
$content .= '<p>' . esc_html__( 'Please helps us improve our panel by allowing us to gather anonymous usage stats so we know which configurations, plugins and themes to test to ensure compatibility.', 'redux-framework' ) . '</p>'; |
| 131 |
$opt_arr = array( |
| 132 |
'content' => $content, |
| 133 |
'position' => array( 'edge' => 'top', 'align' => 'center' ) |
| 134 |
); |
| 135 |
$button2 = esc_html__( 'Allow tracking', 'redux-framework' ); |
| 136 |
|
| 137 |
$function2 = 'redux_store_answer("yes","' . $nonce . '")'; |
| 138 |
$function1 = 'redux_store_answer("no","' . $nonce . '")'; |
| 139 |
|
| 140 |
$this->print_scripts( $id, $opt_arr, esc_html__( 'Do not allow tracking', 'redux-framework' ), $button2, $function2, $function1 ); |
| 141 |
} |
| 142 |
|
| 143 |
/** |
| 144 |
* Shows a popup that asks for permission to allow tracking. |
| 145 |
*/ |
| 146 |
function newsletter_request() { |
| 147 |
$id = '#wpadminbar'; |
| 148 |
$nonce = wp_create_nonce( 'redux_activate_tracking' ); |
| 149 |
|
| 150 |
|
| 151 |
$content = '<h3>' . esc_html__( 'Welcome to the Redux Demo Panel', 'redux-framework' ) . '</h3>'; |
| 152 |
$content .= '<p><strong>' . esc_html__( 'Getting Started', 'redux-framework' ) . '</strong><br>' . sprintf( __( 'This panel demonstrates the many features of Redux. Before digging in, we suggest you get up to speed by reviewing %1$s.', 'redux-framework' ), '<a href="' . 'http://' . 'docs.reduxframework.com/redux-framework/getting-started/" target="_blank">' . esc_html__( 'our documentation', 'redux-framework' ) . '</a>' ); |
| 153 |
$content .= '<p><strong>' . esc_html__( 'Redux Generator', 'redux-framework' ) . '</strong><br>' . sprintf( __( 'Want to get a head start? Use the %1$s. It will create a customized boilerplate theme or a standalone admin folder complete with all things Redux (with the help of Underscores and TGM). Save yourself a headache and try it today.', 'redux-framework' ), '<a href="' . 'http://' . 'generate.reduxframework.com/" target="_blank">' . esc_html__( 'Redux Generator', 'redux-framework' ) . '</a>' ); |
| 154 |
$content .= '<p><strong>' . esc_html__( 'Redux Extensions', 'redux-framework' ) . '</strong><br>' . sprintf( __( 'Did you know we have extensions, which greatly enhance the features of Redux? Visit our %1$s to learn more!', 'redux-framework' ), '<a href="' . 'http://' . 'reduxframework.com/extensions/" target="_blank">' . esc_html__( 'extensions directory', 'redux-framework' ) . '</a>' ); |
| 155 |
$content .= '<p><strong>' . esc_html__( 'Like Redux?', 'redux-framework' ) . '</strong><br>' . sprintf( __( 'If so, please %1$s and consider making a %2$s to keep development of Redux moving forward.', 'redux-framework' ), '<a target="_blank" href="' . 'http://' . 'wordpress.org/support/view/plugin-reviews/redux-framework">' . esc_html__( 'leave us a favorable review on WordPress.org', 'redux-framework' ) . '</a>', '<a href="' . 'https://' . 'www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=N5AD7TSH8YA5U" target="_blank">' . esc_html__( 'donation', 'redux-framework' ) . '</a>' ); |
| 156 |
$content .= '<p><strong>' . esc_html__( 'Newsletter', 'redux-framework' ) . '</strong><br>' . esc_html__( 'If you\'d like to keep up to with all things Redux, please subscribe to our newsletter', 'redux-framework' ) . ':</p>'; |
| 157 |
$content .= '<form action="http://news.redux.io/subscribe" method="POST" target="_blank" accept-charset="utf-8" class="validate"> |
| 158 |
<p style="text-align: center;"> |
| 159 |
<label for="email">' . esc_html__('Email Address', 'redux-framework') . '</label> |
| 160 |
<input type="email" name="email" class="required email" id="email"/> |
| 161 |
<input type="hidden" name="list" value="9K1qDRvB8Ux0DqpEoQSEPA"/> |
| 162 |
|
| 163 |
<input type="submit" class="button button-primary" name="submit" value="' . esc_html__( 'Subscribe', 'redux-framework' ) . '" id="submit"/> |
| 164 |
</p> |
| 165 |
</form>'; |
| 166 |
|
| 167 |
$opt_arr = array( |
| 168 |
'content' => $content, |
| 169 |
'position' => array( 'edge' => 'top', 'align' => 'center' ), |
| 170 |
'pointerWidth' => 450 |
| 171 |
); |
| 172 |
|
| 173 |
$function1 = 'redux_store_answer("tour","' . $nonce . '")'; |
| 174 |
|
| 175 |
$this->print_scripts( $id, $opt_arr, esc_html__( 'Close', 'redux-framework' ), false, '', $function1 ); |
| 176 |
} |
| 177 |
|
| 178 |
/** |
| 179 |
* Prints the pointer script |
| 180 |
* |
| 181 |
* @param string $selector The CSS selector the pointer is attached to. |
| 182 |
* @param array $options The options for the pointer. |
| 183 |
* @param string $button1 Text for button 1 |
| 184 |
* @param string|bool $button2 Text for button 2 (or false to not show it, defaults to false) |
| 185 |
* @param string $button2_function The JavaScript function to attach to button 2 |
| 186 |
* @param string $button1_function The JavaScript function to attach to button 1 |
| 187 |
*/ |
| 188 |
function print_scripts( $selector, $options, $button1, $button2 = false, $button2_function = '', $button1_function = '' ) { |
| 189 |
?> |
| 190 |
<script type="text/javascript"> |
| 191 |
//<![CDATA[ |
| 192 |
// |
| 193 |
(function( $ ) { |
| 194 |
$( document ).ready( |
| 195 |
function() { |
| 196 |
var redux_pointer_options = <?php echo json_encode($options); ?>, setup; |
| 197 |
|
| 198 |
function redux_store_answer( input, nonce ) { |
| 199 |
var redux_tracking_data = { |
| 200 |
action: 'redux_allow_tracking', |
| 201 |
allow_tracking: input, |
| 202 |
nonce: nonce |
| 203 |
} |
| 204 |
jQuery.post( |
| 205 |
ajaxurl, redux_tracking_data, function() { |
| 206 |
jQuery( '#wp-pointer-0' ).remove(); |
| 207 |
} |
| 208 |
); |
| 209 |
} |
| 210 |
|
| 211 |
redux_pointer_options = $.extend( |
| 212 |
redux_pointer_options, { |
| 213 |
buttons: function( event, t ) { |
| 214 |
button = jQuery( '<a id="pointer-close" style="margin-left:5px" class="button-secondary">' + '<?php echo $button1; ?>' + '</a>' ); |
| 215 |
button.bind( |
| 216 |
'click.pointer', function() { |
| 217 |
t.element.pointer( 'close' ); |
| 218 |
//console.log( 'close button' ); |
| 219 |
} |
| 220 |
); |
| 221 |
return button; |
| 222 |
}, |
| 223 |
close: function() { |
| 224 |
} |
| 225 |
} |
| 226 |
); |
| 227 |
|
| 228 |
setup = function() { |
| 229 |
$( '<?php echo $selector; ?>' ).pointer( redux_pointer_options ).pointer( 'open' ); |
| 230 |
<?php if ($button2) { ?> |
| 231 |
jQuery( '#pointer-close' ).after( '<a id="pointer-primary" class="button-primary">' + '<?php echo $button2; ?>' + '</a>' ); |
| 232 |
jQuery( '#pointer-primary' ).click( |
| 233 |
function() { |
| 234 |
<?php echo $button2_function; ?> |
| 235 |
} |
| 236 |
); |
| 237 |
jQuery( '#pointer-close' ).click( |
| 238 |
function() { |
| 239 |
<?php if ($button1_function == '') { ?> |
| 240 |
redux_store_answer( input, nonce ) |
| 241 |
//redux_setIgnore("tour", "wp-pointer-0", "<?php echo wp_create_nonce('redux-ignore'); ?>"); |
| 242 |
<?php } else { ?> |
| 243 |
<?php echo $button1_function; ?> |
| 244 |
<?php } ?> |
| 245 |
} |
| 246 |
); |
| 247 |
<?php } else if ($button1 && !$button2) { ?> |
| 248 |
jQuery( '#pointer-close' ).click( |
| 249 |
function() { |
| 250 |
<?php if ($button1_function != '') { ?> |
| 251 |
<?php echo $button1_function; ?> |
| 252 |
<?php } ?> |
| 253 |
} |
| 254 |
); |
| 255 |
<?php } ?> |
| 256 |
}; |
| 257 |
|
| 258 |
if ( redux_pointer_options.position && redux_pointer_options.position.defer_loading ) |
| 259 |
$( window ).bind( 'load.wp-pointers', setup ); |
| 260 |
else |
| 261 |
$( document ).ready( setup ); |
| 262 |
} |
| 263 |
); |
| 264 |
})( jQuery ); |
| 265 |
//]]> |
| 266 |
</script> |
| 267 |
<?php |
| 268 |
} |
| 269 |
|
| 270 |
function trackingObject() { |
| 271 |
global $blog_id, $wpdb; |
| 272 |
$pts = array(); |
| 273 |
|
| 274 |
foreach ( get_post_types( array( 'public' => true ) ) as $pt ) { |
| 275 |
$count = wp_count_posts( $pt ); |
| 276 |
$pts[ $pt ] = $count->publish; |
| 277 |
} |
| 278 |
|
| 279 |
$comments_count = wp_count_comments(); |
| 280 |
$theme_data = wp_get_theme(); |
| 281 |
$theme = array( |
| 282 |
'version' => $theme_data->Version, |
| 283 |
'name' => $theme_data->Name, |
| 284 |
'author' => $theme_data->Author, |
| 285 |
'template' => $theme_data->Template, |
| 286 |
); |
| 287 |
|
| 288 |
if ( ! function_exists( 'get_plugin_data' ) ) { |
| 289 |
require_once ABSPATH . 'wp-admin/includes/admin.php'; |
| 290 |
} |
| 291 |
|
| 292 |
$plugins = array(); |
| 293 |
foreach ( get_option( 'active_plugins', array() ) as $plugin_path ) { |
| 294 |
$plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path ); |
| 295 |
|
| 296 |
$slug = str_replace( '/' . basename( $plugin_path ), '', $plugin_path ); |
| 297 |
$plugins[ $slug ] = array( |
| 298 |
'version' => $plugin_info['Version'], |
| 299 |
'name' => $plugin_info['Name'], |
| 300 |
'plugin_uri' => $plugin_info['PluginURI'], |
| 301 |
'author' => $plugin_info['AuthorName'], |
| 302 |
'author_uri' => $plugin_info['AuthorURI'], |
| 303 |
); |
| 304 |
} |
| 305 |
if ( is_multisite() ) { |
| 306 |
foreach ( get_option( 'active_sitewide_plugins', array() ) as $plugin_path ) { |
| 307 |
$plugin_info = get_plugin_data( WP_PLUGIN_DIR . '/' . $plugin_path ); |
| 308 |
$slug = str_replace( '/' . basename( $plugin_path ), '', $plugin_path ); |
| 309 |
$plugins[ $slug ] = array( |
| 310 |
'version' => $plugin_info['Version'], |
| 311 |
'name' => $plugin_info['Name'], |
| 312 |
'plugin_uri' => $plugin_info['PluginURI'], |
| 313 |
'author' => $plugin_info['AuthorName'], |
| 314 |
'author_uri' => $plugin_info['AuthorURI'], |
| 315 |
); |
| 316 |
} |
| 317 |
} |
| 318 |
|
| 319 |
|
| 320 |
$version = explode( '.', PHP_VERSION ); |
| 321 |
$version = array( |
| 322 |
'major' => $version[0], |
| 323 |
'minor' => $version[0] . '.' . $version[1], |
| 324 |
'release' => PHP_VERSION |
| 325 |
); |
| 326 |
|
| 327 |
$user_query = new WP_User_Query( array( 'blog_id' => $blog_id, 'count_total' => true, ) ); |
| 328 |
$comments_query = new WP_Comment_Query(); |
| 329 |
$data = array( |
| 330 |
'_id' => $this->options['hash'], |
| 331 |
'localhost' => ( $_SERVER['REMOTE_ADDR'] === '127.0.0.1' ) ? 1 : 0, |
| 332 |
'php' => $version, |
| 333 |
'site' => array( |
| 334 |
'hash' => $this->options['hash'], |
| 335 |
'version' => get_bloginfo( 'version' ), |
| 336 |
'multisite' => is_multisite(), |
| 337 |
'users' => $user_query->get_total(), |
| 338 |
'lang' => get_locale(), |
| 339 |
'wp_debug' => ( defined( 'WP_DEBUG' ) ? WP_DEBUG ? true : false : false ), |
| 340 |
'memory' => WP_MEMORY_LIMIT, |
| 341 |
), |
| 342 |
'pts' => $pts, |
| 343 |
'comments' => array( |
| 344 |
'total' => $comments_count->total_comments, |
| 345 |
'approved' => $comments_count->approved, |
| 346 |
'spam' => $comments_count->spam, |
| 347 |
'pings' => $comments_query->query( array( 'count' => true, 'type' => 'pingback' ) ), |
| 348 |
), |
| 349 |
'options' => apply_filters( 'redux/tracking/options', array() ), |
| 350 |
'theme' => $theme, |
| 351 |
'redux' => array( |
| 352 |
'mode' => ReduxFramework::$_is_plugin ? 'plugin' : 'theme', |
| 353 |
'version' => ReduxFramework::$_version, |
| 354 |
'demo_mode' => get_option( 'ReduxFrameworkPlugin' ), |
| 355 |
), |
| 356 |
'developer' => apply_filters( 'redux/tracking/developer', array() ), |
| 357 |
'plugins' => $plugins, |
| 358 |
); |
| 359 |
|
| 360 |
$parts = explode( ' ', $_SERVER['SERVER_SOFTWARE'] ); |
| 361 |
$software = array(); |
| 362 |
foreach ( $parts as $part ) { |
| 363 |
if ( $part[0] == "(" ) { |
| 364 |
continue; |
| 365 |
} |
| 366 |
if ( strpos( $part, '/' ) !== false ) { |
| 367 |
$chunk = explode( "/", $part ); |
| 368 |
$software[ strtolower( $chunk[0] ) ] = $chunk[1]; |
| 369 |
} |
| 370 |
} |
| 371 |
$software['full'] = $_SERVER['SERVER_SOFTWARE']; |
| 372 |
$data['environment'] = $software; |
| 373 |
//if ( function_exists( 'mysql_get_server_info' ) ) { |
| 374 |
// $data['environment']['mysql'] = mysql_get_server_info(); |
| 375 |
//} |
| 376 |
$data['environment']['mysql'] = $wpdb->db_version(); |
| 377 |
|
| 378 |
if ( empty( $data['developer'] ) ) { |
| 379 |
unset( $data['developer'] ); |
| 380 |
} |
| 381 |
|
| 382 |
return $data; |
| 383 |
} |
| 384 |
|
| 385 |
/** |
| 386 |
* Main tracking function. |
| 387 |
*/ |
| 388 |
function tracking() { |
| 389 |
// Start of Metrics |
| 390 |
global $blog_id, $wpdb; |
| 391 |
|
| 392 |
$data = get_transient( 'redux_tracking_cache' ); |
| 393 |
if ( ! $data ) { |
| 394 |
|
| 395 |
$args = array( |
| 396 |
'body' => $this->trackingObject() |
| 397 |
); |
| 398 |
|
| 399 |
$response = wp_remote_post( 'https://redux-tracking.herokuapp.com', $args ); |
| 400 |
|
| 401 |
// Store for a week, then push data again. |
| 402 |
set_transient( 'redux_tracking_cache', true, WEEK_IN_SECONDS ); |
| 403 |
} |
| 404 |
} |
| 405 |
|
| 406 |
function tracking_arg() { |
| 407 |
echo md5( AUTH_KEY . SECURE_AUTH_KEY . '-redux' ); |
| 408 |
die(); |
| 409 |
} |
| 410 |
|
| 411 |
function support_args() { |
| 412 |
header( "Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); |
| 413 |
header( "Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); |
| 414 |
header( 'Expires: Sat, 26 Jul 1997 05:00:00 GMT' ); |
| 415 |
header( 'Cache-Control: no-store, no-cache, must-revalidate' ); |
| 416 |
header( 'Cache-Control: post-check=0, pre-check=0', false ); |
| 417 |
header( 'Pragma: no-cache' ); |
| 418 |
$instances = ReduxFrameworkInstances::get_all_instances(); |
| 419 |
|
| 420 |
$array = array(); |
| 421 |
|
| 422 |
if ( isset( $_REQUEST['i'] ) && ! empty( $_REQUEST['i'] ) ) { |
| 423 |
if ( is_array( $instances ) && ! empty( $instances ) ) { |
| 424 |
foreach ( $instances as $opt_name => $data ) { |
| 425 |
if ( md5( $opt_name . '-debug' ) == $_REQUEST['i'] ) { |
| 426 |
$array = $instances[ $opt_name ]; |
| 427 |
} |
| 428 |
} |
| 429 |
} |
| 430 |
if ( isset( $array ) ) { |
| 431 |
if ( isset( $array->extensions ) && is_array( $array->extensions ) && ! empty( $array->extensions ) ) { |
| 432 |
foreach ( $array->extensions as $key => $extension ) { |
| 433 |
if ( isset( $extension->$version ) ) { |
| 434 |
$array->extensions[ $key ] = $extension->$version; |
| 435 |
} else { |
| 436 |
$array->extensions[ $key ] = true; |
| 437 |
} |
| 438 |
} |
| 439 |
} |
| 440 |
if ( isset( $array->import_export ) ) { |
| 441 |
unset( $array->import_export ); |
| 442 |
} |
| 443 |
if ( isset( $array->debug ) ) { |
| 444 |
unset( $array->debug ); |
| 445 |
} |
| 446 |
} else { |
| 447 |
die(); |
| 448 |
} |
| 449 |
|
| 450 |
} else { |
| 451 |
$array = $this->trackingObject(); |
| 452 |
if ( is_array( $instances ) && ! empty( $instances ) ) { |
| 453 |
$array['instances'] = array(); |
| 454 |
foreach ( $instances as $opt_name => $data ) { |
| 455 |
$array['instances'][] = $opt_name; |
| 456 |
} |
| 457 |
} |
| 458 |
$array['key'] = md5( AUTH_KEY . SECURE_AUTH_KEY ); |
| 459 |
} |
| 460 |
|
| 461 |
echo @json_encode( $array, true ); |
| 462 |
die(); |
| 463 |
} |
| 464 |
|
| 465 |
} |
| 466 |
|
| 467 |
Redux_Tracking::get_instance(); |
| 468 |
|
| 469 |
/** |
| 470 |
* Adds tracking parameters for Redux settings. Outside of the main class as the class could also be in use in other ways. |
| 471 |
* |
| 472 |
* @param array $options |
| 473 |
* |
| 474 |
* @return array |
| 475 |
*/ |
| 476 |
function redux_tracking_additions( $options ) { |
| 477 |
$opt = array(); |
| 478 |
|
| 479 |
$options['redux'] = array( |
| 480 |
'demo_mode' => get_option( 'ReduxFrameworkPlugin' ), |
| 481 |
); |
| 482 |
|
| 483 |
return $options; |
| 484 |
} |
| 485 |
|
| 486 |
add_filter( 'redux/tracking/options', 'redux_tracking_additions' ); |
| 487 |
|
| 488 |
function redux_allow_tracking_callback() { |
| 489 |
// Verify that the incoming request is coming with the security nonce |
| 490 |
if ( wp_verify_nonce( $_REQUEST['nonce'], 'redux_activate_tracking' ) ) { |
| 491 |
$options = get_option( 'redux-framework-tracking' ); |
| 492 |
|
| 493 |
if ( $_REQUEST['allow_tracking'] == "tour" ) { |
| 494 |
$options['tour'] = 1; |
| 495 |
} else { |
| 496 |
$options['allow_tracking'] = $_REQUEST['allow_tracking']; |
| 497 |
} |
| 498 |
|
| 499 |
if ( update_option( 'redux-framework-tracking', $options ) ) { |
| 500 |
die( '1' ); |
| 501 |
} else { |
| 502 |
die( '0' ); |
| 503 |
} |
| 504 |
} else { |
| 505 |
// Send -1 if the attempt to save via Ajax was completed invalid. |
| 506 |
die( '-1' ); |
| 507 |
} // end if |
| 508 |
} |
| 509 |
|
| 510 |
add_action( 'wp_ajax_redux_allow_tracking', 'redux_allow_tracking_callback' ); |
| 511 |
|
| 512 |
} |
| 513 |
|