Google Analytics Dashboard for WP (GADWP) - Version 5.2

Version Description

  • Enhancements:
    • improvements on exponential backoff system
    • introduces a new authentication method with endpoints
    • multiple updates of plugin's options
    • code cleanup
    • improvements on error reporting system
    • option to report errors to developer
    • move the upgrade notice from the Dashboard to plugin's settings page
    • enable PHP cURL proxy support using WordPress settings, props by Joe Hobson
    • hide unusable options based on plugin's settings
  • Bug Fixes:
    • some thrown errors were not displayed on Errors & Debug screen
    • analytics icon disappears from post list after quick edit, props by karex
    • fix for inline SVG links, props by Andrew Minion
    • fixes a bug on affiliate events tracking
Download this release

Release Info

Developer deconf
Plugin Icon 128x128 Google Analytics Dashboard for WP (GADWP)
Version 5.2
Comparing to
See all releases

Code changes from version 5.1.2.5 to 5.2

admin/ajax-actions.php CHANGED
@@ -20,7 +20,7 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) {
24
  // Items action
25
  add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
26
  }
@@ -66,10 +66,10 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
66
  ob_clean();
67
  }
68
 
69
- if ( ! ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) ) {
70
  wp_die( - 31 );
71
  }
72
- if ( $this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail'] && $from && $to ) {
73
  if ( null === $this->gadwp->gapi_controller ) {
74
  $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
75
  }
@@ -77,9 +77,9 @@ if ( ! class_exists( 'GADWP_Backend_Ajax' ) ) {
77
  wp_die( - 24 );
78
  }
79
  if ( false == $projectId ) {
80
- $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
81
  }
82
- $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_dash_profile_list'], $projectId );
83
  if ( isset( $profile_info[4] ) ) {
84
  $this->gadwp->gapi_controller->timeshift = $profile_info[4];
85
  } else {
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) {
24
  // Items action
25
  add_action( 'wp_ajax_gadwp_backend_item_reports', array( $this, 'ajax_item_reports' ) );
26
  }
66
  ob_clean();
67
  }
68
 
69
+ if ( ! ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( ( 1 == $this->gadwp->config->options['backend_item_reports'] ) || ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) ) ) {
70
  wp_die( - 31 );
71
  }
72
+ if ( $this->gadwp->config->options['token'] && $this->gadwp->config->options['tableid_jail'] && $from && $to ) {
73
  if ( null === $this->gadwp->gapi_controller ) {
74
  $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
75
  }
77
  wp_die( - 24 );
78
  }
79
  if ( false == $projectId ) {
80
+ $projectId = $this->gadwp->config->options['tableid_jail'];
81
  }
82
+ $profile_info = GADWP_Tools::get_selected_profile( $this->gadwp->config->options['ga_profiles_list'], $projectId );
83
  if ( isset( $profile_info[4] ) ) {
84
  $this->gadwp->gapi_controller->timeshift = $profile_info[4];
85
  } else {
admin/css/gadwp.css CHANGED
@@ -1 +1 @@
1
- #gadwp-events,#gadwp-custom,#gadwp-advanced,#gadwp-exclude,#gadwp-config,#gadwp-tmdatalayervars,#gadwp-tmintegration,#gadwp-integration{display:none}table.gadwp-settings-options{padding-left:10px;width:100%}.gadwp-settings-options td{padding:0 5px 5px 5px}td.gadwp-settings-title,td.info{width:140px;padding-left:20px}td.gadwp-settings-title-s{width:300px}.gadwp-help{padding-left:15px}td.gadwp-settings-info{padding-bottom:15px}td.gadwp-settings-title label{font-size:1.1em}.gadash-title{float:left;margin-right:10px;margin-top:2px;clear:left}.gadash-desc{font-size:1em}.gadash-top{vertical-align:top}pre.gadwp-settings-logdata{white-space:pre-wrap}td.gadwp-settings-roles{padding-bottom:15px}#ga_speed_samplerate,#ga_user_samplerate,#ga_realtime_pages{width:50px}#gapi-access-code{color:red !important}#poststuff.gadwp h2{padding-bottom:0;font-size:19.5px;font-weight:normal;padding:0;margin:20px 0 15px 0}#poststuff.gadwp h2.nav-tab-wrapper{border-bottom:1px solid #ccc;padding-bottom:0}.button-primary.gadwp-settings-switchoo{position:relative;width:50px;float:left;border:0;padding:0;height:22px;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}input.gadwp-settings-switchoo-checkbox{display:none}.gadwp-settings-switchoo-label{display:block;overflow:hidden;cursor:pointer;background:transparent;border:1px solid #ddd;border-radius:2px;text-shadow:none}.gadwp-settings-switchoo-inner{width:200%;margin-left:-100%;border-radius:2px;-moz-transition:margin .2s ease-in 0;-webkit-transition:margin .2s ease-in 0;-o-transition:margin .2s ease-in 0;transition:margin .2s ease-in 0}.gadwp-settings-switchoo-inner:before,.gadwp-settings-switchoo-inner:after{float:left;width:50%;font-weight:normal;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;height:22px;line-height:22px;font-size:12px;text-shadow:none}.gadwp-settings-switchoo-inner:before{content:"On";padding-left:5px;border-bottom:0}.gadwp-settings-switchoo-inner:after{content:"Off";padding-right:5px;background-color:#ddd;text-align:right}.gadwp-settings-switchoo-switch{width:22px;height:22px;background:#fff;color:#ddd;border:1px solid #ddd;border-radius:2px;position:absolute;top:0;bottom:0;right:27px;-moz-transition:all .2s ease-in 0;-webkit-transition:all .2s ease-in 0;-o-transition:all .2s ease-in 0;transition:all .2s ease-in 0}.gadwp-settings-switchoo-switch:hover{color:#aaa;border-color:#aaa}.gadwp-settings-switchoo-switch:after{margin:0;outline:0;display:inline-block;font:400 16px/16px dashicons;content:"\f228";padding:3px 0 0 3px;text-align:left;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-inner{margin-left:0}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-switch{right:0}.switch-desc{float:left;margin-left:10px;line-height:20px}
1
+ #gadwp-events,#gadwp-custom,#gadwp-advanced,#gadwp-exclude,#gadwp-config,#gadwp-tmdatalayervars,#gadwp-tmintegration,#gadwp-integration{display:none}table.gadwp-settings-options{padding-left:10px;width:100%}.gadwp-settings-options td{padding:0 5px 5px 5px}td.gadwp-settings-title,td.info{width:140px;padding-left:20px}td.gadwp-settings-title-s{width:300px}.gadwp-help{padding-left:15px}td.gadwp-settings-info{padding-bottom:15px}td.gadwp-settings-title label{font-size:1.1em}.gadwp-title{float:left;margin-right:10px;margin-top:2px;clear:left}.gadwp-desc{font-size:1em}.gadwp-top{vertical-align:top}pre.gadwp-settings-logdata{white-space:pre-wrap}td.gadwp-settings-roles{padding-bottom:15px}#ga_speed_samplerate,#ga_user_samplerate,#ga_realtime_pages{width:50px}#gapi-access-code{color:red !important}#poststuff.gadwp h2{padding-bottom:0;font-size:19.5px;font-weight:normal;padding:0;margin:20px 0 15px 0}#poststuff.gadwp h2.nav-tab-wrapper{border-bottom:1px solid #ccc;padding-bottom:0}.button-primary.gadwp-settings-switchoo{position:relative;width:50px;float:left;border:0;padding:0;height:22px;-moz-box-shadow:none;-webkit-box-shadow:none;-o-box-shadow:none;box-shadow:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}input.gadwp-settings-switchoo-checkbox{display:none}.gadwp-settings-switchoo-label{display:block;overflow:hidden;cursor:pointer;background:transparent;border:1px solid #ddd;border-radius:2px;text-shadow:none}.gadwp-settings-switchoo-inner{width:200%;margin-left:-100%;border-radius:2px;-moz-transition:margin .2s ease-in 0;-webkit-transition:margin .2s ease-in 0;-o-transition:margin .2s ease-in 0;transition:margin .2s ease-in 0}.gadwp-settings-switchoo-inner:before,.gadwp-settings-switchoo-inner:after{float:left;width:50%;font-weight:normal;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;-o-box-sizing:border-box;box-sizing:border-box;height:22px;line-height:22px;font-size:12px;text-shadow:none}.gadwp-settings-switchoo-inner:before{content:"On";padding-left:5px;border-bottom:0}.gadwp-settings-switchoo-inner:after{content:"Off";padding-right:5px;background-color:#ddd;text-align:right}.gadwp-settings-switchoo-switch{width:22px;height:22px;background:#fff;color:#ddd;border:1px solid #ddd;border-radius:2px;position:absolute;top:0;bottom:0;right:27px;-moz-transition:all .2s ease-in 0;-webkit-transition:all .2s ease-in 0;-o-transition:all .2s ease-in 0;transition:all .2s ease-in 0}.gadwp-settings-switchoo-switch:hover{color:#aaa;border-color:#aaa}.gadwp-settings-switchoo-switch:after{margin:0;outline:0;display:inline-block;font:400 16px/16px dashicons;content:"\f228";padding:3px 0 0 3px;text-align:left;text-decoration:none;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-inner{margin-left:0}.gadwp-settings-switchoo-checkbox:checked+.gadwp-settings-switchoo-label .gadwp-settings-switchoo-switch{right:0}.switch-desc{float:left;margin-left:10px;line-height:20px}
admin/images/{gadash-icon.png → gadwp-icon.png} RENAMED
File without changes
admin/item-reports.php CHANGED
@@ -20,7 +20,7 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
  // Add custom column in Posts List
25
  add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
 
@@ -45,7 +45,7 @@ if ( ! class_exists( 'GADWP_Backend_Item_Reports' ) ) {
45
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area">&nbsp;</a>';
47
  } else {
48
- echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '"><img class="gadwp-icon-oldwp" src="' . GADWP_URL . 'admin/images/gadash-icon.png"</a>';
49
  }
50
  }
51
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
 
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && 1 == $this->gadwp->config->options['backend_item_reports'] ) {
24
  // Add custom column in Posts List
25
  add_filter( 'manage_posts_columns', array( $this, 'add_columns' ) );
26
 
45
  if ( version_compare( $wp_version, '3.8.0', '>=' ) ) {
46
  echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area">&nbsp;</a>';
47
  } else {
48
+ echo '<a id="gadwp-' . $id . '" title="' . get_the_title( $id ) . '" href="#' . $id . '"><img class="gadwp-icon-oldwp" src="' . GADWP_URL . 'admin/images/gadwp-icon.png"</a>';
49
  }
50
  }
51
 
admin/js/settings.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){if(window.location.href.indexOf("page=gadash_")!=-1){var a="basic";if(window.location.hash){a=window.location.hash.split("#")[2].split("-")[1]}else{if(window.location.href.indexOf("page=gadash_errors_debugging")!=-1){a="errors"}}jQuery(".nav-tab-wrapper a").each(function(b){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery("#tab-"+a).addClass("nav-tab-active");jQuery("#gadwp-"+a).show()}jQuery('a[href^="#"]').click(function(b){if(window.location.href.indexOf("page=gadash_")!=-1){jQuery(".nav-tab-wrapper a").each(function(c){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery(this).addClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).show()}})});
1
+ jQuery(document).ready(function(){if(window.location.href.indexOf("page=gadwp_")!=-1){var a="basic";if(window.location.hash){a=window.location.hash.split("#")[2].split("-")[1]}else{if(window.location.href.indexOf("page=gadwp_errors_debugging")!=-1){a="errors"}}jQuery(".nav-tab-wrapper a").each(function(b){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery("#tab-"+a).addClass("nav-tab-active");jQuery("#gadwp-"+a).show()}jQuery('a[href^="#"]').click(function(b){if(window.location.href.indexOf("page=gadwp_")!=-1){jQuery(".nav-tab-wrapper a").each(function(c){jQuery(this).removeClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).hide()});jQuery(this).addClass("nav-tab-active");jQuery("#"+this.hash.split("#")[2]).show()}})});
admin/js/ui.js CHANGED
@@ -1 +1 @@
1
- "use strict";jQuery(document).ready(function(){var a={action:"gadwp_dismiss_notices",gadwp_security_dismiss_notices:gadwp_ui_data.security};jQuery("#gadwp-notice .notice-dismiss").click(function(){jQuery.post(gadwp_ui_data.ajaxurl,a)});if(gadwp_ui_data.ed_bubble!=""){jQuery('#toplevel_page_gadash_settings li > a[href*="page=gadash_errors_debugging"]').append('&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;">'+gadwp_ui_data.ed_bubble+"</span></span>")}});
1
+ "use strict";jQuery(document).ready(function(){var a={action:"gadwp_dismiss_notices",gadwp_security_dismiss_notices:gadwp_ui_data.security};jQuery("#gadwp-notice .notice-dismiss").click(function(){jQuery.post(gadwp_ui_data.ajaxurl,a)});if(gadwp_ui_data.ed_bubble!=""){jQuery('#toplevel_page_gadwp_settings li > a[href*="page=gadwp_errors_debugging"]').append('&nbsp;<span class="awaiting-mod count-1"><span class="pending-count" style="padding:0 7px;">'+gadwp_ui_data.ed_bubble+"</span></span>")}});
admin/js/wp-color-picker-script.js CHANGED
@@ -1 +1 @@
1
- jQuery(document).ready(function(){jQuery(".ga_dash_style").wpColorPicker()});
1
+ jQuery(document).ready(function(){jQuery(".theme_color").wpColorPicker()});
admin/settings.php CHANGED
@@ -18,14 +18,14 @@ final class GADWP_Settings {
18
  $gadwp = GADWP();
19
  $network_settings = false;
20
  $options = $gadwp->config->options; // Get current options
21
- if ( isset( $_POST['options']['ga_dash_hidden'] ) && isset( $_POST['options'] ) && ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) && 'Reset' != $who ) {
22
  $new_options = $_POST['options'];
23
  if ( 'tracking' == $who ) {
24
- $options['ga_dash_anonim'] = 0;
25
  $options['ga_event_tracking'] = 0;
26
  $options['ga_enhanced_links'] = 0;
27
  $options['ga_event_precision'] = 0;
28
- $options['ga_dash_remarketing'] = 0;
29
  $options['ga_event_bouncerate'] = 0;
30
  $options['ga_crossdomain_tracking'] = 0;
31
  $options['ga_aff_tracking'] = 0;
@@ -44,30 +44,31 @@ final class GADWP_Settings {
44
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
45
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
46
  }
47
- if ( empty( $new_options['ga_track_exclude'] ) ) {
48
- $new_options['ga_track_exclude'] = array();
49
  }
50
  } elseif ( 'backend' == $who ) {
51
  $options['switch_profile'] = 0;
52
  $options['backend_item_reports'] = 0;
53
  $options['dashboard_widget'] = 0;
54
- if ( empty( $new_options['ga_dash_access_back'] ) ) {
55
- $new_options['ga_dash_access_back'][] = 'administrator';
 
56
  }
57
  } elseif ( 'frontend' == $who ) {
58
  $options['frontend_item_reports'] = 0;
59
- if ( empty( $new_options['ga_dash_access_front'] ) ) {
60
- $new_options['ga_dash_access_front'][] = 'administrator';
61
  }
62
  } elseif ( 'general' == $who ) {
63
- $options['ga_dash_userapi'] = 0;
64
  if ( ! is_multisite() ) {
65
  $options['automatic_updates_minorversion'] = 0;
66
  }
67
  } elseif ( 'network' == $who ) {
68
- $options['ga_dash_userapi'] = 0;
69
- $options['ga_dash_network'] = 0;
70
- $options['ga_dash_excludesa'] = 0;
71
  $options['automatic_updates_minorversion'] = 0;
72
  $network_settings = true;
73
  }
@@ -92,17 +93,17 @@ final class GADWP_Settings {
92
  return;
93
  }
94
  $options = self::update_options( 'frontend' );
95
- if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
96
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
97
- if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
98
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
99
  }
100
  }
101
- if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
102
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
103
  }
104
  ?>
105
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
106
  <div class="wrap">
107
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
108
  </div>
@@ -118,7 +119,7 @@ final class GADWP_Settings {
118
  </tr>
119
  <tr>
120
  <td class="roles gadwp-settings-title">
121
- <label for="ga_dash_access_front"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
122
  </label>
123
  </td>
124
  <td class="gadwp-settings-roles">
@@ -133,7 +134,7 @@ final class GADWP_Settings {
133
  <?php $i++; ?>
134
  <td>
135
  <label>
136
- <input type="checkbox" name="options[ga_dash_access_front][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['ga_dash_access_front']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /><?php echo $name; ?>
137
  </label>
138
  </td>
139
  <?php endif; ?>
@@ -168,8 +169,14 @@ final class GADWP_Settings {
168
  </td>
169
  </tr>
170
  </table>
171
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
172
- <?php wp_nonce_field('gadash_form','gadash_security');?>
 
 
 
 
 
 
173
  </form>
174
  <?php
175
  self::output_sidebar();
@@ -181,17 +188,17 @@ final class GADWP_Settings {
181
  return;
182
  }
183
  $options = self::update_options( 'backend' );
184
- if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
185
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
186
- if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
187
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
188
  }
189
  }
190
- if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
191
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
192
  }
193
  ?>
194
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
195
  <div class="wrap">
196
  <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
197
  </div>
@@ -207,7 +214,7 @@ final class GADWP_Settings {
207
  </tr>
208
  <tr>
209
  <td class="roles gadwp-settings-title">
210
- <label for="ga_dash_access_back"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
211
  </label>
212
  </td>
213
  <td class="gadwp-settings-roles">
@@ -222,7 +229,7 @@ final class GADWP_Settings {
222
  <?php $i++; ?>
223
  <td>
224
  <label>
225
- <input type="checkbox" name="options[ga_dash_access_back][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['ga_dash_access_back']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /> <?php echo $name; ?>
226
  </label>
227
  </td>
228
  <?php endif; ?>
@@ -231,6 +238,12 @@ final class GADWP_Settings {
231
  <tr>
232
  <?php endif; ?>
233
  <?php endforeach; ?>
 
 
 
 
 
 
234
  </table>
235
  </td>
236
  </tr>
@@ -274,6 +287,20 @@ final class GADWP_Settings {
274
  <td colspan="2">
275
  <hr><?php echo "<h2>" . __( "Real-Time Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
276
  </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
277
  <tr>
278
  <td colspan="2" class="gadwp-settings-title"> <?php _e("Maximum number of pages to display on real-time tab:", 'google-analytics-dashboard-for-wp'); ?>
279
  <input type="number" name="options[ga_realtime_pages]" id="ga_realtime_pages" value="<?php echo (int)$options['ga_realtime_pages']; ?>" size="3">
@@ -316,8 +343,14 @@ final class GADWP_Settings {
316
  </td>
317
  </tr>
318
  </table>
319
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
320
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
 
 
 
 
 
 
321
  </form>
322
  <?php
323
  self::output_sidebar();
@@ -330,17 +363,17 @@ final class GADWP_Settings {
330
  return;
331
  }
332
  $options = self::update_options( 'tracking' );
333
- if ( isset( $_POST['options']['ga_dash_hidden'] ) ) {
334
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
335
- if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
336
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
337
  }
338
  }
339
- if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
340
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
341
  }
342
  ?>
343
- <form name="ga_dash_form" method="post" action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
344
  <div class="wrap">
345
  <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
346
  </div>
@@ -349,9 +382,9 @@ final class GADWP_Settings {
349
  <div id="post-body-content">
350
  <div class="settings-wrapper">
351
  <div class="inside">
352
- <?php if ( 'universal' == $options['ga_dash_tracking_type'] ) :?>
353
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ), 'integration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
354
- <?php elseif ( 'tagmanager' == $options['ga_dash_tracking_type'] ) :?>
355
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'tmdatalayervars' => __( "DataLayer Variables", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'tmintegration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
356
  <?php else :?>
357
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ) );?>
@@ -367,29 +400,29 @@ final class GADWP_Settings {
367
  </tr>
368
  <tr>
369
  <td class="gadwp-settings-title">
370
- <label for="ga_dash_tracking_type"><?php _e("Tracking Type:", 'google-analytics-dashboard-for-wp' ); ?>
371
  </label>
372
  </td>
373
  <td>
374
- <select id="ga_dash_tracking_type" name="options[ga_dash_tracking_type]" onchange="this.form.submit()">
375
- <option value="universal" <?php selected( $options['ga_dash_tracking_type'], 'universal' ); ?>><?php _e("Analytics", 'google-analytics-dashboard-for-wp');?></option>
376
- <option value="tagmanager" <?php selected( $options['ga_dash_tracking_type'], 'tagmanager' ); ?>><?php _e("Tag Manager", 'google-analytics-dashboard-for-wp');?></option>
377
- <option value="disabled" <?php selected( $options['ga_dash_tracking_type'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
378
  </select>
379
  </td>
380
  </tr>
381
- <?php if ( 'universal' == $options['ga_dash_tracking_type'] ) : ?>
382
  <tr>
383
  <td class="gadwp-settings-title"></td>
384
  <td>
385
- <?php $profile_info = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail']); ?>
386
  <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
387
  </td>
388
  </tr>
389
- <?php elseif ( 'tagmanager' == $options['ga_dash_tracking_type'] ) : ?>
390
  <tr>
391
  <td class="gadwp-settings-title">
392
- <label for="ga_dash_tracking_type"><?php _e("Web Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
393
  </label>
394
  </td>
395
  <td>
@@ -715,8 +748,8 @@ final class GADWP_Settings {
715
  <tr>
716
  <td colspan="2" class="gadwp-settings-title">
717
  <div class="button-primary gadwp-settings-switchoo">
718
- <input type="checkbox" name="options[ga_dash_anonim]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_anonim" <?php checked( $options['ga_dash_anonim'], 1 ); ?>>
719
- <label class="gadwp-settings-switchoo-label" for="ga_dash_anonim">
720
  <div class="gadwp-settings-switchoo-inner"></div>
721
  <div class="gadwp-settings-switchoo-switch"></div>
722
  </label>
@@ -727,8 +760,8 @@ final class GADWP_Settings {
727
  <tr>
728
  <td colspan="2" class="gadwp-settings-title">
729
  <div class="button-primary gadwp-settings-switchoo">
730
- <input type="checkbox" name="options[ga_dash_remarketing]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_remarketing" <?php checked( $options['ga_dash_remarketing'], 1 ); ?>>
731
- <label class="gadwp-settings-switchoo-label" for="ga_dash_remarketing">
732
  <div class="gadwp-settings-switchoo-inner"></div>
733
  <div class="gadwp-settings-switchoo-switch"></div>
734
  </label>
@@ -875,7 +908,7 @@ final class GADWP_Settings {
875
  </tr>
876
  <tr>
877
  <td class="gadwp-settings-title">
878
- <label for="ga_dash_tracking_type"><?php _e("Ecommerce Tracking:", 'google-analytics-dashboard-for-wp' ); ?>
879
  </label>
880
  </td>
881
  <td>
@@ -915,7 +948,7 @@ final class GADWP_Settings {
915
  </tr>
916
  <tr>
917
  <td class="gadwp-settings-title">
918
- <label for="ga_dash_tracking_type"><?php _e("Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
919
  </label>
920
  </td>
921
  <td>
@@ -943,7 +976,7 @@ final class GADWP_Settings {
943
  </tr>
944
  <tr>
945
  <td class="gadwp-settings-title">
946
- <label for="ga_dash_tracking_type"><?php _e("AMP Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
947
  </label>
948
  </td>
949
  <td>
@@ -959,7 +992,7 @@ final class GADWP_Settings {
959
  </tr>
960
  <tr>
961
  <td class="roles gadwp-settings-title">
962
- <label for="ga_track_exclude"><?php _e("Exclude tracking for:", 'google-analytics-dashboard-for-wp' ); ?></label>
963
  </td>
964
  <td class="gadwp-settings-roles">
965
  <table>
@@ -973,7 +1006,7 @@ final class GADWP_Settings {
973
  <?php $i++; ?>
974
  <td>
975
  <label>
976
- <input type="checkbox" name="options[ga_track_exclude][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_track_exclude'])) echo 'checked="checked"'; ?> /> <?php echo $name; ?>
977
  </label>
978
  </td>
979
  <?php endif; ?>
@@ -982,6 +1015,12 @@ final class GADWP_Settings {
982
  <tr>
983
  <?php endif; ?>
984
  <?php endforeach; ?>
 
 
 
 
 
 
985
  </table>
986
  </td>
987
  </tr>
@@ -999,15 +1038,20 @@ final class GADWP_Settings {
999
  </td>
1000
  </tr>
1001
  </table>
1002
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1003
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
 
 
 
 
 
 
1004
  </form>
1005
  <?php
1006
  self::output_sidebar();
1007
  }
1008
 
1009
  public static function errors_debugging() {
1010
- global $wp_version;
1011
 
1012
  $gadwp = GADWP();
1013
 
@@ -1015,21 +1059,11 @@ final class GADWP_Settings {
1015
  return;
1016
  }
1017
 
1018
- $anonim = $gadwp->config->options;
1019
- $anonim['wp_version'] = $wp_version;
1020
- $anonim['gadwp_version'] = GADWP_CURRENT_VERSION;
1021
- if ( $anonim['ga_dash_token'] ) {
1022
- $anonim['ga_dash_token'] = 'HIDDEN';
1023
- }
1024
- if ( $anonim['ga_dash_clientid'] ) {
1025
- $anonim['ga_dash_clientid'] = 'HIDDEN';
1026
- }
1027
- if ( $anonim['ga_dash_clientsecret'] ) {
1028
- $anonim['ga_dash_clientsecret'] = 'HIDDEN';
1029
- }
1030
  $options = self::update_options( 'frontend' );
1031
- if ( ! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token'] ) {
1032
- $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1033
  }
1034
  ?>
1035
  <div class="wrap">
@@ -1047,22 +1081,17 @@ final class GADWP_Settings {
1047
  <table class="gadwp-settings-options">
1048
  <tr>
1049
  <td>
1050
- <?php echo "<h2>" . __( "Last Error detected", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1051
  </td>
1052
  </tr>
1053
  <tr>
1054
  <td>
1055
- <?php $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' ); ?>
 
 
 
1056
  <pre class="gadwp-settings-logdata"><?php echo __("Last Error: ", 'google-analytics-dashboard-for-wp') . $errors;?></pre>
1057
- </td>
1058
- </tr>
1059
- <tr>
1060
- <td colspan="2">
1061
- <hr><?php echo "<h2>" . __( "Error Details", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
1062
- </tr>
1063
- <tr>
1064
- <td>
1065
- <pre class="gadwp-settings-logdata"><?php _e("Error Details: ", 'google-analytics-dashboard-for-wp'); $error_details = print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ? "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : __( "None", 'google-analytics-dashboard-for-wp' ); echo $error_details; ?></pre>
1066
  <br />
1067
  <hr>
1068
  </td>
@@ -1109,8 +1138,6 @@ final class GADWP_Settings {
1109
  public static function general_settings() {
1110
  $gadwp = GADWP();
1111
 
1112
- global $wp_version;
1113
-
1114
  if ( ! current_user_can( 'manage_options' ) ) {
1115
  return;
1116
  }
@@ -1123,48 +1150,48 @@ final class GADWP_Settings {
1123
  if ( isset( $_POST['gadwp_access_code'] ) ) {
1124
  if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1125
  try {
 
1126
  $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1127
- $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
1128
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1129
  $gadwp->config->set_plugin_options();
1130
  $options = self::update_options( 'general' );
1131
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1132
  GADWP_Tools::delete_cache( 'gapi_errors' );
1133
  GADWP_Tools::delete_cache( 'last_error' );
1134
- if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1135
- if ( ! empty( $gadwp->config->options['ga_dash_profile_list'] ) ) {
1136
- $profiles = $gadwp->config->options['ga_dash_profile_list'];
1137
  } else {
1138
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1139
  }
1140
  if ( $profiles ) {
1141
- $gadwp->config->options['ga_dash_profile_list'] = $profiles;
1142
- if ( ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1143
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1144
- $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1145
- // $gadwp->config->options['ga_dash_tableid'] = $profile;
1146
  }
1147
  $gadwp->config->set_plugin_options();
1148
  $options = self::update_options( 'general' );
1149
  }
1150
  }
1151
  } catch ( Deconf_IO_Exception $e ) {
1152
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $e ), $gadwp->gapi_controller->error_timeout );
1153
- return false;
1154
  } catch ( Deconf_Service_Exception $e ) {
1155
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( "(" . $e->getCode() . ") " . $e->getMessage() ), $gadwp->gapi_controller->error_timeout );
1156
- GADWP_Tools::set_cache( 'gapi_errors', $e->getErrors(), $gadwp->gapi_controller->error_timeout );
1157
- return $e->getCode();
1158
  } catch ( Exception $e ) {
1159
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $e ) . "\nResponseHttpCode:" . $e->getCode(), $gadwp->gapi_controller->error_timeout );
1160
- $gadwp->gapi_controller->reset_token( false );
 
1161
  }
1162
  } else {
1163
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1164
  }
1165
  }
1166
  if ( isset( $_POST['Clear'] ) ) {
1167
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1168
  GADWP_Tools::clear_cache();
1169
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1170
  } else {
@@ -1172,7 +1199,7 @@ final class GADWP_Settings {
1172
  }
1173
  }
1174
  if ( isset( $_POST['Reset'] ) ) {
1175
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1176
  $gadwp->gapi_controller->reset_token( true );
1177
  GADWP_Tools::clear_cache();
1178
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -1182,25 +1209,49 @@ final class GADWP_Settings {
1182
  }
1183
  }
1184
  if ( isset( $_POST['Reset_Err'] ) ) {
1185
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1186
  GADWP_Tools::delete_cache( 'last_error' );
1187
  GADWP_Tools::delete_cache( 'gapi_errors' );
 
1188
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All errors reseted.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1189
  } else {
1190
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1191
  }
1192
  }
1193
- if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Reset_Err'] ) ) {
1194
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1195
- if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
1196
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1197
  }
1198
  }
1199
  if ( isset( $_POST['Hide'] ) ) {
1200
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1201
  $message = "<div class='updated' id='gadwp-action'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1202
- $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1203
- $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
1204
  $options = self::update_options( 'general' );
1205
  } else {
1206
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -1217,7 +1268,7 @@ final class GADWP_Settings {
1217
  <div class="settings-wrapper">
1218
  <div class="inside">
1219
  <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1220
- <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1221
  <?php endif;?>
1222
  <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1223
  <?php GADWP_Tools::clear_cache(); ?>
@@ -1229,9 +1280,9 @@ final class GADWP_Settings {
1229
  <?php if ( isset( $message ) ) :?>
1230
  <?php echo $message;?>
1231
  <?php endif; ?>
1232
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1233
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1234
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1235
  <table class="gadwp-settings-options">
1236
  <tr>
1237
  <td colspan="2">
@@ -1243,39 +1294,39 @@ final class GADWP_Settings {
1243
  <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1244
  </td>
1245
  </tr>
1246
- <?php if (! $options['ga_dash_token'] || $options['ga_dash_userapi']) : ?>
1247
  <tr>
1248
  <td colspan="2" class="gadwp-settings-info">
1249
- <input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" <?php echo ($options['ga_dash_network'])?'disabled="disabled"':''; ?> /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1250
  </td>
1251
  </tr>
1252
  <?php endif; ?>
1253
- <?php if ($options['ga_dash_userapi']) : ?>
1254
  <tr>
1255
  <td class="gadwp-settings-title">
1256
- <label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label>
1257
  </td>
1258
  <td>
1259
- <input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required">
1260
  </td>
1261
  </tr>
1262
  <tr>
1263
  <td class="gadwp-settings-title">
1264
- <label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label>
1265
  </td>
1266
  <td>
1267
- <input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required">
1268
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1269
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1270
  </td>
1271
  </tr>
1272
  <?php endif; ?>
1273
- <?php if ( $options['ga_dash_token'] ) : ?>
1274
  <tr>
1275
  <td colspan="2">
1276
- <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
1277
  <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1278
- <input type="submit" name="Reset_Err" class="button button-secondary" value="<?php _e( "Reset Errors", 'google-analytics-dashboard-for-wp' ); ?>" />
1279
  </td>
1280
  </tr>
1281
  <tr>
@@ -1288,14 +1339,14 @@ final class GADWP_Settings {
1288
  </tr>
1289
  <tr>
1290
  <td class="gadwp-settings-title">
1291
- <label for="ga_dash_tableid_jail"><?php _e("Select View:", 'google-analytics-dashboard-for-wp' ); ?></label>
1292
  </td>
1293
  <td>
1294
- <select id="ga_dash_tableid_jail" <?php disabled(empty($options['ga_dash_profile_list']) || 1 == count($options['ga_dash_profile_list']), true); ?> name="options[ga_dash_tableid_jail]">
1295
- <?php if ( ! empty( $options['ga_dash_profile_list'] ) ) : ?>
1296
- <?php foreach ( $options['ga_dash_profile_list'] as $items ) : ?>
1297
  <?php if ( $items[3] ) : ?>
1298
- <option value="<?php echo esc_attr( $items[1] ); ?>" <?php selected( $items[1], $options['ga_dash_tableid_jail'] ); ?> title="<?php _e( "View Name:", 'google-analytics-dashboard-for-wp' ); ?> <?php echo esc_attr( $items[0] ); ?>">
1299
  <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) )?> &#8658; <?php echo esc_attr( $items[0] ); ?>
1300
  </option>
1301
  <?php endif; ?>
@@ -1304,26 +1355,26 @@ final class GADWP_Settings {
1304
  <option value=""><?php _e( "Property not found", 'google-analytics-dashboard-for-wp' ); ?></option>
1305
  <?php endif; ?>
1306
  </select>
1307
- <?php if ( count( $options['ga_dash_profile_list'] ) > 1 ) : ?>
1308
  &nbsp;<input type="submit" name="Hide" class="button button-secondary" value="<?php _e( "Lock Selection", 'google-analytics-dashboard-for-wp' ); ?>" />
1309
  <?php endif; ?>
1310
  </td>
1311
  </tr>
1312
- <?php if ( $options['ga_dash_tableid_jail'] ) : ?>
1313
  <tr>
1314
  <td class="gadwp-settings-title"></td>
1315
  <td>
1316
- <?php $profile_info = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] ); ?>
1317
  <pre><?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[0] ) . "<br />" . __( "Tracking ID:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[2] ) . "<br />" . __( "Default URL:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[3] ) . "<br />" . __( "Time Zone:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[5] );?></pre>
1318
  </td>
1319
  </tr>
1320
  <?php endif; ?>
1321
  <tr>
1322
  <td class="gadwp-settings-title">
1323
- <label for="ga_dash_style"><?php _e("Theme Color:", 'google-analytics-dashboard-for-wp' ); ?></label>
1324
  </td>
1325
  <td>
1326
- <input type="text" id="ga_dash_style" class="ga_dash_style" name="options[ga_dash_style]" value="<?php echo esc_attr($options['ga_dash_style']); ?>" size="10">
1327
  </td>
1328
  </tr>
1329
  <tr>
@@ -1366,7 +1417,7 @@ final class GADWP_Settings {
1366
  </tr>
1367
  <tr>
1368
  <td colspan="2">
1369
- <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
1370
  <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1371
  </td>
1372
  </tr>
@@ -1391,7 +1442,6 @@ final class GADWP_Settings {
1391
  // Network Settings
1392
  public static function general_settings_network() {
1393
  $gadwp = GADWP();
1394
- global $wp_version;
1395
 
1396
  if ( ! current_user_can( 'manage_network_options' ) ) {
1397
  return;
@@ -1410,8 +1460,10 @@ final class GADWP_Settings {
1410
  if ( isset( $_POST['gadwp_access_code'] ) ) {
1411
  if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1412
  try {
 
 
1413
  $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1414
- $gadwp->config->options['ga_dash_token'] = $gadwp->gapi_controller->client->getAccessToken();
1415
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1416
  $gadwp->config->set_plugin_options( true );
1417
  $options = self::update_options( 'network' );
@@ -1419,61 +1471,61 @@ final class GADWP_Settings {
1419
  if ( is_multisite() ) { // Cleanup errors on the entire network
1420
  foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1421
  switch_to_blog( $blog['blog_id'] );
 
1422
  GADWP_Tools::delete_cache( 'gapi_errors' );
1423
  restore_current_blog();
1424
  }
1425
  } else {
 
1426
  GADWP_Tools::delete_cache( 'gapi_errors' );
1427
  }
1428
- if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1429
- if ( ! empty( $gadwp->config->options['ga_dash_profile_list'] ) ) {
1430
- $profiles = $gadwp->config->options['ga_dash_profile_list'];
1431
  } else {
1432
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1433
  }
1434
  if ( $profiles ) {
1435
- $gadwp->config->options['ga_dash_profile_list'] = $profiles;
1436
- if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1437
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1438
- $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1439
- // $gadwp->config->options['ga_dash_tableid'] = $profile;
1440
  }
1441
  $gadwp->config->set_plugin_options( true );
1442
  $options = self::update_options( 'network' );
1443
  }
1444
  }
1445
  } catch ( Deconf_IO_Exception $e ) {
1446
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $e ), $gadwp->gapi_controller->error_timeout );
1447
- return false;
1448
  } catch ( Deconf_Service_Exception $e ) {
1449
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( "(" . $e->getCode() . ") " . $e->getMessage() ), $gadwp->gapi_controller->error_timeout );
1450
- GADWP_Tools::set_cache( 'gapi_errors', $e->getErrors(), $gadwp->gapi_controller->error_timeout );
1451
- return $e->getCode();
1452
  } catch ( Exception $e ) {
1453
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $e ) . "\nResponseHttpCode:" . $e->getCode(), $gadwp->gapi_controller->error_timeout );
1454
- $gadwp->gapi_controller->reset_token( false );
 
1455
  }
1456
  } else {
1457
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1458
  }
1459
  }
1460
  if ( isset( $_POST['Refresh'] ) ) {
1461
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1462
- $gadwp->config->options['ga_dash_profile_list'] = array();
1463
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1464
  $options = self::update_options( 'network' );
1465
- if ( $gadwp->config->options['ga_dash_token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1466
- if ( ! empty( $gadwp->config->options['ga_dash_profile_list'] ) ) {
1467
- $profiles = $gadwp->config->options['ga_dash_profile_list'];
1468
  } else {
1469
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1470
  }
1471
  if ( $profiles ) {
1472
- $gadwp->config->options['ga_dash_profile_list'] = $profiles;
1473
- if ( isset( $gadwp->config->options['ga_dash_tableid_jail'] ) && ! $gadwp->config->options['ga_dash_tableid_jail'] ) {
1474
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1475
- $gadwp->config->options['ga_dash_tableid_jail'] = $profile;
1476
- // $gadwp->config->options['ga_dash_tableid'] = $profile;
1477
  }
1478
  $gadwp->config->set_plugin_options( true );
1479
  $options = self::update_options( 'network' );
@@ -1484,7 +1536,7 @@ final class GADWP_Settings {
1484
  }
1485
  }
1486
  if ( isset( $_POST['Clear'] ) ) {
1487
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1488
  GADWP_Tools::clear_cache();
1489
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1490
  } else {
@@ -1492,7 +1544,7 @@ final class GADWP_Settings {
1492
  }
1493
  }
1494
  if ( isset( $_POST['Reset'] ) ) {
1495
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1496
  $gadwp->gapi_controller->reset_token( true );
1497
  GADWP_Tools::clear_cache();
1498
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -1501,17 +1553,17 @@ final class GADWP_Settings {
1501
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1502
  }
1503
  }
1504
- if ( isset( $_POST['options']['ga_dash_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
1505
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1506
- if ( ! ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) ) {
1507
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1508
  }
1509
  }
1510
  if ( isset( $_POST['Hide'] ) ) {
1511
- if ( isset( $_POST['gadash_security'] ) && wp_verify_nonce( $_POST['gadash_security'], 'gadash_form' ) ) {
1512
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1513
- $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_dash_profile_list'], $gadwp->config->options['ga_dash_tableid_jail'] );
1514
- $gadwp->config->options['ga_dash_profile_list'] = array( $lock_profile );
1515
  $options = self::update_options( 'network' );
1516
  } else {
1517
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
@@ -1528,7 +1580,7 @@ final class GADWP_Settings {
1528
  <div class="settings-wrapper">
1529
  <div class="inside">
1530
  <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1531
- <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadash_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1532
  <?php endif; ?>
1533
  <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1534
  <?php GADWP_Tools::clear_cache();?>
@@ -1540,9 +1592,9 @@ final class GADWP_Settings {
1540
  <?php if ( isset( $message ) ) : ?>
1541
  <?php echo $message; ?>
1542
  <?php endif; ?>
1543
- <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1544
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1545
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1546
  <table class="gadwp-settings-options">
1547
  <tr>
1548
  <td colspan="2">
@@ -1552,8 +1604,8 @@ final class GADWP_Settings {
1552
  <tr>
1553
  <td colspan="2" class="gadwp-settings-title">
1554
  <div class="button-primary gadwp-settings-switchoo">
1555
- <input type="checkbox" name="options[ga_dash_network]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_network" <?php checked( $options['ga_dash_network'], 1); ?> onchange="this.form.submit()">
1556
- <label class="gadwp-settings-switchoo-label" for="ga_dash_network">
1557
  <div class="gadwp-settings-switchoo-inner"></div>
1558
  <div class="gadwp-settings-switchoo-switch"></div>
1559
  </label>
@@ -1561,7 +1613,7 @@ final class GADWP_Settings {
1561
  <div class="switch-desc"><?php echo " ".__("use a single Google Analytics account for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1562
  </td>
1563
  </tr>
1564
- <?php if ($options['ga_dash_network']) : ?>
1565
  <tr>
1566
  <td colspan="2">
1567
  <hr>
@@ -1575,36 +1627,36 @@ final class GADWP_Settings {
1575
  <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1576
  </td>
1577
  </tr>
1578
- <?php if ( ! $options['ga_dash_token'] || $options['ga_dash_userapi'] ) : ?>
1579
  <tr>
1580
  <td colspan="2" class="gadwp-settings-info">
1581
- <input name="options[ga_dash_userapi]" type="checkbox" id="ga_dash_userapi" value="1" <?php checked( $options['ga_dash_userapi'], 1 ); ?> onchange="this.form.submit()" /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1582
  </td>
1583
  </tr>
1584
  <?php endif; ?>
1585
- <?php if ( $options['ga_dash_userapi'] ) : ?>
1586
  <tr>
1587
  <td class="gadwp-settings-title">
1588
- <label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?>
1589
  </label>
1590
  </td>
1591
  <td>
1592
- <input type="text" name="options[ga_dash_clientid]" value="<?php echo esc_attr($options['ga_dash_clientid']); ?>" size="40" required="required">
1593
  </td>
1594
  </tr>
1595
  <tr>
1596
  <td class="gadwp-settings-title">
1597
- <label for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?>
1598
  </label>
1599
  </td>
1600
  <td>
1601
- <input type="text" name="options[ga_dash_clientsecret]" value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>" size="40" required="required">
1602
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
1603
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1604
  </td>
1605
  </tr>
1606
  <?php endif; ?>
1607
- <?php if ( $options['ga_dash_token'] ) : ?>
1608
  <tr>
1609
  <td colspan="2">
1610
  <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" />
@@ -1622,21 +1674,21 @@ final class GADWP_Settings {
1622
  <?php echo "<h2>" . __( "Properties/Views Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1623
  </td>
1624
  </tr>
1625
- <?php if ( isset( $options['ga_dash_tableid_network'] ) ) : ?>
1626
- <?php $options['ga_dash_tableid_network'] = json_decode( json_encode( $options['ga_dash_tableid_network'] ), false ); ?>
1627
  <?php endif; ?>
1628
  <?php foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) : ?>
1629
  <tr>
1630
  <td class="gadwp-settings-title-s">
1631
- <label for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label>
1632
  </td>
1633
  <td>
1634
- <select id="ga_dash_tableid_network" <?php disabled(!empty($options['ga_dash_profile_list']),false);?> name="options[ga_dash_tableid_network][<?php echo $blog['blog_id'];?>]">
1635
- <?php if ( ! empty( $options['ga_dash_profile_list'] ) ) : ?>
1636
- <?php foreach ( $options['ga_dash_profile_list'] as $items ) : ?>
1637
  <?php if ( $items[3] ) : ?>
1638
  <?php $temp_id = $blog['blog_id']; ?>
1639
- <option value="<?php echo esc_attr( $items[1] );?>" <?php selected( $items[1], isset( $options['ga_dash_tableid_network']->$temp_id ) ? $options['ga_dash_tableid_network']->$temp_id : '');?> title="<?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] );?>">
1640
  <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) );?> &#8658; <?php echo esc_attr( $items[0] );?>
1641
  </option>
1642
  <?php endif; ?>
@@ -1675,8 +1727,8 @@ final class GADWP_Settings {
1675
  <tr>
1676
  <td colspan="2" class="gadwp-settings-title">
1677
  <div class="button-primary gadwp-settings-switchoo">
1678
- <input type="checkbox" name="options[ga_dash_excludesa]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_dash_excludesa"<?php checked( $options['ga_dash_excludesa'], 1); ?>">
1679
- <label class="gadwp-settings-switchoo-label" for="ga_dash_excludesa">
1680
  <div class="gadwp-settings-switchoo-inner"></div>
1681
  <div class="gadwp-settings-switchoo-switch"></div>
1682
  </label>
@@ -1748,7 +1800,7 @@ final class GADWP_Settings {
1748
  <span><?php _e("Follow & Review",'google-analytics-dashboard-for-wp')?></span>
1749
  </h3>
1750
  <div class="inside">
1751
- <div class="gadash-desc">
1752
  <div style="margin-left: -10px;">
1753
  <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1754
  </div>
@@ -1761,15 +1813,15 @@ final class GADWP_Settings {
1761
  </script>
1762
  </div>
1763
  <br />
1764
- <div class="gadash-desc">
1765
  <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1766
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1767
  </div>
1768
  <br />
1769
- <div class="gadash-title">
1770
  <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1771
  </div>
1772
- <div class="gadash-desc">
1773
  <?php printf(__('Your feedback and review are both important, %s!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">%s</a>', __('rate this plugin', 'google-analytics-dashboard-for-wp')));?>
1774
  </div>
1775
  </div>
@@ -1779,25 +1831,25 @@ final class GADWP_Settings {
1779
  <span><?php _e("Further Reading",'google-analytics-dashboard-for-wp')?></span>
1780
  </h3>
1781
  <div class="inside">
1782
- <div class="gadash-title">
1783
  <a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1784
  </div>
1785
- <div class="gadash-desc">
1786
  <?php printf(__('%s service with users tracking at IP level.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">%s</a>', __('Web Analytics', 'google-analytics-dashboard-for-wp')));?>
1787
  </div>
1788
  <br />
1789
- <div class="gadash-title">
1790
  <a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1791
  </div>
1792
- <div class="gadash-desc">
1793
  <?php printf(__('%s by moving your website to HTTPS/SSL.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">%s</a>', __('Improve search rankings', 'google-analytics-dashboard-for-wp')));?>
1794
  </div>
1795
  <br />
1796
- <div class="gadash-title">
1797
  <a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a>
1798
  </div>
1799
- <div class="gadash-desc">
1800
- <?php printf(__('Other %s written by the same author', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp">%s</a>', __('WordPress Plugins', 'google-analytics-dashboard-for-wp')));?>
1801
  </div>
1802
  </div>
1803
  </div>
18
  $gadwp = GADWP();
19
  $network_settings = false;
20
  $options = $gadwp->config->options; // Get current options
21
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && isset( $_POST['options'] ) && ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) && 'Reset' != $who ) {
22
  $new_options = $_POST['options'];
23
  if ( 'tracking' == $who ) {
24
+ $options['ga_anonymize_ip'] = 0;
25
  $options['ga_event_tracking'] = 0;
26
  $options['ga_enhanced_links'] = 0;
27
  $options['ga_event_precision'] = 0;
28
+ $options['ga_remarketing'] = 0;
29
  $options['ga_event_bouncerate'] = 0;
30
  $options['ga_crossdomain_tracking'] = 0;
31
  $options['ga_aff_tracking'] = 0;
44
  if ( isset( $_POST['options']['ga_tracking_code'] ) ) {
45
  $new_options['ga_tracking_code'] = trim( $new_options['ga_tracking_code'], "\t" );
46
  }
47
+ if ( empty( $new_options['track_exclude'] ) ) {
48
+ $new_options['track_exclude'] = array();
49
  }
50
  } elseif ( 'backend' == $who ) {
51
  $options['switch_profile'] = 0;
52
  $options['backend_item_reports'] = 0;
53
  $options['dashboard_widget'] = 0;
54
+ $options['backend_realtime_report'] = 0;
55
+ if ( empty( $new_options['access_back'] ) ) {
56
+ $new_options['access_back'][] = 'administrator';
57
  }
58
  } elseif ( 'frontend' == $who ) {
59
  $options['frontend_item_reports'] = 0;
60
+ if ( empty( $new_options['access_front'] ) ) {
61
+ $new_options['access_front'][] = 'administrator';
62
  }
63
  } elseif ( 'general' == $who ) {
64
+ $options['user_api'] = 0;
65
  if ( ! is_multisite() ) {
66
  $options['automatic_updates_minorversion'] = 0;
67
  }
68
  } elseif ( 'network' == $who ) {
69
+ $options['user_api'] = 0;
70
+ $options['network_mode'] = 0;
71
+ $options['superadmin_tracking'] = 0;
72
  $options['automatic_updates_minorversion'] = 0;
73
  $network_settings = true;
74
  }
93
  return;
94
  }
95
  $options = self::update_options( 'frontend' );
96
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
97
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
98
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
99
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
100
  }
101
  }
102
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
103
+ $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
104
  }
105
  ?>
106
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
107
  <div class="wrap">
108
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
109
  </div>
119
  </tr>
120
  <tr>
121
  <td class="roles gadwp-settings-title">
122
+ <label for="access_front"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
123
  </label>
124
  </td>
125
  <td class="gadwp-settings-roles">
134
  <?php $i++; ?>
135
  <td>
136
  <label>
137
+ <input type="checkbox" name="options[access_front][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['access_front']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /><?php echo $name; ?>
138
  </label>
139
  </td>
140
  <?php endif; ?>
169
  </td>
170
  </tr>
171
  </table>
172
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
173
+ <?php wp_nonce_field('gadwp_form','gadwp_security');?>
174
+
175
+
176
+
177
+
178
+
179
+
180
  </form>
181
  <?php
182
  self::output_sidebar();
188
  return;
189
  }
190
  $options = self::update_options( 'backend' );
191
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
192
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
193
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
194
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
195
  }
196
  }
197
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
198
+ $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
199
  }
200
  ?>
201
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
202
  <div class="wrap">
203
  <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?><hr>
204
  </div>
214
  </tr>
215
  <tr>
216
  <td class="roles gadwp-settings-title">
217
+ <label for="access_back"><?php _e("Show stats to:", 'google-analytics-dashboard-for-wp' ); ?>
218
  </label>
219
  </td>
220
  <td class="gadwp-settings-roles">
229
  <?php $i++; ?>
230
  <td>
231
  <label>
232
+ <input type="checkbox" name="options[access_back][]" value="<?php echo $role; ?>" <?php if ( in_array($role,$options['access_back']) || 'administrator' == $role ) echo 'checked="checked"'; if ( 'administrator' == $role ) echo 'disabled="disabled"';?> /> <?php echo $name; ?>
233
  </label>
234
  </td>
235
  <?php endif; ?>
238
  <tr>
239
  <?php endif; ?>
240
  <?php endforeach; ?>
241
+
242
+
243
+
244
+
245
+
246
+
247
  </table>
248
  </td>
249
  </tr>
287
  <td colspan="2">
288
  <hr><?php echo "<h2>" . __( "Real-Time Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?></td>
289
  </tr>
290
+ <?php if ( $options['user_api'] ) : ?>
291
+ <tr>
292
+ <td colspan="2" class="gadwp-settings-title">
293
+ <div class="button-primary gadwp-settings-switchoo">
294
+ <input type="checkbox" name="options[backend_realtime_report]" value="1" class="gadwp-settings-switchoo-checkbox" id="backend_realtime_report" <?php checked( $options['backend_realtime_report'], 1 ); ?>>
295
+ <label class="gadwp-settings-switchoo-label" for="backend_realtime_report">
296
+ <div class="gadwp-settings-switchoo-inner"></div>
297
+ <div class="gadwp-settings-switchoo-switch"></div>
298
+ </label>
299
+ </div>
300
+ <div class="switch-desc"><?php _e ( "enable Real-Time report (requires access to Real-Time Reporting API)", 'google-analytics-dashboard-for-wp' );?></div>
301
+ </td>
302
+ </tr>
303
+ <?php endif; ?>
304
  <tr>
305
  <td colspan="2" class="gadwp-settings-title"> <?php _e("Maximum number of pages to display on real-time tab:", 'google-analytics-dashboard-for-wp'); ?>
306
  <input type="number" name="options[ga_realtime_pages]" id="ga_realtime_pages" value="<?php echo (int)$options['ga_realtime_pages']; ?>" size="3">
343
  </td>
344
  </tr>
345
  </table>
346
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
347
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
348
+
349
+
350
+
351
+
352
+
353
+
354
  </form>
355
  <?php
356
  self::output_sidebar();
363
  return;
364
  }
365
  $options = self::update_options( 'tracking' );
366
+ if ( isset( $_POST['options']['gadwp_hidden'] ) ) {
367
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
368
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
369
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
370
  }
371
  }
372
+ if ( ! $gadwp->config->options['tableid_jail'] ) {
373
+ $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
374
  }
375
  ?>
376
+ <form name="gadwp_form" method="post" action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
377
  <div class="wrap">
378
  <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
379
  </div>
382
  <div id="post-body-content">
383
  <div class="settings-wrapper">
384
  <div class="inside">
385
+ <?php if ( 'universal' == $options['tracking_type'] ) :?>
386
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'events' => __( "Events Tracking", 'google-analytics-dashboard-for-wp' ), 'custom' => __( "Custom Definitions", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'advanced' => __( "Advanced Settings", 'google-analytics-dashboard-for-wp' ), 'integration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
387
+ <?php elseif ( 'tagmanager' == $options['tracking_type'] ) :?>
388
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ), 'tmdatalayervars' => __( "DataLayer Variables", 'google-analytics-dashboard-for-wp' ), 'exclude' => __( "Exclude Tracking", 'google-analytics-dashboard-for-wp' ), 'tmintegration' => __( "Integration", 'google-analytics-dashboard-for-wp' ) );?>
389
  <?php else :?>
390
  <?php $tabs = array( 'basic' => __( "Basic Settings", 'google-analytics-dashboard-for-wp' ) );?>
400
  </tr>
401
  <tr>
402
  <td class="gadwp-settings-title">
403
+ <label for="tracking_type"><?php _e("Tracking Type:", 'google-analytics-dashboard-for-wp' ); ?>
404
  </label>
405
  </td>
406
  <td>
407
+ <select id="tracking_type" name="options[tracking_type]" onchange="this.form.submit()">
408
+ <option value="universal" <?php selected( $options['tracking_type'], 'universal' ); ?>><?php _e("Analytics", 'google-analytics-dashboard-for-wp');?></option>
409
+ <option value="tagmanager" <?php selected( $options['tracking_type'], 'tagmanager' ); ?>><?php _e("Tag Manager", 'google-analytics-dashboard-for-wp');?></option>
410
+ <option value="disabled" <?php selected( $options['tracking_type'], 'disabled' ); ?>><?php _e("Disabled", 'google-analytics-dashboard-for-wp');?></option>
411
  </select>
412
  </td>
413
  </tr>
414
+ <?php if ( 'universal' == $options['tracking_type'] ) : ?>
415
  <tr>
416
  <td class="gadwp-settings-title"></td>
417
  <td>
418
+ <?php $profile_info = GADWP_Tools::get_selected_profile($gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail']); ?>
419
  <?php echo '<pre>' . __("View Name:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'google-analytics-dashboard-for-wp') . "\t" . esc_html($profile_info[5]) . '</pre>';?>
420
  </td>
421
  </tr>
422
+ <?php elseif ( 'tagmanager' == $options['tracking_type'] ) : ?>
423
  <tr>
424
  <td class="gadwp-settings-title">
425
+ <label for="tracking_type"><?php _e("Web Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
426
  </label>
427
  </td>
428
  <td>
748
  <tr>
749
  <td colspan="2" class="gadwp-settings-title">
750
  <div class="button-primary gadwp-settings-switchoo">
751
+ <input type="checkbox" name="options[ga_anonymize_ip]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_anonymize_ip" <?php checked( $options['ga_anonymize_ip'], 1 ); ?>>
752
+ <label class="gadwp-settings-switchoo-label" for="ga_anonymize_ip">
753
  <div class="gadwp-settings-switchoo-inner"></div>
754
  <div class="gadwp-settings-switchoo-switch"></div>
755
  </label>
760
  <tr>
761
  <td colspan="2" class="gadwp-settings-title">
762
  <div class="button-primary gadwp-settings-switchoo">
763
+ <input type="checkbox" name="options[ga_remarketing]" value="1" class="gadwp-settings-switchoo-checkbox" id="ga_remarketing" <?php checked( $options['ga_remarketing'], 1 ); ?>>
764
+ <label class="gadwp-settings-switchoo-label" for="ga_remarketing">
765
  <div class="gadwp-settings-switchoo-inner"></div>
766
  <div class="gadwp-settings-switchoo-switch"></div>
767
  </label>
908
  </tr>
909
  <tr>
910
  <td class="gadwp-settings-title">
911
+ <label for="tracking_type"><?php _e("Ecommerce Tracking:", 'google-analytics-dashboard-for-wp' ); ?>
912
  </label>
913
  </td>
914
  <td>
948
  </tr>
949
  <tr>
950
  <td class="gadwp-settings-title">
951
+ <label for="tracking_type"><?php _e("Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
952
  </label>
953
  </td>
954
  <td>
976
  </tr>
977
  <tr>
978
  <td class="gadwp-settings-title">
979
+ <label for="tracking_type"><?php _e("AMP Container ID:", 'google-analytics-dashboard-for-wp' ); ?>
980
  </label>
981
  </td>
982
  <td>
992
  </tr>
993
  <tr>
994
  <td class="roles gadwp-settings-title">
995
+ <label for="track_exclude"><?php _e("Exclude tracking for:", 'google-analytics-dashboard-for-wp' ); ?></label>
996
  </td>
997
  <td class="gadwp-settings-roles">
998
  <table>
1006
  <?php $i++; ?>
1007
  <td>
1008
  <label>
1009
+ <input type="checkbox" name="options[track_exclude][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['track_exclude'])) echo 'checked="checked"'; ?> /> <?php echo $name; ?>
1010
  </label>
1011
  </td>
1012
  <?php endif; ?>
1015
  <tr>
1016
  <?php endif; ?>
1017
  <?php endforeach; ?>
1018
+
1019
+
1020
+
1021
+
1022
+
1023
+
1024
  </table>
1025
  </td>
1026
  </tr>
1038
  </td>
1039
  </tr>
1040
  </table>
1041
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1042
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1043
+
1044
+
1045
+
1046
+
1047
+
1048
+
1049
  </form>
1050
  <?php
1051
  self::output_sidebar();
1052
  }
1053
 
1054
  public static function errors_debugging() {
 
1055
 
1056
  $gadwp = GADWP();
1057
 
1059
  return;
1060
  }
1061
 
1062
+ $anonim = GADWP_Tools::anonymize_options( $gadwp->config->options );
1063
+
 
 
 
 
 
 
 
 
 
 
1064
  $options = self::update_options( 'frontend' );
1065
+ if ( ! $gadwp->config->options['tableid_jail'] || ! $gadwp->config->options['token'] ) {
1066
+ $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );
1067
  }
1068
  ?>
1069
  <div class="wrap">
1081
  <table class="gadwp-settings-options">
1082
  <tr>
1083
  <td>
1084
+ <?php echo "<h2>" . __( "Error Details", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1085
  </td>
1086
  </tr>
1087
  <tr>
1088
  <td>
1089
+ <?php $errors_count = GADWP_Tools::get_cache( 'errors_count' ); ?>
1090
+ <pre class="gadwp-settings-logdata"><?php echo __("Count: ", 'google-analytics-dashboard-for-wp') . (int)$errors_count;?></pre>
1091
+ <?php $errors = print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ? esc_html( print_r( GADWP_Tools::get_cache( 'last_error' ), true ) ) : ''; ?>
1092
+ <?php $errors = str_replace( 'Deconf_', 'Google_', $errors); ?>
1093
  <pre class="gadwp-settings-logdata"><?php echo __("Last Error: ", 'google-analytics-dashboard-for-wp') . $errors;?></pre>
1094
+ <pre class="gadwp-settings-logdata"><?php _e("GAPI Error: ", 'google-analytics-dashboard-for-wp'); echo "\n" . esc_html( print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true ) ) ?></pre>
 
 
 
 
 
 
 
 
1095
  <br />
1096
  <hr>
1097
  </td>
1138
  public static function general_settings() {
1139
  $gadwp = GADWP();
1140
 
 
 
1141
  if ( ! current_user_can( 'manage_options' ) ) {
1142
  return;
1143
  }
1150
  if ( isset( $_POST['gadwp_access_code'] ) ) {
1151
  if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1152
  try {
1153
+ $gadwp_access_code = $_POST['gadwp_access_code'];
1154
  $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1155
+ $gadwp->config->options['token'] = $gadwp->gapi_controller->client->getAccessToken();
1156
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1157
  $gadwp->config->set_plugin_options();
1158
  $options = self::update_options( 'general' );
1159
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Plugin authorization succeeded.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1160
  GADWP_Tools::delete_cache( 'gapi_errors' );
1161
  GADWP_Tools::delete_cache( 'last_error' );
1162
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1163
+ if ( ! empty( $gadwp->config->options['ga_profiles_list'] ) ) {
1164
+ $profiles = $gadwp->config->options['ga_profiles_list'];
1165
  } else {
1166
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1167
  }
1168
  if ( $profiles ) {
1169
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1170
+ if ( ! $gadwp->config->options['tableid_jail'] ) {
1171
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1172
+ $gadwp->config->options['tableid_jail'] = $profile;
 
1173
  }
1174
  $gadwp->config->set_plugin_options();
1175
  $options = self::update_options( 'general' );
1176
  }
1177
  }
1178
  } catch ( Deconf_IO_Exception $e ) {
1179
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1180
+ GADWP_Tools::set_error( $e, $timeout );
1181
  } catch ( Deconf_Service_Exception $e ) {
1182
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1183
+ GADWP_Tools::set_error( $e, $timeout );
 
1184
  } catch ( Exception $e ) {
1185
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1186
+ GADWP_Tools::set_error( $e, $timeout );
1187
+ $gadwp->gapi_controller->reset_token( true );
1188
  }
1189
  } else {
1190
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1191
  }
1192
  }
1193
  if ( isset( $_POST['Clear'] ) ) {
1194
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1195
  GADWP_Tools::clear_cache();
1196
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1197
  } else {
1199
  }
1200
  }
1201
  if ( isset( $_POST['Reset'] ) ) {
1202
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1203
  $gadwp->gapi_controller->reset_token( true );
1204
  GADWP_Tools::clear_cache();
1205
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1209
  }
1210
  }
1211
  if ( isset( $_POST['Reset_Err'] ) ) {
1212
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1213
+
1214
+ $anonim = GADWP_Tools::anonymize_options( $gadwp->config->options );
1215
+
1216
+ $sep = "\n---------------------------\n";
1217
+ $error_report = GADWP_Tools::get_cache( 'last_error' );
1218
+ $error_report .= $sep . print_r( GADWP_Tools::get_cache( 'gapi_errors' ), true );
1219
+ $error_report .= $sep . GADWP_Tools::get_cache( 'errors_count' );
1220
+ $error_report .= $sep . print_r( $anonim, true );
1221
+
1222
+ $url = GADWP_ENDPOINT_URL . 'gadwp-report.php';
1223
+ /* @formatter:off */
1224
+ $response = wp_remote_post( $url, array(
1225
+ 'method' => 'POST',
1226
+ 'timeout' => 45,
1227
+ 'redirection' => 5,
1228
+ 'httpversion' => '1.0',
1229
+ 'blocking' => true,
1230
+ 'headers' => array(),
1231
+ 'body' => array( 'error_report' => $error_report ),
1232
+ 'cookies' => array()
1233
+ )
1234
+ );
1235
+ /* @formatter:on */
1236
  GADWP_Tools::delete_cache( 'last_error' );
1237
  GADWP_Tools::delete_cache( 'gapi_errors' );
1238
+ delete_option( 'gadwp_got_updated' );
1239
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All errors reseted.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1240
  } else {
1241
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1242
  }
1243
  }
1244
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Reset_Err'] ) ) {
1245
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1246
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
1247
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1248
  }
1249
  }
1250
  if ( isset( $_POST['Hide'] ) ) {
1251
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1252
  $message = "<div class='updated' id='gadwp-action'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1253
+ $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] );
1254
+ $gadwp->config->options['ga_profiles_list'] = array( $lock_profile );
1255
  $options = self::update_options( 'general' );
1256
  } else {
1257
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1268
  <div class="settings-wrapper">
1269
  <div class="inside">
1270
  <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1271
+ <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1272
  <?php endif;?>
1273
  <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1274
  <?php GADWP_Tools::clear_cache(); ?>
1280
  <?php if ( isset( $message ) ) :?>
1281
  <?php echo $message;?>
1282
  <?php endif; ?>
1283
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1284
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1285
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1286
  <table class="gadwp-settings-options">
1287
  <tr>
1288
  <td colspan="2">
1294
  <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1295
  </td>
1296
  </tr>
1297
+ <?php if (! $options['token'] || ($options['user_api'] && ! $options['network_mode'])) : ?>
1298
  <tr>
1299
  <td colspan="2" class="gadwp-settings-info">
1300
+ <input name="options[user_api]" type="checkbox" id="user_api" value="1" <?php checked( $options['user_api'], 1 ); ?> onchange="this.form.submit()" <?php echo ($options['network_mode'])?'disabled="disabled"':''; ?> /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1301
  </td>
1302
  </tr>
1303
  <?php endif; ?>
1304
+ <?php if ($options['user_api'] && ! $options['network_mode']) : ?>
1305
  <tr>
1306
  <td class="gadwp-settings-title">
1307
+ <label for="options[client_id]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?></label>
1308
  </td>
1309
  <td>
1310
+ <input type="text" name="options[client_id]" value="<?php echo esc_attr($options['client_id']); ?>" size="40" required="required">
1311
  </td>
1312
  </tr>
1313
  <tr>
1314
  <td class="gadwp-settings-title">
1315
+ <label for="options[client_secret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?></label>
1316
  </td>
1317
  <td>
1318
+ <input type="text" name="options[client_secret]" value="<?php echo esc_attr($options['client_secret']); ?>" size="40" required="required">
1319
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1320
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1321
  </td>
1322
  </tr>
1323
  <?php endif; ?>
1324
+ <?php if ( $options['token'] ) : ?>
1325
  <tr>
1326
  <td colspan="2">
1327
+ <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['network_mode']?'disabled="disabled"':''; ?> />
1328
  <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1329
+ <input type="submit" name="Reset_Err" class="button button-secondary" value="<?php _e( "Report & Reset Errors", 'google-analytics-dashboard-for-wp' ); ?>" />
1330
  </td>
1331
  </tr>
1332
  <tr>
1339
  </tr>
1340
  <tr>
1341
  <td class="gadwp-settings-title">
1342
+ <label for="tableid_jail"><?php _e("Select View:", 'google-analytics-dashboard-for-wp' ); ?></label>
1343
  </td>
1344
  <td>
1345
+ <select id="tableid_jail" <?php disabled(empty($options['ga_profiles_list']) || 1 == count($options['ga_profiles_list']), true); ?> name="options[tableid_jail]">
1346
+ <?php if ( ! empty( $options['ga_profiles_list'] ) ) : ?>
1347
+ <?php foreach ( $options['ga_profiles_list'] as $items ) : ?>
1348
  <?php if ( $items[3] ) : ?>
1349
+ <option value="<?php echo esc_attr( $items[1] ); ?>" <?php selected( $items[1], $options['tableid_jail'] ); ?> title="<?php _e( "View Name:", 'google-analytics-dashboard-for-wp' ); ?> <?php echo esc_attr( $items[0] ); ?>">
1350
  <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) )?> &#8658; <?php echo esc_attr( $items[0] ); ?>
1351
  </option>
1352
  <?php endif; ?>
1355
  <option value=""><?php _e( "Property not found", 'google-analytics-dashboard-for-wp' ); ?></option>
1356
  <?php endif; ?>
1357
  </select>
1358
+ <?php if ( count( $options['ga_profiles_list'] ) > 1 ) : ?>
1359
  &nbsp;<input type="submit" name="Hide" class="button button-secondary" value="<?php _e( "Lock Selection", 'google-analytics-dashboard-for-wp' ); ?>" />
1360
  <?php endif; ?>
1361
  </td>
1362
  </tr>
1363
+ <?php if ( $options['tableid_jail'] ) : ?>
1364
  <tr>
1365
  <td class="gadwp-settings-title"></td>
1366
  <td>
1367
+ <?php $profile_info = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] ); ?>
1368
  <pre><?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[0] ) . "<br />" . __( "Tracking ID:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[2] ) . "<br />" . __( "Default URL:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[3] ) . "<br />" . __( "Time Zone:", 'google-analytics-dashboard-for-wp' ) . "\t" . esc_html( $profile_info[5] );?></pre>
1369
  </td>
1370
  </tr>
1371
  <?php endif; ?>
1372
  <tr>
1373
  <td class="gadwp-settings-title">
1374
+ <label for="theme_color"><?php _e("Theme Color:", 'google-analytics-dashboard-for-wp' ); ?></label>
1375
  </td>
1376
  <td>
1377
+ <input type="text" id="theme_color" class="theme_color" name="options[theme_color]" value="<?php echo esc_attr($options['theme_color']); ?>" size="10">
1378
  </td>
1379
  </tr>
1380
  <tr>
1417
  </tr>
1418
  <tr>
1419
  <td colspan="2">
1420
+ <input type="submit" name="Authorize" class="button button-secondary" id="authorize" value="<?php _e( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ); ?>" <?php echo $options['network_mode']?'disabled="disabled"':''; ?> />
1421
  <input type="submit" name="Clear" class="button button-secondary" value="<?php _e( "Clear Cache", 'google-analytics-dashboard-for-wp' ); ?>" />
1422
  </td>
1423
  </tr>
1442
  // Network Settings
1443
  public static function general_settings_network() {
1444
  $gadwp = GADWP();
 
1445
 
1446
  if ( ! current_user_can( 'manage_network_options' ) ) {
1447
  return;
1460
  if ( isset( $_POST['gadwp_access_code'] ) ) {
1461
  if ( 1 == ! stripos( 'x' . $_POST['gadwp_access_code'], 'UA-', 1 ) ) {
1462
  try {
1463
+
1464
+ $gadwp_access_code = $_POST['gadwp_access_code'];
1465
  $gadwp->gapi_controller->client->authenticate( $_POST['gadwp_access_code'] );
1466
+ $gadwp->config->options['token'] = $gadwp->gapi_controller->client->getAccessToken();
1467
  $gadwp->config->options['automatic_updates_minorversion'] = 1;
1468
  $gadwp->config->set_plugin_options( true );
1469
  $options = self::update_options( 'network' );
1471
  if ( is_multisite() ) { // Cleanup errors on the entire network
1472
  foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) {
1473
  switch_to_blog( $blog['blog_id'] );
1474
+ GADWP_Tools::delete_cache( 'last_error' );
1475
  GADWP_Tools::delete_cache( 'gapi_errors' );
1476
  restore_current_blog();
1477
  }
1478
  } else {
1479
+ GADWP_Tools::delete_cache( 'last_error' );
1480
  GADWP_Tools::delete_cache( 'gapi_errors' );
1481
  }
1482
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1483
+ if ( ! empty( $gadwp->config->options['ga_profiles_list'] ) ) {
1484
+ $profiles = $gadwp->config->options['ga_profiles_list'];
1485
  } else {
1486
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1487
  }
1488
  if ( $profiles ) {
1489
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1490
+ if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
1491
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1492
+ $gadwp->config->options['tableid_jail'] = $profile;
 
1493
  }
1494
  $gadwp->config->set_plugin_options( true );
1495
  $options = self::update_options( 'network' );
1496
  }
1497
  }
1498
  } catch ( Deconf_IO_Exception $e ) {
1499
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1500
+ GADWP_Tools::set_error( $e, $timeout );
1501
  } catch ( Deconf_Service_Exception $e ) {
1502
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1503
+ GADWP_Tools::set_error( $e, $timeout );
 
1504
  } catch ( Exception $e ) {
1505
+ $timeout = $gadwp->gapi_controller->get_timeouts( 'midnight' );
1506
+ GADWP_Tools::set_error( $e, $timeout );
1507
+ $gadwp->gapi_controller->reset_token( true );
1508
  }
1509
  } else {
1510
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "The access code is <strong>NOT</strong> your <strong>Tracking ID</strong> (UA-XXXXX-X). Try again, and use the red link to get your access code", 'google-analytics-dashboard-for-wp' ) . ".</p></div>";
1511
  }
1512
  }
1513
  if ( isset( $_POST['Refresh'] ) ) {
1514
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1515
+ $gadwp->config->options['ga_profiles_list'] = array();
1516
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Properties refreshed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1517
  $options = self::update_options( 'network' );
1518
+ if ( $gadwp->config->options['token'] && $gadwp->gapi_controller->client->getAccessToken() ) {
1519
+ if ( ! empty( $gadwp->config->options['ga_profiles_list'] ) ) {
1520
+ $profiles = $gadwp->config->options['ga_profiles_list'];
1521
  } else {
1522
  $profiles = $gadwp->gapi_controller->refresh_profiles();
1523
  }
1524
  if ( $profiles ) {
1525
+ $gadwp->config->options['ga_profiles_list'] = $profiles;
1526
+ if ( isset( $gadwp->config->options['tableid_jail'] ) && ! $gadwp->config->options['tableid_jail'] ) {
1527
  $profile = GADWP_Tools::guess_default_domain( $profiles );
1528
+ $gadwp->config->options['tableid_jail'] = $profile;
 
1529
  }
1530
  $gadwp->config->set_plugin_options( true );
1531
  $options = self::update_options( 'network' );
1536
  }
1537
  }
1538
  if ( isset( $_POST['Clear'] ) ) {
1539
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1540
  GADWP_Tools::clear_cache();
1541
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Cleared Cache.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1542
  } else {
1544
  }
1545
  }
1546
  if ( isset( $_POST['Reset'] ) ) {
1547
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1548
  $gadwp->gapi_controller->reset_token( true );
1549
  GADWP_Tools::clear_cache();
1550
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Token Reseted and Revoked.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1553
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1554
  }
1555
  }
1556
+ if ( isset( $_POST['options']['gadwp_hidden'] ) && ! isset( $_POST['Clear'] ) && ! isset( $_POST['Reset'] ) && ! isset( $_POST['Refresh'] ) ) {
1557
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "Settings saved.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1558
+ if ( ! ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) ) {
1559
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1560
  }
1561
  }
1562
  if ( isset( $_POST['Hide'] ) ) {
1563
+ if ( isset( $_POST['gadwp_security'] ) && wp_verify_nonce( $_POST['gadwp_security'], 'gadwp_form' ) ) {
1564
  $message = "<div class='updated' id='gadwp-autodismiss'><p>" . __( "All other domains/properties were removed.", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1565
+ $lock_profile = GADWP_Tools::get_selected_profile( $gadwp->config->options['ga_profiles_list'], $gadwp->config->options['tableid_jail'] );
1566
+ $gadwp->config->options['ga_profiles_list'] = array( $lock_profile );
1567
  $options = self::update_options( 'network' );
1568
  } else {
1569
  $message = "<div class='error' id='gadwp-autodismiss'><p>" . __( "Cheating Huh?", 'google-analytics-dashboard-for-wp' ) . "</p></div>";
1580
  <div class="settings-wrapper">
1581
  <div class="inside">
1582
  <?php if ( $gadwp->gapi_controller->gapi_errors_handler() || GADWP_Tools::get_cache( 'last_error' ) ) : ?>
1583
+ <?php $message = sprintf( '<div class="error"><p>%s</p></div>', sprintf( __( 'Something went wrong, check %1$s or %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_errors_debugging', false ), __( 'Errors & Debug', 'google-analytics-dashboard-for-wp' ) ), sprintf( '<a href="%1$s">%2$s</a>', menu_page_url( 'gadwp_settings', false ), __( 'authorize the plugin', 'google-analytics-dashboard-for-wp' ) ) ) );?>
1584
  <?php endif; ?>
1585
  <?php if ( isset( $_POST['Authorize'] ) ) : ?>
1586
  <?php GADWP_Tools::clear_cache();?>
1592
  <?php if ( isset( $message ) ) : ?>
1593
  <?php echo $message; ?>
1594
  <?php endif; ?>
1595
+ <form name="gadwp_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1596
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1597
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1598
  <table class="gadwp-settings-options">
1599
  <tr>
1600
  <td colspan="2">
1604
  <tr>
1605
  <td colspan="2" class="gadwp-settings-title">
1606
  <div class="button-primary gadwp-settings-switchoo">
1607
+ <input type="checkbox" name="options[network_mode]" value="1" class="gadwp-settings-switchoo-checkbox" id="network_mode" <?php checked( $options['network_mode'], 1); ?> onchange="this.form.submit()">
1608
+ <label class="gadwp-settings-switchoo-label" for="network_mode">
1609
  <div class="gadwp-settings-switchoo-inner"></div>
1610
  <div class="gadwp-settings-switchoo-switch"></div>
1611
  </label>
1613
  <div class="switch-desc"><?php echo " ".__("use a single Google Analytics account for the entire network", 'google-analytics-dashboard-for-wp' );?></div>
1614
  </td>
1615
  </tr>
1616
+ <?php if ($options['network_mode']) : ?>
1617
  <tr>
1618
  <td colspan="2">
1619
  <hr>
1627
  <?php printf(__('You should watch the %1$s and read this %2$s before proceeding to authorization. This plugin requires a properly configured Google Analytics account!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp', __("video", 'google-analytics-dashboard-for-wp')), sprintf('<a href="%1$s" target="_blank">%2$s</a>', 'https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp', __("tutorial", 'google-analytics-dashboard-for-wp')));?>
1628
  </td>
1629
  </tr>
1630
+ <?php if ( ! $options['token'] || $options['user_api'] ) : ?>
1631
  <tr>
1632
  <td colspan="2" class="gadwp-settings-info">
1633
+ <input name="options[user_api]" type="checkbox" id="user_api" value="1" <?php checked( $options['user_api'], 1 ); ?> onchange="this.form.submit()" /><?php echo " ".__("developer mode (requires advanced API knowledge)", 'google-analytics-dashboard-for-wp' );?>
1634
  </td>
1635
  </tr>
1636
  <?php endif; ?>
1637
+ <?php if ( $options['user_api'] ) : ?>
1638
  <tr>
1639
  <td class="gadwp-settings-title">
1640
+ <label for="options[client_id]"><?php _e("Client ID:", 'google-analytics-dashboard-for-wp'); ?>
1641
  </label>
1642
  </td>
1643
  <td>
1644
+ <input type="text" name="options[client_id]" value="<?php echo esc_attr($options['client_id']); ?>" size="40" required="required">
1645
  </td>
1646
  </tr>
1647
  <tr>
1648
  <td class="gadwp-settings-title">
1649
+ <label for="options[client_secret]"><?php _e("Client Secret:", 'google-analytics-dashboard-for-wp'); ?>
1650
  </label>
1651
  </td>
1652
  <td>
1653
+ <input type="text" name="options[client_secret]" value="<?php echo esc_attr($options['client_secret']); ?>" size="40" required="required">
1654
+ <input type="hidden" name="options[gadwp_hidden]" value="Y">
1655
+ <?php wp_nonce_field('gadwp_form','gadwp_security'); ?>
1656
  </td>
1657
  </tr>
1658
  <?php endif; ?>
1659
+ <?php if ( $options['token'] ) : ?>
1660
  <tr>
1661
  <td colspan="2">
1662
  <input type="submit" name="Reset" class="button button-secondary" value="<?php _e( "Clear Authorization", 'google-analytics-dashboard-for-wp' ); ?>" />
1674
  <?php echo "<h2>" . __( "Properties/Views Settings", 'google-analytics-dashboard-for-wp' ) . "</h2>"; ?>
1675
  </td>
1676
  </tr>
1677
+ <?php if ( isset( $options['network_tableid'] ) ) : ?>
1678
+ <?php $options['network_tableid'] = json_decode( json_encode( $options['network_tableid'] ), false ); ?>
1679
  <?php endif; ?>
1680
  <?php foreach ( GADWP_Tools::get_sites( array( 'number' => apply_filters( 'gadwp_sites_limit', 100 ) ) ) as $blog ) : ?>
1681
  <tr>
1682
  <td class="gadwp-settings-title-s">
1683
+ <label for="network_tableid"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label>
1684
  </td>
1685
  <td>
1686
+ <select id="network_tableid" <?php disabled(!empty($options['ga_profiles_list']),false);?> name="options[network_tableid][<?php echo $blog['blog_id'];?>]">
1687
+ <?php if ( ! empty( $options['ga_profiles_list'] ) ) : ?>
1688
+ <?php foreach ( $options['ga_profiles_list'] as $items ) : ?>
1689
  <?php if ( $items[3] ) : ?>
1690
  <?php $temp_id = $blog['blog_id']; ?>
1691
+ <option value="<?php echo esc_attr( $items[1] );?>" <?php selected( $items[1], isset( $options['network_tableid']->$temp_id ) ? $options['network_tableid']->$temp_id : '');?> title="<?php echo __( "View Name:", 'google-analytics-dashboard-for-wp' ) . ' ' . esc_attr( $items[0] );?>">
1692
  <?php echo esc_html( GADWP_Tools::strip_protocol( $items[3] ) );?> &#8658; <?php echo esc_attr( $items[0] );?>
1693
  </option>
1694
  <?php endif; ?>
1727
  <tr>
1728
  <td colspan="2" class="gadwp-settings-title">
1729
  <div class="button-primary gadwp-settings-switchoo">
1730
+ <input type="checkbox" name="options[superadmin_tracking]" value="1" class="gadwp-settings-switchoo-checkbox" id="superadmin_tracking"<?php checked( $options['superadmin_tracking'], 1); ?>">
1731
+ <label class="gadwp-settings-switchoo-label" for="superadmin_tracking">
1732
  <div class="gadwp-settings-switchoo-inner"></div>
1733
  <div class="gadwp-settings-switchoo-switch"></div>
1734
  </label>
1800
  <span><?php _e("Follow & Review",'google-analytics-dashboard-for-wp')?></span>
1801
  </h3>
1802
  <div class="inside">
1803
+ <div class="gadwp-desc">
1804
  <div style="margin-left: -10px;">
1805
  <div class="g-page" data-width="273" data-href="//plus.google.com/+Deconfcom" data-layout="landscape" data-showtagline="false" data-showcoverphoto="false" data-rel="publisher"></div>
1806
  </div>
1813
  </script>
1814
  </div>
1815
  <br />
1816
+ <div class="gadwp-desc">
1817
  <a href="https://twitter.com/deconfcom" class="twitter-follow-button" data-show-count="false" data-size="large">Follow @deconfcom</a>
1818
  <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
1819
  </div>
1820
  <br />
1821
+ <div class="gadwp-title">
1822
  <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1823
  </div>
1824
+ <div class="gadwp-desc">
1825
  <?php printf(__('Your feedback and review are both important, %s!', 'google-analytics-dashboard-for-wp'), sprintf('<a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">%s</a>', __('rate this plugin', 'google-analytics-dashboard-for-wp')));?>
1826
  </div>
1827
  </div>
1831
  <span><?php _e("Further Reading",'google-analytics-dashboard-for-wp')?></span>
1832
  </h3>
1833
  <div class="inside">
1834
+ <div class="gadwp-title">
1835
  <a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1836
  </div>
1837
+ <div class="gadwp-desc">
1838
  <?php printf(__('%s service with users tracking at IP level.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">%s</a>', __('Web Analytics', 'google-analytics-dashboard-for-wp')));?>
1839
  </div>
1840
  <br />
1841
+ <div class="gadwp-title">
1842
  <a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1843
  </div>
1844
+ <div class="gadwp-desc">
1845
  <?php printf(__('%s by moving your website to HTTPS/SSL.', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">%s</a>', __('Improve search rankings', 'google-analytics-dashboard-for-wp')));?>
1846
  </div>
1847
  <br />
1848
+ <div class="gadwp-title">
1849
  <a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp"><img src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a>
1850
  </div>
1851
+ <div class="gadwp-desc">
1852
+ <?php printf(__('Premium %s', 'google-analytics-dashboard-for-wp'), sprintf('<a href="https://shareasale.com/r.cfm?b=386922&u=926589&m=28169&urllink=&afftrack=">%s</a>', __('WordPress Themes & Plugins', 'google-analytics-dashboard-for-wp')));?>
1853
  </div>
1854
  </div>
1855
  </div>
admin/setup.php CHANGED
@@ -39,12 +39,12 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
39
  global $wp_version;
40
  if ( current_user_can( 'manage_options' ) ) {
41
  include ( GADWP_DIR . 'admin/settings.php' );
42
- add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_settings', array( 'GADWP_Settings', 'general_settings' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadash-icon.png' );
43
- add_submenu_page( 'gadash_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_settings', array( 'GADWP_Settings', 'general_settings' ) );
44
- add_submenu_page( 'gadash_settings', __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_backend_settings', array( 'GADWP_Settings', 'backend_settings' ) );
45
- add_submenu_page( 'gadash_settings', __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_frontend_settings', array( 'GADWP_Settings', 'frontend_settings' ) );
46
- add_submenu_page( 'gadash_settings', __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_tracking_settings', array( 'GADWP_Settings', 'tracking_settings' ) );
47
- add_submenu_page( 'gadash_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadash_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
48
  }
49
  }
50
 
@@ -55,9 +55,9 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
55
  global $wp_version;
56
  if ( current_user_can( 'manage_network' ) ) {
57
  include ( GADWP_DIR . 'admin/settings.php' );
58
- add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), "Google Analytics", 'manage_network', 'gadash_settings', array( 'GADWP_Settings', 'general_settings_network' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadash-icon.png' );
59
- add_submenu_page( 'gadash_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadash_settings', array( 'GADWP_Settings', 'general_settings_network' ) );
60
- add_submenu_page( 'gadash_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadash_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
61
  }
62
  }
63
 
@@ -102,9 +102,9 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
102
  );
103
  /* @formatter:on */
104
 
105
- if ( $this->gadwp->config->options['switch_profile'] && count( $this->gadwp->config->options['ga_dash_profile_list'] ) > 1 ) {
106
  $views = array();
107
- foreach ( $this->gadwp->config->options['ga_dash_profile_list'] as $items ) {
108
  if ( $items[3] ) {
109
  $views[$items[1]] = esc_js( GADWP_Tools::strip_protocol( $items[3] ) ); // . ' &#8658; ' . $items[0] );
110
  }
@@ -119,7 +119,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
119
  $widgets_hooks = array( 'index.php' );
120
 
121
  if ( in_array( $new_hook, $widgets_hooks ) ) {
122
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
123
 
124
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
125
  $country_codes = GADWP_Tools::get_countrycodes();
@@ -149,20 +149,28 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
149
  wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports5.js', array( 'jquery', 'googlecharts', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION, true );
150
 
151
  /* @formatter:off */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
  wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
153
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
154
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
155
- 'dateList' => array(
156
- 'realtime' => __( "Real-Time", 'google-analytics-dashboard-for-wp' ),
157
- 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
158
- 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
159
- '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
160
- '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
161
- '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
162
- '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
163
- '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
164
- '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
165
- ),
166
  'reportList' => array(
167
  'sessions' => __( "Sessions", 'google-analytics-dashboard-for-wp' ),
168
  'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
@@ -193,7 +201,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
193
  __( "No Data", 'google-analytics-dashboard-for-wp' ),
194
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
195
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
196
- __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
197
  __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
198
  __( "Operating System", 'google-analytics-dashboard-for-wp' ),
199
  __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
@@ -209,13 +217,14 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
209
  __( "Session Duration", 'google-analytics-dashboard-for-wp' ),
210
  ),
211
  'rtLimitPages' => $this->gadwp->config->options['ga_realtime_pages'],
212
- 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
213
  'region' => $region,
214
  'mapsApiKey' => $this->gadwp->config->options['maps_api_key'],
215
  'language' => get_bloginfo( 'language' ),
216
  'viewList' => $views,
217
  'scope' => 'admin-widgets',
218
  )
 
219
  );
220
  /* @formatter:on */
221
  }
@@ -226,7 +235,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
226
  */
227
  $contentstats_hooks = array( 'edit.php' );
228
  if ( in_array( $hook, $contentstats_hooks ) ) {
229
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
230
 
231
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
232
  $country_codes = GADWP_Tools::get_countrycodes();
@@ -293,7 +302,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
293
  __( "No Data", 'google-analytics-dashboard-for-wp' ),
294
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
295
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
296
- __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadash_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
297
  __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
298
  __( "Operating System", 'google-analytics-dashboard-for-wp' ),
299
  __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
@@ -308,7 +317,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
308
  __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
309
  __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
310
  ),
311
- 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['ga_dash_style'] ),
312
  'region' => $region,
313
  'mapsApiKey' => $this->gadwp->config->options['maps_api_key'],
314
  'language' => get_bloginfo( 'language' ),
@@ -323,7 +332,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
323
  /*
324
  * Settings Styles & Scripts
325
  */
326
- $settings_hooks = array( '_page_gadash_settings', '_page_gadash_backend_settings', '_page_gadash_frontend_settings', '_page_gadash_tracking_settings', '_page_gadash_errors_debugging' );
327
 
328
  if ( in_array( $new_hook, $settings_hooks ) ) {
329
  wp_enqueue_style( 'wp-color-picker' );
@@ -341,7 +350,7 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
341
  * @return array
342
  */
343
  public function settings_link( $links ) {
344
- $settings_link = '<a href="' . esc_url( get_admin_url( null, 'admin.php?page=gadash_settings' ) ) . '">' . __( "Settings", 'google-analytics-dashboard-for-wp' ) . '</a>';
345
  array_unshift( $links, $settings_link );
346
  return $links;
347
  }
@@ -352,15 +361,16 @@ if ( ! class_exists( 'GADWP_Backend_Setup' ) ) {
352
  function admin_notice() {
353
  $currentScreen = get_current_screen();
354
 
355
- if ( ! current_user_can( 'manage_options' ) || 'dashboard' != $currentScreen->base ) {
356
  return;
357
  }
358
 
359
  if ( get_option( 'gadwp_got_updated' ) ) :
360
  ?>
361
  <div id="gadwp-notice" class="notice is-dismissible">
362
- <p><?php echo sprintf( __('Google Analytics Dashboard for WP has been updated to version %s.', 'google-analytics-dashboard-for-wp' ), GADWP_CURRENT_VERSION).' '.sprintf( __('For details, check out %1$s and %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf(' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_notice&utm_medium=link&utm_content=release_notice&utm_campaign=gadwp">%s</a> ', __('the release notes', 'google-analytics-dashboard-for-wp') ), sprintf(' <a href="%1$s">%2$s</a>', esc_url( get_admin_url( null, 'admin.php?page=gadwp_settings' ) ), __('the plugin&#39;s settings page', 'google-analytics-dashboard-for-wp') ) ); ?></p>
363
  </div>
 
364
  <?php
365
  endif;
366
  }
39
  global $wp_version;
40
  if ( current_user_can( 'manage_options' ) ) {
41
  include ( GADWP_DIR . 'admin/settings.php' );
42
+ add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadwp-icon.png' );
43
+ add_submenu_page( 'gadwp_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings' ) );
44
+ add_submenu_page( 'gadwp_settings', __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), __( "Backend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_backend_settings', array( 'GADWP_Settings', 'backend_settings' ) );
45
+ add_submenu_page( 'gadwp_settings', __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), __( "Frontend Settings", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_frontend_settings', array( 'GADWP_Settings', 'frontend_settings' ) );
46
+ add_submenu_page( 'gadwp_settings', __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), __( "Tracking Code", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_tracking_settings', array( 'GADWP_Settings', 'tracking_settings' ) );
47
+ add_submenu_page( 'gadwp_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_options', 'gadwp_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
48
  }
49
  }
50
 
55
  global $wp_version;
56
  if ( current_user_can( 'manage_network' ) ) {
57
  include ( GADWP_DIR . 'admin/settings.php' );
58
+ add_menu_page( __( "Google Analytics", 'google-analytics-dashboard-for-wp' ), "Google Analytics", 'manage_network', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings_network' ), version_compare( $wp_version, '3.8.0', '>=' ) ? 'dashicons-chart-area' : GADWP_URL . 'admin/images/gadwp-icon.png' );
59
+ add_submenu_page( 'gadwp_settings', __( "General Settings", 'google-analytics-dashboard-for-wp' ), __( "General Settings", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadwp_settings', array( 'GADWP_Settings', 'general_settings_network' ) );
60
+ add_submenu_page( 'gadwp_settings', __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), __( "Errors & Debug", 'google-analytics-dashboard-for-wp' ), 'manage_network', 'gadwp_errors_debugging', array( 'GADWP_Settings', 'errors_debugging' ) );
61
  }
62
  }
63
 
102
  );
103
  /* @formatter:on */
104
 
105
+ if ( $this->gadwp->config->options['switch_profile'] && count( $this->gadwp->config->options['ga_profiles_list'] ) > 1 ) {
106
  $views = array();
107
+ foreach ( $this->gadwp->config->options['ga_profiles_list'] as $items ) {
108
  if ( $items[3] ) {
109
  $views[$items[1]] = esc_js( GADWP_Tools::strip_protocol( $items[3] ) ); // . ' &#8658; ' . $items[0] );
110
  }
119
  $widgets_hooks = array( 'index.php' );
120
 
121
  if ( in_array( $new_hook, $widgets_hooks ) ) {
122
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && $this->gadwp->config->options['dashboard_widget'] ) {
123
 
124
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
125
  $country_codes = GADWP_Tools::get_countrycodes();
149
  wp_enqueue_script( 'gadwp-backend-dashboard-reports', GADWP_URL . 'common/js/reports5.js', array( 'jquery', 'googlecharts', 'gadwp-nprogress', 'jquery-ui-tooltip', 'jquery-ui-core', 'jquery-ui-position', 'jquery-ui-tooltip-html' ), GADWP_CURRENT_VERSION, true );
150
 
151
  /* @formatter:off */
152
+
153
+ $datelist = array(
154
+ 'realtime' => __( "Real-Time", 'google-analytics-dashboard-for-wp' ),
155
+ 'today' => __( "Today", 'google-analytics-dashboard-for-wp' ),
156
+ 'yesterday' => __( "Yesterday", 'google-analytics-dashboard-for-wp' ),
157
+ '7daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 7 ),
158
+ '14daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 14 ),
159
+ '30daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 30 ),
160
+ '90daysAgo' => sprintf( __( "Last %d Days", 'google-analytics-dashboard-for-wp' ), 90 ),
161
+ '365daysAgo' => sprintf( _n( "%s Year", "%s Years", 1, 'google-analytics-dashboard-for-wp' ), __('One', 'google-analytics-dashboard-for-wp') ),
162
+ '1095daysAgo' => sprintf( _n( "%s Year", "%s Years", 3, 'google-analytics-dashboard-for-wp' ), __('Three', 'google-analytics-dashboard-for-wp') ),
163
+ );
164
+
165
+
166
+ if ( $this->gadwp->config->options['user_api'] && ! $this->gadwp->config->options['backend_realtime_report'] ) {
167
+ array_shift( $datelist );
168
+ }
169
+
170
  wp_localize_script( 'gadwp-backend-dashboard-reports', 'gadwpItemData', array(
171
  'ajaxurl' => admin_url( 'admin-ajax.php' ),
172
  'security' => wp_create_nonce( 'gadwp_backend_item_reports' ),
173
+ 'dateList' => $datelist,
 
 
 
 
 
 
 
 
 
 
174
  'reportList' => array(
175
  'sessions' => __( "Sessions", 'google-analytics-dashboard-for-wp' ),
176
  'users' => __( "Users", 'google-analytics-dashboard-for-wp' ),
201
  __( "No Data", 'google-analytics-dashboard-for-wp' ),
202
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
203
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
204
+ __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadwp_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
205
  __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
206
  __( "Operating System", 'google-analytics-dashboard-for-wp' ),
207
  __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
217
  __( "Session Duration", 'google-analytics-dashboard-for-wp' ),
218
  ),
219
  'rtLimitPages' => $this->gadwp->config->options['ga_realtime_pages'],
220
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
221
  'region' => $region,
222
  'mapsApiKey' => $this->gadwp->config->options['maps_api_key'],
223
  'language' => get_bloginfo( 'language' ),
224
  'viewList' => $views,
225
  'scope' => 'admin-widgets',
226
  )
227
+
228
  );
229
  /* @formatter:on */
230
  }
235
  */
236
  $contentstats_hooks = array( 'edit.php' );
237
  if ( in_array( $hook, $contentstats_hooks ) ) {
238
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && $this->gadwp->config->options['backend_item_reports'] ) {
239
 
240
  if ( $this->gadwp->config->options['ga_target_geomap'] ) {
241
  $country_codes = GADWP_Tools::get_countrycodes();
302
  __( "No Data", 'google-analytics-dashboard-for-wp' ),
303
  __( "This report is unavailable", 'google-analytics-dashboard-for-wp' ),
304
  __( "report generated by", 'google-analytics-dashboard-for-wp' ), //14
305
+ __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . ' <a href="' . menu_page_url( 'gadwp_settings', false ) . '">' . __( "authorize the plugin", 'google-analytics-dashboard-for-wp' ) . '</a>.',
306
  __( "Browser", 'google-analytics-dashboard-for-wp' ), //16
307
  __( "Operating System", 'google-analytics-dashboard-for-wp' ),
308
  __( "Screen Resolution", 'google-analytics-dashboard-for-wp' ),
317
  __( "Page Load Time", 'google-analytics-dashboard-for-wp' ),
318
  __( "Exit Rate", 'google-analytics-dashboard-for-wp' ),
319
  ),
320
+ 'colorVariations' => GADWP_Tools::variations( $this->gadwp->config->options['theme_color'] ),
321
  'region' => $region,
322
  'mapsApiKey' => $this->gadwp->config->options['maps_api_key'],
323
  'language' => get_bloginfo( 'language' ),
332
  /*
333
  * Settings Styles & Scripts
334
  */
335
+ $settings_hooks = array( '_page_gadwp_settings', '_page_gadwp_backend_settings', '_page_gadwp_frontend_settings', '_page_gadwp_tracking_settings', '_page_gadwp_errors_debugging' );
336
 
337
  if ( in_array( $new_hook, $settings_hooks ) ) {
338
  wp_enqueue_style( 'wp-color-picker' );
350
  * @return array
351
  */
352
  public function settings_link( $links ) {
353
+ $settings_link = '<a href="' . esc_url( get_admin_url( null, 'admin.php?page=gadwp_settings' ) ) . '">' . __( "Settings", 'google-analytics-dashboard-for-wp' ) . '</a>';
354
  array_unshift( $links, $settings_link );
355
  return $links;
356
  }
361
  function admin_notice() {
362
  $currentScreen = get_current_screen();
363
 
364
+ if ( ! current_user_can( 'manage_options' ) || strpos( $currentScreen->base, '_gadwp_' ) === false ) {
365
  return;
366
  }
367
 
368
  if ( get_option( 'gadwp_got_updated' ) ) :
369
  ?>
370
  <div id="gadwp-notice" class="notice is-dismissible">
371
+ <p><?php echo sprintf( __('Google Analytics Dashboard for WP has been updated to version %s.', 'google-analytics-dashboard-for-wp' ), GADWP_CURRENT_VERSION).' '.sprintf( __('For details, check out %1$s and %2$s.', 'google-analytics-dashboard-for-wp' ), sprintf(' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_notice&utm_medium=link&utm_content=release_notice&utm_campaign=gadwp">%s</a> ', __('the release notes', 'google-analytics-dashboard-for-wp') ), sprintf(' <a href="%1$s">%2$s</a>', esc_url( get_admin_url( null, 'admin.php?page=gadwp_settings' ) ), __('the plugin&#39;s settings page', 'google-analytics-dashboard-for-wp') ) ); ?></p>
372
  </div>
373
+
374
  <?php
375
  endif;
376
  }
admin/views/access-code.php CHANGED
@@ -29,7 +29,7 @@
29
  </tr>
30
  <tr>
31
  <td colspan="2">
32
- <input type="submit" class="button button-secondary" name="ga_dash_authorize" value="<?php _e( "Save Access Code", 'google-analytics-dashboard-for-wp' ); ?>" />
33
  </td>
34
  </tr>
35
  </table>
29
  </tr>
30
  <tr>
31
  <td colspan="2">
32
+ <input type="submit" class="button button-secondary" name="gadwp_authorize" value="<?php _e( "Save Access Code", 'google-analytics-dashboard-for-wp' ); ?>" />
33
  </td>
34
  </tr>
35
  </table>
admin/widgets.php CHANGED
@@ -19,7 +19,7 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) && ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) {
23
  add_action( 'wp_dashboard_setup', array( $this, 'add_widget' ) );
24
  }
25
  }
@@ -31,23 +31,23 @@ if ( ! class_exists( 'GADWP_Backend_Widgets' ) ) {
31
  public function dashboard_widget() {
32
  $projectId = 0;
33
 
34
- if ( empty( $this->gadwp->config->options['ga_dash_token'] ) ) {
35
- echo '<p>' . __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
36
  return;
37
  }
38
 
39
  if ( current_user_can( 'manage_options' ) ) {
40
- if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
41
- $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
42
  } else {
43
- echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
44
  return;
45
  }
46
  } else {
47
- if ( $this->gadwp->config->options['ga_dash_tableid_jail'] ) {
48
- $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
49
  } else {
50
- echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadash_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
51
  return;
52
  }
53
  }
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) && ( 1 == $this->gadwp->config->options['dashboard_widget'] ) ) {
23
  add_action( 'wp_dashboard_setup', array( $this, 'add_widget' ) );
24
  }
25
  }
31
  public function dashboard_widget() {
32
  $projectId = 0;
33
 
34
+ if ( empty( $this->gadwp->config->options['token'] ) ) {
35
+ echo '<p>' . __( "This plugin needs an authorization:", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Authorize Plugin", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
36
  return;
37
  }
38
 
39
  if ( current_user_can( 'manage_options' ) ) {
40
+ if ( $this->gadwp->config->options['tableid_jail'] ) {
41
+ $projectId = $this->gadwp->config->options['tableid_jail'];
42
  } else {
43
+ echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
44
  return;
45
  }
46
  } else {
47
+ if ( $this->gadwp->config->options['tableid_jail'] ) {
48
+ $projectId = $this->gadwp->config->options['tableid_jail'];
49
  } else {
50
+ echo '<p>' . __( "An admin should asign a default Google Analytics Profile.", 'google-analytics-dashboard-for-wp' ) . '</p><form action="' . menu_page_url( 'gadwp_settings', false ) . '" method="POST">' . get_submit_button( __( "Select Domain", 'google-analytics-dashboard-for-wp' ), 'secondary' ) . '</form>';
51
  return;
52
  }
53
  }
common/ajax-actions.php CHANGED
@@ -19,8 +19,8 @@ if ( ! class_exists( 'GADWP_Common_Ajax' ) ) {
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
-
23
- if ( GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_back'] ) || GADWP_Tools::check_roles( $this->gadwp->config->options['ga_dash_access_front'] ) ) {
24
  add_action( 'wp_ajax_gadwp_set_error', array( $this, 'ajax_set_error' ) );
25
  }
26
  }
@@ -34,9 +34,8 @@ if ( ! class_exists( 'GADWP_Common_Ajax' ) ) {
34
  if ( ! isset( $_POST['gadwp_security_set_error'] ) || ! ( wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_backend_item_reports' ) || wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_frontend_item_reports' ) ) ) {
35
  wp_die( - 40 );
36
  }
37
-
38
- GADWP_Tools::set_cache( 'last_error', date( 'Y-m-d H:i:s' ) . ': ' . esc_html( $_POST['response'] ), 24 * 60 * 60 );
39
-
40
  wp_die();
41
  }
42
  }
19
 
20
  public function __construct() {
21
  $this->gadwp = GADWP();
22
+
23
+ if ( GADWP_Tools::check_roles( $this->gadwp->config->options['access_back'] ) || GADWP_Tools::check_roles( $this->gadwp->config->options['access_front'] ) ) {
24
  add_action( 'wp_ajax_gadwp_set_error', array( $this, 'ajax_set_error' ) );
25
  }
26
  }
34
  if ( ! isset( $_POST['gadwp_security_set_error'] ) || ! ( wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_backend_item_reports' ) || wp_verify_nonce( $_POST['gadwp_security_set_error'], 'gadwp_frontend_item_reports' ) ) ) {
35
  wp_die( - 40 );
36
  }
37
+ $timeout = 24 * 60 * 60;
38
+ GADWP_Tools::set_error( $_POST['response'], $timeout );
 
39
  wp_die();
40
  }
41
  }
common/js/reports5.js CHANGED
@@ -1 +1 @@
1
- "use strict";if(gadwpItemData.mapsApiKey){google.charts.load("current",{mapsApiKey:gadwpItemData.mapsApiKey,packages:["corechart","table","orgchart","geochart"]})}else{google.charts.load("current",{packages:["corechart","table","orgchart","geochart"]})}google.charts.setOnLoadCallback(GADWPReportLoad);gadwpItemData.getID=function(a){if(gadwpItemData.scope=="admin-item"){if(typeof a.id=="undefined"){return 0}if(a.id.split("-")[1]=="undefined"){return 0}else{return a.id.split("-")[1]}}else{if(typeof a.id=="undefined"){return 1}if(a.id.split("-")[4]=="undefined"){return 1}else{return a.id.split("-")[4]}}};gadwpItemData.getSelector=function(a){if(a=="admin-item"){return'a[id^="gadwp-"]'}else{return'li[id^="wp-admin-bar-gadwp"] a'}};gadwpItemData.responsiveDialog=function(){var b,a,c;c=jQuery(".ui-dialog:visible");c.each(function(){b=jQuery(this).find(".ui-dialog-content").data("ui-dialog");if(b.options.fluid){a=jQuery(window).width();if(a<(parseInt(b.options.maxWidth)+50)){jQuery(this).css("max-width","90%")}else{jQuery(this).css("max-width",b.options.maxWidth+"px")}b.option("position",b.options.position)}})};jQuery.fn.extend({gadwpItemReport:function(g){var a,d,h,e,f,i,c,b="-"+g;d={setCookie:function(k,m){var j,l=new Date();if(gadwpItemData.scope=="admin-widgets"){k="gadwp_wg_"+k}else{k="gadwp_ir_"+k}l.setTime(l.getTime()+(24*60*60*1000*365));j="expires="+l.toUTCString();document.cookie=k+"="+m+"; "+j+"; path=/"},getCookie:function(j){var l,m,n,k=0;if(gadwpItemData.scope=="admin-widgets"){j="gadwp_wg_"+j+"="}else{j="gadwp_ir_"+j+"="}m=document.cookie.split(";");for(k=0;k<m.length;k++){l=m[k];while(l.charAt(0)==" "){l=l.substring(1)}if(l.indexOf(j)==0){return l.substring(j.length,l.length)}}return false},escape:function(j){div=document.createElement("div");div.appendChild(document.createTextNode(j));return div.innerHTML}};h={addOptions:function(o,n){var j,l,m,k=[];if(!d.getCookie("default_metric")||!d.getCookie("default_dimension")||!d.getCookie("default_swmetric")){j="sessions";l="30daysAgo";if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){c="pageviews"}else{c="sessions"}d.setCookie("default_metric",j);d.setCookie("default_dimension",l);d.setCookie("default_swmetric",c)}else{j=d.getCookie("default_metric");l=d.getCookie("default_dimension");m=d.getCookie("default_view");c=d.getCookie("default_swmetric")}if(n==false){if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){k=""}else{k='<span id="gadwp-swmetric-sessions" title="'+gadwpItemData.i18n[5]+'" class="dashicons dashicons-clock" style="font-size:22px;padding:4px;"></span>'}k+='<span id="gadwp-swmetric-users" title="'+gadwpItemData.i18n[6]+'" class="dashicons dashicons-admin-users" style="font-size:22px;padding:4px;"></span>';k+='<span id="gadwp-swmetric-pageviews" title="'+gadwpItemData.i18n[7]+'" class="dashicons dashicons-admin-page" style="font-size:22px;padding:4px;"></span>';jQuery(o).html(k);jQuery("#gadwp-swmetric-"+c).css("color","#008ec2")}else{jQuery.each(n,function(p,q){if(p==j||p==l||p==m){k.push('<option value="'+p+'" selected="selected">'+q+"</option>")}else{k.push('<option value="'+p+'">'+q+"</option>")}});jQuery(o).html(k.join(""))}},init:function(){var j;if(!jQuery("#gadwp-window"+b).length){return}if(jQuery("#gadwp-window"+b).html().length){return}j='<div id="gadwp-container'+b+'">';if(gadwpItemData.viewList!=false){j+='<select id="gadwp-sel-view'+b+'"></select>'}j+='<select id="gadwp-sel-period'+b+'"></select> ';j+='<select id="gadwp-sel-report'+b+'"></select>';j+='<div id="gadwp-sel-metric'+b+'" style="float:right;display:none;">';j+="</div>";j+='<div id="gadwp-progressbar'+b+'"></div>';j+='<div id="gadwp-status'+b+'"></div>';j+='<div id="gadwp-reports'+b+'"></div>';j+='<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';j+=gadwpItemData.i18n[14];j+=' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';j+="</div>";j+="</div>",jQuery("#gadwp-window"+b).append(j);h.addOptions("#gadwp-sel-view"+b,gadwpItemData.viewList);h.addOptions("#gadwp-sel-period"+b,gadwpItemData.dateList);h.addOptions("#gadwp-sel-report"+b,gadwpItemData.reportList);h.addOptions("#gadwp-sel-metric"+b,false)}};e={oldViewPort:0,orgChartTableChartData:"",tableChartData:"",orgChartPieChartsData:"",geoChartTableChartData:"",areaChartBottomStatsData:"",realtime:"",rtRuns:null,i18n:null,getTitle:function(j){if(j=="admin-item"){return jQuery("#gadwp"+b).attr("title")}else{return document.getElementsByTagName("title")[0].innerHTML}},alertMessage:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});jQuery("#gadwp-status"+b).html(j)},areaChartBottomStats:function(j){e.areaChartBottomStatsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();if(a.query=="visitBounceRate,bottomstats"){e.drawAreaChart(j[0],true)}else{e.drawAreaChart(j[0],false)}}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-areachart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){jQuery("#gadwp-reports"+b).show();e.drawBottomStats(j[1])}else{e.throwDebug(j[1])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-bottomstats"+b,j[1],"40px")}}else{e.throwDebug(j)}NProgress.done()},orgChartPieCharts:function(j){var k=0;e.orgChartPieChartsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}for(k=1;k<j.length;k++){if(!jQuery.isNumeric(j[k])){if(jQuery.isArray(j[k])){jQuery("#gadwp-reports"+b).show();e.drawPieChart("piechart-"+k,j[k],e.i18n[k])}else{e.throwDebug(j[k])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-piechart-"+k+b,j[k],"80px")}}}else{e.throwDebug(j)}NProgress.done()},geoChartTableChart:function(j){e.geoChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawGeoChart(j[0]);e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-geochart"+b,j[0],"125px");e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},orgChartTableChart:function(j){e.orgChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){e.drawTableChart(j[1])}else{e.throwDebug(j[1])}}else{e.throwError("#gadwp-tablechart"+b,j[1],"125px")}}else{e.throwDebug(j)}NProgress.done()},tableChart:function(j){e.tableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},drawTableChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={page:"enable",pageSize:10,width:"100%",allowHtml:true};k=new google.visualization.Table(document.getElementById("gadwp-tablechart"+b));k.draw(l,j)},drawOrgChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={allowCollapse:true,allowHtml:true,height:"100%"};k=new google.visualization.OrgChart(document.getElementById("gadwp-orgchart"+b));k.draw(l,j)},drawPieChart:function(o,m,n){var l,j,k;l=google.visualization.arrayToDataTable(m);j={is3D:false,tooltipText:"percentage",legend:"none",chartArea:{width:"99%",height:"80%"},title:n,pieSliceText:"value",colors:gadwpItemData.colorVariations};k=new google.visualization.PieChart(document.getElementById("gadwp-"+o+b));k.draw(l,j)},drawGeoChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={chartArea:{width:"99%",height:"90%"},colors:[gadwpItemData.colorVariations[5],gadwpItemData.colorVariations[4]]};if(gadwpItemData.region){j.region=gadwpItemData.region;j.displayMode="markers";j.datalessRegionColor="EFEFEF"}k=new google.visualization.GeoChart(document.getElementById("gadwp-geochart"+b));k.draw(l,j)},drawAreaChart:function(n,o){var m,j,l,k;m=google.visualization.arrayToDataTable(n);if(o){k=new google.visualization.NumberFormat({suffix:"%",fractionDigits:2});k.format(m,1)}j={legend:{position:"none"},pointSize:3,colors:[gadwpItemData.colorVariations[0],gadwpItemData.colorVariations[4]],chartArea:{width:"99%",height:"90%"},vAxis:{textPosition:"in",minValue:0},hAxis:{textPosition:"none"}};l=new google.visualization.AreaChart(document.getElementById("gadwp-areachart"+b));l.draw(m,j)},drawBottomStats:function(j){jQuery("#gdsessions"+b).html(j[0]);jQuery("#gdusers"+b).html(j[1]);jQuery("#gdpageviews"+b).html(j[2]);jQuery("#gdbouncerate"+b).html(j[3]);jQuery("#gdorganicsearch"+b).html(j[4]);jQuery("#gdpagespervisit"+b).html(j[5]);jQuery("#gdpagetime"+b).html(j[6]);jQuery("#gdpageload"+b).html(j[7]);jQuery("#gdsessionduration"+b).html(j[8])},rtOnlyUniqueValues:function(l,k,j){return j.indexOf(l)===k},rtCountSessions:function(k,m){var l=0,j=0;for(j=0;j<k.rows.length;j++){if(jQuery.inArray(m,k.rows[j])>-1){l+=parseInt(k.rows[j][6])}}return l},rtGenerateTooltip:function(k){var m=0,l="",j=0;for(j=0;j<k.length;j++){m+=parseInt(k[j].count);l+="<tr><td class='gadwp-pgdetailsl'>"+k[j].value+"</td><td class='gadwp-pgdetailsr'>"+k[j].count+"</td></tr>"}if(m){return("<table>"+l+"</table>")}else{return("")}},rtPageDetails:function(y,n){var w,o,r,x=0,v=0,m=0,s=0,t=0,z=0,C=0,q=0,l=0,u="",A="",p="",k="",B="";y=y.rows;for(x=0;x<y.length;x++){if(y[x][0]==n){o=y[x][5];switch(y[x][3]){case"REFERRAL":t+=parseInt(y[x][6]);u+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"ORGANIC":z+=parseInt(y[x][6]);A+="<tr><td class='gadwp-pgdetailsl'>"+y[x][2]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"SOCIAL":q+=parseInt(y[x][6]);p+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"CUSTOM":l+=parseInt(y[x][6]);k+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"DIRECT":C+=parseInt(y[x][6]);break}}}if(t){u="<table><tr><td>"+e.i18n[0]+"("+t+")</td></tr>"+u+"</table><br />"}if(z){A="<table><tr><td>"+e.i18n[1]+"("+z+")</td></tr>"+A+"</table><br />"}if(q){p="<table><tr><td>"+e.i18n[2]+"("+q+")</td></tr>"+p+"</table><br />"}if(l){k="<table><tr><td>"+e.i18n[3]+"("+l+")</td></tr>"+k+"</table><br />"}if(C){B="<table><tr><td>"+e.i18n[4]+"("+C+")</td></tr></table><br />"}return("<p><center><strong>"+o+"</strong></center></p>"+u+A+p+k+B)},rtRefresh:function(){if(e.render.focusFlag){a.from=false;a.to=false;a.query="realtime";jQuery.post(gadwpItemData.ajaxurl,a,function(j){if(jQuery.isArray(j)){jQuery("#gadwp-reports"+b).show();e.realtime=j[0];e.drawRealtime(e.realtime)}else{e.throwDebug(j)}NProgress.done()})}},drawRealtime:function(y){var j,n,o,w,t,r,x=0,v=[],z=[],p=[],m=[],q=[],k=[],l=[],s="",o=[],w=[],t=[],r=[],u=["REFERRAL","ORGANIC","SOCIAL","CUSTOM"],A=["DIRECT","NEW"];jQuery(function(){jQuery("#gadwp-widget *").tooltip({tooltipClass:"gadwp"})});y=y[0];if(jQuery.isNumeric(y)||typeof y==="undefined"){y=[];y.totalsForAllResults=[];y.totalsForAllResults["rt:activeUsers"]="0";y.rows=[]}if(y.totalsForAllResults["rt:activeUsers"]!==document.getElementById("gadwp-online").innerHTML){jQuery("#gadwp-online").fadeOut("slow");jQuery("#gadwp-online").fadeOut(500);jQuery("#gadwp-online").fadeOut("slow",function(){if((parseInt(y.totalsForAllResults["rt:activeUsers"]))<(parseInt(document.getElementById("gadwp-online").innerHTML))){jQuery("#gadwp-online").css({"background-color":"#FFE8E8"})}else{jQuery("#gadwp-online").css({"background-color":"#E0FFEC"})}document.getElementById("gadwp-online").innerHTML=y.totalsForAllResults["rt:activeUsers"]});jQuery("#gadwp-online").fadeIn("slow");jQuery("#gadwp-online").fadeIn(500);jQuery("#gadwp-online").fadeIn("slow",function(){jQuery("#gadwp-online").css({"background-color":"#FFFFFF"})})}if(y.totalsForAllResults["rt:activeUsers"]==0){y.rows=[]}for(x=0;x<y.rows.length;x++){v.push(y.rows[x][0]);if(y.rows[x][3]=="REFERRAL"){z.push(y.rows[x][1])}if(y.rows[x][3]=="ORGANIC"){p.push(y.rows[x][2])}if(y.rows[x][3]=="SOCIAL"){m.push(y.rows[x][1])}if(y.rows[x][3]=="CUSTOM"){k.push(y.rows[x][1])}q.push(y.rows[x][3])}n=v.filter(e.rtOnlyUniqueValues);for(x=0;x<n.length;x++){l[x]={pagepath:n[x],count:e.rtCountSessions(y,n[x])}}l.sort(function(C,B){return B.count-C.count});s="";for(x=0;x<l.length;x++){if(x<gadwpItemData.rtLimitPages){s+='<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="'+e.rtPageDetails(y,l[x].pagepath)+'">'+l[x].pagepath.substring(0,70)+'</a></div><div class="gadwp-pright">'+l[x].count+"</div></div>"}}document.getElementById("gadwp-pages").innerHTML='<br /><div class="gadwp-pg">'+s+"</div>";o=z.filter(e.rtOnlyUniqueValues);for(x=0;x<o.length;x++){o[x]={value:o[x],count:e.rtCountSessions(y,o[x])}}o.sort(function(C,B){return B.count-C.count});w=p.filter(e.rtOnlyUniqueValues);for(x=0;x<w.length;x++){w[x]={value:w[x],count:e.rtCountSessions(y,w[x])}}w.sort(function(C,B){return B.count-C.count});t=m.filter(e.rtOnlyUniqueValues);for(x=0;x<t.length;x++){t[x]={value:t[x],count:e.rtCountSessions(y,t[x])}}t.sort(function(C,B){return B.count-C.count});r=k.filter(e.rtOnlyUniqueValues);for(x=0;x<r.length;x++){r[x]={value:r[x],count:e.rtCountSessions(y,r[x])}}r.sort(function(C,B){return B.count-C.count});j='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(o)+'"><div class="gadwp-bleft">'+e.i18n[0]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[0])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(w)+'"><div class="gadwp-bleft">'+e.i18n[1]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[1])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(t)+'"><div class="gadwp-bleft">'+e.i18n[2]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[2])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(r)+'"><div class="gadwp-bleft">'+e.i18n[3]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[3])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[4]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[0])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[5]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[1])+"</div></div>";document.getElementById("gadwp-tdo-right").innerHTML=j},throwDebug:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});if(j=="-24"){jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[15])}else{jQuery("#gadwp-reports"+b).css({"background-color":"#F7F7F7",height:"auto","margin-top":"10px","padding-top":"50px","padding-bottom":"50px",color:"#000","text-align":"center"});jQuery("#gadwp-reports"+b).html(j);jQuery("#gadwp-reports"+b).show();jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[11]);console.log("\n********************* GADWP Log ********************* \n\n"+j);a={action:"gadwp_set_error",response:j,gadwp_security_set_error:gadwpItemData.security};jQuery.post(gadwpItemData.ajaxurl,a)}},throwError:function(l,j,k){jQuery(l).css({"background-color":"#F7F7F7",height:"auto","padding-top":k,"padding-bottom":k,color:"#000","text-align":"center"});if(j==-21){jQuery(l).html(gadwpItemData.i18n[12])}else{jQuery(l).html(gadwpItemData.i18n[13]+" ("+j+")")}},render:function(j,o,n){var k,q,p,l,m;if(o=="realtime"){jQuery("#gadwp-sel-report"+b).hide()}else{jQuery("#gadwp-sel-report"+b).show();clearInterval(e.rtRuns)}jQuery("#gadwp-status"+b).html("");switch(o){case"today":q="today";p="today";break;case"yesterday":q="yesterday";p="yesterday";break;case"7daysAgo":q="7daysAgo";p="yesterday";break;case"14daysAgo":q="14daysAgo";p="yesterday";break;case"90daysAgo":q="90daysAgo";p="yesterday";break;case"365daysAgo":q="365daysAgo";p="yesterday";break;case"1095daysAgo":q="1095daysAgo";p="yesterday";break;default:q="30daysAgo";p="yesterday";break}d.setCookie("default_metric",n);d.setCookie("default_dimension",o);if(typeof j!=="undefined"){d.setCookie("default_view",j);k=j}else{k=false}if(gadwpItemData.scope=="admin-item"){a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,from:q,to:p,filter:g}}else{if(gadwpItemData.scope=="front-item"){a={action:"gadwp_frontend_item_reports",gadwp_security_frontend_item_reports:gadwpItemData.security,from:q,to:p,filter:gadwpItemData.filter}}else{a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,projectId:k,from:q,to:p}}}if(o=="realtime"){e.i18n=gadwpItemData.i18n.slice(20,26);e.render.focusFlag=1;jQuery(window).bind("focus",function(r){e.render.focusFlag=1}).bind("blur",function(r){e.render.focusFlag=0});l='<div id="gadwp-realtime'+b+'">';l+='<div class="gadwp-rt-box">';l+='<div class="gadwp-tdo-left">';l+='<div class="gadwp-online" id="gadwp-online">0</div>';l+="</div>";l+='<div class="gadwp-tdo-right" id="gadwp-tdo-right">';l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[0]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[1]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[2]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[3]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[4]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[5]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+="</div>";l+="</div>";l+="<div>";l+='<div id="gadwp-pages" class="gadwp-pages">&nbsp;</div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);e.rtRefresh(e.render.focusFlag);e.rtRuns=setInterval(e.rtRefresh,55000)}else{if(jQuery.inArray(n,["referrers","contentpages","searches"])>-1){l='<div id="gadwp-orgcharttablechart'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query="channelGrouping,"+n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartTableChart(r)})}else{if(n=="404errors"){l='<div id="gadwp-404tablechart'+b+'">';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.tableChart(r)})}else{if(n=="trafficdetails"||n=="technologydetails"){l='<div id="gadwp-orgchartpiecharts'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-1'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-2'+b+'" class="halfsize floatright"></div>';l+="</div>";l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-3'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-4'+b+'" class="halfsize floatright"></div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();if(n=="trafficdetails"){a.query="channelGrouping,medium,visitorType,source,socialNetwork";e.i18n=gadwpItemData.i18n.slice(0,5)}else{e.i18n=gadwpItemData.i18n.slice(15,20);a.query="deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding"}a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartPieCharts(r)})}else{if(n=="locations"){l='<div id="gadwp-geocharttablechart'+b+'">';l+='<div id="gadwp-geochart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.geoChartTableChart(r)})}else{l='<div id="gadwp-areachartbottomstats'+b+'">';l+='<div id="gadwp-areachart'+b+'"></div>';l+='<div id="gadwp-bottomstats'+b+'">';l+='<div class="inside">';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[5]+'</h3><p id="gdsessions'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[6]+'</h3><p id="gdusers'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[7]+'</h3><p id="gdpageviews'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[8]+'</h3><p id="gdbouncerate'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[9]+'</h3><p id="gdorganicsearch'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[10]+'</h3><p id="gdpagespervisit'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[26]+'</h3><p id="gdpagetime'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[27]+'</h3><p id="gdpageload'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[28]+'</h3><p id="gdsessionduration'+b+'">&nbsp;</p></div>';l+="</div>";l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();a.query=n+",bottomstats";jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.areaChartBottomStats(r)})}}}}}},refresh:function(){if(jQuery("#gadwp-areachartbottomstats"+b).length>0&&jQuery.isArray(e.areaChartBottomStatsData)){e.areaChartBottomStats(e.areaChartBottomStatsData)}if(jQuery("#gadwp-orgchartpiecharts"+b).length>0&&jQuery.isArray(e.orgChartPieChartsData)){e.orgChartPieCharts(e.orgChartPieChartsData)}if(jQuery("#gadwp-geocharttablechart"+b).length>0&&jQuery.isArray(e.geoChartTableChartData)){e.geoChartTableChart(e.geoChartTableChartData)}if(jQuery("#gadwp-orgcharttablechart"+b).length>0&&jQuery.isArray(e.orgChartTableChartData)){e.orgChartTableChart(e.orgChartTableChartData)}if(jQuery("#gadwp-404tablechart"+b).length>0&&jQuery.isArray(e.tableChartData)){e.tableChart(e.tableChartData)}},init:function(){if(!jQuery("#gadwp-reports"+b).length){return}if(jQuery("#gadwp-reports"+b).html().length){return}try{NProgress.configure({parent:"#gadwp-progressbar"+b,showSpinner:false});NProgress.start()}catch(j){e.alertMessage(gadwpItemData.i18n[0])}e.render(jQuery("#gadwp-sel-view"+b).val(),jQuery("#gadwp-sel-period"+b).val(),jQuery("#gadwp-sel-report"+b).val());jQuery(window).resize(function(){var k=jQuery(window).width()-e.oldViewPort;if((k<-5)||(k>5)){e.oldViewPort=jQuery(window).width();e.refresh()}})}};h.init();e.init();jQuery("#gadwp-sel-view"+b).change(function(){jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-period"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-report"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("[id^=gadwp-swmetric-]").click(function(){c=this.id.replace("gadwp-swmetric-","");d.setCookie("default_swmetric",c);jQuery("#gadwp-swmetric-sessions").css("color","#444");jQuery("#gadwp-swmetric-users").css("color","#444");jQuery("#gadwp-swmetric-pageviews").css("color","#444");jQuery("#"+this.id).css("color","#008ec2");jQuery("#gadwp-reports"+b).html("");e.init()});if(gadwpItemData.scope=="admin-widgets"){return}else{return this.dialog({width:"auto",maxWidth:510,height:"auto",modal:true,fluid:true,dialogClass:"gadwp wp-dialog",resizable:false,title:e.getTitle(gadwpItemData.scope),position:{my:"top",at:"top+100",of:window}})}}});function GADWPReportLoad(){if(gadwpItemData.scope=="admin-widgets"){jQuery("#gadwp-window-1").gadwpItemReport(1)}else{jQuery(gadwpItemData.getSelector(gadwpItemData.scope)).click(function(){if(!jQuery("#gadwp-window-"+gadwpItemData.getID(this)).length>0){jQuery("body").append('<div id="gadwp-window-'+gadwpItemData.getID(this)+'"></div>')}jQuery("#gadwp-window-"+gadwpItemData.getID(this)).gadwpItemReport(gadwpItemData.getID(this))})}jQuery(window).resize(function(){gadwpItemData.responsiveDialog()});jQuery(document).on("dialogopen",".ui-dialog",function(a,b){gadwpItemData.responsiveDialog()})};
1
+ "use strict";if(gadwpItemData.mapsApiKey){google.charts.load("current",{mapsApiKey:gadwpItemData.mapsApiKey,packages:["corechart","table","orgchart","geochart"]})}else{google.charts.load("current",{packages:["corechart","table","orgchart","geochart"]})}google.charts.setOnLoadCallback(GADWPReportLoad);gadwpItemData.getID=function(a){if(gadwpItemData.scope=="admin-item"){if(typeof a.id=="undefined"){return 0}if(a.id.split("-")[1]=="undefined"){return 0}else{return a.id.split("-")[1]}}else{if(typeof a.id=="undefined"){return 1}if(a.id.split("-")[4]=="undefined"){return 1}else{return a.id.split("-")[4]}}};gadwpItemData.getSelector=function(a){if(a=="admin-item"){return'a[id^="gadwp-"]'}else{return'li[id^="wp-admin-bar-gadwp"] a'}};gadwpItemData.responsiveDialog=function(){var b,a,c;c=jQuery(".ui-dialog:visible");c.each(function(){b=jQuery(this).find(".ui-dialog-content").data("ui-dialog");if(b.options.fluid){a=jQuery(window).width();if(a<(parseInt(b.options.maxWidth)+50)){jQuery(this).css("max-width","90%")}else{jQuery(this).css("max-width",b.options.maxWidth+"px")}b.option("position",b.options.position)}})};jQuery.fn.extend({gadwpItemReport:function(g){var a,d,h,e,f,i,c,b="-"+g;d={setCookie:function(k,m){var j,l=new Date();if(gadwpItemData.scope=="admin-widgets"){k="gadwp_wg_"+k}else{k="gadwp_ir_"+k}l.setTime(l.getTime()+(24*60*60*1000*365));j="expires="+l.toUTCString();document.cookie=k+"="+m+"; "+j+"; path=/"},getCookie:function(j){var l,m,n,k=0;if(gadwpItemData.scope=="admin-widgets"){j="gadwp_wg_"+j+"="}else{j="gadwp_ir_"+j+"="}m=document.cookie.split(";");for(k=0;k<m.length;k++){l=m[k];while(l.charAt(0)==" "){l=l.substring(1)}if(l.indexOf(j)==0){return l.substring(j.length,l.length)}}return false},escape:function(j){div=document.createElement("div");div.appendChild(document.createTextNode(j));return div.innerHTML}};h={addOptions:function(o,n){var j,l,m,k=[];if(!d.getCookie("default_metric")||!d.getCookie("default_dimension")||!d.getCookie("default_swmetric")){j="sessions";l="30daysAgo";if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){c="pageviews"}else{c="sessions"}d.setCookie("default_metric",j);d.setCookie("default_dimension",l);d.setCookie("default_swmetric",c)}else{j=d.getCookie("default_metric");l=d.getCookie("default_dimension");m=d.getCookie("default_view");c=d.getCookie("default_swmetric")}if(n==false){if(gadwpItemData.scope=="front-item"||gadwpItemData.scope=="admin-item"){k=""}else{k='<span id="gadwp-swmetric-sessions" title="'+gadwpItemData.i18n[5]+'" class="dashicons dashicons-clock" style="font-size:22px;padding:4px;"></span>'}k+='<span id="gadwp-swmetric-users" title="'+gadwpItemData.i18n[6]+'" class="dashicons dashicons-admin-users" style="font-size:22px;padding:4px;"></span>';k+='<span id="gadwp-swmetric-pageviews" title="'+gadwpItemData.i18n[7]+'" class="dashicons dashicons-admin-page" style="font-size:22px;padding:4px;"></span>';jQuery(o).html(k);jQuery("#gadwp-swmetric-"+c).css("color","#008ec2")}else{jQuery.each(n,function(p,q){if(p==j||p==l||p==m){k.push('<option value="'+p+'" selected="selected">'+q+"</option>")}else{k.push('<option value="'+p+'">'+q+"</option>")}});jQuery(o).html(k.join(""))}},init:function(){var j;if(!jQuery("#gadwp-window"+b).length){return}if(jQuery("#gadwp-window"+b).html().length){return}j='<div id="gadwp-container'+b+'">';if(gadwpItemData.viewList!=false){j+='<select id="gadwp-sel-view'+b+'"></select>'}j+='<select id="gadwp-sel-period'+b+'"></select> ';j+='<select id="gadwp-sel-report'+b+'"></select>';j+='<div id="gadwp-sel-metric'+b+'" style="float:right;display:none;">';j+="</div>";j+='<div id="gadwp-progressbar'+b+'"></div>';j+='<div id="gadwp-status'+b+'"></div>';j+='<div id="gadwp-reports'+b+'"></div>';j+='<div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">';j+=gadwpItemData.i18n[14];j+=' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_report&utm_medium=link&utm_content=back_report&utm_campaign=gadwp" rel="nofollow" style="text-decoration:none;font-size:1em;">GADWP</a>&nbsp;';j+="</div>";j+="</div>",jQuery("#gadwp-window"+b).append(j);h.addOptions("#gadwp-sel-view"+b,gadwpItemData.viewList);h.addOptions("#gadwp-sel-period"+b,gadwpItemData.dateList);h.addOptions("#gadwp-sel-report"+b,gadwpItemData.reportList);h.addOptions("#gadwp-sel-metric"+b,false)}};e={oldViewPort:0,orgChartTableChartData:"",tableChartData:"",orgChartPieChartsData:"",geoChartTableChartData:"",areaChartBottomStatsData:"",realtime:"",rtRuns:null,i18n:null,getTitle:function(j){if(j=="admin-item"){return jQuery("#gadwp"+b).attr("title")}else{return document.getElementsByTagName("title")[0].innerHTML}},alertMessage:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});jQuery("#gadwp-status"+b).html(j)},areaChartBottomStats:function(j){e.areaChartBottomStatsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();if(a.query=="visitBounceRate,bottomstats"){e.drawAreaChart(j[0],true)}else{e.drawAreaChart(j[0],false)}}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-areachart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){jQuery("#gadwp-reports"+b).show();e.drawBottomStats(j[1])}else{e.throwDebug(j[1])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-bottomstats"+b,j[1],"40px")}}else{e.throwDebug(j)}NProgress.done()},orgChartPieCharts:function(j){var k=0;e.orgChartPieChartsData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}for(k=1;k<j.length;k++){if(!jQuery.isNumeric(j[k])){if(jQuery.isArray(j[k])){jQuery("#gadwp-reports"+b).show();e.drawPieChart("piechart-"+k,j[k],e.i18n[k])}else{e.throwDebug(j[k])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-piechart-"+k+b,j[k],"80px")}}}else{e.throwDebug(j)}NProgress.done()},geoChartTableChart:function(j){e.geoChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawGeoChart(j[0]);e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-geochart"+b,j[0],"125px");e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},orgChartTableChart:function(j){e.orgChartTableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawOrgChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-orgchart"+b,j[0],"125px")}if(!jQuery.isNumeric(j[1])){if(jQuery.isArray(j[1])){e.drawTableChart(j[1])}else{e.throwDebug(j[1])}}else{e.throwError("#gadwp-tablechart"+b,j[1],"125px")}}else{e.throwDebug(j)}NProgress.done()},tableChart:function(j){e.tableChartData=j;if(jQuery.isArray(j)){if(!jQuery.isNumeric(j[0])){if(jQuery.isArray(j[0])){jQuery("#gadwp-reports"+b).show();e.drawTableChart(j[0])}else{e.throwDebug(j[0])}}else{jQuery("#gadwp-reports"+b).show();e.throwError("#gadwp-tablechart"+b,j[0],"125px")}}else{e.throwDebug(j)}NProgress.done()},drawTableChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={page:"enable",pageSize:10,width:"100%",allowHtml:true};k=new google.visualization.Table(document.getElementById("gadwp-tablechart"+b));k.draw(l,j)},drawOrgChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={allowCollapse:true,allowHtml:true,height:"100%"};k=new google.visualization.OrgChart(document.getElementById("gadwp-orgchart"+b));k.draw(l,j)},drawPieChart:function(o,m,n){var l,j,k;l=google.visualization.arrayToDataTable(m);j={is3D:false,tooltipText:"percentage",legend:"none",chartArea:{width:"99%",height:"80%"},title:n,pieSliceText:"value",colors:gadwpItemData.colorVariations};k=new google.visualization.PieChart(document.getElementById("gadwp-"+o+b));k.draw(l,j)},drawGeoChart:function(m){var l,j,k;l=google.visualization.arrayToDataTable(m);j={chartArea:{width:"99%",height:"90%"},colors:[gadwpItemData.colorVariations[5],gadwpItemData.colorVariations[4]]};if(gadwpItemData.region){j.region=gadwpItemData.region;j.displayMode="markers";j.datalessRegionColor="EFEFEF"}k=new google.visualization.GeoChart(document.getElementById("gadwp-geochart"+b));k.draw(l,j)},drawAreaChart:function(n,o){var m,j,l,k;m=google.visualization.arrayToDataTable(n);if(o){k=new google.visualization.NumberFormat({suffix:"%",fractionDigits:2});k.format(m,1)}j={legend:{position:"none"},pointSize:3,colors:[gadwpItemData.colorVariations[0],gadwpItemData.colorVariations[4]],chartArea:{width:"99%",height:"90%"},vAxis:{textPosition:"in",minValue:0},hAxis:{textPosition:"none"}};l=new google.visualization.AreaChart(document.getElementById("gadwp-areachart"+b));l.draw(m,j)},drawBottomStats:function(j){jQuery("#gdsessions"+b).html(j[0]);jQuery("#gdusers"+b).html(j[1]);jQuery("#gdpageviews"+b).html(j[2]);jQuery("#gdbouncerate"+b).html(j[3]);jQuery("#gdorganicsearch"+b).html(j[4]);jQuery("#gdpagespervisit"+b).html(j[5]);jQuery("#gdpagetime"+b).html(j[6]);jQuery("#gdpageload"+b).html(j[7]);jQuery("#gdsessionduration"+b).html(j[8])},rtOnlyUniqueValues:function(l,k,j){return j.indexOf(l)===k},rtCountSessions:function(k,m){var l=0,j=0;for(j=0;j<k.rows.length;j++){if(jQuery.inArray(m,k.rows[j])>-1){l+=parseInt(k.rows[j][6])}}return l},rtGenerateTooltip:function(k){var m=0,l="",j=0;for(j=0;j<k.length;j++){m+=parseInt(k[j].count);l+="<tr><td class='gadwp-pgdetailsl'>"+k[j].value+"</td><td class='gadwp-pgdetailsr'>"+k[j].count+"</td></tr>"}if(m){return("<table>"+l+"</table>")}else{return("")}},rtPageDetails:function(y,n){var w,o,r,x=0,v=0,m=0,s=0,t=0,z=0,C=0,q=0,l=0,u="",A="",p="",k="",B="";y=y.rows;for(x=0;x<y.length;x++){if(y[x][0]==n){o=y[x][5];switch(y[x][3]){case"REFERRAL":t+=parseInt(y[x][6]);u+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"ORGANIC":z+=parseInt(y[x][6]);A+="<tr><td class='gadwp-pgdetailsl'>"+y[x][2]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"SOCIAL":q+=parseInt(y[x][6]);p+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"CUSTOM":l+=parseInt(y[x][6]);k+="<tr><td class='gadwp-pgdetailsl'>"+y[x][1]+"</td><td class='gadwp-pgdetailsr'>"+y[x][6]+"</td></tr>";break;case"DIRECT":C+=parseInt(y[x][6]);break}}}if(t){u="<table><tr><td>"+e.i18n[0]+"("+t+")</td></tr>"+u+"</table><br />"}if(z){A="<table><tr><td>"+e.i18n[1]+"("+z+")</td></tr>"+A+"</table><br />"}if(q){p="<table><tr><td>"+e.i18n[2]+"("+q+")</td></tr>"+p+"</table><br />"}if(l){k="<table><tr><td>"+e.i18n[3]+"("+l+")</td></tr>"+k+"</table><br />"}if(C){B="<table><tr><td>"+e.i18n[4]+"("+C+")</td></tr></table><br />"}return("<p><center><strong>"+o+"</strong></center></p>"+u+A+p+k+B)},rtRefresh:function(){if(e.render.focusFlag){a.from=false;a.to=false;a.query="realtime";jQuery.post(gadwpItemData.ajaxurl,a,function(j){if(jQuery.isArray(j)){jQuery("#gadwp-reports"+b).show();e.realtime=j[0];e.drawRealtime(e.realtime)}else{e.throwDebug(j)}NProgress.done()})}},drawRealtime:function(y){var j,n,o,w,t,r,x=0,v=[],z=[],p=[],m=[],q=[],k=[],l=[],s="",o=[],w=[],t=[],r=[],u=["REFERRAL","ORGANIC","SOCIAL","CUSTOM"],A=["DIRECT","NEW"];jQuery(function(){jQuery("#gadwp-widget *").tooltip({tooltipClass:"gadwp"})});y=y[0];if(jQuery.isNumeric(y)||typeof y==="undefined"){y=[];y.totalsForAllResults=[];y.totalsForAllResults["rt:activeUsers"]="0";y.rows=[]}if(y.totalsForAllResults["rt:activeUsers"]!==document.getElementById("gadwp-online").innerHTML){jQuery("#gadwp-online").fadeOut("slow");jQuery("#gadwp-online").fadeOut(500);jQuery("#gadwp-online").fadeOut("slow",function(){if((parseInt(y.totalsForAllResults["rt:activeUsers"]))<(parseInt(document.getElementById("gadwp-online").innerHTML))){jQuery("#gadwp-online").css({"background-color":"#FFE8E8"})}else{jQuery("#gadwp-online").css({"background-color":"#E0FFEC"})}document.getElementById("gadwp-online").innerHTML=y.totalsForAllResults["rt:activeUsers"]});jQuery("#gadwp-online").fadeIn("slow");jQuery("#gadwp-online").fadeIn(500);jQuery("#gadwp-online").fadeIn("slow",function(){jQuery("#gadwp-online").css({"background-color":"#FFFFFF"})})}if(y.totalsForAllResults["rt:activeUsers"]==0){y.rows=[]}for(x=0;x<y.rows.length;x++){v.push(y.rows[x][0]);if(y.rows[x][3]=="REFERRAL"){z.push(y.rows[x][1])}if(y.rows[x][3]=="ORGANIC"){p.push(y.rows[x][2])}if(y.rows[x][3]=="SOCIAL"){m.push(y.rows[x][1])}if(y.rows[x][3]=="CUSTOM"){k.push(y.rows[x][1])}q.push(y.rows[x][3])}n=v.filter(e.rtOnlyUniqueValues);for(x=0;x<n.length;x++){l[x]={pagepath:n[x],count:e.rtCountSessions(y,n[x])}}l.sort(function(C,B){return B.count-C.count});s="";for(x=0;x<l.length;x++){if(x<gadwpItemData.rtLimitPages){s+='<div class="gadwp-pline"><div class="gadwp-pleft"><a href="#" data-gadwp="'+e.rtPageDetails(y,l[x].pagepath)+'">'+l[x].pagepath.substring(0,70)+'</a></div><div class="gadwp-pright">'+l[x].count+"</div></div>"}}document.getElementById("gadwp-pages").innerHTML='<br /><div class="gadwp-pg">'+s+"</div>";o=z.filter(e.rtOnlyUniqueValues);for(x=0;x<o.length;x++){o[x]={value:o[x],count:e.rtCountSessions(y,o[x])}}o.sort(function(C,B){return B.count-C.count});w=p.filter(e.rtOnlyUniqueValues);for(x=0;x<w.length;x++){w[x]={value:w[x],count:e.rtCountSessions(y,w[x])}}w.sort(function(C,B){return B.count-C.count});t=m.filter(e.rtOnlyUniqueValues);for(x=0;x<t.length;x++){t[x]={value:t[x],count:e.rtCountSessions(y,t[x])}}t.sort(function(C,B){return B.count-C.count});r=k.filter(e.rtOnlyUniqueValues);for(x=0;x<r.length;x++){r[x]={value:r[x],count:e.rtCountSessions(y,r[x])}}r.sort(function(C,B){return B.count-C.count});j='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(o)+'"><div class="gadwp-bleft">'+e.i18n[0]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[0])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(w)+'"><div class="gadwp-bleft">'+e.i18n[1]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[1])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(t)+'"><div class="gadwp-bleft">'+e.i18n[2]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[2])+"</div></div>";j+='<div class="gadwp-bigtext"><a href="#" data-gadwp="'+e.rtGenerateTooltip(r)+'"><div class="gadwp-bleft">'+e.i18n[3]+'</a></div><div class="gadwp-bright">'+e.rtCountSessions(y,u[3])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[4]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[0])+"</div></div>";j+='<div class="gadwp-bigtext"><div class="gadwp-bleft">'+e.i18n[5]+'</div><div class="gadwp-bright">'+e.rtCountSessions(y,A[1])+"</div></div>";document.getElementById("gadwp-tdo-right").innerHTML=j},throwDebug:function(j){jQuery("#gadwp-status"+b).css({"margin-top":"3px","padding-left":"5px",height:"auto",color:"#000","border-left":"5px solid red"});if(j=="-24"){jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[15])}else{jQuery("#gadwp-reports"+b).css({"background-color":"#F7F7F7",height:"auto","margin-top":"10px","padding-top":"50px","padding-bottom":"50px",color:"#000","text-align":"center"});jQuery("#gadwp-reports"+b).html(j);jQuery("#gadwp-reports"+b).show();jQuery("#gadwp-status"+b).html(gadwpItemData.i18n[11]);console.log("\n********************* GADWP Log ********************* \n\n"+j);a={action:"gadwp_set_error",response:j,gadwp_security_set_error:gadwpItemData.security};jQuery.post(gadwpItemData.ajaxurl,a)}},throwError:function(l,j,k){jQuery(l).css({"background-color":"#F7F7F7",height:"auto","padding-top":k,"padding-bottom":k,color:"#000","text-align":"center"});if(j==-21){jQuery(l).html(gadwpItemData.i18n[12])}else{jQuery(l).html(gadwpItemData.i18n[13]+" ("+j+")")}},render:function(j,o,n){var k,q,p,l,m;if(o=="realtime"){jQuery("#gadwp-sel-report"+b).hide()}else{jQuery("#gadwp-sel-report"+b).show();clearInterval(e.rtRuns)}jQuery("#gadwp-status"+b).html("");switch(o){case"today":q="today";p="today";break;case"yesterday":q="yesterday";p="yesterday";break;case"7daysAgo":q="7daysAgo";p="yesterday";break;case"14daysAgo":q="14daysAgo";p="yesterday";break;case"90daysAgo":q="90daysAgo";p="yesterday";break;case"365daysAgo":q="365daysAgo";p="yesterday";break;case"1095daysAgo":q="1095daysAgo";p="yesterday";break;default:q="30daysAgo";p="yesterday";break}d.setCookie("default_metric",n);d.setCookie("default_dimension",o);if(typeof j!=="undefined"){d.setCookie("default_view",j);k=j}else{k=false}if(gadwpItemData.scope=="admin-item"){a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,from:q,to:p,filter:g}}else{if(gadwpItemData.scope=="front-item"){a={action:"gadwp_frontend_item_reports",gadwp_security_frontend_item_reports:gadwpItemData.security,from:q,to:p,filter:gadwpItemData.filter}}else{a={action:"gadwp_backend_item_reports",gadwp_security_backend_item_reports:gadwpItemData.security,projectId:k,from:q,to:p}}}if(o=="realtime"){e.i18n=gadwpItemData.i18n.slice(20,26);e.render.focusFlag=1;jQuery(window).bind("focus",function(r){e.render.focusFlag=1}).bind("blur",function(r){e.render.focusFlag=0});l='<div id="gadwp-realtime'+b+'">';l+='<div class="gadwp-rt-box">';l+='<div class="gadwp-tdo-left">';l+='<div class="gadwp-online" id="gadwp-online">0</div>';l+="</div>";l+='<div class="gadwp-tdo-right" id="gadwp-tdo-right">';l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[0]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[1]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[2]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[3]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[4]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+='<div class="gadwp-bigtext">';l+='<div class="gadwp-bleft">'+e.i18n[5]+"</div>";l+='<div class="gadwp-bright">0</div>';l+="</div>";l+="</div>";l+="</div>";l+="<div>";l+='<div id="gadwp-pages" class="gadwp-pages">&nbsp;</div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);e.rtRefresh(e.render.focusFlag);e.rtRuns=setInterval(e.rtRefresh,55000)}else{if(jQuery.inArray(n,["referrers","contentpages","searches"])>-1){l='<div id="gadwp-orgcharttablechart'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query="channelGrouping,"+n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartTableChart(r)})}else{if(n=="404errors"){l='<div id="gadwp-404tablechart'+b+'">';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.tableChart(r)})}else{if(n=="trafficdetails"||n=="technologydetails"){l='<div id="gadwp-orgchartpiecharts'+b+'">';l+='<div id="gadwp-orgchart'+b+'"></div>';l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-1'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-2'+b+'" class="halfsize floatright"></div>';l+="</div>";l+='<div class="gadwp-floatwraper">';l+='<div id="gadwp-piechart-3'+b+'" class="halfsize floatleft"></div>';l+='<div id="gadwp-piechart-4'+b+'" class="halfsize floatright"></div>';l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();if(n=="trafficdetails"){a.query="channelGrouping,medium,visitorType,source,socialNetwork";e.i18n=gadwpItemData.i18n.slice(0,5)}else{e.i18n=gadwpItemData.i18n.slice(15,20);a.query="deviceCategory,browser,operatingSystem,screenResolution,mobileDeviceBranding"}a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.orgChartPieCharts(r)})}else{if(n=="locations"){l='<div id="gadwp-geocharttablechart'+b+'">';l+='<div id="gadwp-geochart'+b+'"></div>';l+='<div id="gadwp-tablechart'+b+'"></div>';l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();jQuery("#gadwp-sel-metric"+b).show();a.query=n;a.metric=c;jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.geoChartTableChart(r)})}else{l='<div id="gadwp-areachartbottomstats'+b+'">';l+='<div id="gadwp-areachart'+b+'"></div>';l+='<div id="gadwp-bottomstats'+b+'">';l+='<div class="inside">';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[5]+'</h3><p id="gdsessions'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[6]+'</h3><p id="gdusers'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[7]+'</h3><p id="gdpageviews'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[8]+'</h3><p id="gdbouncerate'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[9]+'</h3><p id="gdorganicsearch'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[10]+'</h3><p id="gdpagespervisit'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[26]+'</h3><p id="gdpagetime'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[27]+'</h3><p id="gdpageload'+b+'">&nbsp;</p></div>';l+='<div class="small-box"><h3>'+gadwpItemData.i18n[28]+'</h3><p id="gdsessionduration'+b+'">&nbsp;</p></div>';l+="</div>";l+="</div>";l+="</div>";jQuery("#gadwp-reports"+b).html(l);jQuery("#gadwp-reports"+b).hide();a.query=n+",bottomstats";jQuery.post(gadwpItemData.ajaxurl,a,function(r){e.areaChartBottomStats(r)})}}}}}},refresh:function(){if(jQuery("#gadwp-areachartbottomstats"+b).length>0&&jQuery.isArray(e.areaChartBottomStatsData)){e.areaChartBottomStats(e.areaChartBottomStatsData)}if(jQuery("#gadwp-orgchartpiecharts"+b).length>0&&jQuery.isArray(e.orgChartPieChartsData)){e.orgChartPieCharts(e.orgChartPieChartsData)}if(jQuery("#gadwp-geocharttablechart"+b).length>0&&jQuery.isArray(e.geoChartTableChartData)){e.geoChartTableChart(e.geoChartTableChartData)}if(jQuery("#gadwp-orgcharttablechart"+b).length>0&&jQuery.isArray(e.orgChartTableChartData)){e.orgChartTableChart(e.orgChartTableChartData)}if(jQuery("#gadwp-404tablechart"+b).length>0&&jQuery.isArray(e.tableChartData)){e.tableChart(e.tableChartData)}},init:function(){if(!jQuery("#gadwp-reports"+b).length){return}if(jQuery("#gadwp-reports"+b).html().length){return}try{NProgress.configure({parent:"#gadwp-progressbar"+b,showSpinner:false});NProgress.start()}catch(j){e.alertMessage(gadwpItemData.i18n[0])}e.render(jQuery("#gadwp-sel-view"+b).val(),jQuery("#gadwp-sel-period"+b).val(),jQuery("#gadwp-sel-report"+b).val());jQuery(window).resize(function(){var k=jQuery(window).width()-e.oldViewPort;if((k<-5)||(k>5)){e.oldViewPort=jQuery(window).width();e.refresh()}})}};h.init();e.init();jQuery("#gadwp-sel-view"+b).change(function(){jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-period"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("#gadwp-sel-report"+b).change(function(){jQuery("#gadwp-sel-metric"+b).hide();jQuery("#gadwp-reports"+b).html("");e.init()});jQuery("[id^=gadwp-swmetric-]").click(function(){c=this.id.replace("gadwp-swmetric-","");d.setCookie("default_swmetric",c);jQuery("#gadwp-swmetric-sessions").css("color","#444");jQuery("#gadwp-swmetric-users").css("color","#444");jQuery("#gadwp-swmetric-pageviews").css("color","#444");jQuery("#"+this.id).css("color","#008ec2");jQuery("#gadwp-reports"+b).html("");e.init()});if(gadwpItemData.scope=="admin-widgets"){return}else{return this.dialog({width:"auto",maxWidth:510,height:"auto",modal:true,fluid:true,dialogClass:"gadwp wp-dialog",resizable:false,title:e.getTitle(gadwpItemData.scope),position:{my:"top",at:"top+100",of:window}})}}});function GADWPReportLoad(){if(gadwpItemData.scope=="admin-widgets"){jQuery("#gadwp-window-1").gadwpItemReport(1)}else{console.log("Test");jQuery(gadwpItemData.getSelector(gadwpItemData.scope)).click(function(){if(!jQuery("#gadwp-window-"+gadwpItemData.getID(this)).length>0){jQuery("body").append('<div id="gadwp-window-'+gadwpItemData.getID(this)+'"></div>')}jQuery("#gadwp-window-"+gadwpItemData.getID(this)).gadwpItemReport(gadwpItemData.getID(this))})}jQuery(window).resize(function(){gadwpItemData.responsiveDialog()});jQuery(document).on("dialogopen",".ui-dialog",function(a,b){gadwpItemData.responsiveDialog()})};
config.php CHANGED
@@ -18,7 +18,9 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
18
  public $options;
19
 
20
  public function __construct() {
21
- // Get plugin options
 
 
22
  $this->get_plugin_options();
23
  // Automatic updates
24
  add_filter( 'auto_update_plugin', array( $this, 'automatic_update' ), 10, 2 );
@@ -48,7 +50,6 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
48
  if ( isset( $item['slug'] ) && 'google-analytics-dashboard-for-wp' == $item['slug'] ) {
49
  // Only when a minor update is available
50
  if ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) ) {
51
- update_option( 'gadwp_got_updated', true );
52
  return ( $this->get_major_version( GADWP_CURRENT_VERSION ) == $this->get_major_version( $item['new_version'] ) );
53
  }
54
  }
@@ -87,12 +88,14 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
87
  'trackingcode_infooter',
88
  'trackingevents_infooter',
89
  'ga_formsubmit_tracking',
90
- 'ga_dash_excludesa',
91
  'ga_pagescrolldepth_tracking',
92
  'tm_pagescrolldepth_tracking',
93
  'ga_speed_samplerate',
94
  'ga_user_samplerate',
95
  'ga_event_precision',
 
 
96
  );
97
  foreach ( $numerics as $key ) {
98
  if ( isset( $options[$key] ) ) {
@@ -101,9 +104,9 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
101
  }
102
 
103
  $texts = array( 'ga_crossdomain_list',
104
- 'ga_dash_clientid',
105
- 'ga_dash_clientsecret',
106
- 'ga_dash_style',
107
  'ga_target_geomap',
108
  'ga_cookiedomain',
109
  'ga_cookiename',
@@ -115,7 +118,7 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
115
  'ga_event_downloads',
116
  'ga_event_affiliates',
117
  'ecommerce_mode',
118
- 'ga_dash_tracking_type',
119
  );
120
  foreach ( $texts as $key ) {
121
  if ( isset( $options[$key] ) ) {
@@ -148,45 +151,42 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
148
  $options['ga_cookieexpires'] = (int) $options['ga_cookieexpires'];
149
  }
150
 
151
- $token = json_decode( $options['ga_dash_token'] ); // v4.8.2
152
- if ( isset( $token->token_type ) ) {
153
- unset( $options['ga_dash_refresh_token'] );
154
- }
155
-
156
  return $options;
157
  }
158
 
159
  public function set_plugin_options( $network_settings = false ) {
160
  // Handle Network Mode
161
  $options = $this->options;
162
- $get_network_options = get_site_option( 'gadash_network_options' );
163
  $old_network_options = (array) json_decode( $get_network_options );
 
164
  if ( is_multisite() ) {
165
  if ( $network_settings ) { // Retrieve network options, clear blog options, store both to db
166
- $network_options['ga_dash_token'] = $this->options['ga_dash_token'];
167
- $options['ga_dash_token'] = '';
168
  if ( is_network_admin() ) {
169
- $network_options['ga_dash_profile_list'] = $this->options['ga_dash_profile_list'];
170
- $options['ga_dash_profile_list'] = array();
171
- $network_options['ga_dash_clientid'] = $this->options['ga_dash_clientid'];
172
- $options['ga_dash_clientid'] = '';
173
- $network_options['ga_dash_clientsecret'] = $this->options['ga_dash_clientsecret'];
174
- $options['ga_dash_clientsecret'] = '';
175
- $network_options['ga_dash_userapi'] = $this->options['ga_dash_userapi'];
176
- $options['ga_dash_userapi'] = 0;
177
- $network_options['ga_dash_network'] = $this->options['ga_dash_network'];
178
- $network_options['ga_dash_excludesa'] = $this->options['ga_dash_excludesa'];
179
  $network_options['automatic_updates_minorversion'] = $this->options['automatic_updates_minorversion'];
180
- unset( $options['ga_dash_network'] );
181
- if ( isset( $this->options['ga_dash_tableid_network'] ) ) {
182
- $network_options['ga_dash_tableid_network'] = $this->options['ga_dash_tableid_network'];
183
- unset( $options['ga_dash_tableid_network'] );
184
  }
185
  }
186
- update_site_option( 'gadash_network_options', json_encode( $this->validate_data( array_merge( $old_network_options, $network_options ) ) ) );
 
187
  }
188
  }
189
- update_option( 'gadash_options', json_encode( $this->validate_data( $options ) ) );
190
  }
191
 
192
  private function get_plugin_options() {
@@ -195,24 +195,24 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
195
  */
196
  global $blog_id;
197
 
198
- if ( ! get_option( 'gadash_options' ) ) {
199
  GADWP_Install::install();
200
  }
201
- $this->options = (array) json_decode( get_option( 'gadash_options' ) );
202
  // Maintain Compatibility
203
  $this->maintain_compatibility();
204
  // Handle Network Mode
205
  if ( is_multisite() ) {
206
- $get_network_options = get_site_option( 'gadash_network_options' );
207
  $network_options = (array) json_decode( $get_network_options );
208
- if ( isset( $network_options['ga_dash_network'] ) && ( $network_options['ga_dash_network'] ) ) {
209
- if ( ! is_network_admin() && ! empty( $network_options['ga_dash_profile_list'] ) && isset( $network_options['ga_dash_tableid_network']->$blog_id ) ) {
210
- $network_options['ga_dash_profile_list'] = array( 0 => GADWP_Tools::get_selected_profile( $network_options['ga_dash_profile_list'], $network_options['ga_dash_tableid_network']->$blog_id ) );
211
- $network_options['ga_dash_tableid_jail'] = $network_options['ga_dash_profile_list'][0][1];
212
  }
213
  $this->options = array_merge( $this->options, $network_options );
214
  } else {
215
- $this->options['ga_dash_network'] = 0;
216
  }
217
  }
218
  }
@@ -220,21 +220,11 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
220
  private function maintain_compatibility() {
221
  $flag = false;
222
 
223
- if ( GADWP_CURRENT_VERSION != get_option( 'gadwp_version' ) ) {
 
224
  $flag = true;
225
  update_option( 'gadwp_version', GADWP_CURRENT_VERSION );
226
- $rebuild_token = json_decode( $this->options['ga_dash_token'] ); // v4.8.2
227
- if ( is_object( $rebuild_token ) && ! isset( $rebuild_token->token_type ) ) {
228
- if ( isset( $this->options['ga_dash_refresh_token'] ) ) {
229
- $rebuild_token->refresh_token = $this->options['ga_dash_refresh_token'];
230
- }
231
- $rebuild_token->token_type = "Bearer";
232
- $this->options['ga_dash_token'] = json_encode( $rebuild_token );
233
- unset( $this->options['ga_dash_refresh_token'] );
234
- $this->set_plugin_options( true );
235
- } else {
236
- unset( $this->options['ga_dash_refresh_token'] );
237
- }
238
  GADWP_Tools::clear_cache();
239
  GADWP_Tools::delete_cache( 'last_error' );
240
  if ( is_multisite() ) { // Cleanup errors and cookies on the entire network
@@ -246,16 +236,13 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
246
  } else {
247
  GADWP_Tools::delete_cache( 'gapi_errors' );
248
  }
249
- // GADWP_Tools::unset_cookie( 'default_metric' );
250
- // GADWP_Tools::unset_cookie( 'default_dimension' );
251
- // GADWP_Tools::unset_cookie( 'default_view' );
252
  }
253
 
254
  /* @formatter:off */
255
  $zeros = array( 'ga_enhanced_links',
256
- 'ga_dash_network',
257
  'ga_enhanced_excludesa',
258
- 'ga_dash_remarketing',
259
  'ga_event_bouncerate',
260
  'ga_author_dimindex',
261
  'ga_tag_dimindex',
@@ -282,11 +269,13 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
282
  'trackingcode_infooter', //v5.0
283
  'trackingevents_infooter', //v5.0
284
  'ga_formsubmit_tracking', //v5.0
285
- 'ga_dash_excludesa', //v5.0
286
  'ga_pagescrolldepth_tracking', //v5.0
287
  'tm_pagescrolldepth_tracking', //v5.0
288
  'ga_event_precision', //v5.1.1.1
289
  'ga_force_ssl', //v5.1.2
 
 
290
  );
291
  foreach ( $zeros as $key ) {
292
  if ( ! isset( $this->options[$key] ) ) {
@@ -303,7 +292,7 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
303
  }
304
 
305
  if ( isset($this->options['ga_dash_tracking']) && 0 == $this->options['ga_dash_tracking'] ) { // v5.0.1
306
- $this->options['ga_dash_tracking_type'] = 'disabled';
307
  $flag = true;
308
  }
309
 
@@ -318,6 +307,9 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
318
  'ga_dash_frontend_stats', // v4.8
319
  'item_reports', // v4.8
320
  'ga_dash_tracking', // v5.0
 
 
 
321
  );
322
  foreach ( $unsets as $key ) {
323
  if ( isset( $this->options[$key] ) ) {
@@ -354,10 +346,10 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
354
  }
355
  }
356
 
357
- $arrays = array( 'ga_dash_access_front',
358
- 'ga_dash_access_back',
359
- 'ga_dash_profile_list',
360
- 'ga_track_exclude',
361
  );
362
  foreach ( $arrays as $key ) {
363
  if ( ! is_array( $this->options[$key] ) ) {
@@ -365,11 +357,11 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
365
  $flag = true;
366
  }
367
  }
368
- if ( empty( $this->options['ga_dash_access_front'] ) ) {
369
- $this->options['ga_dash_access_front'][] = 'administrator';
370
  }
371
- if ( empty( $this->options['ga_dash_access_back'] ) ) {
372
- $this->options['ga_dash_access_back'][] = 'administrator';
373
  }
374
  /* @formatter:on */
375
 
@@ -397,8 +389,8 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
397
  $flag = true;
398
  }
399
 
400
- if ( 'classic' == $this->options['ga_dash_tracking_type'] ) { // v5.0
401
- $this->options['ga_dash_tracking_type'] = 'universal';
402
  $flag = true;
403
  }
404
 
@@ -406,5 +398,47 @@ if ( ! class_exists( 'GADWP_Config' ) ) {
406
  $this->set_plugin_options( false );
407
  }
408
  }