Google Analytics Dashboard for WP (GADWP) - Version 4.5

Version Description

  • Requirements: WordPress 3.5 and above
  • Enhancement: automatic updates for minor versions (security and maintenance releases)
  • Enhancement: improvements while enqueuing styles & scripts
  • Enhancement: reports per post in Post List (new feature)
  • Enhancement: reports per page in Page List (new feature)
  • Enhancement: gadwp_backenditem_uri allows URI corrections for backend item reports
  • Enhancement: option to enable/disable the custom dashboard widget
  • Enhancement: Japanese translation, translated by
  • Enhancement: Dutch translation, translated by Willem-Jan Meerkerk
  • Enhancement: Portuguese (Brazil) translation, updated by Treed Box
  • Enhancement: UI improvements props by Paal Joachim Romdahl
  • Bug Fix: Arabic translation not loading properly
  • Bug Fix: initialize time-shift for all API calls
  • Bug Fix: include GAPI only when a API call is made
  • Bug Fix: keep the percentage numeric while anonymizing data
  • Bug Fix: add PHP 5.3 as a requirement when forcing IPv4
  • Bug Fix: typo fix by Andrew Minion
Download this release

Release Info

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

Code changes from version 4.4.7 to 4.5

Files changed (46) hide show
  1. admin/ajax-actions.php +40 -76
  2. admin/css/{ga_dash.css → gadwp.css} +0 -0
  3. admin/css/item-reports.css +103 -0
  4. admin/item-reports.php +64 -0
  5. admin/js/item-reports.js +631 -0
  6. admin/js/settings.js +36 -0
  7. admin/js/{admin.js → widgets.js} +3 -34
  8. admin/{ga_dash_settings.php → settings.php} +127 -52
  9. admin/setup.php +268 -0
  10. admin/{dashboard_widgets.php → widgets.php} +24 -183
  11. config.php +76 -7
  12. front/ajax-actions.php +9 -19
  13. front/css/{content_stats.css → item-reports.css} +0 -0
  14. front/{frontend.php → item-reports.php} +5 -9
  15. front/js/{content_stats.js → item-reports.js} +0 -0
  16. front/tracking.php +0 -4
  17. front/tracking/code-universal.php +0 -1
  18. front/widgets.php +3 -7
  19. gadwp.php +24 -12
  20. install/install.php +9 -2
  21. languages/ar.mo +0 -0
  22. languages/ga-dash-ar.mo +0 -0
  23. languages/{ar.po → ga-dash-ar.po} +463 -415
  24. languages/ga-dash-de_DE.mo +0 -0
  25. languages/ga-dash-de_DE.po +465 -416
  26. languages/ga-dash-es_ES.mo +0 -0
  27. languages/ga-dash-es_ES.po +457 -415
  28. languages/ga-dash-fr_FR.mo +0 -0
  29. languages/ga-dash-fr_FR.po +466 -418
  30. languages/ga-dash-hu_HU.mo +0 -0
  31. languages/ga-dash-hu_HU.po +464 -416
  32. languages/ga-dash-it_IT.mo +0 -0
  33. languages/ga-dash-it_IT.po +1153 -1104
  34. languages/ga-dash-ja.mo +0 -0
  35. languages/ga-dash-ja.po +1123 -0
  36. languages/ga-dash-nl_NL.mo +0 -0
  37. languages/ga-dash-nl_NL.po +949 -0
  38. languages/ga-dash-pl_PL.mo +0 -0
  39. languages/ga-dash-pl_PL.po +463 -415
  40. languages/ga-dash-pt_BR.mo +0 -0
  41. languages/ga-dash-pt_BR.po +573 -515
  42. languages/ga-dash.pot +678 -499
  43. readme.txt +45 -20
  44. tools/gapi.php +160 -76
  45. tools/iso3166.php +241 -240
  46. tools/tools.php +21 -10
admin/ajax-actions.php CHANGED
@@ -12,135 +12,99 @@ if (! class_exists('GADASH_Backend_Ajax')) {
12
13
function __construct()
14
{
15
- // Backend Widget Realtime action
16
- add_action('wp_ajax_gadashadmin_get_realtime', array(
17
$this,
18
- 'ajax_adminwidget_realtime'
19
));
20
- // Admin Widget get Reports action
21
- add_action('wp_ajax_gadashadmin_get_widgetreports', array(
22
$this,
23
- 'ajax_adminwidget_reports'
24
));
25
}
26
27
- function send_json($response)
28
- {
29
- @header('Content-Type: application/json; charset=' . get_option('blog_charset'));
30
- echo json_encode($response);
31
- if (defined('DOING_AJAX') && DOING_AJAX)
32
- wp_die();
33
- else
34
- die();
35
- }
36
-
37
/**
38
- * Ajax handler for getting reports for Admin Widget
39
*
40
- * @return string|int
41
*/
42
- function ajax_adminwidget_reports()
43
{
44
global $GADASH_Config;
45
- if (! isset($_REQUEST['gadashadmin_security_widget_reports']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widget_reports'], 'gadashadmin_get_widgetreports')) {
46
wp_die(- 30);
47
}
48
- $projectId = $_REQUEST['projectId'];
49
$from = $_REQUEST['from'];
50
$to = $_REQUEST['to'];
51
$query = $_REQUEST['query'];
52
if (ob_get_length()) {
53
ob_clean();
54
}
55
- /*
56
- * Include Tools
57
- */
58
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
59
$tools = new GADASH_Tools();
60
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
61
wp_die(- 31);
62
}
63
- if ($GADASH_Config->options['ga_dash_token'] and $projectId and $from and $to) {
64
include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
65
global $GADASH_GAPI;
66
} else {
67
wp_die(- 24);
68
}
69
-
70
$profile_info = $tools->get_selected_profile($GADASH_Config->options['ga_dash_profile_list'], $projectId);
71
if (isset($profile_info[4])) {
72
$GADASH_GAPI->timeshift = $profile_info[4];
73
} else {
74
$GADASH_GAPI->timeshift = (int) current_time('timestamp') - time();
75
- }
76
-
77
- switch ($query) {
78
- case 'referrers':
79
- $this->send_json($GADASH_GAPI->get_referrers($projectId, $from, $to));
80
- break;
81
- case 'contentpages':
82
- $this->send_json($GADASH_GAPI->get_contentpages($projectId, $from, $to));
83
- break;
84
- case 'locations':
85
- $this->send_json($GADASH_GAPI->get_locations($projectId, $from, $to));
86
- break;
87
- case 'bottomstats':
88
- $this->send_json($GADASH_GAPI->get_bottomstats($projectId, $from, $to));
89
- break;
90
- case 'trafficchannels':
91
- $this->send_json($GADASH_GAPI->get_trafficchannels($projectId, $from, $to));
92
- break;
93
- case 'medium':
94
- $this->send_json($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'medium'));
95
- break;
96
- case 'visitorType':
97
- $this->send_json($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'visitorType'));
98
- break;
99
- case 'socialNetwork':
100
- $this->send_json($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'socialNetwork'));
101
- break;
102
- case 'source':
103
- $this->send_json($GADASH_GAPI->get_trafficdetails($projectId, $from, $to, 'source'));
104
- break;
105
- case 'searches':
106
- $this->send_json($GADASH_GAPI->get_searches($projectId, $from, $to));
107
- break;
108
- default:
109
- $this->send_json($GADASH_GAPI->get_mainreport($projectId, $from, $to, $query));
110
- break;
111
}
112
}
113
- // Real-Time Request
114
/**
115
- * Ajax handler for getting realtime analytics data for Admin widget
116
*
117
- * @return string|int
118
*/
119
- function ajax_adminwidget_realtime()
120
{
121
global $GADASH_Config;
122
- if (! isset($_REQUEST['gadashadmin_security_widgetrealtime']) or ! wp_verify_nonce($_REQUEST['gadashadmin_security_widgetrealtime'], 'gadashadmin_get_realtime')) {
123
wp_die(- 30);
124
}
125
$projectId = $_REQUEST['projectId'];
126
if (ob_get_length()) {
127
ob_clean();
128
}
129
- /*
130
- * Include Tools
131
- */
132
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
133
$tools = new GADASH_Tools();
134
- if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back'])) {
135
wp_die(- 31);
136
}
137
- if ($GADASH_Config->options['ga_dash_token'] and $projectId) {
138
include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
139
global $GADASH_GAPI;
140
} else {
141
wp_die(- 24);
142
}
143
- $this->send_json($GADASH_GAPI->gadash_realtime_data($projectId));
144
}
145
}
146
}
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
}
admin/css/{ga_dash.css → gadwp.css} RENAMED
File without changes
admin/css/item-reports.css ADDED
@@ -0,0 +1,103 @@
1
+ /* Posts & Pages stats */
2
+ .column-gadwp_stats {
3
+ width: 70px;
4
+ }
5
+
6
+ .gadwp-icon {
7
+ color: #555;
8
+ }
9
+
10
+ .gadwp-icon:hover {
11
+ color: #2ea2cc;
12
+ }
13
+
14
+ .gadwp-icon:selected {
15
+ color: #0074a2;
16
+ }
17
+
18
+ .gadwp-icon-oldwp {
19
+ padding-top: 5px;
20
+ }
21
+
22
+ [id^=gadwp-container] {
23
+ width: 480px;
24
+ }
25
+
26
+ [id^=gadwp-mainchart] {
27
+ height: 280px;
28
+ }
29
+
30
+ [id^=gadwp-progressbar] {
31
+ width: 100%;
32
+ height: 3px;
33
+ margin: 5px 0 0px 0;
34
+ }
35
+
36
+ .gadwp-wrapper {
37
+ width: 100%;
38
+ }
39
+
40
+ .gadwp-wrapper .inside {
41
+ display: table;
42
+ margin: 0 auto;
43
+ padding: 0px;
44
+ }
45
+
46
+ .gadwp-wrapper .inside .small-box {
47
+ width: 31.2%;
48
+ float: left;
49
+ margin: 10px 5px 10px 5px;
50
+ background: #fff;
51
+ text-align: center;
52
+ -moz-box-shadow: 0px 0px 7px 0px #BBB;
53
+ -webkit-box-shadow: 0px 0px 7px 0px #BBB;
54
+ box-shadow: 0px 0px 7px 0px #BBB;
55
+ }
56
+
57
+ .gadwp-wrapper .inside .small-box h3 {
58
+ font-size: 1em;
59
+ color: #777;
60
+ padding: 0px 5px 0px 5px;
61
+ margin: 0px 0px 0px 0px;
62
+ }
63
+
64
+ .gadwp-wrapper .inside .small-box p {
65
+ font-size: 1.2em;
66
+ margin: 0px 0px 2px 0px;
67
+ }
68
+
69
+ [id^=gadwp-trafficmediums], [id^=gadwp-traffictype], [id^=gadwp-trafficorganic],
70
+ [id^=gadwp-socialnetworks] {
71
+ width: 49.6%;
72
+ margin: 10px 0 0 0;
73
+ border-right: 1px solid white;
74
+ height: 200px;
75
+ float: left;
76
+ }
77
+
78
+ [id^=gadwp-locations], [id^=gadwp-prs] {
79
+ margin: 10px 0 0 0;
80
+ }
81
+
82
+ .ui-dialog-titlebar {
83
+ text-overflow: ellipsis;
84
+ overflow: hidden;
85
+ }
86
+
87
+ @media screen and (max-width: 500px) {
88
+ [id^=gadwp-container] {
89
+ width: 410px;
90
+ }
91
+ .gadwp-wrapper .inside .small-box {
92
+ width: 30.8%;
93
+ }
94
+ }
95
+
96
+ @media screen and (max-width: 410px) {
97
+ [id^=gadwp-container] {
98
+ width: 260px;
99
+ }
100
+ .gadwp-wrapper .inside .small-box {
101
+ width: 46%;
102
+ }
103
+ }
admin/item-reports.php ADDED
@@ -0,0 +1,64 @@
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
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 (version_compare($wp_version, '3.8.0', '>=')) {
47
+ echo '<a id="gadwp-' . $id . '" title="' . get_the_title($id) . '" href="#' . $id . '" class="gadwp-icon dashicons-before dashicons-chart-area"></a>';
48
+ } else {
49
+ 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>';
50
+ }
51
+ }
52
+
53
+ function add_stats_column($columns)
54
+ {
55
+ return array_merge($columns, array(
56
+ 'gadwp_stats' => __('Analytics', 'ga-dash')
57
+ ));
58
+ }
59
+ }
60
+ }
61
+
62
+ if (is_admin()) {
63
+ $GADASH_Back_Stats = new GADASH_Back_Stats();
64
+ }
admin/js/item-reports.js ADDED
@@ -0,0 +1,631 @@
1
+ "use strict";
2
+
3
+ google.load("visualization", "1", {
4
+ packages : ["corechart", "table", "orgchart", "geochart"]
5
+ });
6
+
7
+ jQuery(document).ready(
8
+
9
+ function() {
10
+ jQuery('a[id^="gadwp-"]').click(function(e) {
11
+
12
+ var item_id = getID(this);
13
+ var slug = "-" + item_id;
14
+
15
+ if (!jQuery("#gadwp-window" + slug).length > 0) {
16
+ jQuery("body").append('<div id="gadwp-window' + slug + '"></div>');
17
+ }
18
+ jQuery('#gadwp-window' + slug).gadwpItemReport(slug, item_id);
19
+ });
20
+
21
+ function getID(item) {
22
+ if (typeof item.id == "undefined") {
23
+ return 0
24
+ }
25
+ if (item.id.split('-')[1] == "undefined") {
26
+ return 0;
27
+ } else {
28
+ return item.id.split('-')[1];
29
+ }
30
+ }
31
+
32
+ // on window resize
33
+ jQuery(window).resize(function() {
34
+ fluidDialog();
35
+ });
36
+
37
+ // dialog width larger than viewport
38
+ jQuery(document).on("dialogopen", ".ui-dialog", function(event, ui) {
39
+ fluidDialog();
40
+ });
41
+
42
+ function fluidDialog() {
43
+ var visible = jQuery(".ui-dialog:visible");
44
+ // on each visible dialog
45
+ visible.each(function() {
46
+ var $this = jQuery(this);
47
+ var dialog = $this.find(".ui-dialog-content").data("ui-dialog");
48
+ // on each fluid dialog
49
+ if (dialog.options.fluid) {
50
+ var wWidth = jQuery(window).width();
51
+ // window width vs dialog width
52
+ if (wWidth < (parseInt(dialog.options.maxWidth) + 50)) {
53
+ // don't fill the entire screen
54
+ $this.css("max-width", "90%");
55
+ } else {
56
+ // maxWidth bug fix
57
+ $this.css("max-width", dialog.options.maxWidth + "px");
58
+ }
59
+ // change dialog position
60
+ dialog.option("position", dialog.options.position);
61
+ }
62
+ });
63
+
64
+ }
65
+ });
66
+
67
+ jQuery.fn.extend({
68
+ gadwpItemReport : function(slug, item_id) {
69
+
70
+ var template = {
71
+
72
+ data : '<div id="gadwp-container' + slug + '"><select id="gadwp-sel-period' + slug + '"></select> <select id="gadwp-sel-report' + slug + '"></select><div id="gadwp-progressbar' + slug + '"></div><div id="gadwp-status' + slug + '"></div><div id="gadwp-reports' + slug + '"></div><div style="text-align:right;width:100%;font-size:0.8em;clear:both;margin-right:5px;margin-top:10px;">' + gadwp_item_data.i18n[14] + ' <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;</div></div>',
73
+
74
+ addOptions : function(id, list) {
75
+
76
+ var output = [];
77
+ jQuery.each(list, function(key, value) {
78
+ if (key == '30daysAgo' || key == 'sessions') {
79
+ output.push('<option value="' + key + '" selected="selected">' + value + '</option>');
80
+ } else {
81
+ output.push('<option value="' + key + '">' + value + '</option>');
82
+ }
83
+ });
84
+ jQuery(id).html(output.join(''));
85
+ },
86
+
87
+ init : function() {
88
+ if (jQuery('#gadwp-window' + slug).html().length) { // add main template once
89
+ return;
90
+ }
91
+
92
+ jQuery('#gadwp-window' + slug).append(this.data);
93
+
94
+ this.addOptions('#gadwp-sel-period' + slug, gadwp_item_data.dateList);
95
+ this.addOptions('#gadwp-sel-report' + slug, gadwp_item_data.reportList);
96
+
97
+ }
98
+ }
99
+
100
+ var reports = {
101
+
102
+ npcounter : 0,
103
+ prs : '',
104
+ trafficchannels : '',
105
+ trafficmediums : '',
106
+ traffictype : '',
107
+ trafficorganic : '',
108
+ socialnetworks : '',
109
+ locations : '',
110
+ mainchart : '',
111
+ bottomstats : '',
112
+
113
+ alertMessage : function(msg) {
114
+ jQuery("#gadwp-status" + slug).css({
115
+ "margin-top" : "3px",
116
+ "padding-left" : "5px",
117
+ "height" : "auto",
118
+ "color" : "#000",
119
+ "border-left" : "5px solid red"
120
+ });
121
+ jQuery("#gadwp-status" + slug).html(msg);
122
+ },
123
+
124
+ drawprs : function(gadwp_prs) {
125
+ var data = google.visualization.arrayToDataTable(gadwp_prs);
126
+ var options = {
127
+ page : 'enable',
128
+ pageSize : 10,
129
+ width : '100%'
130
+ };
131
+
132
+ var chart = new google.visualization.Table(document.getElementById('gadwp-prs' + slug));
133
+ chart.draw(data, options);
134
+ },
135
+
136
+ drawtrafficchannels : function(gadwp_trafficchannels) {
137
+ var data = google.visualization.arrayToDataTable(gadwp_trafficchannels);
138
+ var options = {
139
+ allowCollapse : true,
140
+ allowHtml : true
141
+ };
142
+
143
+ var chart = new google.visualization.OrgChart(document.getElementById('gadwp-trafficchannels' + slug));
144
+ chart.draw(data, options);
145
+ },
146
+
147
+ drawtrafficmediums : function(gadwp_trafficmediums) {
148
+ var data = google.visualization.arrayToDataTable(gadwp_trafficmediums);
149
+ var options = {
150
+ is3D : false,
151
+ tooltipText : 'percentage',
152
+ legend : 'none',
153
+ chartArea : {
154
+ width : '99%',
155
+ height : '80%'
156
+ },
157
+ title : gadwp_item_data.i18n[1],
158
+ colors : gadwp_item_data.colorVariations
159
+ };
160
+
161
+ var chart = new google.visualization.PieChart(document.getElementById('gadwp-trafficmediums' + slug));
162
+ chart.draw(data, options);
163
+ },
164
+
165
+ drawtraffictype : function(gadwp_traffictype) {
166
+ var data = google.visualization.arrayToDataTable(gadwp_traffictype);
167
+ var options = {
168
+ is3D : false,
169
+ tooltipText : 'percentage',
170
+ legend : 'none',
171
+ chartArea : {
172
+ width : '99%',
173
+ height : '80%'
174
+ },
175
+ title : gadwp_item_data.i18n[2],
176
+ colors : gadwp_item_data.colorVariations
177
+ };
178
+
179
+ var chart = new google.visualization.PieChart(document.getElementById('gadwp-traffictype' + slug));
180
+ chart.draw(data, options);
181
+ },
182
+
183
+ drawsocialnetworks : function(gadwp_socialnetworks) {
184
+ var data = google.visualization.arrayToDataTable(gadwp_socialnetworks);
185
+ var options = {
186
+ is3D : false,
187
+ tooltipText : 'percentage',
188
+ legend : 'none',
189
+ chartArea : {
190
+ width : '99%',
191
+ height : '80%'
192
+ },
193
+ title : gadwp_item_data.i18n[3],
194
+ colors : gadwp_item_data.colorVariations
195
+ };
196
+
197
+ var chart = new google.visualization.PieChart(document.getElementById('gadwp-socialnetworks' + slug));
198
+ chart.draw(data, options);
199
+ },
200
+
201
+ drawtrafficorganic : function(gadwp_trafficorganic) {
202
+ var data = google.visualization.arrayToDataTable(gadwp_trafficorganic);
203
+ var options = {
204
+ is3D : false,
205
+ tooltipText : 'percentage',
206
+ legend : 'none',
207
+ chartArea : {
208
+ width : '99%',
209
+ height : '80%'
210
+ },
211
+ title : gadwp_item_data.i18n[4],
212
+ colors : gadwp_item_data.colorVariations
213
+ };
214
+
215
+ var chart = new google.visualization.PieChart(document.getElementById('gadwp-trafficorganic' + slug));
216
+ chart.draw(data, options);
217
+ },
218
+
219
+ drawlocations : function(gadwp_locations) {
220
+ var data = google.visualization.arrayToDataTable(gadwp_locations);
221
+ var options = {
222
+ page : 'enable',
223
+ pageSize : 10,
224
+ width : '100%'
225
+ };
226
+
227
+ var chart = new google.visualization.Table(document.getElementById('gadwp-locations' + slug));
228
+ chart.draw(data, options);
229
+ },
230
+
231
+ drawmaplocations : function(gadwp_locations) {
232
+
233
+ var data = google.visualization.arrayToDataTable(gadwp_locations);
234
+
235
+ var options = {
236
+ chartArea : {
237
+ width : '99%',
238
+ height : '90%'
239
+ },
240
+ colors : [gadwp_item_data.colorVariations[5], gadwp_item_data.colorVariations[4]],
241
+ }
242
+
243
+ if (gadwp_item_data.region) {
244
+ options.region = gadwp_item_data.region;
245
+ options.displayMode = 'markers';
246
+ options.datalessRegionColor = 'EFEFEF';
247
+ }
248
+
249
+ var chart = new google.visualization.GeoChart(document.getElementById('gadwp-map' + slug));
250
+ chart.draw(data, options);
251
+ },
252
+
253
+ drawmainchart : function(gadwp_mainchart) {
254
+
255
+ var data = google.visualization.arrayToDataTable(gadwp_mainchart);
256
+
257
+ var options = {
258
+ legend : {
259
+ position : 'none'
260
+ },
261
+ pointSize : 3,
262
+ colors : [gadwp_item_data.colorVariations[0], gadwp_item_data.colorVariations[4]],
263
+ chartArea : {
264
+ width : '99%',
265
+ height : '90%'
266
+ },
267
+ vAxis : {
268
+ textPosition : "in",
269
+ minValue : 0
270
+ },
271
+ hAxis : {
272
+ textPosition : 'none'
273
+ }
274
+ };
275
+ var chart = new google.visualization.AreaChart(document.getElementById('gadwp-mainchart' + slug));
276
+ chart.draw(data, options);
277
+ },
278
+
279
+ drawbottomstats : function(gadwp_bottomstats) {
280
+ jQuery("#gdsessions" + slug).text(gadwp_bottomstats[0]);
281
+ jQuery("#gdusers" + slug).text(gadwp_bottomstats[1]);
282
+ jQuery("#gdpageviews" + slug).text(gadwp_bottomstats[2]);
283
+ jQuery("#gdbouncerate" + slug).text(parseFloat(gadwp_bottomstats[3]).toFixed(2) + "%");
284
+ jQuery("#gdorganicsearch" + slug).text(gadwp_bottomstats[4]);
285
+ jQuery("#gdpagespervisit" + slug).text(parseFloat(gadwp_bottomstats[5]).toFixed(2));
286
+ },
287
+
288
+ checknpcounter : function(max) {
289
+ try {
290
+ if (this.npcounter == max) {
291
+ NProgress.done();
292
+ } else {
293
+ this.npcounter++;
294
+ NProgress.set((1 / (max + 1)) * this.npcounter);
295
+ }
296
+ } catch (e) {
297
+ }
298
+ },
299
+
300
+ throwDebug : function(response) {
301
+ jQuery("#gadwp-status" + slug).css({
302
+ "margin-top" : "3px",
303
+ "padding-left" : "5px",
304
+ "height" : "auto",
305
+ "color" : "#000",
306
+ "border-left" : "5px solid red"
307
+ });
308
+ jQuery("#gadwp-status" + slug).html(gadwp_item_data.i18n[11]);
309
+ console.log("\n********************* GADWP Log ********************* \n\n" + response);
310
+ },
311
+
312
+ throwError : function(target, response, n, p) {
313
+ jQuery(target).css({
314
+ "background-color" : "#F7F7F7",
315
+ "height" : "auto",
316
+ "padding-top" : p,
317
+ "padding-bottom" : p,
318
+ "color" : "#000",
319
+ "text-align" : "center"
320
+ });
321
+ if (response == -21) {
322
+ jQuery(target).html(gadwp_item_data.i18n[12] + ' (' + response + ')');
323
+ } else {
324
+ jQuery(target).html(gadwp_item_data.i18n[13] + ' (' + response + ')');
325
+ }
326
+ this.checknpcounter(n);
327
+ },
328
+
329
+ render : function(period, query) {
330
+ var from, to;
331
+ jQuery('#gadwp-status' + slug).html('');
332
+ switch (period) {
333
+ case 'today' :
334
+ from = 'today';
335
+ to = 'today';
336
+ break;
337
+ case 'yesterday' :
338
+ from = 'yesterday';
339
+ to = 'yesterday';
340
+ break;
341
+ case '7daysAgo' :
342
+ from = '7daysAgo';
343
+ to = 'yesterday';
344
+ break;
345
+ case '14daysAgo' :
346
+ from = '14daysAgo';
347
+ to = 'yesterday';
348
+ break;
349
+ case '90daysAgo' :
350
+ from = '90daysAgo';
351
+ to = 'yesterday';
352
+ break;
353
+ default :
354
+ from = '30daysAgo';
355
+ to = 'yesterday';
356
+ break;
357
+ }
358
+
359
+ var data = {
360
+ action : 'gadwp_get_ItemReports',
361
+ gadwp_security_item_reports : gadwp_item_data.security,
362
+ from : from,
363
+ to : to,
364
+ filter : item_id
365
+ }
366
+
367
+ if (jQuery.inArray(query, ['referrers', 'contentpages', 'searches']) > -1) {
368
+ jQuery('#gadwp-reports' + slug).html('<div id="gadwp-trafficchannels' + slug + '"></div>')
369
+ jQuery('#gadwp-reports' + slug).append('<div id="gadwp-prs' + slug + '"></div>');
370
+ data.query = 'trafficchannels';
371
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
372
+ if (!jQuery.isNumeric(response)) {
373
+ if (jQuery.isArray(response)) {
374
+ reports.trafficchannels = response;
375
+ google.setOnLoadCallback(reports.drawtrafficchannels(reports.trafficchannels));
376
+ reports.checknpcounter(1);
377
+ } else {
378
+ reports.throwDebug(response);
379
+ reports.checknpcounter(1);
380
+ }
381
+ } else {
382
+ reports.throwError('#gadwp-trafficchannels' + slug, response, 1, "125px");
383
+ }
384
+ });
385
+ data.query = query;
386
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
387
+ if (!jQuery.isNumeric(response)) {
388
+ if (jQuery.isArray(response)) {
389
+ reports.prs = response;
390
+ google.setOnLoadCallback(reports.drawprs(reports.prs));
391
+ reports.checknpcounter(1);
392
+ } else {
393
+ reports.throwDebug(response);
394
+ reports.checknpcounter(1);
395
+ }
396
+ } else {
397
+ reports.throwError('#gadwp-prs' + slug, response, 1, "125px");
398
+ }
399
+ });
400
+ } else if (query == 'trafficdetails') {
401
+ jQuery('#gadwp-reports' + slug).html('<div id="gadwp-trafficchannels' + slug + '"></div>')
402
+ jQuery('#gadwp-reports' + slug).append('<div class="gadwp-floatwraper"><div id="gadwp-trafficmediums' + slug + '"></div><div id="gadwp-traffictype' + slug + '"></div></div>');
403
+ jQuery('#gadwp-reports' + slug).append('<div class="gadwp-floatwraper"><div id="gadwp-trafficorganic' + slug + '"></div><div id="gadwp-socialnetworks' + slug + '"></div></div>');
404
+ data.query = 'trafficchannels';
405
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
406
+ if (!jQuery.isNumeric(response)) {
407
+ if (jQuery.isArray(response)) {
408
+ reports.trafficchannels = response;
409
+ google.setOnLoadCallback(reports.drawtrafficchannels(reports.trafficchannels));
410
+ reports.checknpcounter(4);
411
+ } else {
412
+ reports.throwDebug(response);
413
+ reports.checknpcounter(4);
414
+ }
415
+ } else {
416
+ reports.throwError('#gadwp-trafficchannels' + slug, response, 4, "125px");
417
+ }
418
+ });
419
+ data.query = 'medium';
420
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
421
+ if (!jQuery.isNumeric(response)) {
422
+ if (jQuery.isArray(response)) {
423
+ reports.trafficmediums = response;
424
+ google.setOnLoadCallback(reports.drawtrafficmediums(reports.trafficmediums));
425
+ reports.checknpcounter(4);
426
+ } else {
427
+ reports.throwDebug(response);
428
+ reports.checknpcounter(4);
429
+ }
430
+ } else {
431
+ reports.throwError('#gadwp-trafficmediums' + slug, response, 4, "80px");
432
+ }
433
+ });
434
+ data.query = 'visitorType';
435
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
436
+ if (!jQuery.isNumeric(response)) {
437
+ if (jQuery.isArray(response)) {
438
+ reports.traffictype = response;
439
+ google.setOnLoadCallback(reports.drawtraffictype(reports.traffictype));
440
+ reports.checknpcounter(4);
441
+ } else {
442
+ reports.throwDebug(response);
443
+ reports.checknpcounter(4);
444
+ }
445
+ } else {
446
+ reports.throwError('#gadwp-traffictype' + slug, response, 4, "80px");
447
+ }
448
+ });
449
+ data.query = 'source';
450
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
451
+ if (!jQuery.isNumeric(response)) {
452
+ if (jQuery.isArray(response)) {
453
+ reports.trafficorganic = response;
454
+ google.setOnLoadCallback(reports.drawtrafficorganic(reports.trafficorganic));
455
+ reports.checknpcounter(4);
456
+ } else {
457
+ reports.throwDebug(response);
458
+ reports.checknpcounter(4);
459
+ }
460
+ } else {
461
+ reports.throwError('#gadwp-trafficorganic' + slug, response, 4, "80px");
462
+ }
463
+ });
464
+ data.query = 'socialNetwork';
465
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
466
+ if (!jQuery.isNumeric(response)) {
467
+ if (jQuery.isArray(response)) {
468
+ reports.socialnetworks = response;
469
+ google.setOnLoadCallback(reports.drawsocialnetworks(reports.socialnetworks));
470
+ reports.checknpcounter(4);
471
+ } else {
472
+ reports.throwDebug(response);
473
+ reports.checknpcounter(4);
474
+ }
475
+ } else {
476
+ reports.throwError('#gadwp-socialnetworks' + slug, response, 4, "80px");
477
+ }
478
+ });
479
+ } else if (query == 'locations') {
480
+ jQuery('#gadwp-reports' + slug).html('<div id="gadwp-map' + slug + '"></div>')
481
+ jQuery('#gadwp-reports' + slug).append('<div id="gadwp-locations' + slug + '"></div>');
482
+ data.query = query;
483
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
484
+ if (!jQuery.isNumeric(response)) {
485
+ if (jQuery.isArray(response)) {
486
+ reports.locations = response;
487
+ google.setOnLoadCallback(reports.drawmaplocations(reports.locations));
488
+ reports.checknpcounter(1);
489
+ google.setOnLoadCallback(reports.drawlocations(reports.locations));
490
+ reports.checknpcounter(1);
491
+ } else {
492
+ reports.throwDebug(response);
493
+ reports.checknpcounter(1);
494
+ }
495
+ } else {
496
+ reports.throwError('#gadwp-map' + slug, response, 1, "125px");
497
+ reports.throwError('#gadwp-locations' + slug, response, 1, "125px");
498
+ }
499
+ });
500
+ } else {
501
+ jQuery('#gadwp-reports' + slug).html('<div id="gadwp-mainchart' + slug + '"></div>')
502
+ jQuery('#gadwp-reports' + slug).append('<div id="gadwp-bottomstats' + slug + '" class="gadwp-wrapper"><div class="inside"><div class="small-box"><h3>' + gadwp_item_data.i18n[5] + '</h3><p id="gdsessions' + slug + '">&nbsp;</p></div><div class="small-box"><h3>' + gadwp_item_data.i18n[6] + '</h3><p id="gdusers' + slug + '">&nbsp;</p></div><div class="small-box"><h3>' + gadwp_item_data.i18n[7] + '</h3><p id="gdpageviews' + slug + '">&nbsp;</p></div><div class="small-box"><h3>' + gadwp_item_data.i18n[8] + '</h3><p id="gdbouncerate' + slug + '">&nbsp;</p></div><div class="small-box"><h3>' + gadwp_item_data.i18n[9] + '</h3><p id="gdorganicsearch' + slug + '">&nbsp;</p></div><div class="small-box"><h3>' + gadwp_item_data.i18n[10] + '</h3><p id="gdpagespervisit' + slug + '">&nbsp;</p></div></div></div>');
503
+
504
+ data.query = query;
505
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
506
+ if (!jQuery.isNumeric(response)) {
507
+ if (jQuery.isArray(response)) {
508
+ reports.mainchart = response;
509
+ google.setOnLoadCallback(reports.drawmainchart(reports.mainchart));
510
+ reports.checknpcounter(1);
511
+ } else {
512
+ reports.throwDebug(response);
513
+ reports.checknpcounter(1);
514
+ }
515
+ } else {
516
+ reports.throwError('#gadwp-mainchart' + slug, response, 1, "125px");
517
+ }
518
+ });
519
+
520
+ data.query = 'bottomstats';
521
+ jQuery.post(gadwp_item_data.ajaxurl, data, function(response) {
522
+
523
+ if (!jQuery.isNumeric(response)) {
524
+ if (jQuery.isArray(response)) {
525
+ reports.bottomstats = response;
526
+ google.setOnLoadCallback(reports.drawbottomstats(reports.bottomstats));
527
+ reports.checknpcounter(1);
528
+ } else {
529
+ reports.throwDebug(response);
530
+ reports.checknpcounter(1);
531
+ }
532
+ } else {
533
+ reports.throwError('#gadwp-bottomstats' + slug, response, response, 1, "40px");
534
+ }
535
+ });
536
+
537
+ }
538
+
539
+ },
540
+
541
+ refresh : function() {
542
+ if (jQuery('#gadwp-bottomstats' + slug).length > 0){
543
+ this.drawbottomstats(this.bottomstats);
544
+ }
545
+ if (jQuery('#gadwp-mainchart' + slug).length > 0 && jQuery.isArray(this.mainchart)){
546
+ this.drawmainchart(this.mainchart);
547
+ }
548
+ if (jQuery('#gadwp-map' + slug).length > 0 && jQuery.isArray(this.locations)){
549
+ this.drawmaplocations(this.locations);
550
+ }
551
+ if (jQuery('#gadwp-locations' + slug).length > 0 && jQuery.isArray(this.locations)){
552
+ this.drawlocations(this.locations);
553
+ }
554
+ if (jQuery('#gadwp-socialnetworks' + slug).length > 0 && jQuery.isArray(this.socialnetworks)){
555
+ this.drawsocialnetworks(this.socialnetworks);
556
+ }
557
+ if (jQuery('#gadwp-trafficorganic' + slug).length > 0 && jQuery.isArray(this.trafficorganic)){
558
+ this.drawtrafficorganic(this.trafficorganic);
559
+ }
560
+ if (jQuery('#gadwp-traffictype' + slug).length > 0 && jQuery.isArray(this.traffictype)){
561
+ this.drawtraffictype(this.traffictype);
562
+ }
563
+ if (jQuery('#gadwp-trafficmediums' + slug).length > 0 && jQuery.isArray(this.trafficmediums)){
564
+ this.drawtrafficmediums(this.trafficmediums);
565
+ }
566
+ if (jQuery('#gadwp-trafficchannels' + slug).length > 0 && jQuery.isArray(this.trafficchannels)){
567
+ this.drawtrafficchannels(this.trafficchannels);
568
+ }
569
+ if (jQuery('#gadwp-prs' + slug).length > 0 && jQuery.isArray(this.prs)){
570
+ this.drawprs(this.prs);
571
+ }
572
+ },
573
+
574
+ init : function() {
575
+
576
+ if (jQuery("#gadwp-reports" + slug).html().length) { // only when report is empty
577
+ return;
578
+ }
579
+
580
+ try {
581
+ NProgress.configure({
582
+ parent : "#gadwp-progressbar" + slug
583
+ });
584
+ NProgress.configure({
585
+ showSpinner : false
586
+ });
587
+ NProgress.start();
588
+ } catch (e) {
589
+ this.alertMessage(gadwp_item_data.i18n[0]);
590
+ }
591
+
592
+ this.render(jQuery('#gadwp-sel-period' + slug).val(), jQuery('#gadwp-sel-report' + slug).val());
593
+
594
+ jQuery(window).resize(function() {
595
+ reports.refresh();
596
+ });
597
+ }
598
+ }
599
+
600
+ template.init();
601
+
602
+ reports.init();
603
+
604
+ jQuery('#gadwp-sel-period' + slug).change(function() {
605
+ jQuery('#gadwp-reports' + slug).html('');
606
+ reports.init();
607
+ });
608
+
609
+ jQuery('#gadwp-sel-report' + slug).change(function() {
610
+ jQuery('#gadwp-reports' + slug).html('');
611
+ reports.init();
612
+ });
613
+
614
+ return this.dialog({
615
+ width : 'auto',
616
+ maxWidth : 510,
617
+ height : 'auto',
618
+ modal : true,
619
+ fluid : true,
620
+ dialogClass : 'wp-dialog',
621
+ resizable : false,
622
+ title : jQuery('#gadwp'+slug).attr( "title" ).substring(0,44),
623
+ position : {
624
+ my : "top",
625
+ at : "top+100",
626
+ of : window
627
+ }
628
+ });
629
+
630
+ }
631
+ });
admin/js/settings.js ADDED
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Navigation Tabs
3
+ */
4
+ jQuery(document).ready(
5
+ function() {
6
+ if (window.location.href.indexOf("page=gadash_") != -1) {
7
+ var ident = 'basic';
8
+
9
+ if (window.location.hash) {
10
+ ident = window.location.hash.split('#')[2].split('-')[1];
11
+ }else if (window.location.href.indexOf("page=gadash_errors_debugging") != -1){
12
+ ident = 'errors';
13
+ }
14
+
15
+ jQuery(".nav-tab-wrapper a").each(function(index) {
16
+ jQuery(this).removeClass("nav-tab-active");
17
+ jQuery("#" + this.hash.split('#')[2]).hide();
18
+ });
19
+ jQuery("#tab-" + ident).addClass("nav-tab-active");
20
+ jQuery("#gadwp-" + ident).show();
21
+ }
22
+
23
+ jQuery('a[href^="#"]').click(function(e) {
24
+ if (window.location.href.indexOf("page=gadash_") != -1) {
25
+ jQuery(".nav-tab-wrapper a").each(function(index) {
26
+ jQuery(this).removeClass("nav-tab-active");
27
+ jQuery("#" + this.hash.split('#')[2]).hide();
28
+ });
29
+ jQuery(this).addClass("nav-tab-active");
30
+ jQuery("#" + this.hash.split('#')[2]).show();
31
+ }
32
+ });
33
+
34
+ }
35
+
36
+ );
admin/js/{admin.js → widgets.js} RENAMED
@@ -1,37 +1,6 @@
1
- jQuery(document).ready(
2
- function() {
3
- if (window.location.href.indexOf("page=gadash_") != -1) {
4
- var ident = 'basic';
5
-
6
- if (window.location.hash) {
7
- ident = window.location.hash.split('#')[2].split('-')[1];
8
- }else if (window.location.href.indexOf("page=gadash_errors_debugging") != -1){
9
- ident = 'errors';
10
- }
11
-
12
- jQuery(".nav-tab-wrapper a").each(function(index) {
13
- jQuery(this).removeClass("nav-tab-active");
14
- jQuery("#" + this.hash.split('#')[2]).hide();
15
- });
16
- jQuery("#tab-" + ident).addClass("nav-tab-active");
17
- jQuery("#gadwp-" + ident).show();
18
- }
19
-
20
- jQuery('a[href^="#"]').click(function(e) {
21
- if (window.location.href.indexOf("page=gadash_") != -1) {
22
- jQuery(".nav-tab-wrapper a").each(function(index) {
23
- jQuery(this).removeClass("nav-tab-active");
24
- jQuery("#" + this.hash.split('#')[2]).hide();
25
- });
26
- jQuery(this).addClass("nav-tab-active");
27
- jQuery("#" + this.hash.split('#')[2]).show();
28
- }
29
- });
30
-
31
- }
32
-
33
- );
34
-
35
jQuery(window).resize(
36
function() {
37
if (typeof ga_dash_drawmainchart == "function"
1
+ /*
2
+ * Responsive charts
3
+ */
4
jQuery(window).resize(
5
function() {
6
if (typeof ga_dash_drawmainchart == "function"
admin/{ga_dash_settings.php → settings.php} RENAMED
@@ -34,7 +34,9 @@ final class GADASH_Settings
34
}
35
} else
36
if ($who == 'backend') {
37
- $options['ga_dash_jailadmins'] = 0;
38
if (empty($new_options['ga_dash_access_back'])) {
39
$new_options['ga_dash_access_back'][] = 'administrator';
40
}
@@ -48,11 +50,15 @@ final class GADASH_Settings
48
} else
49
if ($who == 'general') {
50
$options['ga_dash_userapi'] = 0;
51
} else
52
if ($who == 'network') {
53
$options['ga_dash_userapi'] = 0;
54
$options['ga_dash_network'] = 0;
55
$options['ga_dash_excludesa'] = 0;
56
$network_settings = true;
57
}
58
$options = array_merge($options, $new_options);
@@ -86,7 +92,7 @@ final class GADASH_Settings
86
}
87
}
88
if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
89
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
90
}
91
?>
92
<form name="ga_dash_form" method="post"
@@ -102,7 +108,7 @@ final class GADASH_Settings
102
<?php if (isset($message)) echo $message; ?>
103
<table class="options">
104
<tr>
105
- <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'ga-dash' ) . "</h2>"; ?></td>
106
</tr>
107
<tr>
108
<td class="roles title"><label for="ga_dash_access_front"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
@@ -134,7 +140,8 @@ final class GADASH_Settings
134
<?php
135
}
136
}
137
- ?>
138
</td>
139
</tr>
140
<tr>
@@ -197,13 +204,13 @@ final class GADASH_Settings
197
}
198
}
199
if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
200
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
201
}
202
?>
203
<form name="ga_dash_form" method="post"
204
action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
205
<div class="wrap">
206
- <?php echo "<h2>" . __( "Google Analytics Dashboard Settings", 'ga-dash' ) . "</h2>"; ?><hr>
207
</div>
208
<div id="poststuff">
209
<div id="post-body" class="metabox-holder columns-2">
@@ -213,7 +220,7 @@ final class GADASH_Settings
213
<?php if (isset($message)) echo $message; ?>
214
<table class="options">
215
<tr>
216
- <td colspan="2"><?php echo "<h2>" . __( "General Settings", 'ga-dash' ) . "</h2>"; ?></td>
217
</tr>
218
<tr>
219
<td class="roles title"><label for="ga_dash_access_back"><?php _e("Show stats to:", 'ga-dash' ); ?></label></td>
@@ -246,22 +253,51 @@ final class GADASH_Settings
246
<?php
247
}
248
}
249
- ?>
250
</td>
251
</tr>
252
<tr>
253
<td colspan="2" class="title">
254
<div class="onoffswitch">
255
- <input type="checkbox" name="options[ga_dash_jailadmins]"
256
value="1" class="onoffswitch-checkbox"
257
- id="ga_dash_jailadmins"
258
- <?php checked( $options['ga_dash_jailadmins'], 1 ); ?>> <label
259
- class="onoffswitch-label" for="ga_dash_jailadmins">
260
<div class="onoffswitch-inner"></div>
261
<div class="onoffswitch-switch"></div>
262
</label>
263
</div>
264
- <div class="switch-desc"><?php _e ( "disable Switch Profile/View functionality", 'ga-dash' );?></div>
265
</td>
266
</tr>
267
<tr>
@@ -314,10 +350,6 @@ final class GADASH_Settings
314
public static function tracking_settings()
315
{
316
global $GADASH_Config;
317
- /*
318
- * Include Tools
319
- */
320
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
321
$tools = new GADASH_Tools();
322
if (! current_user_can('manage_options')) {
323
return;
@@ -330,7 +362,7 @@ final class GADASH_Settings
330
}
331
}
332
if (! $GADASH_Config->options['ga_dash_tableid_jail']) {
333
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
334
}
335
if (! $options['ga_dash_tracking']) {
336
$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>";
@@ -681,7 +713,7 @@ final class GADASH_Settings
681
}
682
$options = self::set_get_options('frontend');
683
if (! $GADASH_Config->options['ga_dash_tableid_jail'] or ! $GADASH_Config->options['ga_dash_token']) {
684
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
685
}
686
?>
687
<div class="wrap">
@@ -704,7 +736,7 @@ final class GADASH_Settings
704
<table class="options">
705
<tr>
706
<td>
707
- <?php echo __("For errors and/or other issues please check",'ga-dash')." <a href='https://deconf.com/google-analytics-dashboard-wordpress/?utm_source=gadwp_config&utm_medium=link&utm_content=errors_screen&utm_campaign=gadwp' target='_blank'>". __("the plugin documentation page",'ga-dash')."</a> ".__("and related tutorials",'ga-dash').".";?>
708
</td>
709
</tr>
710
<tr>
@@ -731,6 +763,8 @@ final class GADASH_Settings
731
?></pre><br />
732
<hr>
733
</td>
734
<tr>
735
736
</table>
@@ -774,10 +808,6 @@ final class GADASH_Settings
774
{
775
global $GADASH_Config;
776
global $wp_version;
777
- /*
778
- * Include Tools
779
- */
780
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
781
$tools = new GADASH_Tools();
782
if (! current_user_can('manage_options')) {
783
return;
@@ -786,7 +816,7 @@ final class GADASH_Settings
786
/*
787
* Include GAPI
788
*/
789
- 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/ask/question/ga-dashboard-absolutely-empty-general-settings#answer-770">Library conflicts between WordPress plugins</a></p></div>';
790
include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
791
global $GADASH_GAPI;
792
echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
@@ -811,7 +841,7 @@ final class GADASH_Settings
811
return $e->getCode();
812
} catch (Exception $e) {
813
set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
814
- $GADASH_GAPI->ga_dash_reset_token(false);
815
}
816
} else {
817
$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>";
@@ -836,7 +866,7 @@ final class GADASH_Settings
836
}
837
if (isset($_POST['Clear'])) {
838
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
839
- $tools->ga_dash_clear_cache();
840
$message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
841
} else {
842
$message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
@@ -844,15 +874,24 @@ final class GADASH_Settings
844
}
845
if (isset($_POST['Reset'])) {
846
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
847
- $GADASH_GAPI->ga_dash_reset_token(true);
848
- $tools->ga_dash_clear_cache();
849
$message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
850
$options = self::set_get_options('Reset');
851
} else {
852
$message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
853
}
854
}
855
- if (isset($_POST['options']['ga_dash_hidden']) and ! isset($_POST['Clear']) and ! isset($_POST['Reset'])) {
856
$message = "<div class='updated'><p>" . __("Settings saved.", 'ga-dash') . "</p></div>";
857
if (! (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form'))) {
858
$message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
@@ -880,10 +919,10 @@ final class GADASH_Settings
880
<div class="settings-wrapper">
881
<div class="inside">
882
if ($GADASH_GAPI->gapi_errors_handler()) {
883
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
884
}
885
if (isset($_POST['Authorize'])) {
886
- $tools->ga_dash_clear_cache();
887
$GADASH_GAPI->token_request();
888
echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
889
} else {
@@ -956,7 +995,10 @@ final class GADASH_Settings
956
<?php echo $options['ga_dash_network']?'disabled="disabled"':''; ?> />
957
<input type="submit" name="Clear"
958
class="button button-secondary"
959
- value="<?php _e( "Clear Cache", 'ga-dash' ); ?>" /></td>
960
</tr>
961
<tr>
962
<td colspan="2"><hr></td>
@@ -974,7 +1016,7 @@ final class GADASH_Settings
974
foreach ($options['ga_dash_profile_list'] as $items) {
975
if ($items[3]) {
976
echo '<option value="' . esc_attr($items[1]) . '" ' . selected($items[1], $options['ga_dash_tableid_jail']);
977
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . esc_html($tools->ga_dash_get_profile_domain($items[3])) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
978
}
979
}
980
} else {
@@ -1014,9 +1056,28 @@ final class GADASH_Settings
1014
<tr>
1015
<td colspan="2"><hr></td>
1016
</tr>
1017
<tr>
1018
- <td colspan="2"><?php echo __('A new frontend widget is available! To enable it, go to','ga-dash').' <a href="widgets.php">'.__('Appearance -> Widgets').'</a> '.__('and look for Google Analytics Dashboard.','ga-dash').' '.''; ?></td>
1019
</tr>
1020
<tr>
1021
<td colspan="2"><hr></td>
1022
</tr>
@@ -1058,10 +1119,6 @@ final class GADASH_Settings
1058
{
1059
global $GADASH_Config;
1060
global $wp_version;
1061
- /*
1062
- * Include Tools
1063
- */
1064
- include_once ($GADASH_Config->plugin_path . '/tools/tools.php');
1065
$tools = new GADASH_Tools();
1066
if (! current_user_can('manage_network_options')) {
1067
return;
@@ -1070,7 +1127,7 @@ final class GADASH_Settings
1070
/*
1071
* Include GAPI
1072
*/
1073
- 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/ask/question/ga-dashboard-absolutely-empty-general-settings#answer-770">Library conflicts between WordPress plugins</a></p></div>';
1074
include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
1075
global $GADASH_GAPI;
1076
echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
@@ -1104,7 +1161,7 @@ final class GADASH_Settings
1104
return $e->getCode();
1105
} catch (Exception $e) {
1106
set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
1107
- $GADASH_GAPI->ga_dash_reset_token(false);
1108
}
1109
} else {
1110
$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>";
@@ -1138,7 +1195,7 @@ final class GADASH_Settings
1138
}
1139
if (isset($_POST['Clear'])) {
1140
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1141
- $tools->ga_dash_clear_cache();
1142
$message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
1143
} else {
1144
$message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
@@ -1146,8 +1203,8 @@ final class GADASH_Settings
1146
}
1147
if (isset($_POST['Reset'])) {
1148
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1149
- $GADASH_GAPI->ga_dash_reset_token(true);
1150
- $tools->ga_dash_clear_cache();
1151
$message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
1152
$options = self::set_get_options('Reset');
1153
} else {
@@ -1182,10 +1239,10 @@ final class GADASH_Settings
1182
<div class="settings-wrapper">
1183
<div class="inside">
1184
if ($GADASH_GAPI->gapi_errors_handler()) {
1185
- $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) . "'>" . __('auhorize the plugin', 'ga-dash') . "</a>.</p></div>";
1186
}
1187
if (isset($_POST['Authorize'])) {
1188
- $tools->ga_dash_clear_cache();
1189
$GADASH_GAPI->token_request();
1190
echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
1191
} else {
@@ -1313,7 +1370,7 @@ final class GADASH_Settings
1313
foreach ($options['ga_dash_profile_list'] as $items) {
1314
if ($items[3]) {
1315
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'] : '');
1316
- echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . $tools->ga_dash_get_profile_domain($items[3]) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
1317
}
1318
}
1319
} else {
@@ -1325,7 +1382,27 @@ final class GADASH_Settings
1325
<?php
1326
}
1327
?>
1328
- <tr>
1329
<td colspan="2"><hr><?php echo "<h2>" . __( "Exclude Tracking", 'ga-dash' ) . "</h2>"; ?></td>
1330
</tr>
1331
<tr>
@@ -1448,7 +1525,8 @@ final class GADASH_Settings
1448
</h3>
1449
<div class="inside">
1450
<div class="gadash-title">
1451
- <a href="https://deconf.com/wordpress-cdn-speeds-up-your-site/"><img
1452
src="<?php echo plugins_url( 'images/mcdn.png' , __FILE__ ); ?>" /></a>
1453
</div>
1454
<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>
@@ -1466,8 +1544,5 @@ final class GADASH_Settings
1466
</div>
1467
</div>
1468
<?php
1469
- /*
1470
- * Include Tools
1471
- */
1472
}
1473
}
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
}
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);
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"
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>
140
<?php
141
}
142
}
143
+ ?>
144
+ </table>
145
</td>
146
</tr>
147
<tr>
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">
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>
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>
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;
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>";
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">
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>
763
?></pre><br />
764
<hr>
765
</td>
766
+
767
+
768
<tr>
769
770
</table>
808
{
809
global $GADASH_Config;
810
global $wp_version;
811
$tools = new GADASH_Tools();
812
if (! current_user_can('manage_options')) {
813
return;
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>';
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>";
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>";
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>";
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 {
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>
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 {
1056
<tr>
1057
<td colspan="2"><hr></td>
1058
</tr>
1059
+ <?php if ( !is_multisite()) {?>
1060
<tr>
1061
+ <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'ga-dash' ) . "</h2>"; ?></td>
1062
+ </tr>
1063
+ <tr>
1064
+ <td colspan="2" class="title">
1065
+ <div class="onoffswitch">
1066
+ <input type="checkbox"
1067
+ name="options[automatic_updates_minorversion]" value="1"
1068
+ class="onoffswitch-checkbox"
1069
+ id="automatic_updates_minorversion"
1070
+ <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1071
+ <label class="onoffswitch-label"
1072
+ for="automatic_updates_minorversion">
1073
+ <div class="onoffswitch-inner"></div>
1074
+ <div class="onoffswitch-switch"></div>
1075
+ </label>
1076
+ </div>
1077
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'ga-dash' );?></div>
1078
+ </td>
1079
</tr>
1080
+ <?php }?>
1081
<tr>
1082
<td colspan="2"><hr></td>
1083
</tr>
1119
{
1120
global $GADASH_Config;
1121
global $wp_version;
1122
$tools = new GADASH_Tools();
1123
if (! current_user_can('manage_network_options')) {
1124
return;
1127
/*
1128
* Include GAPI
1129
*/
1130
+ 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>';
1131
include_once ($GADASH_Config->plugin_path . '/tools/gapi.php');
1132
global $GADASH_GAPI;
1133
echo '<script type="text/javascript">jQuery("#gapi-warning").hide()</script>';
1161
return $e->getCode();
1162
} catch (Exception $e) {
1163
set_transient('ga_dash_lasterror', date('Y-m-d H:i:s') . ': ' . esc_html($e) . "\nResponseHttpCode:" . $e->getCode(), $GADASH_GAPI->error_timeout);
1164
+ $GADASH_GAPI->reset_token(false);
1165
}
1166
} else {
1167
$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>";
1195
}
1196
if (isset($_POST['Clear'])) {
1197
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1198
+ $tools->clear_cache();
1199
$message = "<div class='updated'><p>" . __("Cleared Cache.", 'ga-dash') . "</p></div>";
1200
} else {
1201
$message = "<div class='error'><p>" . __("Cheating Huh?", 'ga-dash') . "</p></div>";
1203
}
1204
if (isset($_POST['Reset'])) {
1205
if (isset($_POST['gadash_security']) && wp_verify_nonce($_POST['gadash_security'], 'gadash_form')) {
1206
+ $GADASH_GAPI->reset_token(true);
1207
+ $tools->clear_cache();
1208
$message = "<div class='updated'><p>" . __("Token Reseted and Revoked.", 'ga-dash') . "</p></div>";
1209
$options = self::set_get_options('Reset');
1210
} else {
1239
<div class="settings-wrapper">
1240
<div class="inside">
1241
if ($GADASH_GAPI->gapi_errors_handler()) {
1242
+ $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>";
1243
}
1244
if (isset($_POST['Authorize'])) {
1245
+ $tools->clear_cache();
1246
$GADASH_GAPI->token_request();
1247
echo "<div class='updated'><p>" . __("Use the red link (see below) to generate and get your access code!", 'ga-dash') . "</p></div>";
1248
} else {
1370
foreach ($options['ga_dash_profile_list'] as $items) {
1371
if ($items[3]) {
1372
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'] : '');
1373
+ echo ' title="' . __("View Name:", 'ga-dash') . ' ' . esc_attr($items[0]) . '">' . esc_html($tools->strip_protocol($items[3])) . ' &#8658; ' . esc_attr($items[0]) . '</option>';
1374
}
1375
}
1376
} else {
1382
<?php
1383
}
1384
?>
1385
+ <tr>
1386
+ <td colspan="2"><?php echo "<h2>" . __( "Automatic Updates", 'ga-dash' ) . "</h2>"; ?></td>
1387
+ </tr>
1388
+ <tr>
1389
+ <td colspan="2" class="title">
1390
+ <div class="onoffswitch">
1391
+ <input type="checkbox"
1392
+ name="options[automatic_updates_minorversion]"
1393
+ value="1" class="onoffswitch-checkbox"
1394
+ id="automatic_updates_minorversion"
1395
+ <?php checked( $options['automatic_updates_minorversion'], 1 ); ?>>
1396
+ <label class="onoffswitch-label"
1397
+ for="automatic_updates_minorversion">
1398
+ <div class="onoffswitch-inner"></div>
1399
+ <div class="onoffswitch-switch"></div>
1400
+ </label>
1401
+ </div>
1402
+ <div class="switch-desc"><?php echo " ".__( "automatic updates for minor versions (security and maintenance releases only)", 'ga-dash' );?></div>
1403
+ </td>
1404
+ </tr>
1405
+ <tr>
1406
<td colspan="2"><hr><?php echo "<h2>" . __( "Exclude Tracking", 'ga-dash' ) . "</h2>"; ?></td>
1407
</tr>
1408
<tr>
1525
</h3>
1526
<div class="inside">
1527
<div class="gadash-title">
1528
+ <a
1529
+ href="https://deconf.com/wordpress-cdn-speeds-up-your-site/"><img
1530
src="<?php echo plugins_url( 'images/mcdn.png' , __FILE__ ); ?>" /></a>
1531
</div>
1532
<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>
1544
</div>
1545
</div>
1546
<?php
1547
}
1548
}
admin/setup.php ADDED
@@ -0,0 +1,268 @@
1
+ <?php
2
+ /**
3
+ * Author: Alin Marcu
4
+ * Author URI: https://deconf.com
5
+ * License: GPLv2 or later
6
+ * License URI: http://www.gnu.org/licenses/gpl-2.0.html
7
+ */
8
+ if (! class_exists('GADASH_Back_Setup')) {
9
+
10
+ final class GADASH_Back_Setup
11
+ {
12
+
13
+ function __construct()
14
+ {
15
+ global $GADASH_Config;
16
+ // Styles & Scripts
17
+ add_action('admin_enqueue_scripts', array(
18
+ $this,
19
+ 'load_styles_scripts'
20
+ ));
21
+ // Site Menu
22
+ add_action('admin_menu', array(
23
+ $this,
24
+ 'site_menu'
25
+ ));
26
+ // Network Menu
27
+ add_action('network_admin_menu', array(
28
+ $this,
29
+ 'network_menu'
30
+ ));
31
+ // Settings link
32
+ add_filter("plugin_action_links_" . plugin_basename($GADASH_Config->plugin_path) . '/gadwp.php', array(
33
+ $this,
34
+ 'settings_link'
35
+ ));
36
+ // Error bubble
37
+ add_action('admin_print_scripts', array(
38
+ $this,
39
+ 'draw_error_bubble'
40
+ ), 10000);
41
+ }
42
+
43
+ /**
44
+ * Error bubble for Errors & Debug
45
+ */
46
+ function draw_error_bubble()
47
+ {
48
+ $bubble_msg = '!';
49
+ if (get_transient('ga_dash_gapi_errors')) {
50
+ ?>
51
+ <script type="text/javascript">
52
+ jQuery(document).ready(function() {
53
+ 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;"><?php echo $bubble_msg ?></span></span>');
54
+ });
55
+ </script>
56
+ <?php
57
+ }
58
+ }
59
+
60
+ /**
61
+ * Add Site Menu
62
+ */
63
+ function site_menu()
64
+ {
65
+ global $GADASH_Config;
66
+ global $wp_version;
67
+ if (current_user_can('manage_options')) {
68
+ include ($GADASH_Config->plugin_path . '/admin/settings.php');
69
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_options', 'gadash_settings', array(
70
+ 'GADASH_Settings',
71
+ 'general_settings'
72
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
73
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_options', 'gadash_settings', array(
74
+ 'GADASH_Settings',
75
+ 'general_settings'
76
+ ));
77
+ add_submenu_page('gadash_settings', __("Backend Settings", 'ga-dash'), __("Backend Settings", 'ga-dash'), 'manage_options', 'gadash_backend_settings', array(
78
+ 'GADASH_Settings',
79
+ 'backend_settings'
80
+ ));
81
+ add_submenu_page('gadash_settings', __("Frontend Settings", 'ga-dash'), __("Frontend Settings", 'ga-dash'), 'manage_options', 'gadash_frontend_settings', array(
82
+ 'GADASH_Settings',
83
+ 'frontend_settings'
84
+ ));
85
+ add_submenu_page('gadash_settings', __("Tracking Code", 'ga-dash'), __("Tracking Code", 'ga-dash'), 'manage_options', 'gadash_tracking_settings', array(
86
+ 'GADASH_Settings',
87
+ 'tracking_settings'
88
+ ));
89
+ add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_options', 'gadash_errors_debugging', array(
90
+ 'GADASH_Settings',
91
+ 'errors_debugging'
92
+ ));
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Add Network Menu
98
+ */
99
+ function network_menu()
100
+ {
101
+ global $GADASH_Config;
102
+ global $wp_version;
103
+ if (current_user_can('manage_netwrok')) {
104
+ include ($GADASH_Config->plugin_path . '/admin/settings.php');
105
+ add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
106
+ 'GADASH_Settings',
107
+ 'general_settings_network'
108
+ ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
109
+ add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
110
+ 'GADASH_Settings',
111
+ 'general_settings_network'
112
+ ));
113
+ add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_network', 'gadash_errors_debugging', array(
114
+ 'GADASH_Settings',
115
+ 'errors_debugging'
116
+ ));
117
+ }
118
+ }
119
+
120
+ /**
121
+ * Styles & Scripts conditional loading (based on current URI)
122
+ *
123
+ * @param
124
+ * $hook
125
+ */
126
+ function load_styles_scripts($hook)
127
+ {
128
+ global $GADASH_Config;
129
+ $tools = new GADASH_Tools();
130
+ /*
131
+ * GADWP main stylesheet
132
+ */
133
+ wp_enqueue_style('gadwp', $GADASH_Config->plugin_url . '/admin/css/gadwp.css', NULL, GADWP_CURRENT_VERSION);
134
+ /*
135
+ * Dashboard Widgets Styles & Scripts
136
+ */
137
+ $widgets_hooks = array(
138
+ 'index.php'
139
+ );
140
+ if (in_array($hook, $widgets_hooks)) {
141
+ wp_enqueue_style('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
142
+ wp_enqueue_style('gadwp-admin-widgets', $GADASH_Config->plugin_url . '/admin/css/gadwp.css', NULL, GADWP_CURRENT_VERSION);
143
+ wp_enqueue_script('gadwp-admin-widgets', plugins_url('js/widgets.js', __FILE__), array(
144
+ 'jquery'
145
+ ), GADWP_CURRENT_VERSION);
146
+ if (! wp_script_is('googlejsapi')) {
147
+ wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
148
+ wp_enqueue_script('googlejsapi');
149
+ }
150
+ wp_enqueue_script('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array(
151
+ 'jquery'
152
+ ), GADWP_CURRENT_VERSION);
153
+ }
154
+ /*
155
+ * Posts/Pages List Styles & Scripts
156
+ */
157
+ $contentstats_hooks = array(
158
+ 'edit.php'
159
+ );
160
+ if (in_array($hook, $contentstats_hooks)) {
161
+ if (! $tools->check_roles($GADASH_Config->options['ga_dash_access_back']) or 0 == $GADASH_Config->options['item_reports']) {
162
+ return;
163
+ }
164
+ wp_enqueue_style('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
165
+ wp_enqueue_style('gadwp_itemreports', $GADASH_Config->plugin_url . '/admin/css/item-reports.css', NULL, GADWP_CURRENT_VERSION);
166
+ $tools->getcountrycodes();
167
+ if ($GADASH_Config->options['ga_target_geomap'] and isset($tools->country_codes[$GADASH_Config->options['ga_target_geomap']])) {
168
+ $region = $GADASH_Config->options['ga_target_geomap'];
169
+ } else {
170
+ $region = false;
171
+ }
172
+ wp_enqueue_style("wp-jquery-ui-dialog");
173
+ if (! wp_script_is('googlejsapi')) {
174
+ wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
175
+ }
176
+ wp_enqueue_script('gadwp-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.js', array(
177
+ 'jquery'
178
+ ), GADWP_CURRENT_VERSION);
179
+ wp_enqueue_script('gadwp_itemreports', plugins_url('js/item-reports.js', __FILE__), array(
180
+ 'gadwp-nprogress',
181
+ 'googlejsapi',
182
+ 'jquery',
183
+ 'jquery-ui-dialog'
184
+ ), GADWP_CURRENT_VERSION);
185
+ wp_localize_script('gadwp_itemreports', 'gadwp_item_data',
186
+ array(
187
+ 'ajaxurl' => admin_url('admin-ajax.php'),
188
+ 'security' => wp_create_nonce('gadwp_get_itemreports'),
189
+ 'dateList' => array(
190
+ 'today' => __("Today", 'ga-dash'),
191
+ 'yesterday' => __("Yesterday", 'ga-dash'),
192
+ '7daysAgo' => __("Last 7 Days", 'ga-dash'),
193
+ '30daysAgo' => __("Last 30 Days", 'ga-dash'),
194
+ '90daysAgo' => __("Last 90 Days", 'ga-dash')
195
+ ),
196
+ 'reportList' => array(
197
+ 'uniquePageviews' => __("Unique Views", 'ga-dash'),
198
+ 'users' => __("Users", 'ga-dash'),
199
+ 'organicSearches' => __("Organic", 'ga-dash'),
200
+ 'pageviews' => __("Page Views", 'ga-dash'),
201
+ 'visitBounceRate' => __("Bounce Rate", 'ga-dash'),
202
+ 'locations' => __("Location", 'ga-dash'),
203
+ 'referrers' => __("Referrers", 'ga-dash'),
204
+ 'searches' => __("Searches", 'ga-dash'),
205
+ 'trafficdetails' => __("Traffic Details", 'ga-dash')
206
+ ),
207
+ 'i18n' => array(
208
+ __("A JavaScript Error is blocking plugin resources!", 'ga-dash'),
209
+ __("Traffic Mediums", 'ga-dash'),
210
+ __("Visitor Type", 'ga-dash'),
211
+ __("Social Networks", 'ga-dash'),
212
+ __("Search Engines", 'ga-dash'),
213
+ __("Unique Views", 'ga-dash'),
214
+ __("Users", 'ga-dash'),
215
+ __("Page Views", 'ga-dash'),
216
+ __("Bounce Rate", 'ga-dash'),
217
+ __("Organic Search", 'ga-dash'),
218
+ __("Pages/Session", 'ga-dash'),
219
+ __("Invalid response, more details in JavaScript Console (F12).", 'ga-dash'),
220
+ __("Not enough data collected", 'ga-dash'),
221
+ __("This report is unavailable", 'ga-dash'),
222
+ __("report generated by", 'ga-dash')
223
+ ),
224
+ 'colorVariations' => $tools->variations($GADASH_Config->options['ga_dash_style']),
225
+ 'region' => $region
226
+ ));
227
+ }
228
+ /*
229
+ * Settings Styles & Scripts
230
+ */
231
+ $settings_hooks = array(
232
+ 'toplevel_page_gadash_settings',
233
+ 'google-analytics_page_gadash_backend_settings',
234
+ 'google-analytics_page_gadash_frontend_settings',
235
+ 'google-analytics_page_gadash_tracking_settings',
236
+ 'google-analytics_page_gadash_errors_debugging'
237
+ );
238
+
239
+ if (in_array($hook, $settings_hooks)) {
240
+ wp_enqueue_style('wp-color-picker');
241
+ wp_enqueue_script('wp-color-picker');
242
+ wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array(
243
+ 'wp-color-picker'
244
+ ), false, true);
245
+ wp_enqueue_script('gadwp-settings', plugins_url('js/settings.js', __FILE__), array(
246
+ 'jquery'
247
+ ), GADWP_CURRENT_VERSION);
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Add "Settings" link in Plugins List
253
+ *
254
+ * @param
255
+ * $links
256
+ * @return array
257
+ */
258
+ function settings_link($links)
259
+ {
260
+ $settings_link = '<a href="' . get_admin_url(null, 'admin.php?page=gadash_settings') . '">' . __("Settings", 'ga-dash') . '</a>';
261
+ array_unshift($links, $settings_link);
262
+ return $links;
263
+ }
264
+ }
265
+ }
266
+ if (is_admin()) {
267
+ $GADASH_Back_Setup = new GADASH_Back_Setup();
268
+ }
admin/{dashboard_widgets.php → widgets.php} RENAMED
@@ -15,178 +15,29 @@ if (! class_exists('GADASH_Widgets')) {
15
global $GADASH_Config;
16
add_action('wp_dashboard_setup', array(
17
$this,
18
- 'ga_dash_setup'
19
));
20
- // Admin Styles
21
- add_action('admin_enqueue_scripts', array(
22
- $this,
23
- 'ga_dash_admin_enqueue_styles'
24
- ));
25
- // Admin Menu
26
- add_action('admin_menu', array(
27
- $this,
28
- 'ga_dash_admin_actions'
29
- ));
30
- // Network Menu
31
- add_action('network_admin_menu', array(
32
- $this,
33
- 'ga_dash_network_actions'
34
- ));
35
- // Plugin Settings link
36
- add_filter("plugin_action_links_" . plugin_basename($GADASH_Config->plugin_path) . '/gadwp.php', array(
37
- $this,
38
- 'ga_dash_settings_link'
39
- ));
40
- // Add error bubble
41
- add_action('admin_print_scripts', array(
42
- $this,
43
- 'draw_error_bubble'
44
- ), 10000);
45
- }
46
-
47
- function draw_error_bubble()
48
- {
49
- $bubble_msg = '!';
50
- if (get_transient('ga_dash_gapi_errors')) {
51
- ?>
52
- <script type="text/javascript">
53
- jQuery(document).ready(function() {
54
- 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;"><?php echo $bubble_msg ?></span></span>');
55
- });
56
- </script>
57
- <?php
58
- }
59
- }
60
-
61
- function ga_dash_admin_actions()
62
- {
63
- global $GADASH_Config;
64
- global $wp_version;
65
- if (current_user_can('manage_options')) {
66
- include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
67
- add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_options', 'gadash_settings', array(
68
- 'GADASH_Settings',
69
- 'general_settings'
70
- ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
71
- add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_options', 'gadash_settings', array(
72
- 'GADASH_Settings',
73
- 'general_settings'
74
- ));
75
- add_submenu_page('gadash_settings', __("Backend Settings", 'ga-dash'), __("Backend Settings", 'ga-dash'), 'manage_options', 'gadash_backend_settings', array(
76
- 'GADASH_Settings',
77
- 'backend_settings'
78
- ));
79
- add_submenu_page('gadash_settings', __("Frontend Settings", 'ga-dash'), __("Frontend Settings", 'ga-dash'), 'manage_options', 'gadash_frontend_settings', array(
80
- 'GADASH_Settings',
81
- 'frontend_settings'
82
- ));
83
- add_submenu_page('gadash_settings', __("Tracking Code", 'ga-dash'), __("Tracking Code", 'ga-dash'), 'manage_options', 'gadash_tracking_settings', array(
84
- 'GADASH_Settings',
85
- 'tracking_settings'
86
- ));
87
- add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_options', 'gadash_errors_debugging', array(
88
- 'GADASH_Settings',
89
- 'errors_debugging'
90
- ));
91
- }
92
- }
93
-
94
- function ga_dash_network_actions()
95
- {
96
- global $GADASH_Config;
97
- global $wp_version;
98
- if (current_user_can('manage_netwrok')) {
99
- include ($GADASH_Config->plugin_path . '/admin/ga_dash_settings.php');
100
- add_menu_page(__("Google Analytics", 'ga-dash'), __("Google Analytics", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
101
- 'GADASH_Settings',
102
- 'general_settings_network'
103
- ), version_compare($wp_version, '3.8.0', '>=') ? 'dashicons-chart-area' : $GADASH_Config->plugin_url . '/admin/images/gadash-icon.png');
104
- add_submenu_page('gadash_settings', __("General Settings", 'ga-dash'), __("General Settings", 'ga-dash'), 'manage_netwrok', 'gadash_settings', array(
105
- 'GADASH_Settings',
106
- 'general_settings_network'
107
- ));
108
- add_submenu_page('gadash_settings', __("Errors & Debug", 'ga-dash'), __("Errors & Debug", 'ga-dash'), 'manage_network', 'gadash_errors_debugging', array(
109
- 'GADASH_Settings',
110
- 'errors_debugging'
111
- ));
112
- }
113
}
114
115
- /*
116
- * Include styles
117
- */
118
- function ga_dash_admin_enqueue_styles($hook)
119
{
120
global $GADASH_Config;
121
- $valid_hooks = array(
122
- 'toplevel_page_gadash_settings',
123
- 'google-analytics_page_gadash_backend_settings',
124
- 'google-analytics_page_gadash_frontend_settings',
125
- 'google-analytics_page_gadash_tracking_settings',
126
- 'google-analytics_page_gadash_errors_debugging'
127
- );
128
- if (! in_array($hook, $valid_hooks) and 'index.php' != $hook)
129
- return;
130
- wp_enqueue_style('ga_dash-nprogress', $GADASH_Config->plugin_url . '/tools/nprogress/nprogress.css', NULL, GADWP_CURRENT_VERSION);
131
- wp_register_style('ga_dash', $GADASH_Config->plugin_url . '/admin/css/ga_dash.css', NULL, GADWP_CURRENT_VERSION);
132
- wp_enqueue_style('ga_dash');
133
- wp_enqueue_style('wp-color-picker');
134
- wp_enqueue_script('wp-color-picker');
135
- wp_enqueue_script('wp-color-picker-script-handle', plugins_url('js/wp-color-picker-script.js', __FILE__), array(
136
- 'wp-color-picker'
137
- ), false, true);
138
- wp_enqueue_script('gadash-general-settings', plugins_url('js/admin.js', __FILE__), array(
139
- 'jquery'
140
- ), GADWP_CURRENT_VERSION);
141
- if (! wp_script_is('googlejsapi')) {
142
- wp_register_script('googlejsapi', 'https://www.google.com/jsapi');
143
- wp_enqueue_script('googlejsapi');
144
- }