monsterinsights_switch_to_jsevents

The Google Analytics for WordPress by MonsterInsights monsterinsights switch to jsevents function.

Description

monsterinsights_switch_to_jsevents(); 

Usage

  1. if ( !function_exists( 'monsterinsights_switch_to_jsevents' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'google-analytics-for-wordpress-by-monsterinsights/includes/admin/pages/settings.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = monsterinsights_switch_to_jsevents(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/includes/admin/pages/settings.php  
  1. function monsterinsights_switch_to_jsevents() { 
  2. $nonce = ''; 
  3. if ( ! empty( $_REQUEST['monsterinsights-switch-to-jsevents-nonce'] ) ) { 
  4. $nonce = 'monsterinsights-switch-to-jsevents-nonce'; 
  5. } else if ( ! empty( $_REQUEST['_wpnonce'] ) ) { 
  6. $nonce = '_wpnonce'; 
  7.  
  8. if ( empty( $nonce ) ) { 
  9. return; 
  10.  
  11. if ( ! wp_verify_nonce( $_REQUEST[$nonce], 'monsterinsights-switch-to-jsevents-nonce' ) ) { 
  12. return; 
  13.  
  14. if ( empty( $_REQUEST['monsterinsights-action'] ) || $_REQUEST['monsterinsights-action'] !== 'switch_to_jsevents' ) { 
  15. return; 
  16.  
  17. if ( ! current_user_can( 'monsterinsights_save_settings' ) ) { 
  18. wp_die( esc_html__( 'You do not have permission to manage MonsterInsights settings', 'google-analytics-for-wordpress' ), esc_html__( 'Error', 'google-analytics-for-wordpress' ), array( 'response' => 403 ) ); 
  19.  
  20. $return = ''; 
  21. $allowed_tabs = array( 'engagement', 'performance', 'ecommerce', 'demographics', 'dimensions' ); 
  22. if ( ! empty( $_REQUEST['return'] ) && in_array( $_REQUEST['return'], $allowed_tabs ) ) { 
  23. $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched#monsterinsights-main-tab-tracking?monsterinsights-sub-tab-') . $_REQUEST['return']; 
  24. $return = add_query_arg( 'return', $_REQUEST['return'], $return ); 
  25. } else { 
  26. $return = admin_url( 'admin.php?page=monsterinsights_settings&monsterinsights-message=jsvents_mode_switched'); 
  27. monsterinsights_update_option( 'events_mode', 'js' ); 
  28. wp_safe_redirect( $return );exit;