Google Analytics Dashboard for WP (GADWP) - Version 4.6

Version Description

  • Enhancement: Italian translation, updated by Leo
  • Enhancement: Japanese translation, updated by Hinaloe
  • Enhancement: Portuguese (Brazil) translation, updated by Treed Box
  • Enhancement: introducing a manager class to keep track of all instances and their references
  • Enhancement: push the tracking code at the end of head section, props by Caleb Evans
  • Enhancement: better support for remove_action and wp_dequeue_script
  • Enhancement: Ajax calls optimization
  • Bug Fix: loading bar issues while not all frontend features are enabled
  • Bug Fix: in-existent script enqueued in frontend component, reported by mmokrejs
  • Bug Fix: i18n improvements, committed by Hinaloe
  • Bug Fix: PHP notice when using bbPress, reported by sheridencharles
  • Bug Fix: inexistent script enqueued in frontend component, reported by mmokrejs
  • Bug Fix: improved URI detection in Pages and Posts backend reports
  • Bug Fix: color picker and settings page tabs not working when per posts/pages reports are disabled
Download this release

Release Info

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

Code changes from version 4.5.1 to 4.6

Files changed (56) hide show
  1. admin/ajax-actions.php +113 -97
  2. admin/css/gadwp.css +5 -2
  3. admin/item-reports.php +57 -54
  4. admin/settings.php +1249 -1436
  5. admin/setup.php +248 -244
  6. admin/widgets.php +271 -286
  7. config.php +302 -309
  8. front/ajax-actions.php +127 -118
  9. front/item-reports.php +79 -72
  10. front/tracking.php +54 -51
  11. front/tracking/code-classic.php +9 -4
  12. front/tracking/code-universal.php +51 -46
  13. front/tracking/events-classic.php +6 -1
  14. front/tracking/events-universal.php +20 -14
  15. front/widgets.php +107 -107
  16. gadwp.php +248 -73
  17. install/install.php +132 -127
  18. install/uninstall.php +36 -31
  19. languages/ga-dash-ar.mo +0 -0
  20. languages/ga-dash-ar.po +417 -349
  21. languages/ga-dash-de_DE.mo +0 -0
  22. languages/ga-dash-de_DE.po +396 -346
  23. languages/ga-dash-es_ES.mo +0 -0
  24. languages/ga-dash-es_ES.po +361 -343
  25. languages/ga-dash-fr_FR.mo +0 -0
  26. languages/ga-dash-fr_FR.po +413 -354
  27. languages/ga-dash-hu_HU.mo +0 -0
  28. languages/ga-dash-hu_HU.po +395 -345
  29. languages/ga-dash-it_IT.mo +0 -0
  30. languages/ga-dash-it_IT.po +468 -387
  31. languages/ga-dash-ja.mo +0 -0
  32. languages/ga-dash-ja.po +494 -596
  33. languages/ga-dash-nl_NL.mo +0 -0
  34. languages/ga-dash-nl_NL.po +338 -334
  35. languages/ga-dash-pl_PL.mo +0 -0
  36. languages/ga-dash-pl_PL.po +407 -350
  37. languages/ga-dash-pt_BR.mo +0 -0
  38. languages/ga-dash-pt_BR.po +505 -366
  39. languages/ga-dash.pot +435 -605
  40. readme.txt +24 -8
  41. tools/autoload.php +17 -12
  42. tools/gapi.php +943 -937
  43. tools/iso3166.php +244 -239
  44. tools/nprogress/nprogress.css +64 -48
  45. tools/src/Google/Auth/Abstract.php +11 -11
  46. tools/src/Google/Auth/AppIdentity.php +64 -59
  47. tools/src/Google/Auth/AssertionCredentials.php +112 -103
  48. tools/src/Google/Auth/LoginTicket.php +46 -45
  49. tools/src/Google/Auth/OAuth2.php +481 -473
  50. tools/src/Google/Auth/Simple.php +31 -29
  51. tools/src/Google/Cache/Abstract.php +29 -29
  52. tools/src/Google/Cache/Apc.php +72 -71
  53. tools/src/Google/Cache/File.php +146 -142
  54. tools/src/Google/Cache/Memcache.php +137 -132
  55. tools/src/Google/Cache/Null.php +25 -25
  56. tools/src/Google/Client.php +630 -721
admin/ajax-actions.php CHANGED
@@ -5,107 +5,123 @@
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
8
- if (! class_exists('GADASH_Backend_Ajax')) {
9
 
10
- final class GADASH_Backend_Ajax
11
- {
 
12
 
13
- function __construct()
14
- {
15
- // Admin Widget action
16
- add_action('wp_ajax_gadash_get_widgetreports', array(
17
- $this,
18
- 'ajax_widget_reports'
19
- ));
20
- // Items action
21
- add_action('wp_ajax_gadwp_get_ItemReports', array(
22
- $this,
23
- 'ajax_item_reports'
24
- ));
25
- }
26
 
27
- /**
28
- * Ajax handler for Items (posts/pages)
29
- *
30
- * @return json|int
31
- */
32
- function ajax_item_reports()
33
  {
34
- global $GADASH_Config;
35
- if (! isset($_REQUEST['gadwp_security_item_reports']) or ! wp_verify_nonce($_REQUEST['gadwp_security_item_reports'], 'gadwp_get_itemreports')) {
36
- wp_die(- 30);
37
- }
38
- $from = $_REQUEST['from'];
39
- $to = $_REQUEST['to'];
40
- $query = $_REQUEST['query'];
41
- $filter_id = $_REQUEST['filter'];
42
- if (ob_get_length()) {
43
- ob_clean();
44
- }
45
- $tools = new GADASH_Tools();
46
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['item_reports']) {
47
- wp_die(- 31);
48
- }
49
- if ($GADASH_Config->options['ga_dash_token'] and $GADASH_Config->options['ga_dash_tableid_jail'] and $from and $to) {
50
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
51
- global $GADASH_GAPI;
52
- } else {
53
- wp_die(- 24);
54
- }
55
- $projectId = $GADASH_Config->options['ga_dash_tableid_jail'];
56
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
57
- if (isset($profile_info[4])) {
58
- $GADASH_GAPI->timeshift = $profile_info[4];
59
- } else {
60
- $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
61
- }
62
- // strip the protocol & domain
63
- $uri = str_replace($tools->strip_protocol($profile_info[3]), '', $tools->strip_protocol(get_permalink($filter_id)));
64
- // make sure the path starts with '/'
65
- if ($uri) {
66
- $uri = '/' . ltrim($uri, '/');
67
- }
68
- // allow URI correction before sending an API request
69
- $filter = apply_filters('gadwp_backenditem_uri', $uri);
70
- $GADASH_GAPI->get($projectId, $query, $from, $to, $filter);
71
- }
72
 
73
- /**
74
- * Ajax handler for Admin Widget
75
- *
76
- * @return json|int
77
- */
78
- function ajax_widget_reports()
79
- {
80
- global $GADASH_Config;
81
- if (! isset($_REQUEST['gadash_security_widget_reports']) or ! wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
82
- wp_die(- 30);
83
- }
84
- $projectId = $_REQUEST['projectId'];
85
- $from = $_REQUEST['from'];
86
- $to = $_REQUEST['to'];
87
- $query = $_REQUEST['query'];
88
- if (ob_get_length()) {
89
- ob_clean();
90
- }
91
- $tools = new GADASH_Tools();
92
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['dashboard_widget']) {
93
- wp_die(- 31);
94
- }
95
- if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
96
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
97
- global $GADASH_GAPI;
98
- } else {
99
- wp_die(- 24);
100
- }
101
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
102
- if (isset($profile_info[4])) {
103
- $GADASH_GAPI->timeshift = $profile_info[4];
104
- } else {
105
- $GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
106
- }
107
- $GADASH_GAPI->get($projectId, $query, $from, $to);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  }
109
- }
110
  }
111
- $GADASH_Backend_Ajax = new GADASH_Backend_Ajax();
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
 
8
 
9
+ // Exit if accessed directly
10
+ if (! defined('ABSPATH'))
11
+ exit();
12
 
13
+ if (! class_exists('GADWP_Backend_Ajax')) {
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ final class GADWP_Backend_Ajax
 
 
 
 
 
16
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ private $gadwp;
19
+
20
+ public function __construct()
21
+ {
22
+ $this->gadwp = GADWP();
23
+
24
+ if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && (1 == $this->gadwp->config->options['dashboard_widget'])) {
25
+ // Admin Widget action
26
+ add_action('wp_ajax_gadash_get_widgetreports', array(
27
+ $this,
28
+ 'ajax_widget_reports'
29
+ ));
30
+ }
31
+
32
+ if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && (1 == $this->gadwp->config->options['item_reports'])) {
33
+ // Items action
34
+ add_action('wp_ajax_gadwp_get_ItemReports', array(
35
+ $this,
36
+ 'ajax_item_reports'
37
+ ));
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Ajax handler for Items (posts/pages)
43
+ *
44
+ * @return json|int
45
+ */
46
+ public function ajax_item_reports()
47
+ {
48
+ if (! isset($_REQUEST['gadwp_security_item_reports']) || ! wp_verify_nonce($_REQUEST['gadwp_security_item_reports'], 'gadwp_get_itemreports')) {
49
+ wp_die(- 30);
50
+ }
51
+ $from = $_REQUEST['from'];
52
+ $to = $_REQUEST['to'];
53
+ $query = $_REQUEST['query'];
54
+ $filter_id = $_REQUEST['filter'];
55
+ if (ob_get_length()) {
56
+ ob_clean();
57
+ }
58
+
59
+ if (! GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) || 0 == $this->gadwp->config->options['item_reports']) {
60
+ wp_die(- 31);
61
+ }
62
+ if ($this->gadwp->config->options['ga_dash_token'] && $this->gadwp->config->options['ga_dash_tableid_jail'] && $from && $to) {
63
+ if (null === $this->gadwp->gapi_controller) {
64
+ $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
65
+ }
66
+ } else {
67
+ wp_die(- 24);
68
+ }
69
+ $projectId = $this->gadwp->config->options['ga_dash_tableid_jail'];
70
+ $profile_info = GADWP_Tools::get_selected_profile($this->gadwp->config->options['ga_dash_profile_list'], $projectId);
71
+ if (isset($profile_info[4])) {
72
+ $this->gadwp->gapi_controller->timeshift = $profile_info[4];
73
+ } else {
74
+ $this->gadwp->gapi_controller->timeshift = (int) current_time('timestamp') - time();
75
+ }
76
+
77
+ $uri_parts = explode('/', get_permalink($filter_id), 4);
78
+
79
+ if (isset($uri_parts[3])) {
80
+ $uri = '/' . $uri_parts[3];
81
+ } else {
82
+ wp_die(- 25);
83
+ }
84
+
85
+ // allow URI correction before sending an API request
86
+ $filter = apply_filters('gadwp_backenditem_uri', $uri);
87
+ $this->gadwp->gapi_controller->get($projectId, $query, $from, $to, $filter);
88
+ }
89
+
90
+ /**
91
+ * Ajax handler for Admin Widget
92
+ *
93
+ * @return json|int
94
+ */
95
+ public function ajax_widget_reports()
96
+ {
97
+ if (! isset($_REQUEST['gadash_security_widget_reports']) || ! wp_verify_nonce($_REQUEST['gadash_security_widget_reports'], 'gadash_get_widgetreports')) {
98
+ wp_die(- 30);
99
+ }
100
+ $projectId = $_REQUEST['projectId'];
101
+ $from = $_REQUEST['from'];
102
+ $to = $_REQUEST['to'];
103
+ $query = $_REQUEST['query'];
104
+ if (ob_get_length()) {
105
+ ob_clean();
106
+ }
107
+
108
+ if (! GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) || 0 == $this->gadwp->config->options['dashboard_widget']) {
109
+ wp_die(- 31);
110
+ }
111
+ if ($this->gadwp->config->options['ga_dash_token'] && $projectId && $from && $to) {
112
+ if (null === $this->gadwp->gapi_controller) {
113
+ $this->gadwp->gapi_controller = new GADWP_GAPI_Controller();
114
+ }
115
+ } else {
116
+ wp_die(- 24);
117
+ }
118
+ $profile_info = GADWP_Tools::get_selected_profile($this->gadwp->config->options['ga_dash_profile_list'], $projectId);
119
+ if (isset($profile_info[4])) {
120
+ $this->gadwp->gapi_controller->timeshift = $profile_info[4];
121
+ } else {
122
+ $this->gadwp->gapi_controller->timeshift = (int) current_time('timestamp') - time();
123
+ }
124
+ $this->gadwp->gapi_controller->get($projectId, $query, $from, $to);
125
+ }
126
  }
 
127
  }
 
admin/css/gadwp.css CHANGED
@@ -1,6 +1,5 @@
1
  /* Tab navigation */
2
- #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude,
3
- #gadwp-config {
4
  display: none;
5
  }
6
 
@@ -23,6 +22,10 @@ td.title-select {
23
  width: 300px;
24
  }
25
 
 
 
 
 
26
  td.debugging {
27
  width: 300px;
28
  }
1
  /* Tab navigation */
2
+ #gadwp-events, #gadwp-custom, #gadwp-advanced, #gadwp-exclude, #gadwp-config {
 
3
  display: none;
4
  }
5
 
22
  width: 300px;
23
  }
24
 
25
+ .gadwp-help{
26
+ padding-left:15px;
27
+ }
28
+
29
  td.debugging {
30
  width: 300px;
31
  }
admin/item-reports.php CHANGED
@@ -5,64 +5,67 @@
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
8
- if (! class_exists('GADASH_Back_Stats')) {
9
 
10
- final class GADASH_Back_Stats
11
- {
 
12
 
13
- function __construct()
14
- {
15
- global $GADASH_Config;
16
- $tools = new GADASH_Tools();
17
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['item_reports']) {
18
- return;
19
- }
20
- // Add custom column in Posts List
21
- add_filter('manage_posts_columns', array(
22
- $this,
23
- 'add_stats_column'
24
- ));
25
- // Populate custom column in Posts List
26
- add_action('manage_posts_custom_column', array(
27
- $this,
28
- 'display_item_stats'
29
- ), 10, 2);
30
- // Add custom column in Pages List
31
- add_filter('manage_pages_columns', array(
32
- $this,
33
- 'add_stats_column'
34
- ));
35
- // Populate custom column in Pages List
36
- add_action('manage_pages_custom_column', array(
37
- $this,
38
- 'display_item_stats'
39
- ), 10, 2);
40
- }
41
 
42
- function display_item_stats($column, $id)
43
  {
44
- global $GADASH_Config, $wp_version;
45
-
46
- if ($column != 'gadwp_stats'){
47
- return;
48
- }
49
-
50
- if (version_compare($wp_version, '3.8.0', '>=')) {
51
- echo '<a id="gadwp-' . $id . '" title="' . get_the_title($id) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
52
- } else {
53
- echo '<a id="gadwp-' . $id . '" title="' . get_the_title($id) . '" href="#' . $id . '"><img class="gadwp-icon-oldwp" src="' . $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png"</a>';
54
- }
55
- }
56
 
57
- function add_stats_column($columns)
58
- {
59
- return array_merge($columns, array(
60
- 'gadwp_stats' => __('Analytics', 'ga-dash'),
61
- ));
62
- }
63
- }
64
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
- if (is_admin()) {
67
- $GADASH_Back_Stats = new GADASH_Back_Stats();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
  }
5
  * License: GPLv2 or later
6
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
  */
 
8
 
9
+ // Exit if accessed directly
10
+ if (! defined('ABSPATH'))
11
+ exit();
12
 
13
+ if (! class_exists('GADWP_Backend_Item_Reports')) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ final class GADWP_Backend_Item_Reports
16
  {
 
 
 
 
 
 
 
 
 
 
 
 
17
 
18
+ private $gadwp;
19
+
20
+ public function __construct()
21
+ {
22
+ $this->gadwp = GADWP();
23
+
24
+ if (GADWP_Tools::check_roles($this->gadwp->config->options['ga_dash_access_back']) && 1 == $this->gadwp->config->options['item_reports']) {
25
+
26
+ // Add custom column in Posts List
27
+ add_filter('manage_posts_columns', array(
28
+ $this,
29
+ 'add_columns'
30
+ ));
31
+ // Populate custom column in Posts List
32
+ add_action('manage_posts_custom_column', array(
33
+ $this,
34
+ 'add_icons'
35
+ ), 10, 2);
36
+ // Add custom column in Pages List
37
+ add_filter('manage_pages_columns', array(
38
+ $this,
39
+ 'add_columns'
40
+ ));
41
+ // Populate custom column in Pages List
42
+ add_action('manage_pages_custom_column', array(
43
+ $this,
44
+ 'add_icons'
45
+ ), 10, 2);
46
+ }
47
+ }
48
 
49
+ public function add_icons($column, $id)
50
+ {
51
+ global $wp_version;
52
+
53
+ if ($column != 'gadwp_stats') {
54
+ return;
55
+ }
56
+
57
+ if (version_compare($wp_version, '3.8.0', '>=')) {
58
+ echo '<a id="gadwp-' . $id . '" title="' . get_the_title($id) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
59
+ } else {
60
+ 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>';
61
+ }
62
+ }
63
+
64
+ public function add_columns($columns)
65
+ {
66
+ return array_merge($columns, array(
67
+ 'gadwp_stats' => __('Analytics', 'ga-dash')
68
+ ));
69
+ }
70
+ }
71
  }
admin/settings.php CHANGED
@@ -6,1543 +6,1356 @@
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
9
- final class GADASH_Settings
 
 
 
 
 
10
  {
11
 
12
- private static function set_get_options($who)
13
- {
14
- global $GADASH_Config;
15
- $network_settings = false;
16
- $options = $GADASH_Config->options; // Get current options
17
- if (isset($_POST['options']['ga_dash_hidden']) and isset($_POST['options']) and (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) and $who != 'Reset') {
18
- $new_options = $_POST['options'];
19
- if ($who == 'tracking') {
20
- $options['ga_dash_anonim'] = 0;
21
- $options['ga_event_tracking'] = 0;
22
- $options['ga_enhanced_links'] = 0;
23
- $options['ga_dash_remarketing'] = 0;
24
- $options['ga_dash_adsense'] = 0;
25
- $options['ga_event_bouncerate'] = 0;
26
- $options['ga_crossdomain_tracking'] = 0;
27
- $options['ga_aff_tracking'] = 0;
28
- $options['ga_hash_tracking'] = 0;
29
- if (isset($_POST['options']['ga_tracking_code'])) {
30
- $new_options['ga_tracking_code'] = trim($new_options['ga_tracking_code'], "\t");
31
- }
32
- if (empty($new_options['ga_track_exclude'])) {
33
- $new_options['ga_track_exclude'] = array();
34
- }
35
- } else
36
- if ($who == 'backend') {
37
- $options['switch_profile'] = 0;
38
- $options['item_reports'] = 0;
39
- $options['dashboard_widget'] = 0;
40
- if (empty($new_options['ga_dash_access_back'])) {
41
- $new_options['ga_dash_access_back'][] = 'administrator';
42
- }
43
- } else
44
- if ($who == 'frontend') {
45
- $options['ga_dash_frontend_stats'] = 0;
46
- $options['ga_dash_frontend_keywords'] = 0;
47
- if (empty($new_options['ga_dash_access_front'])) {
48
- $new_options['ga_dash_access_front'][] = 'administrator';
49
- }
50
- } else
51
- if ($who == 'general') {
52
- $options['ga_dash_userapi'] = 0;
53
- if (!is_multisite()){
54
- $options['automatic_updates_minorversion'] = 0;
55
- }
56
  } else
57
- if ($who == 'network') {
58
- $options['ga_dash_userapi'] = 0;
59
- $options['ga_dash_network'] = 0;
60
- $options['ga_dash_excludesa'] = 0;
61
- $options['automatic_updates_minorversion'] = 0;
62
- $network_settings = true;
63
- }
64
- $options = array_merge($options, $new_options);
65
- $GADASH_Config->options = $options;
66
- $GADASH_Config->set_plugin_options($network_settings);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  }
68
- return $options;
69
- }
70
 
71
- private static function navigation_tabs($tabs)
72
- {
73
- echo '<div id="icon-themes" class="icon32"><br></div>';
74
- echo '<h2 class="nav-tab-wrapper">';
75
- foreach ($tabs as $tab => $name) {
76
- echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
 
 
77
  }
78
- echo '</h2>';
79
- }
80
 
81
- public static function frontend_settings()
82
- {
83
- global $GADASH_Config;
84
- if (! current_user_can('manage_options')) {
85
- return;
86
- }
87
- $options = self::set_get_options('frontend');
88
- if (isset($_POST['options']['ga_dash_hidden'])) {
89
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
90
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
91
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
92
- }
93
- }
94
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
95
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
96
- }
97
- ?>
98
- <form name="ga_dash_form" method="post"
99
- action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
100
- <div class="wrap">
101
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'ga-dash' ) . "</h2>"; ?><hr>
102
- </div>
103
- <div id="poststuff">
104
- <div id="post-body" class="metabox-holder columns-2">
105
- <div id="post-body-content">
106
- <div class="settings-wrapper">
107
- <div class="inside">
108
  <?php if (isset($message)) echo $message; ?>
109
  <table class="options">
110
- <tr>
111
- <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'ga-dash' ) . "</h2>"; ?></td>
112
- </tr>
113
- <tr>
114
- <td class="roles title"><label for="ga_dash_access_front"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
115
- <td class="roles">
 
 
 
 
 
116
  <?php
117
- if (! isset($wp_roles)) {
118
- $wp_roles = new WP_Roles();
119
- }
120
- $i = 0;
121
- ?><table>
122
- <tr>
123
- <?php
124
- foreach ($wp_roles->role_names as $role => $name) {
125
- if ($role != 'subscriber') {
126
- $i ++;
127
- ?>
128
- <td><label> <input
129
- type="checkbox" name="options[ga_dash_access_front][]"
130
- value="<?php echo $role; ?>"
131
- <?php if (in_array($role,$options['ga_dash_access_front']) OR $role=='administrator') echo 'checked="checked"'; if ($role=='administrator') echo 'disabled="disabled"';?> />
132
- <?php echo $name; ?>
133
- </label></td>
134
  <?php
135
- }
136
- if ($i % 4 == 0) {
 
 
 
 
 
 
137
  ?>
138
- </tr>
139
- <tr>
140
- <?php
141
- }
142
- }
143
- ?>
144
- </table>
145
- </td>
146
- </tr>
147
- <tr>
148
- <td colspan="2" class="title">
149
- <div class="onoffswitch">
150
- <input type="checkbox" name="options[ga_dash_frontend_stats]"
151
- value="1" class="onoffswitch-checkbox"
152
- id="ga_dash_frontend_stats"
153
- <?php checked( $options['ga_dash_frontend_stats'], 1 ); ?>> <label
154
- class="onoffswitch-label" for="ga_dash_frontend_stats">
155
- <div class="onoffswitch-inner"></div>
156
- <div class="onoffswitch-switch"></div>
157
- </label>
158
- </div>
159
- <div class="switch-desc"><?php _e ( " show page sessions and users in frontend (after each article)", 'ga-dash' );?></div>
160
- </td>
161
- </tr>
162
- <tr>
163
- <td colspan="2" class="title">
164
- <div class="onoffswitch">
165
- <input type="checkbox"
166
- name="options[ga_dash_frontend_keywords]" value="1"
167
- class="onoffswitch-checkbox" id="ga_dash_frontend_keywords"
168
- <?php checked( $options['ga_dash_frontend_keywords'], 1 ); ?>>
169
- <label class="onoffswitch-label"
170
- for="ga_dash_frontend_keywords">
171
- <div class="onoffswitch-inner"></div>
172
- <div class="onoffswitch-switch"></div>
173
- </label>
174
- </div>
175
- <div class="switch-desc"><?php _e ( " show page searches (after each article)", 'ga-dash' );?></div>
176
- </td>
177
- </tr>
178
- <tr>
179
- <td colspan="2"><hr></td>
180
- </tr>
181
- <tr>
182
- <td colspan="2" class="submit"><input type="submit"
183
- name="Submit" class="button button-primary"
184
- value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
185
- </tr>
186
- </table>
187
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
188
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
189
- <?php
190
- self::output_sidebar();
191
- }
192
 
193
- public static function backend_settings()
194
- {
195
- global $GADASH_Config;
196
- if (! current_user_can('manage_options')) {
197
- return;
198
- }
199
- $options = self::set_get_options('backend');
200
- if (isset($_POST['options']['ga_dash_hidden'])) {
201
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
202
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
203
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
204
- }
205
- }
206
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
207
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
208
  }
209
- ?>
210
- <form name="ga_dash_form" method="post"
211
- action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
212
- <div class="wrap">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  <?php echo "<h2>" . __( "Google Analytics Backend Settings", 'ga-dash' ) . "</h2>"; ?><hr>
214
- </div>
215
- <div id="poststuff">
216
- <div id="post-body" class="metabox-holder columns-2">
217
- <div id="post-body-content">
218
- <div class="settings-wrapper">
219
- <div class="inside">
220
  <?php if (isset($message)) echo $message; ?>
221
  <table class="options">
222
- <tr>
223
- <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'ga-dash' ) . "</h2>"; ?></td>
224
- </tr>
225
- <tr>
226
- <td class="roles title"><label for="ga_dash_access_back"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
227
- <td class="roles">
228
- <?php
229
- if (! isset($wp_roles)) {
230
- $wp_roles = new WP_Roles();
231
- }
232
- $i = 0;
233
- ?>
234
- <table>
235
- <tr>
236
  <?php
237
- foreach ($wp_roles->role_names as $role => $name) {
238
- if ($role != 'subscriber') {
239
- $i ++;
240
- ?>
241
- <td><label> <input
242
- type="checkbox" name="options[ga_dash_access_back][]"
243
- value="<?php echo $role; ?>"
244
- <?php if (in_array($role,$options['ga_dash_access_back']) OR $role=='administrator') echo 'checked="checked"'; if ($role=='administrator') echo 'disabled="disabled"';?> />
245
- <?php echo $name; ?>
246
- </label></td>
247
- <?php
248
- }
249
- if ($i % 4 == 0) {
250
  ?>
251
- </tr>
252
- <tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253
  <?php
254
- }
255
- }
256
- ?>
257
- </table>
258
- </td>
259
- </tr>
260
- <tr>
261
- <td colspan="2" class="title">
262
- <div class="onoffswitch">
263
- <input type="checkbox" name="options[switch_profile]"
264
- value="1" class="onoffswitch-checkbox"
265
- id="switch_profile"
266
- <?php checked( $options['switch_profile'], 1 ); ?>> <label
267
- class="onoffswitch-label" for="switch_profile">
268
- <div class="onoffswitch-inner"></div>
269
- <div class="onoffswitch-switch"></div>
270
- </label>
271
- </div>
272
- <div class="switch-desc"><?php _e ( "enable Switch Profile/View functionality", 'ga-dash' );?></div>
273
- </td>
274
- </tr>
275
- <tr>
276
- <td colspan="2" class="title">
277
- <div class="onoffswitch">
278
- <input type="checkbox" name="options[item_reports]" value="1"
279
- class="onoffswitch-checkbox" id="item_reports"
280
- <?php checked( $options['item_reports'], 1 ); ?>> <label
281
- class="onoffswitch-label" for="item_reports">
282
- <div class="onoffswitch-inner"></div>
283
- <div class="onoffswitch-switch"></div>
284
- </label>
285
- </div>
286
- <div class="switch-desc"><?php _e ( "enable reports on Posts List and Pages List", 'ga-dash' );?></div>
287
- </td>
288
- </tr>
289
- <tr>
290
- <td colspan="2" class="title">
291
- <div class="onoffswitch">
292
- <input type="checkbox" name="options[dashboard_widget]"
293
- value="1" class="onoffswitch-checkbox" id="dashboard_widget"
294
- <?php checked( $options['dashboard_widget'], 1 ); ?>> <label
295
- class="onoffswitch-label" for="dashboard_widget">
296
- <div class="onoffswitch-inner"></div>
297
- <div class="onoffswitch-switch"></div>
298
- </label>
299
- </div>
300
- <div class="switch-desc"><?php _e ( "enable the main Dashboard Widget", 'ga-dash' );?></div>
301
- </td>
302
- </tr>
303
- <tr>
304
- <td colspan="2"><hr><?php echo "<h2>" . __( "Real-Time Settings", 'ga-dash' ) . "</h2>"; ?></td>
305
- </tr>
306
- <tr>
307
- <td colspan="2" class="title"> <?php _e("Maximum number of pages to display on real-time tab:", 'ga-dash'); ?>
308
- <input type="number" name="options[ga_realtime_pages]"
309
- id="ga_realtime_pages"
310
- value="<?php echo (int)$options['ga_realtime_pages']; ?>"
311
- size="3">
312
- <?php echo '('.__("find out more", 'ga-dash')?> <a
313
- href="https://deconf.com/google-analytics-dashboard-real-time-reports/"
314
- target="_blank"><?php _e("about this feature", 'ga-dash') ?></a>
315
- )
316
  </td>
317
- </tr>
318
- <tr>
319
- <td colspan="2"><hr><?php echo "<h2>" . __( "Location Settings", 'ga-dash' ) . "</h2>"; ?></td>
320
- </tr>
321
- <tr>
322
- <td colspan="2" class="title">
323
  <?php echo __("Target Geo Map to country:", 'ga-dash'); ?>
324
- <input type="text" style="text-align: center;"
325
- name="options[ga_target_geomap]"
326
- value="<?php echo esc_attr($options['ga_target_geomap']); ?>"
327
- size="3">
328
- <?php echo '('.__("find out more", 'ga-dash')?>
329
- <a
330
- href="https://deconf.com/country-codes-for-google-analytics-dashboard/"
331
- target="_blank"><?php _e("about this feature", 'ga-dash') ?></a>
332
- )
333
  </td>
334
- </tr>
335
- <tr>
336
- <td colspan="2"><hr></td>
337
- </tr>
338
- <tr>
339
- <td colspan="2" class="submit"><input type="submit"
340
- name="Submit" class="button button-primary"
341
- value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
342
- </tr>
343
- </table>
344
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
345
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
346
- <?php
347
- self::output_sidebar();
348
- }
349
 
350
- public static function tracking_settings()
351
- {
352
- global $GADASH_Config;
353
- $tools = new GADASH_Tools();
354
- if (! current_user_can('manage_options')) {
355
- return;
356
- }
357
- $options = self::set_get_options('tracking');
358
- if (isset($_POST['options']['ga_dash_hidden'])) {
359
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
360
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
361
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
362
- }
363
- }
364
- if (! $GADASH_Config->options['ga_dash_tableid_jail']) {
365
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
366
- }
367
- if (! $options['ga_dash_tracking']) {
368
- $message = "<div class='error'><p>" . __("The tracking component is disabled. You should set", 'ga-dash') . " <strong>" . __("Tracking Options", 'ga-dash') . "</strong> " . __("to", 'ga-dash') . " <strong>" . __("Enabled", 'ga-dash') . "</strong>.</p></div>";
369
  }
370
- ?>
371
- <form name="ga_dash_form" method="post"
372
- action="<?php esc_url($_SERVER['REQUEST_URI']); ?>">
373
- <div class="wrap">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
374
  <?php echo "<h2>" . __( "Google Analytics Tracking Code", 'ga-dash' ) . "</h2>"; ?>
375
  </div>
376
- <div id="poststuff">
377
- <div id="post-body" class="metabox-holder columns-2">
378
- <div id="post-body-content">
379
- <div class="settings-wrapper">
380
- <div class="inside">
381
  <?php
382
- $tabs = array(
383
- 'basic' => __("Basic Settings", 'ga-dash'),
384
- 'events' => __("Events Tracking", 'ga-dash'),
385
- 'custom' => __("Custom Definitions", 'ga-dash'),
386
- 'exclude' => __("Exclude Tracking", 'ga-dash'),
387
- 'advanced' => __("Advanced Settings", 'ga-dash')
388
- );
389
- self::navigation_tabs($tabs);
390
- ?>
 
391
  <?php if (isset($message)) echo $message; ?>
392
  <div id="gadwp-basic">
393
- <table class="options">
394
- <tr>
395
- <td colspan="2"><?php echo "<h2>" . __( "Tracking Settings", 'ga-dash' ) . "</h2>"; ?></td>
396
- </tr>
397
- <tr>
398
- <td class="title"><label for="ga_dash_tracking"><?php _e("Tracking Options:", 'ga-dash' ); ?></label></td>
399
- <td><select id="ga_dash_tracking"
400
- name="options[ga_dash_tracking]" onchange="this.form.submit()">
401
- <option value="0"
402
- <?php selected( $options['ga_dash_tracking'], 0 ); ?>><?php _e("Disabled", 'ga-dash');?></option>
403
- <option value="1"
404
- <?php selected( $options['ga_dash_tracking'], 1 ); ?>><?php _e("Enabled", 'ga-dash');?></option>
405
- </select></td>
406
- </tr>
407
  <?php if ($options['ga_dash_tracking']) {?>
408
  <tr>
409
- <td class="title"></td>
410
- <td><?php
411
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
412
- echo '<pre>' . __("View Name:", 'ga-dash') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'ga-dash') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'ga-dash') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'ga-dash') . "\t" . esc_html($profile_info[5]) . '</pre>';
413
- ?></td>
414
- </tr>
415
  <?php }?>
416
  <tr>
417
- <td colspan="2"><hr><?php echo "<h2>" . __( "Basic Tracking", 'ga-dash' ) . "</h2>"; ?></td>
418
- </tr>
419
- <tr>
420
- <td class="title"><label for="ga_dash_tracking_type"><?php _e("Tracking Type:", 'ga-dash' ); ?></label></td>
421
- <td><select id="ga_dash_tracking_type"
422
- name="options[ga_dash_tracking_type]">
423
- <option value="classic"
424
- <?php selected( $options['ga_dash_tracking_type'], 'classic' ); ?>><?php _e("Classic Analytics", 'ga-dash');?></option>
425
- <option value="universal"
426
- <?php selected( $options['ga_dash_tracking_type'], 'universal' ); ?>><?php _e("Universal Analytics", 'ga-dash');?></option>
427
- </select></td>
428
- </tr>
429
- <tr>
430
- <td colspan="2" class="title">
431
- <div class="onoffswitch">
432
- <input type="checkbox" name="options[ga_dash_anonim]"
433
- value="1" class="onoffswitch-checkbox" id="ga_dash_anonim"
434
- <?php checked( $options['ga_dash_anonim'], 1 ); ?>> <label
435
- class="onoffswitch-label" for="ga_dash_anonim">
436
- <div class="onoffswitch-inner"></div>
437
- <div class="onoffswitch-switch"></div>
438
- </label>
439
- </div>
440
- <div class="switch-desc"><?php _e ( " anonymize IPs while tracking", 'ga-dash' );?></div>
441
- </td>
442
- </tr>
443
- <tr>
444
- <td colspan="2" class="title">
445
- <div class="onoffswitch">
446
- <input type="checkbox" name="options[ga_dash_remarketing]"
447
- value="1" class="onoffswitch-checkbox"
448
- id="ga_dash_remarketing"
449
- <?php checked( $options['ga_dash_remarketing'], 1 ); ?>> <label
450
- class="onoffswitch-label" for="ga_dash_remarketing">
451
- <div class="onoffswitch-inner"></div>
452
- <div class="onoffswitch-switch"></div>
453
- </label>
454
- </div>
455
- <div class="switch-desc"><?php _e ( " enable remarketing, demographics and interests reports", 'ga-dash' );?></div>
456
- </td>
457
- </tr>
458
- </table>
459
- </div>
460
- <div id="gadwp-events">
461
- <table class="options">
462
- <tr>
463
- <td colspan="2"><?php echo "<h2>" . __( "Events Tracking", 'ga-dash' ) . "</h2>"; ?></td>
464
- </tr>
465
- <tr>
466
- <td colspan="2" class="title">
467
- <div class="onoffswitch">
468
- <input type="checkbox" name="options[ga_event_tracking]"
469
- value="1" class="onoffswitch-checkbox"
470
- id="ga_event_tracking"
471
- <?php checked( $options['ga_event_tracking'], 1 ); ?>> <label
472
- class="onoffswitch-label" for="ga_event_tracking">
473
- <div class="onoffswitch-inner"></div>
474
- <div class="onoffswitch-switch"></div>
475
- </label>
476
- </div>
477
- <div class="switch-desc"><?php _e(" track downloads, mailto and outbound links", 'ga-dash' ); ?></div>
478
- </td>
479
- </tr>
480
- <tr>
481
- <td class="title"><label for="ga_event_downloads"><?php _e("Downloads Regex:", 'ga-dash'); ?></label></td>
482
- <td><input type="text" id="ga_event_downloads"
483
- name="options[ga_event_downloads]"
484
- value="<?php echo esc_attr($options['ga_event_downloads']); ?>"
485
- size="50"></td>
486
- </tr>
487
- <tr>
488
- <td colspan="2" class="title">
489
- <div class="onoffswitch">
490
- <input type="checkbox" name="options[ga_aff_tracking]"
491
- value="1" class="onoffswitch-checkbox" id="ga_aff_tracking"
492
- <?php checked( $options['ga_aff_tracking'], 1 ); ?>> <label
493
- class="onoffswitch-label" for="ga_aff_tracking">
494
- <div class="onoffswitch-inner"></div>
495
- <div class="onoffswitch-switch"></div>
496
- </label>
497
- </div>
498
- <div class="switch-desc"><?php _e(" track affiliate links matching this regex", 'ga-dash' ); ?></div>
499
- </td>
500
- </tr>
501
- <tr>
502
- <td class="title"><label for="ga_event_affiliates"><?php _e("Affiliates Regex:", 'ga-dash'); ?></label></td>
503
- <td><input type="text" id="ga_event_affiliates"
504
- name="options[ga_event_affiliates]"
505
- value="<?php echo esc_attr($options['ga_event_affiliates']); ?>"
506
- size="50"></td>
507
- </tr>
508
- <tr>
509
- <td colspan="2" class="title">
510
- <div class="onoffswitch">
511
- <input type="checkbox" name="options[ga_hash_tracking]"
512
- value="1" class="onoffswitch-checkbox" id="ga_hash_tracking"
513
- <?php checked( $options['ga_hash_tracking'], 1 ); ?>> <label
514
- class="onoffswitch-label" for="ga_hash_tracking">
515
- <div class="onoffswitch-inner"></div>
516
- <div class="onoffswitch-switch"></div>
517
- </label>
518
- </div>
519
- <div class="switch-desc"><?php _e(" track fragment identifiers, hashmarks (#) in URI links", 'ga-dash' ); ?></div>
520
- </td>
521
- </tr>
522
- </table>
523
- </div>
524
- <div id="gadwp-custom">
525
- <table class="options">
526
- <tr>
527
- <td colspan="2"><?php echo "<h2>" . __( "Custom Definitions", 'ga-dash' ) . "</h2>"; ?></td>
528
- </tr>
529
- <tr>
530
- <td class="title"><label for="ga_author_dimindex"><?php _e("Authors:", 'ga-dash' ); ?></label></td>
531
- <td><select id="ga_author_dimindex"
532
- name="options[ga_author_dimindex]">
533
  <?php for ($i=0;$i<21;$i++){?>
534
- <option value="<?php echo $i;?>"
535
- <?php selected( $options['ga_author_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
536
- <?php } ?>
537
  </select></td>
538
- </tr>
539
- <tr>
540
- <td class="title"><label for="ga_pubyear_dimindex"><?php _e("Publication Year:", 'ga-dash' ); ?></label></td>
541
- <td><select id="ga_pubyear_dimindex"
542
- name="options[ga_pubyear_dimindex]">
543
  <?php for ($i=0;$i<21;$i++){?>
544
- <option value="<?php echo $i;?>"
545
- <?php selected( $options['ga_pubyear_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
546
- <?php } ?>
547
  </select></td>
548
- </tr>
549
- <tr>
550
- <td class="title"><label for="ga_category_dimindex"><?php _e("Categories:", 'ga-dash' ); ?></label></td>
551
- <td><select id="ga_category_dimindex"
552
- name="options[ga_category_dimindex]">
553
  <?php for ($i=0;$i<21;$i++){?>
554
- <option value="<?php echo $i;?>"
555
- <?php selected( $options['ga_category_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
556
- <?php } ?>
557
  </select></td>
558
- </tr>
559
- <tr>
560
- <td class="title"><label for="ga_user_dimindex"><?php _e("User Type:", 'ga-dash' ); ?></label></td>
561
- <td><select id="ga_user_dimindex"
562
- name="options[ga_user_dimindex]">
563
  <?php for ($i=0;$i<21;$i++){?>
564
- <option value="<?php echo $i;?>"
565
- <?php selected( $options['ga_user_dimindex'], $i ); ?>><?php echo $i==0?'Disabled':'dimension '.$i; ?></option>
566
- <?php } ?>
567
  </select></td>
568
- </tr>
569
- </table>
570
- </div>
571
- <div id="gadwp-advanced">
572
- <table class="options">
573
- <tr>
574
- <td colspan="2"><?php echo "<h2>" . __( "Advanced Tracking", 'ga-dash' ) . "</h2>"; ?></td>
575
- </tr>
576
- <tr>
577
- <td class="title"><label for="ga_speed_samplerate"><?php _e("Page Speed SR:", 'ga-dash'); ?></label></td>
578
- <td><input type="number" id="ga_speed_samplerate"
579
- name="options[ga_speed_samplerate]"
580
- value="<?php echo (int)($options['ga_speed_samplerate']); ?>"
581
- max="100" min="1"> %</td>
582
- </tr>
583
- <tr>
584
- <td colspan="2" class="title">
585
- <div class="onoffswitch">
586
- <input type="checkbox" name="options[ga_event_bouncerate]"
587
- value="1" class="onoffswitch-checkbox"
588
- id="ga_event_bouncerate"
589
- <?php checked( $options['ga_event_bouncerate'], 1 ); ?>> <label
590
- class="onoffswitch-label" for="ga_event_bouncerate">
591
- <div class="onoffswitch-inner"></div>
592
- <div class="onoffswitch-switch"></div>
593
- </label>
594
- </div>
595
- <div class="switch-desc"><?php _e ( " exclude events from bounce-rate calculation", 'ga-dash' );?></div>
596
- </td>
597
- </tr>
598
- <tr>
599
- <td colspan="2" class="title">
600
- <div class="onoffswitch">
601
- <input type="checkbox" name="options[ga_enhanced_links]"
602
- value="1" class="onoffswitch-checkbox"
603
- id="ga_enhanced_links"
604
- <?php checked( $options['ga_enhanced_links'], 1 ); ?>> <label
605
- class="onoffswitch-label" for="ga_enhanced_links">
606
- <div class="onoffswitch-inner"></div>
607
- <div class="onoffswitch-switch"></div>
608
- </label>
609
- </div>
610
- <div class="switch-desc"><?php _e ( " enable enhanced link attribution", 'ga-dash' );?></div>
611
- </td>
612
- </tr>
613
- <tr>
614
- <td colspan="2" class="title">
615
- <div class="onoffswitch">
616
- <input type="checkbox" name="options[ga_dash_adsense]"
617
- value="1" class="onoffswitch-checkbox" id="ga_dash_adsense"
618
- <?php checked( $options['ga_dash_adsense'], 1 ); ?>> <label
619
- class="onoffswitch-label" for="ga_dash_adsense">
620
- <div class="onoffswitch-inner"></div>
621
- <div class="onoffswitch-switch"></div>
622
- </label>
623
- </div>
624
- <div class="switch-desc"><?php _e ( " enable AdSense account linking", 'ga-dash' );?></div>
625
- </td>
626
- </tr>
627
- <tr>
628
- <td colspan="2" class="title">
629
- <div class="onoffswitch">
630
- <input type="checkbox"
631
- name="options[ga_crossdomain_tracking]" value="1"
632
- class="onoffswitch-checkbox" id="ga_crossdomain_tracking"
633
- <?php checked( $options['ga_crossdomain_tracking'], 1 ); ?>>
634
- <label class="onoffswitch-label"
635
- for="ga_crossdomain_tracking">
636
- <div class="onoffswitch-inner"></div>
637
- <div class="onoffswitch-switch"></div>
638
- </label>
639
- </div>
640
- <div class="switch-desc"><?php _e(" enable cross domain tracking", 'ga-dash' ); ?></div>
641
- </td>
642
- </tr>
643
- <tr>
644
- <td class="title"><label for="ga_crossdomain_list"><?php _e("Cross Domains:", 'ga-dash'); ?></label></td>
645
- <td><input type="text" id="ga_crossdomain_list"
646
- name="options[ga_crossdomain_list]"
647
- value="<?php echo esc_attr($options['ga_crossdomain_list']); ?>"
648
- size="50"></td>
649
- </tr>
650
- </table>
651
- </div>
652
- <div id="gadwp-exclude">
653
- <table class="options">
654
- <tr>
655
- <td colspan="2"><?php echo "<h2>" . __( "Exclude Tracking", 'ga-dash' ) . "</h2>"; ?></td>
656
- </tr>
657
- <tr>
658
- <td class="roles title"><label for="ga_track_exclude"><?php _e("Exclude tracking for:", 'ga-dash' ); ?></label></td>
659
- <td class="roles">
660
  <?php
661
- if (! isset($wp_roles)) {
662
- $wp_roles = new WP_Roles();
663
- }
664
- $i = 0;
665
- ?> <table>
666
- <tr>
667
  <?php
668
- foreach ($wp_roles->role_names as $role => $name) {
669
- $i ++;
670
- ?>
671
- <td><label> <input type="checkbox"
672
- name="options[ga_track_exclude][]"
673
- value="<?php echo $role; ?>"
674
- <?php if (in_array($role,$options['ga_track_exclude'])) echo 'checked="checked"'; ?> />
675
  <?php echo $name; ?>
676
  </label></td>
677
  <?php
678
- if ($i % 4 == 0) {
679
- ?>
680
  </tr>
681
- <tr>
682
  <?php
683
- }
684
- }
685
- ?>
686
- </table>
687
- </td>
688
- </tr>
689
- </table>
690
- </div>
691
- <table class="options">
692
- <tr>
693
- <td colspan="2"><hr></td>
694
- </tr>
695
- <tr>
696
- <td colspan="2" class="submit"><input type="submit"
697
- name="Submit" class="button button-primary"
698
- value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
699
- </tr>
700
- </table>
701
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
702
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
703
- <?php
704
- self::output_sidebar();
705
- }
706
 
707
- public static function errors_debugging()
708
- {
709
- global $GADASH_Config;
710
- global $wp_version;
711
- if (! current_user_can('manage_options')) {
712
- return;
713
- }
714
- $options = self::set_get_options('frontend');
715
- if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
716
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
717
  }
718
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  <div class="wrap">
720
  <?php echo "<h2>" . __( "Google Analytics Errors & Debugging", 'ga-dash' ) . "</h2>"; ?>
721
  </div>
722
  <div id="poststuff">
723
- <div id="post-body" class="metabox-holder columns-2">
724
- <div id="post-body-content">
725
- <div class="settings-wrapper">
726
- <div class="inside">
727
  <?php if (isset($message)) echo $message; ?>
728
  <?php
729
- $tabs = array(
730
- 'errors' => __("Errors & Details", 'ga-dash'),
731
- 'config' => __("Plugin Settings", 'ga-dash')
732
- );
733
- self::navigation_tabs($tabs);
734
- ?>
735
  <div id="gadwp-errors">
736
- <table class="options">
737
- <tr>
738
- <td>
739
- <?php echo __("For errors and/or other issues please check",'ga-dash')." <a href='https://deconf.com/error-codes-in-google-analytics-dashboard-for-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=errors_screen&utm_campaign=gadwp' target='_blank'>". __("this documentation page",'ga-dash')."</a> ".__("and related tutorials",'ga-dash').".";?>
740
  </td>
741
- </tr>
742
- <tr>
743
- <td><?php echo "<h2>" . __( "Last Error detected", 'ga-dash' ) . "</h2>"; ?></td>
744
- </tr>
745
- <tr>
746
- <td>
 
 
747
  <?php
748
- $errors = esc_html(print_r(get_transient('ga_dash_lasterror'), true)) ? esc_html(print_r(get_transient('ga_dash_lasterror'), true)) : __("None", 'ga-dash');
749
- echo '<pre class="log_data">Last Error: ';
750
- echo $errors;
751
- ?></pre>
752
- </td>
753
- </tr>
754
- <tr>
755
- <td colspan="2"><hr><?php echo "<h2>" . __( "Error Details", 'ga-dash' ) . "</h2>"; ?></td>
756
- </tr>
757
- <tr>
758
- <td>
759
  <?php
760
- echo '<pre class="log_data">Error Details: ';
761
- $error_details = esc_html(print_r(get_transient('ga_dash_gapi_errors'), true)) ? "\n" . esc_html(print_r(get_transient('ga_dash_gapi_errors'), true)) : __("None", 'ga-dash');
762
- echo $error_details;
763
- ?></pre><br />
764
- <hr>
765
- </td>
766
-
767
-
768
- <tr>
769
-
770
- </table>
771
- </div>
772
- <div id="gadwp-config">
773
- <table class="options">
774
- <tr>
775
- <td><?php echo "<h2>" . __( "Plugin Configuration", 'ga-dash' ) . "</h2>"; ?></td>
776
- </tr>
777
- <tr>
778
- <td><pre class="log_data"><?php
779
- $anonim = $GADASH_Config->options;
780
- $anonim['wp_version'] = $wp_version;
781
- $anonim['gadwp_version'] = GADWP_CURRENT_VERSION;
782
- if ($anonim['ga_dash_token']) {
783
- $anonim['ga_dash_token'] = 'HIDDEN';
784
- }
785
- if ($anonim['ga_dash_refresh_token']) {
786
- $anonim['ga_dash_refresh_token'] = 'HIDDEN';
787
- }
788
- if ($anonim['ga_dash_clientid']) {
789
- $anonim['ga_dash_clientid'] = 'HIDDEN';
790
- }
791
- if ($anonim['ga_dash_clientsecret']) {
792
- $anonim['ga_dash_clientsecret'] = 'HIDDEN';
793
- }
794
- if ($anonim['ga_dash_apikey']) {
795
- $anonim['ga_dash_apikey'] = 'HIDDEN';
796
- }
797
- echo esc_html(print_r($anonim, true));
798
- ?></pre><br />
799
- <hr></td>
800
- </tr>
801
- </table>
802
- </div>
803
  <?php
804
- self::output_sidebar();
805
- }
806
-
807
- public static function general_settings()
808
- {
809
- global $GADASH_Config;
810
- global $wp_version;
811
- $tools = new GADASH_Tools();
812
- if (! current_user_can('manage_options')) {
813
- return;
814
  }
815
- $options = self::set_get_options('general');
816
- /*
817
- * Include GAPI
818
- */
819
- echo '<div id="gapi-warning" class="updated"><p>' . __('Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', "ga-dash") . ' <a href="https://deconf.com/error-codes-in-google-analytics-dashboard-for-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
820
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
821
- global $GADASH_GAPI;
822
- echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
823
- if (isset($_POST['ga_dash_code'])) {
824
- if (! stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
825
- try {
826
- $GADASH_GAPI->client->authenticate($_POST['ga_dash_code']);
827
- $GADASH_Config->options['ga_dash_token'] = $GADASH_GAPI->client->getAccessToken();
828
- $google_token = json_decode($GADASH_GAPI->client->getAccessToken());
829
- $GADASH_Config->options['ga_dash_refresh_token'] = $google_token->refresh_token;
830
- $GADASH_Config->set_plugin_options();
831
- $message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'ga-dash') . "</p></div>";
832
- $options = self::set_get_options('general');
833
- delete_transient('ga_dash_gapi_errors');
834
- delete_transient('ga_dash_lasterror');
835
- } catch (Google_IO_Exception $e) {
836
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $GADASH_GAPI->error_timeout);
837
- return false;
838
- } catch (Google_Service_Exception $e) {
839
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $GADASH_GAPI->error_timeout);
840
- set_transient('ga_dash_gapi_errors', $e->getErrors(), $GADASH_GAPI->error_timeout);
841
- return $e->getCode();
842
- } catch (Exception $e) {
843
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
844
- $GADASH_GAPI->reset_token(false);
845
  }
846
- } else {
847
- $message = "<div class='error'><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", 'ga-dash') . ".</p></div>";
848
- }
849
- }
850
- if ($GADASH_Config->options['ga_dash_token'] and $GADASH_GAPI->client->getAccessToken()) {
851
- if ($GADASH_Config->options['ga_dash_profile_list']) {
852
- $profiles = $GADASH_Config->options['ga_dash_profile_list'];
853
- } else {
854
- $profiles = $GADASH_GAPI->refresh_profiles();
855
- }
856
- if ($profiles) {
857
- $GADASH_Config->options['ga_dash_profile_list'] = $profiles;
858
- if (! $GADASH_Config->options['ga_dash_tableid_jail']) {
859
- $profile = $tools->guess_default_domain($profiles);
860
- $GADASH_Config->options['ga_dash_tableid_jail'] = $profile;
861
- $GADASH_Config->options['ga_dash_tableid'] = $profile;
862
  }
863
- $GADASH_Config->set_plugin_options();
864
- $options = self::set_get_options('general');
865
- }
866
- }
867
- if (isset($_POST['Clear'])) {
868
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
869
- $tools->clear_cache();
870
- $message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
871
- } else {
872
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
873
- }
874
- }
875
- if (isset($_POST['Reset'])) {
876
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
877
- $GADASH_GAPI->reset_token(true);
878
- $tools->clear_cache();
879
- $message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
880
- $options = self::set_get_options('Reset');
881
- } else {
882
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
883
- }
884
- }
885
- if (isset($_POST['Reset_Err'])) {
886
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
887
- delete_transient('ga_dash_lasterror');
888
- delete_transient('ga_dash_gapi_errors');
889
- $message = "<div class='updated'><p>" . __("All errors reseted.", 'ga-dash') . "</p></div>";
890
- } else {
891
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
892
- }
893
- }
894
- if (isset($_POST['options']['ga_dash_hidden']) and ! isset($_POST['Clear']) and ! isset($_POST['Reset']) and ! isset($_POST['Reset_Err'])) {
895
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
896
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
897
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
898
- }
899
- }
900
- if (isset($_POST['Hide'])) {
901
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
902
- $message = "<div class='updated'><p>" . __("All other domains/properties were removed.", 'ga-dash') . "</p></div>";
903
- $lock_profile = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
904
- $GADASH_Config->options['ga_dash_profile_list'] = array(
905
- $lock_profile
906
- );
907
- $options = self::set_get_options('general');
908
- } else {
909
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
910
- }
911
- }
912
- ?>
913
- <div class="wrap">
914
- <?php echo "<h2>" . __( "Google Analytics Settings", 'ga-dash' ) . "</h2>"; ?><hr>
915
- </div>
916
- <div id="poststuff">
917
- <div id="post-body" class="metabox-holder columns-2">
918
- <div id="post-body-content">
919
- <div class="settings-wrapper">
920
- <div class="inside">
921
- if ($GADASH_GAPI->gapi_errors_handler()) {
922
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
923
- }
924
- if (isset($_POST['Authorize'])) {
925
- $tools->clear_cache();
926
- $GADASH_GAPI->token_request();
927
- echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
928
- } else {
929
- if (isset($message))
930
- echo $message;
931
- ?>
932
- <form name="ga_dash_form" method="post"
933
- action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
934
- <input type="hidden" name="options[ga_dash_hidden]" value="Y">
935
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
936
- <table class="options">
937
- <tr>
938
- <td colspan="2"><?php echo "<h2>" . __( "Plugin Authorization", 'ga-dash' ) . "</h2>"; ?></td>
939
- </tr>
940
- <tr>
941
- <td colspan="2" class="info">
942
- <?php echo __("You should watch the",'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_video&utm_campaign=gadwp' target='_blank'>". __("video",'ga-dash')."</a> ".__("and read this", 'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=top_tutorial&utm_campaign=gadwp' target='_blank'>". __("tutorial",'ga-dash')."</a> ".__("before proceeding to authorization. This plugin requires a properly configured Google Analytics account", 'ga-dash')."!";?>
943
- </td>
944
- </tr>
945
- <?php
946
- if (! $options['ga_dash_token'] or $options['ga_dash_userapi']) {
947
- ?>
948
- <tr>
949
- <td colspan="2" class="info"><input
950
- name="options[ga_dash_userapi]" type="checkbox"
951
- id="ga_dash_userapi" value="1"
952
- <?php checked( $options['ga_dash_userapi'], 1 ); ?>
953
- onchange="this.form.submit()"
954
- <?php echo ($options['ga_dash_network'])?'disabled="disabled"':''; ?> /><?php _e ( " use your own API Project credentials", 'ga-dash' );?>
955
- </td>
956
- </tr>
957
- }
958
- if ($options['ga_dash_userapi']) {
959
- ?>
960
- <tr>
961
- <td class="title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'ga-dash'); ?></label>
962
- </td>
963
- <td><input type="text" name="options[ga_dash_apikey]"
964
- value="<?php echo esc_attr($options['ga_dash_apikey']); ?>"
965
- size="40" required="required"></td>
966
- </tr>
967
- <tr>
968
- <td class="title"><label for="options[ga_dash_clientid]"><?php _e("Client ID:", 'ga-dash'); ?></label>
969
- </td>
970
- <td><input type="text" name="options[ga_dash_clientid]"
971
- value="<?php echo esc_attr($options['ga_dash_clientid']); ?>"
972
- size="40" required="required"></td>
973
- </tr>
974
- <tr>
975
- <td class="title"><label
976
- for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'ga-dash'); ?></label>
977
- </td>
978
- <td><input type="text" name="options[ga_dash_clientsecret]"
979
- value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>"
980
- size="40" required="required"> <input type="hidden"
981
- name="options[ga_dash_hidden]" value="Y">
982
- <?php wp_nonce_field('gadash_form','gadash_security'); ?>
983
- </td>
984
- </tr>
985
- <?php
986
- }
987
- ?>
988
- <?php
989
- if ($options['ga_dash_token']) {
990
- ?>
991
- <tr>
992
- <td colspan="2"><input type="submit" name="Reset"
993
- class="button button-secondary"
994
- value="<?php _e( "Clear Authorization", 'ga-dash' ); ?>"
995
- <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
996
- <input type="submit" name="Clear"
997
- class="button button-secondary"
998
- value="<?php _e( "Clear Cache", 'ga-dash' ); ?>" /> <input
999
- type="submit" name="Reset_Err"
1000
- class="button button-secondary"
1001
- value="<?php _e( "Reset Errors", 'ga-dash' ); ?>" /></td>
1002
- </tr>
1003
- <tr>
1004
- <td colspan="2"><hr></td>
1005
- </tr>
1006
- <tr>
1007
- <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'ga-dash' ) . "</h2>"; ?></td>
1008
- </tr>
1009
- <tr>
1010
- <td class="title"><label for="ga_dash_tableid_jail"><?php _e("Select Domain:", 'ga-dash' ); ?></label></td>
1011
- <td><select id="ga_dash_tableid_jail"
1012
- <?php disabled(is_array($options['ga_dash_profile_list']), false); ?>
1013
- name="options[ga_dash_tableid_jail]">
1014
- <?php
1015
- if (is_array($options['ga_dash_profile_list'])) {
1016
- foreach ($options['ga_dash_profile_list'] as $items) {
1017
- if ($items[3]) {
1018
- echo '<option value="' . esc_attr($items[1]) . '" ' . selected($items[1], $options['ga_dash_tableid_jail']);
1019
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . esc_html($tools->strip_protocol($items[3])) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
1020
  }
1021
- }
1022
- } else {
1023
- echo '<option value="">' . __("Property not found", 'ga-dash') . '</option>';
1024
  }
1025
- ?>
1026
- </select>
1027
- if (count($options['ga_dash_profile_list']) > 1) {
1028
- _e("and/or hide all other domains", 'ga-dash');
1029
- ?>
1030
- <input type="submit" name="Hide" class="button button-secondary"
1031
- value="<?php _e( "Hide Now", 'ga-dash' ); ?>" />
1032
- <?php
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1033
  }
1034
  ?>
1035
- </td>
1036
- </tr>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1037
  <?php } if ($options['ga_dash_userapi']) { ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1038
  <?php
 
 
 
 
 
 
 
1039
  <?php
1040
- if ($options['ga_dash_tableid_jail']) {
1041
- ?>
1042
  <tr>
1043
- <td class="title"></td>
1044
- <td><?php
1045
- $profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
1046
- echo '<pre>' . __("View Name:", 'ga-dash') . "\t" . esc_html($profile_info[0]) . "<br />" . __("Tracking ID:", 'ga-dash') . "\t" . esc_html($profile_info[2]) . "<br />" . __("Default URL:", 'ga-dash') . "\t" . esc_html($profile_info[3]) . "<br />" . __("Time Zone:", 'ga-dash') . "\t" . esc_html($profile_info[5]) . '</pre>';
1047
- ?></td>
1048
- </tr>
1049
  <?php
1050
- }
1051
- ?>
1052
- <td class="title"><label for="ga_dash_style"><?php _e("Theme Color:", 'ga-dash' ); ?></label></td>
1053
- <td><input type="text" id="ga_dash_style"
1054
- class="ga_dash_style" name="options[ga_dash_style]"
1055
- value="<?php echo esc_attr($options['ga_dash_style']); ?>"
1056
- size="10"></td>
1057
- </tr>
1058
- <tr>
1059
- <td colspan="2"><hr></td>
1060
- </tr>
1061
- <?php if ( !is_multisite()) {?>
1062
  <tr>
1063
- <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'ga-dash' ) . "</h2>"; ?></td>
1064
- </tr>
 
 
 
 
 
 
 
 
 
 
 
1065
  <tr>
1066
- <td colspan="2" class="title">
1067
- <div class="onoffswitch">
1068
- <input type="checkbox"
1069
- name="options[automatic_updates_minorversion]" value="1"
1070
- class="onoffswitch-checkbox"
1071
- id="automatic_updates_minorversion"
1072
- <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1073
- <label class="onoffswitch-label"
1074
- for="automatic_updates_minorversion">
1075
- <div class="onoffswitch-inner"></div>
1076
- <div class="onoffswitch-switch"></div>
1077
- </label>
1078
- </div>
1079
- <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'ga-dash' );?></div>
1080
- </td>
1081
- </tr>
1082
  <?php }?>
1083
- <tr>
1084
- <td colspan="2"><hr></td>
1085
- </tr>
1086
- <tr>
1087
- <td colspan="2" class="submit"><input type="submit"
1088
- name="Submit" class="button button-primary"
1089
- value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
1090
- </tr>
1091
- } else {
1092
- ?>
1093
- <tr>
1094
- <td colspan="2"><hr></td>
1095
- </tr>
1096
- <tr>
1097
- <td colspan="2"><input type="submit" name="Authorize"
1098
- class="button button-secondary" id="authorize"
1099
- value="<?php _e( "Authorize Plugin", 'ga-dash' ); ?>"
1100
- <?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
1101
- <input type="submit" name="Clear"
1102
- class="button button-secondary"
1103
- value="<?php _e( "Clear Cache", 'ga-dash' ); ?>" /></td>
1104
- </tr>
1105
- <tr>
1106
- <td colspan="2"><hr></td>
1107
- </tr>
1108
- </table>
1109
- </form>
1110
  <?php
 
 
 
 
 
 
1111
  self::output_sidebar();
1112
- return;
1113
- }
1114
- ?>
1115
- </form>
1116
- }
1117
- self::output_sidebar();
1118
- }
1119
- // Network Settings
1120
- public static function general_settings_network()
1121
- {
1122
- global $GADASH_Config;
1123
- global $wp_version;
1124
- $tools = new GADASH_Tools();
1125
- if (! current_user_can('manage_network_options')) {
1126
- return;
1127
  }
1128
- $options = self::set_get_options('network');
1129
- /*
1130
- * Include GAPI
1131
- */
1132
- echo '<div id="gapi-warning" class="updated"><p>' . __('Loading the required libraries. If this results in a blank screen or a fatal error, try this solution:', "ga-dash") . ' <a href="https://deconf.com/error-codes-in-google-analytics-dashboard-for-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=general_screen&utm_campaign=gadwp">Library conflicts between WordPress plugins</a></p></div>';
1133
- include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
1134
- global $GADASH_GAPI;
1135
- echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1136
- if (isset($_POST['ga_dash_code'])) {
1137
- if (! stripos('x' . $_POST['ga_dash_code'], 'UA-', 1) == 1) {
1138
- try {
1139
- $GADASH_GAPI->client->authenticate($_POST['ga_dash_code']);
1140
- $GADASH_Config->options['ga_dash_token'] = $GADASH_GAPI->client->getAccessToken();
1141
- $google_token = json_decode($GADASH_GAPI->client->getAccessToken());
1142
- $GADASH_Config->options['ga_dash_refresh_token'] = $google_token->refresh_token;
1143
- $GADASH_Config->set_plugin_options(true);
1144
- $message = "<div class='updated'><p>" . __("Plugin authorization succeeded.", 'ga-dash') . "</p></div>";
1145
- $options = self::set_get_options('network');
1146
- if (is_multisite()) { // Cleanup errors on the entire network
1147
- foreach (wp_get_sites(array(
1148
- 'limit' => apply_filters('gadwp_sites_limit', 100)
1149
- )) as $blog) {
1150
- switch_to_blog($blog['blog_id']);
1151
- delete_transient('ga_dash_gapi_errors');
1152
- restore_current_blog();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1153
  }
1154
- } else {
1155
- delete_transient('ga_dash_gapi_errors');
1156
- }
1157
- } catch (Google_IO_Exception $e) {
1158
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e), $GADASH_GAPI->error_timeout);
1159
- return false;
1160
- } catch (Google_Service_Exception $e) {
1161
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html("(" . $e->getCode() . ") " . $e->getMessage()), $GADASH_GAPI->error_timeout);
1162
- set_transient('ga_dash_gapi_errors', $e->getErrors(), $GADASH_GAPI->error_timeout);
1163
- return $e->getCode();
1164
- } catch (Exception $e) {
1165
- set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
1166
- $GADASH_GAPI->reset_token(false);
1167
  }
1168
- } else {
1169
- $message = "<div class='error'><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", 'ga-dash') . ".</p></div>";
1170
- }
1171
- }
1172
- if (isset($_POST['Refresh'])) {
1173
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1174
- $GADASH_Config->options['ga_dash_profile_list'] = '';
1175
- $message = "<div class='updated'><p>" . __("Properties refreshed.", 'ga-dash') . "</p></div>";
1176
- $options = self::set_get_options('network');
1177
- } else {
1178
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1179
- }
1180
- }
1181
- if ($GADASH_Config->options['ga_dash_token'] and $GADASH_GAPI->client->getAccessToken()) {
1182
- if ($GADASH_Config->options['ga_dash_profile_list']) {
1183
- $profiles = $GADASH_Config->options['ga_dash_profile_list'];
1184
- } else {
1185
- $profiles = $GADASH_GAPI->refresh_profiles();
1186
- }
1187
- if ($profiles) {
1188
- $GADASH_Config->options['ga_dash_profile_list'] = $profiles;
1189
- if (isset($GADASH_Config->options['ga_dash_tableid_jail']) and ! $GADASH_Config->options['ga_dash_tableid_jail']) {
1190
- $profile = $tools->guess_default_domain($profiles);
1191
- $GADASH_Config->options['ga_dash_tableid_jail'] = $profile;
1192
- $GADASH_Config->options['ga_dash_tableid'] = $profile;
1193
  }
1194
- $GADASH_Config->set_plugin_options(true);
1195
- $options = self::set_get_options('network');
1196
- }
1197
- }
1198
- if (isset($_POST['Clear'])) {
1199
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1200
- $tools->clear_cache();
1201
- $message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
1202
- } else {
1203
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1204
- }
1205
- }
1206
- if (isset($_POST['Reset'])) {
1207
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1208
- $GADASH_GAPI->reset_token(true);
1209
- $tools->clear_cache();
1210
- $message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
1211
- $options = self::set_get_options('Reset');
1212
- } else {
1213
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1214
- }
1215
- }
1216
- if (isset($_POST['options']['ga_dash_hidden']) and ! isset($_POST['Clear']) and ! isset($_POST['Reset']) and ! isset($_POST['Refresh'])) {
1217
- $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
1218
- if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
1219
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1220
- }
1221
- }
1222
- if (isset($_POST['Hide'])) {
1223
- if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1224
- $message = "<div class='updated'><p>" . __("All other domains/properties were removed.", 'ga-dash') . "</p></div>";
1225
- $lock_profile = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $GADASH_Config->options['ga_dash_tableid_jail']);
1226
- $GADASH_Config->options['ga_dash_profile_list'] = array(
1227
- $lock_profile
1228
- );
1229
- $options = self::set_get_options('network');
1230
- } else {
1231
- $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1232
- }
1233
- }
1234
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
1235
  <div class="wrap">
1236
  <?php echo "<h2>" . __( "Google Analytics Settings", 'ga-dash' ) . "</h2>"; ?><hr>
1237
- </div>
1238
- <div id="poststuff">
1239
- <div id="post-body" class="metabox-holder columns-2">
1240
- <div id="post-body-content">
1241
- <div class="settings-wrapper">
1242
- <div class="inside">
1243
- if ($GADASH_GAPI->gapi_errors_handler()) {
1244
- $message = "<div class='error'><p>" . __("Something went wrong, check", 'ga-dash') . " <a href='" . menu_page_url('gadash_errors_debugging', false) . "'>" . __('Errors & Debug', 'ga-dash') . "</a> " . __('or', 'ga-dash') . " <a href='" . menu_page_url('gadash_settings', false) . "'>" . __('authorize the plugin', 'ga-dash') . "</a>.</p></div>";
1245
- }
1246
- if (isset($_POST['Authorize'])) {
1247
- $tools->clear_cache();
1248
- $GADASH_GAPI->token_request();
1249
- echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
1250
- } else {
1251
- if (isset($message))
1252
- echo $message;
1253
- ?>
1254
- <form name="ga_dash_form" method="post"
1255
- action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
1256
- <input type="hidden" name="options[ga_dash_hidden]"
1257
- value="Y">
1258
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1259
  <table class="options">
1260
- <tr>
1261
- <td colspan="2"><?php echo "<h2>" . __( "Network Setup", 'ga-dash' ) . "</h2>"; ?></td>
1262
- </tr>
1263
- <tr>
1264
- <td colspan="2" class="title">
1265
- <div class="onoffswitch">
1266
- <input type="checkbox"
1267
- name="options[ga_dash_network]" value="1"
1268
- class="onoffswitch-checkbox" id="ga_dash_network"
1269
- <?php checked( $options['ga_dash_network'], 1); ?>
1270
- onchange="this.form.submit()"> <label
1271
- class="onoffswitch-label" for="ga_dash_network">
1272
- <div class="onoffswitch-inner"></div>
1273
- <div class="onoffswitch-switch"></div>
1274
- </label>
1275
- </div>
1276
- <div class="switch-desc"><?php _e ( " use a single Google Analytics account for the entire network", 'ga-dash' );?></div>
1277
- </td>
1278
- </tr>
1279
  <?php if ($options['ga_dash_network']){ //Network Mode check?>
1280
  <tr>
1281
- <td colspan="2"><hr></td>
1282
- </tr>
1283
- <tr>
1284
- <td colspan="2"><?php echo "<h2>" . __( "Plugin Authorization", 'ga-dash' ) . "</h2>"; ?></td>
1285
- </tr>
1286
- <tr>
1287
- <td colspan="2" class="info">
1288
- <?php echo __("You should watch the",'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/' target='_blank'>". __("video",'ga-dash')."</a> ".__("and read this", 'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/' target='_blank'>". __("tutorial",'ga-dash')."</a> ".__("before proceeding to authorization. This plugin requires a properly configured Google Analytics account", 'ga-dash')."!";?>
1289
- </td>
1290
- </tr>
1291
  <?php
1292
- if (! $options['ga_dash_token'] or $options['ga_dash_userapi']) {
1293
- ?>
1294
- <tr>
1295
- <td colspan="2" class="info"><input
1296
- name="options[ga_dash_userapi]" type="checkbox"
1297
- id="ga_dash_userapi" value="1"
1298
- <?php checked( $options['ga_dash_userapi'], 1 ); ?>
1299
- onchange="this.form.submit()" /><?php _e ( " use your own API Project credentials", 'ga-dash' );?>
1300
- </td>
1301
- </tr>
1302
- }
1303
- if ($options['ga_dash_userapi']) {
1304
- ?>
1305
- <tr>
1306
- <td class="title"><label for="options[ga_dash_apikey]"><?php _e("API Key:", 'ga-dash'); ?></label>
1307
- </td>
1308
- <td><input type="text" name="options[ga_dash_apikey]"
1309
- value="<?php echo esc_attr($options['ga_dash_apikey']); ?>"
1310
- size="40" required="required"></td>
1311
- </tr>
1312
- <tr>
1313
- <td class="title"><label
1314
- for="options[ga_dash_clientid]"><?php _e("Client ID:", 'ga-dash'); ?></label>
1315
- </td>
1316
- <td><input type="text"
1317
- name="options[ga_dash_clientid]"
1318
- value="<?php echo esc_attr($options['ga_dash_clientid']); ?>"
1319
- size="40" required="required"></td>
1320
- </tr>
1321
- <tr>
1322
- <td class="title"><label
1323
- for="options[ga_dash_clientsecret]"><?php _e("Client Secret:", 'ga-dash'); ?></label>
1324
- </td>
1325
- <td><input type="text"
1326
- name="options[ga_dash_clientsecret]"
1327
- value="<?php echo esc_attr($options['ga_dash_clientsecret']); ?>"
1328
- size="40" required="required"> <input type="hidden"
1329
- name="options[ga_dash_hidden]" value="Y">
1330
  <?php wp_nonce_field('gadash_form','gadash_security'); ?>
1331
  </td>
1332
- </tr>
1333
  <?php
1334
- }
1335
- ?>
1336
- <?php
1337
- if ($options['ga_dash_token']) {
1338
- ?>
1339
  <tr>
1340
- <td colspan="2"><input type="submit" name="Reset"
1341
- class="button button-secondary"
1342
- value="<?php _e( "Clear Authorization", 'ga-dash' ); ?>" />
1343
- <input type="submit" name="Clear"
1344
- class="button button-secondary"
1345
- value="<?php _e( "Clear Cache", 'ga-dash' ); ?>" /> <input
1346
- type="submit" name="Refresh"
1347
- class="button button-secondary"
1348
- value="<?php _e( "Refresh Properties", 'ga-dash' ); ?>" /></td>
1349
- </tr>
1350
- <tr>
1351
- <td colspan="2"><hr></td>
1352
- </tr>
1353
- <tr>
1354
- <td colspan="2"><?php echo "<h2>" . __( "Properties/Views Settings", 'ga-dash' ) . "</h2>"; ?></td>
1355
- </tr>
1356
  <?php
1357
- if (isset($options['ga_dash_tableid_network'])) {
1358
- $options['ga_dash_tableid_network'] = json_decode(json_encode($options['ga_dash_tableid_network']), FALSE);
1359
- }
1360
- foreach (wp_get_sites(array(
1361
- 'limit' => apply_filters('gadwp_sites_limit', 100)
1362
- )) as $blog) {
1363
- ?>
1364
- <tr>
1365
- <td class="title-select"><label
1366
- for="ga_dash_tableid_network"><?php echo '<strong>'.$blog['domain'].$blog['path'].'</strong>: ';?></label></td>
1367
- <td><select id="ga_dash_tableid_network"
1368
- <?php disabled(is_array($options['ga_dash_profile_list']),false);?>
1369
- name="options[ga_dash_tableid_network][<?php echo $blog['blog_id'];?>]">
1370
  <?php
1371
- if (is_array($options['ga_dash_profile_list'])) {
1372
- foreach ($options['ga_dash_profile_list'] as $items) {
1373
- if ($items[3]) {
1374
- echo '<option value="' . esc_attr($items[1]) . '" ' . selected($items[1], isset($options['ga_dash_tableid_network']->$blog['blog_id']) ? $options['ga_dash_tableid_network']->$blog['blog_id'] : '');
1375
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . esc_html($tools->strip_protocol($items[3])) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
1376
- }
1377
- }
1378
- } else {
1379
- echo '<option value="">' . __("Property not found", 'ga-dash') . '</option>';
1380
- }
1381
- ?>
1382
- </select><br /></td>
1383
- </tr>
1384
  <?php
1385
- }
1386
- ?>
1387
  <tr>
1388
- <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'ga-dash' ) . "</h2>"; ?></td>
1389
- </tr>
1390
- <tr>
1391
- <td colspan="2" class="title">
1392
- <div class="onoffswitch">
1393
- <input type="checkbox"
1394
- name="options[automatic_updates_minorversion]"
1395
- value="1" class="onoffswitch-checkbox"
1396
- id="automatic_updates_minorversion"
1397
- <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1398
- <label class="onoffswitch-label"
1399
- for="automatic_updates_minorversion">
1400
- <div class="onoffswitch-inner"></div>
1401
- <div class="onoffswitch-switch"></div>
1402
- </label>
1403
- </div>
1404
- <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'ga-dash' );?></div>
1405
- </td>
1406
- </tr>
1407
- <tr>
1408
- <td colspan="2"><hr><?php echo "<h2>" . __( "Exclude Tracking", 'ga-dash' ) . "</h2>"; ?></td>
1409
- </tr>
1410
- <tr>
1411
- <td colspan="2" class="title">
1412
- <div class="onoffswitch">
1413
- <input type="checkbox"
1414
- name="options[ga_dash_excludesa]" value="1"
1415
- class="onoffswitch-checkbox" id="ga_dash_excludesa"<?php checked( $options['ga_dash_excludesa'], 1); ?>">
1416
- <label class="onoffswitch-label"
1417
- for="ga_dash_excludesa">
1418
- <div class="onoffswitch-inner"></div>
1419
- <div class="onoffswitch-switch"></div>
1420
- </label>
1421
- </div>
1422
- <div class="switch-desc"><?php _e ( " exclude Super Admin tracking for the entire network", 'ga-dash' );?></div>
1423
- </td>
1424
- </tr>
1425
- <tr>
1426
- <td colspan="2"><hr></td>
1427
- </tr>
1428
- <tr>
1429
- <td colspan="2" class="submit"><input type="submit"
1430
- name="Submit" class="button button-primary"
1431
- value="<?php _e('Save Changes', 'ga-dash' ) ?>" /></td>
1432
- </tr>
1433
- } else {
1434
- ?>
1435
- <td colspan="2"><hr></td>
1436
- </tr>
1437
- <tr>
1438
- <td colspan="2"><input type="submit" name="Authorize"
1439
- class="button button-secondary" id="authorize"
1440
- value="<?php _e( "Authorize Plugin", 'ga-dash' ); ?>" />
1441
- <input type="submit" name="Clear"
1442
- class="button button-secondary"
1443
- value="<?php _e( "Clear Cache", 'ga-dash' ); ?>" /></td>
1444
- </tr>
1445
  <?php } //Network Mode check?>
1446
- <tr>
1447
- <td colspan="2"><hr></td>
1448
- </tr>
1449
- </table>
1450
- </form>
1451
  <?php
1452
- self::output_sidebar();
1453
- return;
1454
- }
1455
- ?>
1456
  </table>
1457
- </form>
1458
  <?php
 
 
1459
  }
1460
- self::output_sidebar();
1461
- }
1462
 
1463
- public static function output_sidebar()
1464
- {
1465
- global $GADASH_Config;
1466
- ?>
1467
- </div>
1468
- </div>
1469
- </div>
1470
- <div id="postbox-container-1" class="postbox-container">
1471
- <div class="meta-box-sortables">
1472
- <div class="postbox">
1473
- <h3>
1474
- <span><?php _e("Setup Tutorial & Demo",'ga-dash') ?></span>
1475
- </h3>
1476
- <div class="inside">
1477
- <a
1478
- href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=video&utm_campaign=gadwp"
1479
- target="_blank"><img
1480
- src="<?php echo plugins_url( 'images/google-analytics-dashboard.png' , __FILE__ );?>"
1481
- width="100%" alt="" /></a>
1482
- </div>
1483
- </div>
1484
- <div class="postbox">
1485
- <h3>
1486
- <span><?php _e("Support & Reviews",'ga-dash')?></span>
1487
- </h3>
1488
- <div class="inside">
1489
- <div class="gadash-title">
1490
- <a
1491
- href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=support&utm_campaign=gadwp"><img
1492
- src="<?php echo plugins_url( 'images/help.png' , __FILE__ ); ?>" /></a>
1493
- </div>
1494
- <div class="gadash-desc"><?php echo __('Plugin documentation and support on', 'ga-dash') . ' <a href="https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=support&utm_campaign=gadwp">deconf.com</a>.'; ?></div>
1495
- <br />
1496
- <div class="gadash-title">
1497
- <a
1498
- href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info"><img
1499
- src="<?php echo plugins_url( 'images/star.png' , __FILE__ ); ?>" /></a>
1500
- </div>
1501
- <div class="gadash-desc"><?php echo __('Your feedback and review are both important,', 'ga-dash').' <a href="http://wordpress.org/support/view/plugin-reviews/google-analytics-dashboard-for-wp#plugin-info">'.__('rate this plugin', 'ga-dash').'</a>!'; ?></div>
1502
- </div>
1503
- </div>
1504
- <div class="postbox">
1505
- <h3>
1506
- <span><?php _e("Further Reading",'ga-dash')?></span>
1507
- </h3>
1508
- <div class="inside">
1509
- <div class="gadash-title">
1510
- <a
1511
- href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp"><img
1512
- src="<?php echo plugins_url( 'images/ssl.png' , __FILE__ ); ?>" /></a>
1513
- </div>
1514
- <div class="gadash-desc"><?php echo '<a href="https://deconf.com/move-website-https-ssl/?utm_source=gadwp_config&utm_medium=link&utm_content=ssl&utm_campaign=gadwp">'.__('Improve search rankings', 'ga-dash').'</a> '.__('by moving your website to HTTPS/SSL.', 'ga-dash'); ?></div>
1515
- <br />
1516
- <div class="gadash-title">
1517
- <a
1518
- href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp"><img
1519
- src="<?php echo plugins_url( 'images/wp.png' , __FILE__ ); ?>" /></a>
1520
- </div>
1521
- <div class="gadash-desc"><?php echo __('Other', 'ga-dash').' <a href="https://deconf.com/wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=plugins&utm_campaign=gadwp">'.__('WordPress Plugins', 'ga-dash').'</a> '.__('written by the same author', 'ga-dash').'.'; ?></div>
1522
- </div>
1523
- </div>
1524
- <div class="postbox">
1525
- <h3>
1526
- <span><?php _e("Other Services",'ga-dash')?></span>
1527
- </h3>
1528
- <div class="inside">
1529
- <div class="gadash-title">
1530
- <a
1531
- href="https://deconf.com/wordpress-cdn-speeds-up-your-site/"><img
1532
- src="<?php echo plugins_url( 'images/mcdn.png' , __FILE__ ); ?>" /></a>
1533
- </div>
1534
- <div class="gadash-desc"><?php echo __('Speed up your website and plug into a whole', 'ga-dash').' <a href="https://deconf.com/wordpress-cdn-speeds-up-your-site/">'.__('new level of site speed', 'ga-dash').'</a>.'; ?></div>
1535
- <br />
1536
- <div class="gadash-title">
1537
- <a
1538
- href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp"><img
1539
- src="<?php echo plugins_url( 'images/clicky.png' , __FILE__ ); ?>" /></a>
1540
- </div>
1541
- <div class="gadash-desc"><?php echo '<a href="https://deconf.com/clicky-web-analytics-review/?utm_source=gadwp_config&utm_medium=link&utm_content=clicky&utm_campaign=gadwp">'.__('Web Analytics', 'ga-dash').'</a> '.__('service with users tracking at IP level.', 'ga-dash'); ?></div>
1542
- </div>
1543
- </div>
1544
- </div>
1545
- </div>
1546
- </div>
1547
- </div>
1548
- <?php
1549
- }
1550
  }
6
  * License: GPLv2 or later
7
  * License URI: http://www.gnu.org/licenses/gpl-2.0.html
8
  */
9
+
10
+ // Exit if accessed directly
11
+ if (! defined('ABSPATH'))
12
+ exit();
13
+
14
+ final class GADWP_Settings
15
  {
16
 
17
+ private static function update_options($who)
18
+ {
19
+ $gadwp = GADWP();
20
+ $network_settings = false;
21
+ $options = $gadwp->config->options; // Get current options
22
+ if (isset($_POST['options']['ga_dash_hidden']) && isset($_POST['options']) && (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) && $who != 'Reset') {
23
+ $new_options = $_POST['options'];
24
+ if ($who == 'tracking') {
25
+ $options['ga_dash_anonim'] = 0;
26
+ $options['ga_event_tracking'] = 0;
27
+ $options['ga_enhanced_links'] = 0;
28
+ $options['ga_dash_remarketing'] = 0;
29
+ $options['ga_dash_adsense'] = 0;
30
+ $options['ga_event_bouncerate'] = 0;
31
+ $options['ga_crossdomain_tracking'] = 0;
32
+ $options['ga_aff_tracking'] = 0;
33
+ $options['ga_hash_tracking'] = 0;
34
+ if (isset($_POST['options']['ga_tracking_code'])) {
35
+ $new_options['ga_tracking_code'] = trim($new_options['ga_tracking_code'], "\t");
36
+ }
37
+ if (empty($new_options['ga_track_exclude'])) {
38
+ $new_options['ga_track_exclude'] = array();
39
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
  } else
41
+ if ($who == 'backend') {
42
+ $options['switch_profile'] = 0;
43
+ $options['item_reports'] = 0;
44
+ $options['dashboard_widget'] = 0;
45
+ if (empty($new_options['ga_dash_access_back'])) {
46
+ $new_options['ga_dash_access_back'][] = 'administrator';
47
+ }
48
+ } else
49
+ if ($who == 'frontend') {
50
+ $options['ga_dash_frontend_stats'] = 0;
51
+ $options['ga_dash_frontend_keywords'] = 0;
52
+ if (empty($new_options['ga_dash_access_front'])) {
53
+ $new_options['ga_dash_access_front'][] = 'administrator';
54
+ }
55
+ } else
56
+ if ($who == 'general') {
57
+ $options['ga_dash_userapi'] = 0;
58
+ if (! is_multisite()) {
59
+ $options['automatic_updates_minorversion'] = 0;
60
+ }
61
+ } else
62
+ if ($who == 'network') {
63
+ $options['ga_dash_userapi'] = 0;
64
+ $options['ga_dash_network'] = 0;
65
+ $options['ga_dash_excludesa'] = 0;
66
+ $options['automatic_updates_minorversion'] = 0;
67
+ $network_settings = true;
68
+ }
69
+ $options = array_merge($options, $new_options);
70
+ $gadwp->config->options = $options;
71
+ $gadwp->config->set_plugin_options($network_settings);
72
+ }
73
+ return $options;
74
  }
 
 
75
 
76
+ private static function navigation_tabs($tabs)
77
+ {
78
+ echo '<div id="icon-themes" class="icon32"><br></div>';
79
+ echo '<h2 class="nav-tab-wrapper">';
80
+ foreach ($tabs as $tab => $name) {
81
+ echo "<a class='nav-tab' id='tab-$tab' href='#top#gadwp-$tab'>$name</a>";
82
+ }
83
+ echo '</h2>';
84
  }
 
 
85
 
86
+ public static function frontend_settings()
87
+ {
88
+ $gadwp = GADWP();
89
+ if (! current_user_can('manage_options')) {
90
+ return;
91
+ }
92
+ $options = self::update_options('frontend');
93
+ if (isset($_POST['options']['ga_dash_hidden'])) {
94
+ $message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
95
+ if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
96
+ $message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
97
+ }
98
+ }
99
+ if (! $gadwp->config->options['ga_dash_tableid_jail'] || ! $gadwp->config->options['ga_dash_token']) {
100
+ $message = sprintf('<div class="error"><p>%s</p></div>', sprintf(__('Something went wrong, check %1$s or %2$s.', 'ga-dash'), sprintf('<a href="%1$s">%2$s</a>', menu_page_url('gadash_errors_debugging', false), __('Errors & Debug', 'ga-dash')), sprintf('<a href="%1$s">%2$s</a>', menu_page_url('gadash_settings', false), __('authorize the plugin', 'ga-dash'))));
101
+ }
102
+ ?>
103
+ <form name="ga_dash_form" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
104
+ <div class="wrap">
 
105
  <?php echo "<h2>" . __( "Google Analytics Frontend Settings", 'ga-dash' ) . "</h2>"; ?><hr>
106
+ </div>
107
+ <div id="poststuff">
108
+ <div id="post-body" class="metabox-holder columns-2">
109
+ <div id="post-body-content">
110
+ <div class="settings-wrapper">
111
+ <div class="inside">
112
  <?php if (isset($message)) echo $message; ?>
113
  <table class="options">
114
+ <tr>
115
+ <td colspan="2">
116
+ <?php printf(__('Read %s for more information about Frontend Features and Options.', 'ga-dash'), 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=frontend_screen&utm_campaign=gadwp', __('this documentation page', 'ga-dash')))?>
117
+ </td>
118
+ </tr>
119
+ <tr>
120
+ <td colspan="2"><?php echo "<h2>" . __( "Permissions", 'ga-dash' ) . "</h2>"; ?></td>
121
+ </tr>
122
+ <tr>
123
+ <td class="roles title"><label for="ga_dash_access_front"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
124
+ <td class="roles">
125
  <?php
126
+ if (! isset($wp_roles)) {
127
+ $wp_roles = new WP_Roles();
128
+ }
129
+ $i = 0;
130
+ ?>
131
+ <table>
132
+ <tr>
133
+ <?php
134
+ foreach ($wp_roles->role_names as $role => $name) {
135
+ if ($role != 'subscriber') {
136
+ $i ++;
137
+ ?>
138
+ <td><label> <input type="checkbox" name="options[ga_dash_access_front][]" value="<?php echo $role; ?>" <?php if (in_array($role,$options['ga_dash_access_front']) || $role=='administrator') echo 'checked="checked"'; if ($role=='administrator') echo 'disabled="disabled"';?> /><?php echo $name; ?>
139
+ </label></td>
 
 
 
140
  <?php
141
+ }
142
+ if ($i % 4 == 0) {
143
+ ?>
144
+ </tr>
145
+ <tr>
146
+ <?php
147
+ }
148
+ }
149
  ?>
150
+
151
+ </table>
152
+ </td>
153
+ </tr>
154
+ <tr>
155
+ <td colspan="2" class="title">
156
+ <div class="onoffswitch">
157
+ <input type="checkbox" name="options[ga_dash_frontend_stats]" value="1" class="onoffswitch-checkbox" id="ga_dash_frontend_stats" <?php checked( $options['ga_dash_frontend_stats'], 1 ); ?>> <label class="onoffswitch-label" for="ga_dash_frontend_stats">
158
+ <div class="onoffswitch-inner"></div>
159
+ <div class="onoffswitch-switch"></div>
160
+ </label>
161
+ </div>
162
+ <div class="switch-desc"><?php echo " ".__("show page sessions and users in frontend (after each article)", 'ga-dash' );?></div>
163
+ </td>
164
+ </tr>
165
+ <tr>
166
+ <td colspan="2" class="title">
167
+ <div class="onoffswitch">
168
+ <input type="checkbox" name="options[ga_dash_frontend_keywords]" value="1" class="onoffswitch-checkbox" id="ga_dash_frontend_keywords" <?php checked( $options['ga_dash_frontend_keywords'], 1 ); ?>> <label class="onoffswitch-label" for="ga_dash_frontend_keywords">
169
+ <div class="onoffswitch-inner"></div>
170
+ <div class="onoffswitch-switch"></div>
171