Version Description
- Added: Alerts functionality
- Added: Emails functionality
- Fixed: Exclude tracking for user
Download this release
Release Info
Developer | webdorado |
Plugin | WD Google Analytics |
Version | 1.2.3 |
Comparing to | |
See all releases |
Code changes from version 1.2.2 to 1.2.3
- admin/pages/dashboard.php +2 -2
- admin/pages/settings.php +53 -30
- admin/pages/tracking.php +13 -3
- admin/pages/uninstall.php +45 -0
- config.php +1 -1
- gawd_class.php +250 -239
- google-analytics-wd.php +1 -1
- inc/css/gawd_admin.css +8 -7
- inc/js/gawd_admin.js +156 -6
- inc/js/gawd_settings.js +22 -7
- library/file-generators/gawd-csv-generator-class.php +400 -0
- library/file-generators/gawd-file-generator-class.php +76 -0
- library/gawd-alert-class.php +96 -0
- library/gawd-custom-ajax-class.php +28 -13
- library/gawd-email-class.php +392 -0
- library/gawd-google-class.php +45 -31
- library/gawd-helper-class.php +111 -0
- library/gawd-save-settings-goals.php +24 -40
- readme.txt +62 -77
admin/pages/dashboard.php
CHANGED
@@ -608,7 +608,7 @@ if(in_array($_GET['tab'], $line_column)) {
|
|
608 |
<div class="gawd_email_input_attachment" >
|
609 |
<select id="gawd_attachment_type" name="export_type">
|
610 |
<option value='csv'>CSV</option>
|
611 |
-
<option value='pdf'>PDF</option
|
612 |
</select>
|
613 |
</div>
|
614 |
<div class="gawd_email_input gawd_email_month_day_div" id="gawd_email_month_day" data-hint="Select the day of month to send report on.">
|
@@ -650,7 +650,7 @@ if(in_array($_GET['tab'], $line_column)) {
|
|
650 |
<li class="gawd_email_week_day" data-atribute="sunday">Sun</li>
|
651 |
<li class="gawd_email_week_day" data-atribute="monday">Mon</li>
|
652 |
<li class="gawd_email_week_day" data-atribute="tuesday">Tue</li>
|
653 |
-
<li class="gawd_email_week_day" data-atribute="
|
654 |
<li class="gawd_email_week_day" data-atribute="thursday">Thu</li>
|
655 |
<li class="gawd_email_week_day" data-atribute="friday">Fri</li>
|
656 |
<li class="gawd_email_week_day" data-atribute="saturday">Sat</li>
|
608 |
<div class="gawd_email_input_attachment" >
|
609 |
<select id="gawd_attachment_type" name="export_type">
|
610 |
<option value='csv'>CSV</option>
|
611 |
+
<!-- <option value='pdf'>PDF</option>-->
|
612 |
</select>
|
613 |
</div>
|
614 |
<div class="gawd_email_input gawd_email_month_day_div" id="gawd_email_month_day" data-hint="Select the day of month to send report on.">
|
650 |
<li class="gawd_email_week_day" data-atribute="sunday">Sun</li>
|
651 |
<li class="gawd_email_week_day" data-atribute="monday">Mon</li>
|
652 |
<li class="gawd_email_week_day" data-atribute="tuesday">Tue</li>
|
653 |
+
<li class="gawd_email_week_day" data-atribute="wednesday">Wed</li>
|
654 |
<li class="gawd_email_week_day" data-atribute="thursday">Thu</li>
|
655 |
<li class="gawd_email_week_day" data-atribute="friday">Fri</li>
|
656 |
<li class="gawd_email_week_day" data-atribute="saturday">Sat</li>
|
admin/pages/settings.php
CHANGED
@@ -50,6 +50,22 @@ foreach ($roles->role_names as $key => $name) {
|
|
50 |
}
|
51 |
$roles_changed['role_names'][$name] = $key;
|
52 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
?>
|
54 |
|
55 |
<div id="gawd_body">
|
@@ -217,7 +233,7 @@ foreach ($roles->role_names as $key => $name) {
|
|
217 |
<option value="sessions"><?php echo __('Sessions', 'gawd'); ?></option>
|
218 |
<option value="users"><?php echo __('Users', 'gawd'); ?></option>
|
219 |
<option value="bounceRate"><?php echo __('Bounce Rate', 'gawd'); ?></option>
|
220 |
-
<option value="
|
221 |
</select>
|
222 |
</span>
|
223 |
<div class="gawd_info"
|
@@ -246,9 +262,8 @@ foreach ($roles->role_names as $key => $name) {
|
|
246 |
<div class='clear'></div>
|
247 |
</div>
|
248 |
<?php
|
249 |
-
$alerts = get_option('gawd_alerts');
|
250 |
|
251 |
-
if ($
|
252 |
?>
|
253 |
<table border="1" class="gawd_table">
|
254 |
<tr>
|
@@ -259,16 +274,29 @@ foreach ($roles->role_names as $key => $name) {
|
|
259 |
<th>Action</th>
|
260 |
</tr>
|
261 |
<?php
|
262 |
-
foreach ($
|
|
|
263 |
$condition = $alert['condition'] == 'less' ? ' is less then ' : ' greater than ';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
264 |
?>
|
265 |
-
<tr
|
266 |
<td><?php echo $alert['name']; ?></td>
|
267 |
-
<td><?php echo
|
268 |
-
<td><?php echo $
|
269 |
<td><?php echo $alert['alert_view_name']; ?></td>
|
270 |
-
|
271 |
-
|
272 |
</td>
|
273 |
</tr>
|
274 |
<?php
|
@@ -521,40 +549,35 @@ foreach ($roles->role_names as $key => $name) {
|
|
521 |
?>
|
522 |
</div>
|
523 |
<div class="gawd_emails">
|
|
|
|
|
|
|
|
|
524 |
<?php
|
525 |
-
$gawd_emails = get_option('gawd_email');
|
526 |
|
527 |
-
if ($
|
528 |
?>
|
529 |
<table border="1" class="gawd_table">
|
530 |
<tr>
|
531 |
<th>Subject</th>
|
532 |
<th>Frequency</th>
|
533 |
-
<th>
|
534 |
<th>Recipients</th>
|
535 |
-
<th>
|
536 |
<th>Action</th>
|
537 |
</tr>
|
538 |
<?php
|
539 |
-
foreach ($
|
540 |
-
|
541 |
-
$email['period'] = 'Weekly';
|
542 |
-
}
|
543 |
-
elseif ($email['period'] == 'gawd_monthly') {
|
544 |
-
$email['period'] = 'Monthly';
|
545 |
-
}
|
546 |
-
else {
|
547 |
-
$email['period'] = 'Daily';
|
548 |
-
}
|
549 |
?>
|
550 |
-
<tr
|
551 |
-
<td><?php echo $email['
|
552 |
-
<td><?php echo $
|
553 |
-
<td><?php echo $email['
|
554 |
-
<td><span class="gawd_break"><?php echo
|
555 |
-
<td><span class="gawd_break"><?php echo $email['view_id']; ?></span></td>
|
556 |
<td><a href="" class="gawd_remove_emails"
|
557 |
-
onclick="if (confirm('<?php echo addslashes(__("Do you want to delete selected item?", 'gawd')); ?>')) {gawd_remove_item('<?php echo $key
|
558 |
</td>
|
559 |
</tr>
|
560 |
<?php
|
50 |
}
|
51 |
$roles_changed['role_names'][$name] = $key;
|
52 |
}
|
53 |
+
|
54 |
+
$gawd_emails = get_option('gawd_emails_info');
|
55 |
+
|
56 |
+
$alerts_list = array();
|
57 |
+
$email_list = array();
|
58 |
+
|
59 |
+
if(is_array($gawd_emails)) {
|
60 |
+
foreach($gawd_emails as $key=>$email_info) {
|
61 |
+
if(isset($email_info['email_info']['other_info']['alert_data'])) {
|
62 |
+
$alerts_list[$key] = $email_info;
|
63 |
+
} else {
|
64 |
+
$email_list[$key] = $email_info;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
}
|
68 |
+
|
69 |
?>
|
70 |
|
71 |
<div id="gawd_body">
|
233 |
<option value="sessions"><?php echo __('Sessions', 'gawd'); ?></option>
|
234 |
<option value="users"><?php echo __('Users', 'gawd'); ?></option>
|
235 |
<option value="bounceRate"><?php echo __('Bounce Rate', 'gawd'); ?></option>
|
236 |
+
<option value="avgSessionDuration"><?php echo __('Avg Session Duration', 'gawd'); ?></option>
|
237 |
</select>
|
238 |
</span>
|
239 |
<div class="gawd_info"
|
262 |
<div class='clear'></div>
|
263 |
</div>
|
264 |
<?php
|
|
|
265 |
|
266 |
+
if ($alerts_list) {
|
267 |
?>
|
268 |
<table border="1" class="gawd_table">
|
269 |
<tr>
|
274 |
<th>Action</th>
|
275 |
</tr>
|
276 |
<?php
|
277 |
+
foreach ($alerts_list as $key => $alert_data) {
|
278 |
+
$alert = $alert_data['email_info']['other_info']['alert_data'];
|
279 |
$condition = $alert['condition'] == 'less' ? ' is less then ' : ' greater than ';
|
280 |
+
$metric = $alert['metric'];
|
281 |
+
|
282 |
+
if($metric == 'bounceRate'){
|
283 |
+
$metric = 'Bounce Rate';
|
284 |
+
}else if($metric == 'avgSessionDuration'){
|
285 |
+
$metric = 'Avg Session Duration';
|
286 |
+
}else {
|
287 |
+
$metric = ucfirst($metric);
|
288 |
+
}
|
289 |
+
|
290 |
+
$period = (strpos($alert['period'], 'gawd') > -1) ? substr($alert['period'], 5) : $alert['period'];
|
291 |
+
$period = ucfirst($period);
|
292 |
?>
|
293 |
+
<tr>
|
294 |
<td><?php echo $alert['name']; ?></td>
|
295 |
+
<td><?php echo $period; ?></td>
|
296 |
+
<td><?php echo $metric . $condition . $alert['value']; ?></td>
|
297 |
<td><?php echo $alert['alert_view_name']; ?></td>
|
298 |
+
<td><a href="" class="gawd_remove_emails"
|
299 |
+
onclick="if (confirm('<?php echo addslashes(__("Do you want to delete selected item?", 'gawd')); ?>')) {gawd_remove_item('<?php echo $key; ?>','gawd_email_remove');return false;} else {return false;}">remove</a>
|
300 |
</td>
|
301 |
</tr>
|
302 |
<?php
|
549 |
?>
|
550 |
</div>
|
551 |
<div class="gawd_emails">
|
552 |
+
<!-- FOR DEBUG -->
|
553 |
+
<div style="display: none !important;">
|
554 |
+
<?php echo 'Next :' . date('Y-m-d H:i:s', get_option('gawd_next_mail_date')); ?>
|
555 |
+
</div>
|
556 |
<?php
|
|
|
557 |
|
558 |
+
if ($email_list) {
|
559 |
?>
|
560 |
<table border="1" class="gawd_table">
|
561 |
<tr>
|
562 |
<th>Subject</th>
|
563 |
<th>Frequency</th>
|
564 |
+
<th>Next Date</th>
|
565 |
<th>Recipients</th>
|
566 |
+
<th>Website</th>
|
567 |
<th>Action</th>
|
568 |
</tr>
|
569 |
<?php
|
570 |
+
foreach ($email_list as $key => $email) {
|
571 |
+
$period = str_replace('gawd_', '', $email['email_info']['period']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
?>
|
573 |
+
<tr>
|
574 |
+
<td><?php echo $email['email_info']['subject']; ?></td>
|
575 |
+
<td><?php echo ucfirst($period); ?></td>
|
576 |
+
<td><?php echo date('Y-m-d H:i', $email['next_date']); ?></td>
|
577 |
+
<td><span class="gawd_break"><?php echo $email['email_info']['email_to']; ?></span></td>
|
578 |
+
<td><span class="gawd_break"><?php echo GAWD_helper::get_account_name_by_profile_id($email['email_info']['view_id']); ?></span></td>
|
579 |
<td><a href="" class="gawd_remove_emails"
|
580 |
+
onclick="if (confirm('<?php echo addslashes(__("Do you want to delete selected item?", 'gawd')); ?>')) {gawd_remove_item('<?php echo $key; ?>','gawd_email_remove');return false;} else {return false;}">remove</a>
|
581 |
</td>
|
582 |
</tr>
|
583 |
<?php
|
admin/pages/tracking.php
CHANGED
@@ -118,7 +118,7 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
118 |
</div>
|
119 |
<div class="gawd_info" title="Enable to track file downloads and mailing links."></div>
|
120 |
<div class="onoffswitch_text track_label">
|
121 |
-
Mailto, Download tracking (
|
122 |
</div>
|
123 |
<div class="clear"></div>
|
124 |
</div>
|
@@ -148,7 +148,7 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
148 |
<textarea class="gawd_custom_code" name="gawd_custom_code"><?php echo $gawd_custom_code; ?></textarea>
|
149 |
</div>
|
150 |
</span>
|
151 |
-
<div class="gawd_info" title="
|
152 |
<div class="clear"></div>
|
153 |
</div>
|
154 |
<div style="margin-top: 15px;">
|
@@ -231,6 +231,10 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
231 |
|
232 |
<input type='hidden' name="gawd_settings_tab" id="gawd_settings_tab"/>
|
233 |
<input type='hidden' name="add_dimension_value" id="add_dimension_value"/>
|
|
|
|
|
|
|
|
|
234 |
<div class="gawd_exclude_users_popup_overlay"></div>
|
235 |
<div class="gawd_exclude_users_popup">
|
236 |
<div class="close_btn_cont">
|
@@ -259,7 +263,13 @@ $domain = GAWD::get_domain(esc_html(get_option('siteurl')));
|
|
259 |
</label>
|
260 |
</td>
|
261 |
<td>
|
262 |
-
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
</td>
|
264 |
<td>
|
265 |
<input id="gawd_excluded_users<?php echo $inp_id; ?>" type="checkbox"
|
118 |
</div>
|
119 |
<div class="gawd_info" title="Enable to track file downloads and mailing links."></div>
|
120 |
<div class="onoffswitch_text track_label">
|
121 |
+
Mailto, Download tracking (e.g. .doc, .pdf, .jpg)
|
122 |
</div>
|
123 |
<div class="clear"></div>
|
124 |
</div>
|
148 |
<textarea class="gawd_custom_code" name="gawd_custom_code"><?php echo $gawd_custom_code; ?></textarea>
|
149 |
</div>
|
150 |
</span>
|
151 |
+
<div class="gawd_info" title="Input the custom script to add to Google Analytics tracking code."></div>
|
152 |
<div class="clear"></div>
|
153 |
</div>
|
154 |
<div style="margin-top: 15px;">
|
231 |
|
232 |
<input type='hidden' name="gawd_settings_tab" id="gawd_settings_tab"/>
|
233 |
<input type='hidden' name="add_dimension_value" id="add_dimension_value"/>
|
234 |
+
<input type="hidden" id="gawd_excluded_roles_list" name="gawd_excluded_roles_list"
|
235 |
+
value="<?php echo implode(',', $gawd_excluded_roles); ?>"/>
|
236 |
+
<input type="hidden" id="gawd_excluded_users_list" name="gawd_excluded_users_list" value="<?php echo implode(',', $gawd_excluded_users); ?>" />
|
237 |
+
|
238 |
<div class="gawd_exclude_users_popup_overlay"></div>
|
239 |
<div class="gawd_exclude_users_popup">
|
240 |
<div class="close_btn_cont">
|
263 |
</label>
|
264 |
</td>
|
265 |
<td>
|
266 |
+
<?php
|
267 |
+
if(isset($user->roles[0])){
|
268 |
+
echo $user->roles[0];
|
269 |
+
}else{
|
270 |
+
echo "No role for this site";
|
271 |
+
}
|
272 |
+
?>
|
273 |
</td>
|
274 |
<td>
|
275 |
<input id="gawd_excluded_users<?php echo $inp_id; ?>" type="checkbox"
|
admin/pages/uninstall.php
CHANGED
@@ -82,6 +82,51 @@ class GAWDUninstall{
|
|
82 |
global $wpdb;
|
83 |
check_admin_referer('gawd_save_form', 'gawd_save_form_field');
|
84 |
$wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '%gawd%'");
|
|
|
|
|
|
|
85 |
set_site_transient('gawd_uninstall', '1', 5 * 60);
|
86 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
87 |
}
|
82 |
global $wpdb;
|
83 |
check_admin_referer('gawd_save_form', 'gawd_save_form_field');
|
84 |
$wpdb->query("DELETE FROM {$wpdb->prefix}options WHERE option_name LIKE '%gawd%'");
|
85 |
+
|
86 |
+
$this->delete_upload_dir();
|
87 |
+
|
88 |
set_site_transient('gawd_uninstall', '1', 5 * 60);
|
89 |
}
|
90 |
+
|
91 |
+
public function delete_upload_dir(){
|
92 |
+
$upload_dir = wp_get_upload_dir();
|
93 |
+
if(empty($upload_dir['basedir'])){
|
94 |
+
return;
|
95 |
+
}
|
96 |
+
|
97 |
+
$upload_dir = $upload_dir['basedir'] . '/wd-google-analytics/';
|
98 |
+
$this->delete_dir($upload_dir);
|
99 |
+
}
|
100 |
+
|
101 |
+
private function delete_dir($dir){
|
102 |
+
|
103 |
+
if(empty($dir)) {
|
104 |
+
return;
|
105 |
+
}
|
106 |
+
|
107 |
+
if(substr($dir, -1) !== '/') {
|
108 |
+
$dir .= '/';
|
109 |
+
}
|
110 |
+
|
111 |
+
$dir_info = scandir($dir);
|
112 |
+
|
113 |
+
foreach($dir_info as $item) {
|
114 |
+
|
115 |
+
if($item == '.' || $item == '..') {
|
116 |
+
continue;
|
117 |
+
}
|
118 |
+
|
119 |
+
$new_dir = $dir . $item;
|
120 |
+
|
121 |
+
if(is_dir($new_dir)) {
|
122 |
+
$this->delete_dir($new_dir);
|
123 |
+
} else {
|
124 |
+
unlink($new_dir);
|
125 |
+
}
|
126 |
+
|
127 |
+
}
|
128 |
+
|
129 |
+
rmdir($dir);
|
130 |
+
}
|
131 |
+
|
132 |
}
|
config.php
CHANGED
@@ -13,7 +13,7 @@ if(!defined('GAWD_DIR')) {
|
|
13 |
define('GWD_NAME', plugin_basename(dirname(__FILE__)));
|
14 |
define('GAWD_URL', plugins_url(plugin_basename(dirname(__FILE__))));
|
15 |
define('GAWD_INC', GAWD_URL . '/inc');
|
16 |
-
define('GAWD_VERSION', '1.2.
|
17 |
|
18 |
$upload_dir = wp_upload_dir();
|
19 |
define('GAWD_UPLOAD_DIR', $upload_dir['basedir'] . '/' . plugin_basename(dirname(__FILE__)));
|
13 |
define('GWD_NAME', plugin_basename(dirname(__FILE__)));
|
14 |
define('GAWD_URL', plugins_url(plugin_basename(dirname(__FILE__))));
|
15 |
define('GAWD_INC', GAWD_URL . '/inc');
|
16 |
+
define('GAWD_VERSION', '1.2.3');
|
17 |
|
18 |
$upload_dir = wp_upload_dir();
|
19 |
define('GAWD_UPLOAD_DIR', $upload_dir['basedir'] . '/' . plugin_basename(dirname(__FILE__)));
|
gawd_class.php
CHANGED
@@ -168,7 +168,8 @@ class GAWD {
|
|
168 |
|
169 |
|
170 |
//todo add_action('wp_ajax_create_pdf_file', array($this, 'create_pdf_file'));
|
171 |
-
|
|
|
172 |
|
173 |
add_action('wp_ajax_show_data', array($this, 'show_data'));
|
174 |
add_action('wp_ajax_remove_zoom_message', array($this, 'remove_zoom_message'));
|
@@ -177,7 +178,6 @@ class GAWD {
|
|
177 |
add_action('wp_dashboard_setup', array($this, 'google_analytics_wd_dashboard_widget'));
|
178 |
}
|
179 |
add_action('admin_menu', array($this, 'overview_date_meta'));
|
180 |
-
//add_filter('cron_schedules', array($this, 'gawd_my_schedule'));
|
181 |
//todo add_action('admin_init', array($this, 'gawd_export'));
|
182 |
// add_action( 'gawd_pushover_daily', array( $this, 'gawd_pushover_daily' ) );
|
183 |
// add_action( 'gawd_pushover_gawd_weekly', array( $this, 'gawd_pushover_weekly' ) );
|
@@ -185,11 +185,12 @@ class GAWD {
|
|
185 |
// add_action('gawd_alert_daily', array($this, 'gawd_alert_daily'));
|
186 |
// add_action('gawd_alert_gawd_monthly', array($this, 'gawd_alert_monthly'));
|
187 |
// add_action('gawd_alert_gawd_weekly', array($this, 'gawd_alert_weekly'));
|
188 |
-
// add_action('gawd_email_daily', array($this, 'gawd_daily_email'), 0);
|
189 |
-
// add_action('gawd_email_gawd_weekly', array($this, 'gawd_weekly_email'));
|
190 |
-
// add_action('gawd_email_gawd_monthly', array($this, 'gawd_monthly_email'));
|
191 |
add_action('admin_notices', array($this, 'admin_notices'), 9999);
|
192 |
|
|
|
|
|
|
|
|
|
193 |
}
|
194 |
|
195 |
public function gawd_last_viewed_profile(){
|
@@ -301,43 +302,255 @@ class GAWD {
|
|
301 |
}
|
302 |
}
|
303 |
|
304 |
-
public function create_csv_file(
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
}
|
310 |
-
|
311 |
-
|
312 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
313 |
}
|
314 |
}
|
315 |
-
require_once(GAWD_DIR . '/admin/gawd_google_class.php');
|
316 |
-
$this->gawd_google_client = GAWD_google_client::get_instance();
|
317 |
|
318 |
-
$
|
|
|
319 |
|
|
|
|
|
|
|
|
|
|
|
320 |
|
321 |
-
|
|
|
|
|
|
|
|
|
|
|
322 |
|
323 |
-
$file = new GAWD_CSV_FILE();
|
324 |
-
$file->get_request_data($this, $ajax, $data, $dimension, $start_date, $end_date, $metric_compare_recc, $metric_recc);
|
325 |
|
326 |
-
$
|
|
|
327 |
|
328 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
329 |
|
330 |
-
$
|
331 |
-
if($
|
332 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
} else {
|
334 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
335 |
}
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
} else {
|
339 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
340 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
341 |
}
|
342 |
|
343 |
public static function get_domain($domain){
|
@@ -924,89 +1137,6 @@ class GAWD {
|
|
924 |
require_once('admin/pages/dashboard.php');
|
925 |
}
|
926 |
|
927 |
-
public function gawd_daily_email(){
|
928 |
-
$emails = get_option('gawd_email');
|
929 |
-
foreach($emails as $email) {
|
930 |
-
if(isset($email['period']) && $email['period'] == 'daily') {
|
931 |
-
//pls send email if ....
|
932 |
-
$date = date('Y-m-d', strtotime('yesterday'));
|
933 |
-
$email_subject = preg_match('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', $email['email_subject']) ? preg_replace('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', '(' . $date . ' - ' . $date . ')', $email['email_subject']) : $email['email_subject'] . ' (' . $date . ' - ' . $date . ')';
|
934 |
-
$data = $this->show_data(array(
|
935 |
-
'metric' => 'ga:' . $email['metric'],
|
936 |
-
'dimension' => $email['dimension'],
|
937 |
-
'start_date' => $date,
|
938 |
-
'end_date' => $date
|
939 |
-
));
|
940 |
-
if($email['export_type'] == 'pdf') {
|
941 |
-
$filedir = $this->create_pdf_file(false, $data, $email['dimension'], $date, $date, $email['metric_compare'], $email['metric']);
|
942 |
-
} else {
|
943 |
-
$filedir = $this->create_csv_file(false, $data, $email['dimension'], $date, $date, $email['metric_compare'], $email['metric']);
|
944 |
-
}
|
945 |
-
//$attachment = gawd_export_data($data, $export_type, 'email', $email['dimension'], $email['metric'], $email['metric_compare'], $email['img'], $email['tab_name'], $start_date, $end_date, $gawd_user_data['web_property_name'],$filter_type);
|
946 |
-
$attachment = $filedir;
|
947 |
-
$headers = 'From: <' . $email['email_from'] . '>';
|
948 |
-
wp_mail($email['emails'], $email_subject, $email['email_body'], $headers, $attachment);
|
949 |
-
}
|
950 |
-
}
|
951 |
-
}
|
952 |
-
|
953 |
-
public function gawd_weekly_email(){
|
954 |
-
$emails = get_option('gawd_email');
|
955 |
-
foreach($emails as $email) {
|
956 |
-
if(isset($email['period']) && $email['period'] == 'gawd_weekly') {
|
957 |
-
//pls send email if ....
|
958 |
-
/*$start_date = date('Y-m-d', strtotime('last' . $email['period_day']));
|
959 |
-
$end_date = date('Y-m-d', strtotime('this' . $email['period_day']));*/
|
960 |
-
$start_date = date('Y-m-d', strtotime('last week -1 day'));
|
961 |
-
$end_date = date('l') != 'Sunday' ? date('Y-m-d', strtotime('last sunday -1 day')) : date('Y-m-d', strtotime('-1 day'));
|
962 |
-
$email_subject = preg_match('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', $email['email_subject']) ? preg_replace('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', '(' . $start_date . ' - ' . $end_date . ')', $email['email_subject']) : $email['email_subject'] . ' (' . $start_date . ' - ' . $end_date . ')';
|
963 |
-
$data = $this->show_data(array(
|
964 |
-
'metric' => 'ga:' . $email['metric'],
|
965 |
-
'dimension' => $email['dimension'],
|
966 |
-
'start_date' => $start_date,
|
967 |
-
'end_date' => $end_date
|
968 |
-
));
|
969 |
-
if($email['export_type'] == 'pdf') {
|
970 |
-
$filedir = $this->create_pdf_file(false, $data, $email['dimension'], $start_date, $end_date, $email['metric_compare'], $email['metric']);
|
971 |
-
} else {
|
972 |
-
$filedir = $this->create_csv_file(false, $data, $email['dimension'], $start_date, $end_date, $email['metric_compare'], $email['metric']);
|
973 |
-
}
|
974 |
-
//$attachment = gawd_export_data($data, $export_type, 'email', $email['dimension'], $email['metric'], $email['metric_compare'], $email['img'], $email['tab_name'], $start_date, $end_date, $gawd_user_data['web_property_name'],$filter_type);
|
975 |
-
$attachment = $filedir;
|
976 |
-
|
977 |
-
$headers = 'From: <' . $email['email_from'] . '>';
|
978 |
-
wp_mail($email['emails'], $email_subject, $email['email_body'], $headers, $attachment);
|
979 |
-
}
|
980 |
-
}
|
981 |
-
}
|
982 |
-
|
983 |
-
public function gawd_monthly_email(){
|
984 |
-
$emails = get_option('gawd_email');
|
985 |
-
foreach($emails as $email) {
|
986 |
-
if(isset($email['period']) && $email['period'] == 'gawd_monthly') {
|
987 |
-
//pls send email if ....
|
988 |
-
$end_date = date('Y-m-d', strtotime(date('Y-' . date('m') . '-1') . '-1 day'));
|
989 |
-
$start_date = date('Y-m-d', strtotime($end_date . '- 1 month'));
|
990 |
-
$data = $this->show_data(array(
|
991 |
-
'metric' => 'ga:' . $email['metric'],
|
992 |
-
'dimension' => $email['dimension'],
|
993 |
-
'start_date' => $start_date,
|
994 |
-
'end_date' => $end_date
|
995 |
-
));
|
996 |
-
$email_subject = preg_match('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', $email['email_subject']) ? preg_replace('/\(([0-9]{4}-[0-1][0-9]-[0-3][0-9] \- [0-9]{4}-[0-1][0-9]-[0-3][0-9])\)/', '(' . $start_date . ' - ' . $end_date . ')', $email['email_subject']) : $email['email_subject'] . ' (' . $start_date . ' - ' . $end_date . ')';
|
997 |
-
if($email['export_type'] == 'pdf') {
|
998 |
-
$filedir = $this->create_pdf_file(false, $data, $email['dimension'], $start_date, $end_date, $email['metric_compare'], $email['metric']);
|
999 |
-
} else {
|
1000 |
-
$filedir = $this->create_csv_file(false, $data, $email['dimension'], $start_date, $end_date, $email['metric_compare'], $email['metric']);
|
1001 |
-
}
|
1002 |
-
//$attachment = gawd_export_data($data, $export_type, 'email', $email['dimension'], $email['metric'], $email['metric_compare'], $email['img'], $email['tab_name'], $start_date, $end_date, $gawd_user_data['web_property_name'],$filter_type);
|
1003 |
-
$attachment = $filedir;
|
1004 |
-
$headers = 'From: <' . $email['email_from'] . '>';
|
1005 |
-
wp_mail($email['emails'], $email_subject, $email['email_body'], $headers, $attachment);
|
1006 |
-
}
|
1007 |
-
}
|
1008 |
-
}
|
1009 |
-
|
1010 |
/**
|
1011 |
* Prepares the settings to be displayed then displays the settings page.
|
1012 |
*/
|
@@ -1077,6 +1207,13 @@ class GAWD {
|
|
1077 |
'error');
|
1078 |
}
|
1079 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1080 |
require_once('admin/pages/settings.php');
|
1081 |
}
|
1082 |
|
@@ -1095,19 +1232,6 @@ class GAWD {
|
|
1095 |
require_once('admin/pages/authentication.php');
|
1096 |
}
|
1097 |
|
1098 |
-
public function gawd_my_schedule($schedules){
|
1099 |
-
$schedules['gawd_weekly'] = array(
|
1100 |
-
'interval' => 604800,
|
1101 |
-
'display' => __('Every week')
|
1102 |
-
);
|
1103 |
-
$schedules['gawd_monthly'] = array(
|
1104 |
-
'interval' => 18748800,
|
1105 |
-
'display' => __('Every month')
|
1106 |
-
);
|
1107 |
-
|
1108 |
-
return $schedules;
|
1109 |
-
}
|
1110 |
-
|
1111 |
public function gawd_pushover_api($user_key, $metric, $condition, $value){
|
1112 |
$ch = curl_init();
|
1113 |
curl_setopt($ch, CURLOPT_URL, "https://api.pushover.net/1/messages.json");
|
@@ -1285,120 +1409,6 @@ class GAWD {
|
|
1285 |
}
|
1286 |
}
|
1287 |
|
1288 |
-
public function show_data($params = array()){
|
1289 |
-
// require_once(GAWD_DIR . '/admin/gawd_google_class.php');
|
1290 |
-
// $return = true;
|
1291 |
-
// if($params == '') {
|
1292 |
-
// $params = $_POST;
|
1293 |
-
// $return = false;
|
1294 |
-
// }
|
1295 |
-
// $gawd_client = GAWD_google_client::get_instance();
|
1296 |
-
// $start_date = isset($params["start_date"]) && $params["start_date"] != '' ? $params["start_date"] : date('Y-m-d', strtotime('-7 days'));
|
1297 |
-
// $end_date = isset($params["end_date"]) && $params["end_date"] != '' ? $params["end_date"] : date('Y-m-d');
|
1298 |
-
// $metric = isset($params["metric"]) ? $params["metric"] : 'ga:sessions';
|
1299 |
-
// $metric = is_array($metric) ? count($metric) > 1 ? implode(",", $metric) : $metric[0] : $metric;
|
1300 |
-
// $dimension = isset($params["dimension"]) ? $params["dimension"] : 'date';
|
1301 |
-
//
|
1302 |
-
// $country_filter = isset($params["country_filter"]) ? $params["country_filter"] : '';
|
1303 |
-
// $geo_type = isset($params["geo_type"]) ? $params["geo_type"] : '';
|
1304 |
-
// $filter_type = isset($params["filter_type"]) && $params["filter_type"] != '' ? $params["filter_type"] : '';
|
1305 |
-
// $custom = isset($params["custom"]) && $params["custom"] != '' ? $params["custom"] : '';
|
1306 |
-
// $same_dimension = $dimension;
|
1307 |
-
// $dimension = $filter_type != '' && $dimension == 'date' ? $filter_type : $dimension;
|
1308 |
-
// if($dimension == 'week' || $dimension == 'month') {
|
1309 |
-
// $same_dimension = $dimension;
|
1310 |
-
// }
|
1311 |
-
//
|
1312 |
-
//
|
1313 |
-
// $timezone = isset($params["timezone"]) && $params["timezone"] != '' ? $params["timezone"] : 0;
|
1314 |
-
// if($dimension == 'pagePath' || $dimension == 'PagePath' || $dimension == 'landingPagePath' || $dimension == 'LandingPagePath') {
|
1315 |
-
// if(get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date)) {
|
1316 |
-
// $grid_data = get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date);
|
1317 |
-
// } else {
|
1318 |
-
// $grid_data = $gawd_client->get_page_data($dimension, $start_date, $end_date, $timezone);
|
1319 |
-
// }
|
1320 |
-
// if($return) {
|
1321 |
-
// return $grid_data;
|
1322 |
-
// }
|
1323 |
-
// echo $grid_data;
|
1324 |
-
// die();
|
1325 |
-
// } elseif($dimension == 'goals') {
|
1326 |
-
// if(get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date)) {
|
1327 |
-
// $goal_data = get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date);
|
1328 |
-
// } else {
|
1329 |
-
// $goal_data = $gawd_client->get_goal_data('date', $start_date, $end_date, $timezone, $same_dimension);
|
1330 |
-
// }
|
1331 |
-
// if($return) {
|
1332 |
-
// return $goal_data;
|
1333 |
-
// }
|
1334 |
-
// echo $goal_data;
|
1335 |
-
// die();
|
1336 |
-
// } elseif($custom == '' && (($dimension == 'region' || $dimension == 'city') || ($dimension == 'Region' || $dimension == 'City'))) {
|
1337 |
-
// if(get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $country_filter . '-' . $start_date . '-' . $end_date)) {
|
1338 |
-
// $chart_data = get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $country_filter . '-' . $start_date . '-' . $end_date);
|
1339 |
-
// } else {
|
1340 |
-
//
|
1341 |
-
// $chart_data = $gawd_client->get_country_data($metric, $dimension, $start_date, $end_date, $country_filter, $geo_type, $timezone);
|
1342 |
-
// }
|
1343 |
-
// if($return) {
|
1344 |
-
// return $chart_data;
|
1345 |
-
// }
|
1346 |
-
// echo $chart_data;
|
1347 |
-
// die();
|
1348 |
-
// } else {
|
1349 |
-
//
|
1350 |
-
// if($custom != '') {
|
1351 |
-
// $chart_data = $gawd_client->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
1352 |
-
// if($return) {
|
1353 |
-
// return $chart_data;
|
1354 |
-
// }
|
1355 |
-
// } else {
|
1356 |
-
// if($dimension == 'siteSpeed') {
|
1357 |
-
// if(get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $same_dimension . '_' . $filter_type . '-' . $start_date . '-' . $end_date)) {
|
1358 |
-
// $chart_data = get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date);
|
1359 |
-
// } else {
|
1360 |
-
// $chart_data = $gawd_client->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
1361 |
-
// }
|
1362 |
-
// if($return) {
|
1363 |
-
// return $chart_data;
|
1364 |
-
// }
|
1365 |
-
// } else {
|
1366 |
-
//
|
1367 |
-
// /* if (get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date)) {
|
1368 |
-
// $chart_data = get_transient('gawd-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date);
|
1369 |
-
// } */
|
1370 |
-
// //else {
|
1371 |
-
//
|
1372 |
-
// $chart_data = $gawd_client->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
1373 |
-
// //}
|
1374 |
-
// if($return) {
|
1375 |
-
// return $chart_data;
|
1376 |
-
// }
|
1377 |
-
// }
|
1378 |
-
// }
|
1379 |
-
// echo $chart_data;
|
1380 |
-
// die();
|
1381 |
-
// }
|
1382 |
-
}
|
1383 |
-
|
1384 |
-
public function show_data_compact(){
|
1385 |
-
// require_once(GAWD_DIR . '/admin/gawd_google_class.php');
|
1386 |
-
// $gawd_client = GAWD_google_client::get_instance();
|
1387 |
-
// $start_date = isset($_POST["start_date"]) && $_POST["start_date"] != '' ? $_POST["start_date"] : date('Y-m-d', strtotime('-30 days'));
|
1388 |
-
// $end_date = isset($_POST["end_date"]) && $_POST["end_date"] != '' ? $_POST["end_date"] : date('Y-m-d');
|
1389 |
-
// $metric = isset($_POST["metric"]) ? $_POST["metric"] : 'sessions';
|
1390 |
-
// $metric = is_array($metric) ? count($metric) > 1 ? implode(",", $metric) : $metric[0] : 'ga:' . $metric;
|
1391 |
-
// $dimension = isset($_POST["dimension"]) ? $_POST["dimension"] : 'date';
|
1392 |
-
// $timezone = isset($_POST["timezone"]) ? $_POST["timezone"] : 0;
|
1393 |
-
// if(get_transient('gawd-compact-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date)) {
|
1394 |
-
// $chart_data = get_transient('gawd-compact-' . $gawd_client->get_profile_id() . '-' . $dimension . '-' . $start_date . '-' . $end_date);
|
1395 |
-
// } else {
|
1396 |
-
// $chart_data = $gawd_client->get_data_compact($metric, $dimension, $start_date, $end_date, $timezone);
|
1397 |
-
// }
|
1398 |
-
// echo $chart_data;
|
1399 |
-
// die();
|
1400 |
-
}
|
1401 |
-
|
1402 |
public static function add_dashboard_menu(){
|
1403 |
$get_custom_reports = get_option('gawd_custom_reports');
|
1404 |
if(!$get_custom_reports) {
|
@@ -1646,7 +1656,8 @@ class GAWD {
|
|
1646 |
public static function activate(){
|
1647 |
|
1648 |
delete_site_transient('gawd_uninstall');
|
1649 |
-
|
|
|
1650 |
update_option('gawd_credentials', GAWD_helper::get_project_default_credentials());
|
1651 |
}
|
1652 |
|
168 |
|
169 |
|
170 |
//todo add_action('wp_ajax_create_pdf_file', array($this, 'create_pdf_file'));
|
171 |
+
add_action('wp_ajax_gawd_create_csv_file', array($this, 'create_csv_file'));
|
172 |
+
add_action('wp_ajax_gawd_send_email', array($this, 'send_email'));
|
173 |
|
174 |
add_action('wp_ajax_show_data', array($this, 'show_data'));
|
175 |
add_action('wp_ajax_remove_zoom_message', array($this, 'remove_zoom_message'));
|
178 |
add_action('wp_dashboard_setup', array($this, 'google_analytics_wd_dashboard_widget'));
|
179 |
}
|
180 |
add_action('admin_menu', array($this, 'overview_date_meta'));
|
|
|
181 |
//todo add_action('admin_init', array($this, 'gawd_export'));
|
182 |
// add_action( 'gawd_pushover_daily', array( $this, 'gawd_pushover_daily' ) );
|
183 |
// add_action( 'gawd_pushover_gawd_weekly', array( $this, 'gawd_pushover_weekly' ) );
|
185 |
// add_action('gawd_alert_daily', array($this, 'gawd_alert_daily'));
|
186 |
// add_action('gawd_alert_gawd_monthly', array($this, 'gawd_alert_monthly'));
|
187 |
// add_action('gawd_alert_gawd_weekly', array($this, 'gawd_alert_weekly'));
|
|
|
|
|
|
|
188 |
add_action('admin_notices', array($this, 'admin_notices'), 9999);
|
189 |
|
190 |
+
if(!wp_next_scheduled("gawd_email_scheduled")) {
|
191 |
+
wp_schedule_single_event( time(), 'gawd_email_scheduled' );
|
192 |
+
}
|
193 |
+
add_action('gawd_email_scheduled', array($this, 'gawd_email_scheduled'));
|
194 |
}
|
195 |
|
196 |
public function gawd_last_viewed_profile(){
|
302 |
}
|
303 |
}
|
304 |
|
305 |
+
public function create_csv_file(){
|
306 |
+
$response = array();
|
307 |
+
if(isset($_POST['security']) && !wp_verify_nonce($_POST['security'], 'gawd_admin_page_nonce')) {
|
308 |
+
$response['error']['code'] = 'wrong_nonce';
|
309 |
+
$response['error']['msg'] = 'wrong_nonce';
|
310 |
+
die(json_encode($response));
|
311 |
+
}
|
312 |
+
|
313 |
+
$csv_response = $this->generate_csv_file();
|
314 |
+
$response = array(
|
315 |
+
'success'=> $csv_response['success'],
|
316 |
+
'error' => $csv_response['error'],
|
317 |
+
'data' => $csv_response['data']
|
318 |
+
);
|
319 |
+
|
320 |
+
die(json_encode($response));
|
321 |
+
}
|
322 |
+
|
323 |
+
|
324 |
+
public function save_alert($alert_data){
|
325 |
+
|
326 |
+
include_once 'library/gawd-alert-class.php';
|
327 |
+
$alert = new GAWD_alert($alert_data);
|
328 |
+
$alert->add_email_data_to_POST();
|
329 |
+
|
330 |
+
$this->send_email(false);
|
331 |
+
}
|
332 |
+
|
333 |
+
|
334 |
+
public function send_email($die = true){
|
335 |
+
if($die !== false) {
|
336 |
+
$die = true;
|
337 |
+
}
|
338 |
+
|
339 |
+
$response = array(
|
340 |
+
'success' => false,
|
341 |
+
'error' => array('code' => '', 'msg' => ''),
|
342 |
+
'data' => array('msg' => 'Something went wrong')
|
343 |
+
);
|
344 |
+
|
345 |
+
if(isset($_POST['security']) && !wp_verify_nonce($_POST['security'], 'gawd_admin_page_nonce')) {
|
346 |
+
$response['error']['code'] = 'wrong_nonce';
|
347 |
+
$response['error']['msg'] = 'wrong_nonce';
|
348 |
+
|
349 |
+
if($die == true) {
|
350 |
+
die(json_encode($response));
|
351 |
+
} else {
|
352 |
+
return $response;
|
353 |
}
|
354 |
+
}
|
355 |
+
|
356 |
+
|
357 |
+
include_once 'library/gawd-email-class.php';
|
358 |
+
$email = new GAWD_email();
|
359 |
+
if($email->parse_ajax_data() === false) {
|
360 |
+
$response['error'] = $email->get_error();
|
361 |
+
if($die == true) {
|
362 |
+
die(json_encode($response));
|
363 |
+
} else {
|
364 |
+
return $response;
|
365 |
}
|
366 |
}
|
|
|
|
|
367 |
|
368 |
+
$file_response = $this->generate_csv_file();
|
369 |
+
if($file_response['success'] === false) {
|
370 |
|
371 |
+
$response = array(
|
372 |
+
'success' => $file_response['success'],
|
373 |
+
'error' => $file_response['error'],
|
374 |
+
'data' => $file_response['data']
|
375 |
+
);
|
376 |
|
377 |
+
if($die == true) {
|
378 |
+
die(json_encode($response));
|
379 |
+
} else {
|
380 |
+
return $response;
|
381 |
+
}
|
382 |
+
}
|
383 |
|
|
|
|
|
384 |
|
385 |
+
if($email->get_period() !== 'once') {
|
386 |
+
$email->save_email_info($file_response['ajax_args'], $file_response['csv_generator']);
|
387 |
|
388 |
+
$response['success'] = true;
|
389 |
+
$response['data']['msg'] = 'Email successfully Scheduled </br> Go to <a href="admin.php?page=gawd_settings#gawd_emails_tab">Settings page</a> to delete scheduled e-mails.';
|
390 |
+
if($die == true) {
|
391 |
+
die(json_encode($response));
|
392 |
+
} else {
|
393 |
+
return $response;
|
394 |
+
}
|
395 |
+
}
|
396 |
|
397 |
+
$email->attach_file($file_response['csv_generator']);
|
398 |
+
if($email->send_mail() === true) {
|
399 |
+
$response['success'] = true;
|
400 |
+
$response['data']['msg'] = 'Email successfully sent.';
|
401 |
+
if($die == true) {
|
402 |
+
die(json_encode($response));
|
403 |
+
} else {
|
404 |
+
return $response;
|
405 |
+
}
|
406 |
} else {
|
407 |
+
$response['error']['code'] = 'fail_to_sent_email';
|
408 |
+
$response['error']['code'] = 'Fail to sent email.';
|
409 |
+
|
410 |
+
if($die == true) {
|
411 |
+
die(json_encode($response));
|
412 |
+
} else {
|
413 |
+
return $response;
|
414 |
+
}
|
415 |
}
|
416 |
+
|
417 |
+
}
|
418 |
+
|
419 |
+
private function generate_csv_file($data = array(), $view_id = null, $ajax_response = array()){
|
420 |
+
$response = array(
|
421 |
+
'success' => false,
|
422 |
+
'error' => array('code' => 'something_went_wrong', 'msg' => 'something went wrong.'),
|
423 |
+
'data' => ''
|
424 |
+
);
|
425 |
+
|
426 |
+
if(!empty($data)) {
|
427 |
+
$gawd_request_last_args = $data['last_args'];
|
428 |
+
$compare_by = $data['compare_by'];
|
429 |
+
$gawd_compare_request_last_args = $data['compare_last_args'];
|
430 |
+
$menu_name = $data['menu_name'];
|
431 |
+
$info = $data['info'];
|
432 |
} else {
|
433 |
+
$gawd_request_last_args = $_POST['gawd_request_last_args'];
|
434 |
+
$compare_by = $_POST['compare_by'];
|
435 |
+
$gawd_compare_request_last_args = (!empty($_POST['gawd_compare_request_last_args'])) ? $_POST['gawd_compare_request_last_args'] : null;
|
436 |
+
$info = $_POST['info'];
|
437 |
+
$menu_name = $_POST['menu_name'];
|
438 |
+
}//else set defaults
|
439 |
+
|
440 |
+
if(is_array($ajax_response) && !empty($ajax_response)) {
|
441 |
+
$data = $ajax_response;
|
442 |
+
} else {
|
443 |
+
$data = GAWD_helper::ajax_request($gawd_request_last_args, $view_id);
|
444 |
+
if($data === false) {
|
445 |
+
return $response;
|
446 |
+
}
|
447 |
+
}
|
448 |
+
|
449 |
+
if($gawd_compare_request_last_args !== null) {
|
450 |
+
|
451 |
+
$compare_data = GAWD_helper::ajax_request($gawd_compare_request_last_args, $view_id);
|
452 |
+
|
453 |
+
if($compare_data === false) {
|
454 |
+
return $response;
|
455 |
+
}
|
456 |
+
|
457 |
+
} else {
|
458 |
+
$compare_data = null;
|
459 |
+
}
|
460 |
+
|
461 |
+
include_once 'library/file-generators/gawd-csv-generator-class.php';
|
462 |
+
$csv = new GAWD_csv_file_generator();
|
463 |
+
$csv->parse_data($data, $gawd_request_last_args, $compare_data, $gawd_compare_request_last_args, $compare_by);
|
464 |
+
if(!empty($menu_name)) {
|
465 |
+
$csv->set_menu_name(sanitize_text_field($menu_name));
|
466 |
+
}
|
467 |
+
|
468 |
+
$site_title = "";
|
469 |
+
if($view_id !== null) {
|
470 |
+
$site_title = GAWD_helper::get_account_name_by_profile_id($view_id);
|
471 |
+
} else {
|
472 |
+
$last_viewed_profile = GAWD_helper::get_last_viewed_profile();
|
473 |
+
if(isset($last_viewed_profile['web_property_name'])) {
|
474 |
+
$site_title = $last_viewed_profile['web_property_name'];
|
475 |
+
}
|
476 |
}
|
477 |
+
|
478 |
+
if(!empty($site_title)) {
|
479 |
+
$csv->set_site_title($site_title);
|
480 |
+
}
|
481 |
+
|
482 |
+
$csv->generate();
|
483 |
+
|
484 |
+
$response['success'] = true;
|
485 |
+
$response['error'] = array();
|
486 |
+
$response['data'] = array('download_url' => $csv->get_file_url());
|
487 |
+
$response['csv_generator'] = $csv;
|
488 |
+
$response['ajax_args'] = array(
|
489 |
+
'last_args' => $gawd_request_last_args,
|
490 |
+
'compare_last_args' => $gawd_compare_request_last_args,
|
491 |
+
'compare_by' => $compare_by,
|
492 |
+
'menu_name' => $menu_name,
|
493 |
+
'info' => $info
|
494 |
+
);
|
495 |
+
|
496 |
+
return $response;
|
497 |
+
}
|
498 |
+
|
499 |
+
public function gawd_email_scheduled(){
|
500 |
+
|
501 |
+
$gawd_emails_info = get_option('gawd_emails_info');
|
502 |
+
if(empty($gawd_emails_info)) {
|
503 |
+
return;
|
504 |
+
}
|
505 |
+
|
506 |
+
include_once 'library/gawd-email-class.php';
|
507 |
+
|
508 |
+
$now = time();
|
509 |
+
$new_dates = array();
|
510 |
+
|
511 |
+
foreach($gawd_emails_info as $i => $email_info) {
|
512 |
+
|
513 |
+
if($now < $email_info['next_date']) {
|
514 |
+
continue;
|
515 |
+
}
|
516 |
+
|
517 |
+
$new_dates[] = $i;
|
518 |
+
|
519 |
+
$email = new GAWD_email();
|
520 |
+
$email->set_email_info($email_info['email_info']);
|
521 |
+
|
522 |
+
if($email->check_condition($email_info) === false) {
|
523 |
+
continue;
|
524 |
+
}
|
525 |
+
|
526 |
+
$email->add_content();
|
527 |
+
|
528 |
+
$file_response = $this->generate_csv_file($email_info['ajax_args'], $email_info['email_info']['view_id'], $email->get_ajax_response());
|
529 |
+
|
530 |
+
if($file_response['success'] === false) {
|
531 |
+
continue;
|
532 |
+
}
|
533 |
+
|
534 |
+
$email->attach_file($file_response['csv_generator']);
|
535 |
+
$email->send_mail();
|
536 |
+
}
|
537 |
+
|
538 |
+
if(!empty($new_dates)) {
|
539 |
+
|
540 |
+
foreach($new_dates as $i => $index) {
|
541 |
+
$info = GAWD_email::calc_next_date($gawd_emails_info[$index]);
|
542 |
+
$info = GAWD_email::calc_date_range($info);
|
543 |
+
$gawd_emails_info[$index] = $info;
|
544 |
+
}
|
545 |
+
|
546 |
+
update_option('gawd_emails_info', $gawd_emails_info);
|
547 |
+
|
548 |
+
$this->gawd_email_scheduled();
|
549 |
+
return;
|
550 |
+
} else {
|
551 |
+
GAWD_email::set_new_scheduled();
|
552 |
+
}
|
553 |
+
|
554 |
}
|
555 |
|
556 |
public static function get_domain($domain){
|
1137 |
require_once('admin/pages/dashboard.php');
|
1138 |
}
|
1139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1140 |
/**
|
1141 |
* Prepares the settings to be displayed then displays the settings page.
|
1142 |
*/
|
1207 |
'error');
|
1208 |
}
|
1209 |
|
1210 |
+
if(isset($_POST['gawd_email_remove'])){
|
1211 |
+
if(isset($_POST['gawd_save_form_fild']) && wp_verify_nonce($_POST['gawd_save_form_fild'], 'gawd_save_form')){
|
1212 |
+
include_once 'library/gawd-email-class.php';
|
1213 |
+
GAWD_email::delete_email($_POST['gawd_email_remove']);
|
1214 |
+
}
|
1215 |
+
}
|
1216 |
+
|
1217 |
require_once('admin/pages/settings.php');
|
1218 |
}
|
1219 |
|
1232 |
require_once('admin/pages/authentication.php');
|
1233 |
}
|
1234 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1235 |
public function gawd_pushover_api($user_key, $metric, $condition, $value){
|
1236 |
$ch = curl_init();
|
1237 |
curl_setopt($ch, CURLOPT_URL, "https://api.pushover.net/1/messages.json");
|
1409 |
}
|
1410 |
}
|
1411 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1412 |
public static function add_dashboard_menu(){
|
1413 |
$get_custom_reports = get_option('gawd_custom_reports');
|
1414 |
if(!$get_custom_reports) {
|
1656 |
public static function activate(){
|
1657 |
|
1658 |
delete_site_transient('gawd_uninstall');
|
1659 |
+
$gawd_credentials = get_option('gawd_credentials');
|
1660 |
+
if(empty($gawd_credentials)) {
|
1661 |
update_option('gawd_credentials', GAWD_helper::get_project_default_credentials());
|
1662 |
}
|
1663 |
|
google-analytics-wd.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Google Analytics
|
4 |
* Plugin URI: https://web-dorado.com/products/wordpress-google-analytics-plugin.html
|
5 |
* Description: Google Analytics WD is a user-friendly all in one plugin, which allows to manage and monitor your website analytics from WordPress dashboard.
|
6 |
-
* Version: 1.2.
|
7 |
* Author: WebDorado
|
8 |
* Author URI: https://web-dorado.com
|
9 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
3 |
* Plugin Name: Google Analytics
|
4 |
* Plugin URI: https://web-dorado.com/products/wordpress-google-analytics-plugin.html
|
5 |
* Description: Google Analytics WD is a user-friendly all in one plugin, which allows to manage and monitor your website analytics from WordPress dashboard.
|
6 |
+
* Version: 1.2.3
|
7 |
* Author: WebDorado
|
8 |
* Author URI: https://web-dorado.com
|
9 |
* License: GNU/GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
|
inc/css/gawd_admin.css
CHANGED
@@ -533,10 +533,14 @@
|
|
533 |
box-sizing: border-box;
|
534 |
}
|
535 |
|
536 |
-
.gawd_export_button_csv
|
537 |
display: block !important;
|
538 |
}
|
539 |
|
|
|
|
|
|
|
|
|
540 |
#date_chart_conteiner {
|
541 |
width: 39%
|
542 |
|
@@ -2996,7 +3000,6 @@ a:focus {
|
|
2996 |
padding: 5px 0;
|
2997 |
|
2998 |
}
|
2999 |
-
|
3000 |
.gawd_refresh_button_wrapper .refresh_user_info_goal{
|
3001 |
float: right !important;
|
3002 |
}
|
@@ -3004,7 +3007,6 @@ a:focus {
|
|
3004 |
float: right !important;
|
3005 |
}
|
3006 |
|
3007 |
-
|
3008 |
.gwd_refresh_page,
|
3009 |
.gawd_auth_button {
|
3010 |
background-color: #5ba5d8;
|
@@ -3361,11 +3363,10 @@ a:focus {
|
|
3361 |
min-height: 300px;
|
3362 |
}
|
3363 |
|
3364 |
-
|
3365 |
-
|
3366 |
-
|
3367 |
.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_pushover,
|
3368 |
-
.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_emails,
|
3369 |
.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_filters {
|
3370 |
display: none;
|
3371 |
}
|
533 |
box-sizing: border-box;
|
534 |
}
|
535 |
|
536 |
+
.gawd_export_button_csv {
|
537 |
display: block !important;
|
538 |
}
|
539 |
|
540 |
+
.gawd_export_button_pdf {
|
541 |
+
display: none !important;
|
542 |
+
}
|
543 |
+
|
544 |
#date_chart_conteiner {
|
545 |
width: 39%
|
546 |
|
3000 |
padding: 5px 0;
|
3001 |
|
3002 |
}
|
|
|
3003 |
.gawd_refresh_button_wrapper .refresh_user_info_goal{
|
3004 |
float: right !important;
|
3005 |
}
|
3007 |
float: right !important;
|
3008 |
}
|
3009 |
|
|
|
3010 |
.gwd_refresh_page,
|
3011 |
.gawd_auth_button {
|
3012 |
background-color: #5ba5d8;
|
3363 |
min-height: 300px;
|
3364 |
}
|
3365 |
|
3366 |
+
/*#gawd_export_buttons,*/
|
3367 |
+
/*#gawd_email_button,*/
|
3368 |
+
/*.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_alerts,*/
|
3369 |
.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_pushover,
|
|
|
3370 |
.gawd_menu_coteiner.gawd_settings_menu_coteiner #gawd_filters {
|
3371 |
display: none;
|
3372 |
}
|
inc/js/gawd_admin.js
CHANGED
@@ -35,6 +35,9 @@ monthnames[10] = 'October';
|
|
35 |
monthnames[11] = 'November';
|
36 |
monthnames[12] = 'December';
|
37 |
var gawd_chart_data = [];
|
|
|
|
|
|
|
38 |
function gawd_compare() {
|
39 |
console.log("ajax111");
|
40 |
jQuery("#gawd_metric_compare").show();
|
@@ -104,6 +107,7 @@ function gawd_compare() {
|
|
104 |
};
|
105 |
|
106 |
jQuery.ajax(args).done(function (data) {
|
|
|
107 |
jQuery('#compare_datepicker_wraper').css('background-color','#4F9A55');
|
108 |
jQuery('#opacity_div').hide();
|
109 |
jQuery('#loading_div').hide();
|
@@ -518,7 +522,6 @@ function gawd_draw_analytics() {
|
|
518 |
} else if (dimension == 'custom')
|
519 |
{
|
520 |
|
521 |
-
|
522 |
var custom = jQuery("#gawd_custom_option").val();
|
523 |
var not_exist = '<div id="gawd_error">There are no custom dimensions set for current profile.</div>';
|
524 |
if(custom === null || typeof custom === 'undefined'){
|
@@ -534,11 +537,13 @@ function gawd_draw_analytics() {
|
|
534 |
};
|
535 |
args.success = function (data){
|
536 |
if(data.data.length === 0){
|
|
|
537 |
jQuery("#wdi_no_custom_dimensions").css({
|
538 |
'display':'block'
|
539 |
});
|
540 |
jQuery('#chartdiv').append(not_exist);
|
541 |
return;
|
|
|
542 |
}
|
543 |
else{
|
544 |
jQuery("#gawd_custom_option").css({
|
@@ -623,6 +628,7 @@ function gawd_draw_analytics() {
|
|
623 |
gawd_add_notice(data);
|
624 |
return;
|
625 |
}
|
|
|
626 |
data = data.data.gawd_reports_data;
|
627 |
|
628 |
var result = JSON.parse(data);
|
@@ -856,7 +862,26 @@ function gawd_draw_analytics() {
|
|
856 |
|
857 |
////////
|
858 |
jQuery(document).ready(function () {
|
859 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
860 |
|
861 |
if (typeof d_tab_name[1] == 'undefined') {
|
862 |
d_tab_name[1] = 'general';
|
@@ -1112,6 +1137,54 @@ jQuery(document).ready(function () {
|
|
1112 |
}
|
1113 |
/* END FREE*/
|
1114 |
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1115 |
function get_order_data_for_export() {
|
1116 |
var el = jQuery('.ui-jqgrid-htable').find('th[aria-selected="true"]');
|
1117 |
if (el.length == 0) {
|
@@ -1174,6 +1247,7 @@ function gawd_widget_all(start_date, end_date, metric) {
|
|
1174 |
gawd_add_notice(data, '#chart_widget');
|
1175 |
return;
|
1176 |
}
|
|
|
1177 |
data = data.data.gawd_reports_data;
|
1178 |
data = JSON.parse(data);
|
1179 |
data = data.chart_data;
|
@@ -1259,7 +1333,7 @@ function gawd_pie_chart() {
|
|
1259 |
gawd_add_notice(data);
|
1260 |
return;
|
1261 |
}
|
1262 |
-
|
1263 |
data = data.data.gawd_reports_data;
|
1264 |
var result = JSON.parse(data);
|
1265 |
_data = result;
|
@@ -1508,7 +1582,8 @@ function gawd_chart_type() {
|
|
1508 |
var period_compare_start_date = Date.parse(start_date).add(-diff).days().toString("yyyy-MM-dd");
|
1509 |
var year_compare_start_date = Date.parse(start_date).add(-1).years().toString("yyyy-MM-dd");
|
1510 |
var year_compare_end_date = Date.parse(end_date).add(-1).years().toString("yyyy-MM-dd");
|
1511 |
-
|
|
|
1512 |
'ranges': {
|
1513 |
'Previous period': [moment(period_compare_start_date), moment(start_date).subtract(1, 'days')],
|
1514 |
'Previous year': [moment(year_compare_start_date), moment(year_compare_end_date)]
|
@@ -1521,8 +1596,15 @@ function gawd_chart_type() {
|
|
1521 |
"applyClass": 'gawd_compare_apply',
|
1522 |
"cancelClass": "gawd_compare_cancel"
|
1523 |
}, gawd_datepicker_compare);
|
|
|
|
|
|
|
|
|
|
|
1524 |
jQuery(document).mouseup(function (e) {
|
1525 |
|
|
|
|
|
1526 |
if (!jQuery('.gawd_compare_apply').is(e.target) && ( jQuery('.gawd_compare_cancel').is(e.target))) {
|
1527 |
jQuery('#gawd_metric_compare').attr('disabled',false);
|
1528 |
jQuery('#gawd_metric_compare').removeClass('gawd_disabled');
|
@@ -1985,7 +2067,7 @@ function datepicker_js(opens,callback) {
|
|
1985 |
callback = 'gawd_datepicker_main';
|
1986 |
}
|
1987 |
window[callback](default_start(), default_end());
|
1988 |
-
jQuery('#reportrange').daterangepicker({
|
1989 |
"ranges": {
|
1990 |
'Today': [moment(), moment()],
|
1991 |
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
@@ -2009,6 +2091,9 @@ function datepicker_js(opens,callback) {
|
|
2009 |
var start_end_date = start_end_date.split('/-/');
|
2010 |
var start_date = start_end_date[0];
|
2011 |
var end_date = start_end_date[1];
|
|
|
|
|
|
|
2012 |
|
2013 |
}
|
2014 |
function onDashboardLoad() {
|
@@ -2093,9 +2178,73 @@ function onDashboardLoad() {
|
|
2093 |
}
|
2094 |
})
|
2095 |
jQuery("#email_submit").on('click', function () {
|
2096 |
-
|
|
|
2097 |
})
|
2098 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2099 |
function email_popup() {
|
2100 |
jQuery("#gawd_email_metric").val(jQuery("#gawd_metric").val());
|
2101 |
var metric_compare_email = jQuery("#gawd_metric_compare").val();
|
@@ -2208,6 +2357,7 @@ function email_popup() {
|
|
2208 |
})
|
2209 |
}
|
2210 |
}
|
|
|
2211 |
function numFormat( cellvalue, options, rowObject ){
|
2212 |
if(typeof options != 'undefined' ){
|
2213 |
if(options.colModel.index != 'Pageviews Per Session' && options.colModel.index != 'Pageviews Per Session compare'){
|
35 |
monthnames[11] = 'November';
|
36 |
monthnames[12] = 'December';
|
37 |
var gawd_chart_data = [];
|
38 |
+
var gawd_compare_request_last_args;
|
39 |
+
var gawd_request_last_args;
|
40 |
+
|
41 |
function gawd_compare() {
|
42 |
console.log("ajax111");
|
43 |
jQuery("#gawd_metric_compare").show();
|
107 |
};
|
108 |
|
109 |
jQuery.ajax(args).done(function (data) {
|
110 |
+
gawd_compare_request_last_args = args;
|
111 |
jQuery('#compare_datepicker_wraper').css('background-color','#4F9A55');
|
112 |
jQuery('#opacity_div').hide();
|
113 |
jQuery('#loading_div').hide();
|
522 |
} else if (dimension == 'custom')
|
523 |
{
|
524 |
|
|
|
525 |
var custom = jQuery("#gawd_custom_option").val();
|
526 |
var not_exist = '<div id="gawd_error">There are no custom dimensions set for current profile.</div>';
|
527 |
if(custom === null || typeof custom === 'undefined'){
|
537 |
};
|
538 |
args.success = function (data){
|
539 |
if(data.data.length === 0){
|
540 |
+
|
541 |
jQuery("#wdi_no_custom_dimensions").css({
|
542 |
'display':'block'
|
543 |
});
|
544 |
jQuery('#chartdiv').append(not_exist);
|
545 |
return;
|
546 |
+
|
547 |
}
|
548 |
else{
|
549 |
jQuery("#gawd_custom_option").css({
|
628 |
gawd_add_notice(data);
|
629 |
return;
|
630 |
}
|
631 |
+
gawd_request_last_args = args;
|
632 |
data = data.data.gawd_reports_data;
|
633 |
|
634 |
var result = JSON.parse(data);
|
862 |
|
863 |
////////
|
864 |
jQuery(document).ready(function () {
|
865 |
+
|
866 |
+
jQuery('.gawd_export_button_csv').on('click', function (e) {
|
867 |
+
e.preventDefault();
|
868 |
+
|
869 |
+
var data = gawd_get_report_file_data();
|
870 |
+
data['action'] = 'gawd_create_csv_file';
|
871 |
+
|
872 |
+
|
873 |
+
jQuery.post(gawd_admin.ajaxurl, data ).done(function (response) {
|
874 |
+
response = JSON.parse(response);
|
875 |
+
if(response.success === true){
|
876 |
+
window.location.href =response['data']['download_url'];
|
877 |
+
}
|
878 |
+
|
879 |
+
});
|
880 |
+
|
881 |
+
return false;
|
882 |
+
});
|
883 |
+
|
884 |
+
jQuery('.gawd_export_button_csvs').on('click', function () {
|
885 |
|
886 |
if (typeof d_tab_name[1] == 'undefined') {
|
887 |
d_tab_name[1] = 'general';
|
1137 |
}
|
1138 |
/* END FREE*/
|
1139 |
});
|
1140 |
+
|
1141 |
+
function gawd_get_report_file_data(){
|
1142 |
+
if (typeof gawd_request_last_args === "undefined") {
|
1143 |
+
return false;
|
1144 |
+
}
|
1145 |
+
|
1146 |
+
var last_args = gawd_request_last_args.data;
|
1147 |
+
var compare_last_args = (typeof gawd_compare_request_last_args !== 'undefined' && typeof gawd_compare_request_last_args.data !== 'undefined') ? gawd_compare_request_last_args.data : null;
|
1148 |
+
|
1149 |
+
var compare_by = (typeof jQuery('#gawd_metric_compare').attr('disabled') === 'undefined') ? "metric" : "date";
|
1150 |
+
if(compare_by === "date"){
|
1151 |
+
var compare_metric_name = jQuery('#gawd_metric_compare').val();
|
1152 |
+
|
1153 |
+
if(last_args.gawd_data.metric.length > 1){
|
1154 |
+
|
1155 |
+
if (last_args.gawd_data.metric[0] === "ga:" + compare_metric_name) {
|
1156 |
+
last_args.gawd_data.metric = [last_args.gawd_data.metric[1]];
|
1157 |
+
} else if (last_args.gawd_data.metric[1] === "ga:" + compare_metric_name) {
|
1158 |
+
last_args.gawd_data.metric = [last_args.gawd_data.metric[0]];
|
1159 |
+
}
|
1160 |
+
|
1161 |
+
}
|
1162 |
+
}
|
1163 |
+
|
1164 |
+
var gawd_daterange = jQuery('.gawd_daterange .ranges li.active').text();
|
1165 |
+
if(gawd_daterange === ""){
|
1166 |
+
gawd_daterange = "Last 30 Days ";
|
1167 |
+
}
|
1168 |
+
|
1169 |
+
var gawd_compare_daterange = jQuery('.gawd_compare_daterange .ranges li.active').text();
|
1170 |
+
if(gawd_compare_daterange === ""){
|
1171 |
+
gawd_compare_daterange = "Previous period";
|
1172 |
+
}
|
1173 |
+
|
1174 |
+
var data = {
|
1175 |
+
security: gawd_admin.ajaxnonce,
|
1176 |
+
gawd_request_last_args: gawd_request_last_args.data,
|
1177 |
+
gawd_compare_request_last_args: (typeof gawd_compare_request_last_args !== 'undefined' && typeof gawd_compare_request_last_args.data !== 'undefined') ? gawd_compare_request_last_args.data : null,
|
1178 |
+
menu_name: jQuery('#gawd_page_title').text().trim(),
|
1179 |
+
compare_by: (typeof jQuery('#gawd_metric_compare').attr('disabled') === 'undefined') ? "metric" : "date",
|
1180 |
+
info: {
|
1181 |
+
'date_ranges': [gawd_daterange, gawd_compare_daterange]
|
1182 |
+
}
|
1183 |
+
};
|
1184 |
+
|
1185 |
+
return data;
|
1186 |
+
}
|
1187 |
+
|
1188 |
function get_order_data_for_export() {
|
1189 |
var el = jQuery('.ui-jqgrid-htable').find('th[aria-selected="true"]');
|
1190 |
if (el.length == 0) {
|
1247 |
gawd_add_notice(data, '#chart_widget');
|
1248 |
return;
|
1249 |
}
|
1250 |
+
gawd_request_last_args = args;
|
1251 |
data = data.data.gawd_reports_data;
|
1252 |
data = JSON.parse(data);
|
1253 |
data = data.chart_data;
|
1333 |
gawd_add_notice(data);
|
1334 |
return;
|
1335 |
}
|
1336 |
+
gawd_request_last_args = args;
|
1337 |
data = data.data.gawd_reports_data;
|
1338 |
var result = JSON.parse(data);
|
1339 |
_data = result;
|
1582 |
var period_compare_start_date = Date.parse(start_date).add(-diff).days().toString("yyyy-MM-dd");
|
1583 |
var year_compare_start_date = Date.parse(start_date).add(-1).years().toString("yyyy-MM-dd");
|
1584 |
var year_compare_end_date = Date.parse(end_date).add(-1).years().toString("yyyy-MM-dd");
|
1585 |
+
|
1586 |
+
var compare_daterange = jQuery('#compare_datepicker_wraper').daterangepicker({
|
1587 |
'ranges': {
|
1588 |
'Previous period': [moment(period_compare_start_date), moment(start_date).subtract(1, 'days')],
|
1589 |
'Previous year': [moment(year_compare_start_date), moment(year_compare_end_date)]
|
1596 |
"applyClass": 'gawd_compare_apply',
|
1597 |
"cancelClass": "gawd_compare_cancel"
|
1598 |
}, gawd_datepicker_compare);
|
1599 |
+
|
1600 |
+
if(typeof compare_daterange.data('daterangepicker') != "undefined"){
|
1601 |
+
compare_daterange.data('daterangepicker').container.addClass('gawd_compare_daterange');
|
1602 |
+
}
|
1603 |
+
|
1604 |
jQuery(document).mouseup(function (e) {
|
1605 |
|
1606 |
+
|
1607 |
+
|
1608 |
if (!jQuery('.gawd_compare_apply').is(e.target) && ( jQuery('.gawd_compare_cancel').is(e.target))) {
|
1609 |
jQuery('#gawd_metric_compare').attr('disabled',false);
|
1610 |
jQuery('#gawd_metric_compare').removeClass('gawd_disabled');
|
2067 |
callback = 'gawd_datepicker_main';
|
2068 |
}
|
2069 |
window[callback](default_start(), default_end());
|
2070 |
+
var daterange = jQuery('#reportrange').daterangepicker({
|
2071 |
"ranges": {
|
2072 |
'Today': [moment(), moment()],
|
2073 |
'Yesterday': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
|
2091 |
var start_end_date = start_end_date.split('/-/');
|
2092 |
var start_date = start_end_date[0];
|
2093 |
var end_date = start_end_date[1];
|
2094 |
+
if(typeof daterange.data('daterangepicker') != "undefined") {
|
2095 |
+
daterange.data('daterangepicker').container.addClass('gawd_daterange');
|
2096 |
+
}
|
2097 |
|
2098 |
}
|
2099 |
function onDashboardLoad() {
|
2178 |
}
|
2179 |
})
|
2180 |
jQuery("#email_submit").on('click', function () {
|
2181 |
+
gawd_send_email_info();
|
2182 |
+
//email_popup();
|
2183 |
})
|
2184 |
}
|
2185 |
+
|
2186 |
+
function gawd_send_email_info() {
|
2187 |
+
|
2188 |
+
var email_info = {
|
2189 |
+
'period': jQuery("#gawd_email_period :selected").val(),
|
2190 |
+
'email_from': jQuery("#gawd_email_from").val(),
|
2191 |
+
'email_to': jQuery("#gawd_email_to").val(),
|
2192 |
+
'subject': jQuery(".gawd_email_subject").val(),
|
2193 |
+
'content': jQuery("#gawd_email_body").val(),
|
2194 |
+
'week_day': jQuery("#gawd_email_week_day_hidden").val(),
|
2195 |
+
'month_day': jQuery("#gawd_email_month_day_select").val(),
|
2196 |
+
'email_time': jQuery("#gawd_email_time_input").val(),
|
2197 |
+
'view_id': jQuery("#gawd_id option:selected").val(),
|
2198 |
+
};
|
2199 |
+
|
2200 |
+
var empty_subject = false;
|
2201 |
+
var is_valid_email = true;
|
2202 |
+
|
2203 |
+
jQuery("#gawd_email_to").removeClass('gawd_invalid')
|
2204 |
+
jQuery("#gawd_email_subject").removeClass('gawd_invalid')
|
2205 |
+
var emails = email_info.email_to.split(',');
|
2206 |
+
var invalid_emalis = [];
|
2207 |
+
for (var j = 0; j < emails.length; j++) {
|
2208 |
+
var re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
2209 |
+
if (re.test(emails[j]) == false) {
|
2210 |
+
invalid_emalis.push(emails[j])
|
2211 |
+
}
|
2212 |
+
}
|
2213 |
+
if (invalid_emalis.length > 0) {
|
2214 |
+
is_valid_email = false;
|
2215 |
+
jQuery("#gawd_email_to").addClass('gawd_invalid');
|
2216 |
+
}
|
2217 |
+
if (email_info.subject == '') {
|
2218 |
+
empty_subject = true;
|
2219 |
+
jQuery("#gawd_email_subject").addClass('gawd_email_subject');
|
2220 |
+
}
|
2221 |
+
|
2222 |
+
|
2223 |
+
if (!(is_valid_email == true && empty_subject == false)) {
|
2224 |
+
return;
|
2225 |
+
}
|
2226 |
+
|
2227 |
+
var data = gawd_get_report_file_data();
|
2228 |
+
data['action'] = 'gawd_send_email';
|
2229 |
+
data['email_info'] = email_info;
|
2230 |
+
|
2231 |
+
jQuery('#loading_div').css('z-index','999999');
|
2232 |
+
jQuery('#loading_div').show();
|
2233 |
+
|
2234 |
+
jQuery.post(gawd_admin.ajaxurl, data).done(function (response) {
|
2235 |
+
response = JSON.parse(response);
|
2236 |
+
|
2237 |
+
jQuery('.gawd_email_body').hide();
|
2238 |
+
jQuery('#loading_div').css('z-index', '99999');
|
2239 |
+
jQuery('#loading_div').hide();
|
2240 |
+
jQuery('.email_message_cont').show();
|
2241 |
+
|
2242 |
+
jQuery('.email_message_cont').html(response.data.msg);
|
2243 |
+
|
2244 |
+
|
2245 |
+
});
|
2246 |
+
}
|
2247 |
+
|
2248 |
function email_popup() {
|
2249 |
jQuery("#gawd_email_metric").val(jQuery("#gawd_metric").val());
|
2250 |
var metric_compare_email = jQuery("#gawd_metric_compare").val();
|
2357 |
})
|
2358 |
}
|
2359 |
}
|
2360 |
+
|
2361 |
function numFormat( cellvalue, options, rowObject ){
|
2362 |
if(typeof options != 'undefined' ){
|
2363 |
if(options.colModel.index != 'Pageviews Per Session' && options.colModel.index != 'Pageviews Per Session compare'){
|
inc/js/gawd_settings.js
CHANGED
@@ -20,7 +20,9 @@ jQuery(function () {
|
|
20 |
hash !== "" && hash !== "#" &&
|
21 |
hash !== "#gawd_authenicate_tab" &&
|
22 |
hash !== "#gawd_tracking_tab" &&
|
23 |
-
hash !== "#gawd_advanced_tab"
|
|
|
|
|
24 |
){
|
25 |
window.location.hash = "";
|
26 |
window.location.reload();
|
@@ -154,8 +156,8 @@ jQuery(document).ready(function () {
|
|
154 |
}
|
155 |
if (jQuery(".gawd_emails table").length <= 0) {
|
156 |
gawd_emails = true;
|
157 |
-
jQuery('#gawd_settings_button').hide();
|
158 |
}
|
|
|
159 |
jQuery('.gawd_emails').show();
|
160 |
}
|
161 |
else if (window.location.hash === '#gawd_advanced_tab') {
|
@@ -300,8 +302,8 @@ jQuery(document).ready(function () {
|
|
300 |
jQuery('.gawd_emails').show();
|
301 |
if (jQuery(".gawd_emails table").length <= 0) {
|
302 |
gawd_emails = true;
|
303 |
-
jQuery('#gawd_settings_button').hide();
|
304 |
}
|
|
|
305 |
jQuery('#gawd_settings_logout').hide();
|
306 |
}
|
307 |
else if (tab == 'gawd_pushover') {
|
@@ -424,13 +426,15 @@ jQuery(document).ready(function () {
|
|
424 |
|
425 |
jQuery("#gawd_right_conteiner").show();
|
426 |
|
427 |
-
function exclude_popup(popup_overlay, popup_body, popup_btn, exclude_content, add_content, excluded_items, remove_excluded, excluded_data) {
|
428 |
popup_overlay = "." + popup_overlay;
|
429 |
popup_btn = "." + popup_btn;
|
430 |
popup_body = "." + popup_body;
|
431 |
exclude_content = "#" + exclude_content;
|
432 |
add_content = "#" + add_content;
|
|
|
433 |
|
|
|
434 |
jQuery(popup_overlay + ', ' + popup_btn).on('click', function () {
|
435 |
jQuery(popup_body).fadeOut('fast');
|
436 |
jQuery(popup_overlay).fadeOut('fast');
|
@@ -459,11 +463,13 @@ jQuery(document).ready(function () {
|
|
459 |
jQuery(this).removeAttr('checked');
|
460 |
}
|
461 |
});
|
|
|
462 |
});
|
|
|
463 |
});
|
464 |
|
465 |
jQuery("." + remove_excluded).on('click', function () {
|
466 |
-
var find = jQuery(this).closest('.time_wrap').find(excluded_data).html();
|
467 |
jQuery(this).closest('div').remove();
|
468 |
|
469 |
jQuery(popup_body + " .gawd_table input[type='checkbox']:checked").each(function () {
|
@@ -471,13 +477,22 @@ jQuery(document).ready(function () {
|
|
471 |
jQuery(this).removeAttr('checked');
|
472 |
}
|
473 |
});
|
|
|
|
|
474 |
});
|
475 |
|
|
|
|
|
|
|
|
|
|
|
476 |
|
|
|
|
|
477 |
}
|
478 |
|
479 |
-
exclude_popup('gawd_exclude_users_popup_overlay', 'gawd_exclude_users_popup', 'gawd_exclude_users_popup_btn', 'exclude_users', 'gawd_add_users', 'excluded_items', 'remove_excluded_user', 'excluded_username');
|
480 |
-
exclude_popup('gawd_exclude_roles_popup_overlay', 'gawd_exclude_roles_popup', 'gawd_exclude_roles_popup_btn', 'exclude_roles', 'gawd_add_roles', 'excluded_roles', 'remove_excluded_role', 'excluded_role');
|
481 |
});
|
482 |
|
483 |
function gawd_save_settings() {
|
20 |
hash !== "" && hash !== "#" &&
|
21 |
hash !== "#gawd_authenicate_tab" &&
|
22 |
hash !== "#gawd_tracking_tab" &&
|
23 |
+
hash !== "#gawd_advanced_tab" &&
|
24 |
+
hash !== "#gawd_emails_tab" &&
|
25 |
+
hash !== "#gawd_alerts_tab"
|
26 |
){
|
27 |
window.location.hash = "";
|
28 |
window.location.reload();
|
156 |
}
|
157 |
if (jQuery(".gawd_emails table").length <= 0) {
|
158 |
gawd_emails = true;
|
|
|
159 |
}
|
160 |
+
jQuery('#gawd_settings_button').hide();
|
161 |
jQuery('.gawd_emails').show();
|
162 |
}
|
163 |
else if (window.location.hash === '#gawd_advanced_tab') {
|
302 |
jQuery('.gawd_emails').show();
|
303 |
if (jQuery(".gawd_emails table").length <= 0) {
|
304 |
gawd_emails = true;
|
|
|
305 |
}
|
306 |
+
jQuery('#gawd_settings_button').hide();
|
307 |
jQuery('#gawd_settings_logout').hide();
|
308 |
}
|
309 |
else if (tab == 'gawd_pushover') {
|
426 |
|
427 |
jQuery("#gawd_right_conteiner").show();
|
428 |
|
429 |
+
function exclude_popup(popup_overlay, popup_body, popup_btn, exclude_content, add_content, excluded_items, remove_excluded, excluded_data, hidden_input) {
|
430 |
popup_overlay = "." + popup_overlay;
|
431 |
popup_btn = "." + popup_btn;
|
432 |
popup_body = "." + popup_body;
|
433 |
exclude_content = "#" + exclude_content;
|
434 |
add_content = "#" + add_content;
|
435 |
+
hidden_input = '#' + hidden_input;
|
436 |
|
437 |
+
gawd_hidden_input();
|
438 |
jQuery(popup_overlay + ', ' + popup_btn).on('click', function () {
|
439 |
jQuery(popup_body).fadeOut('fast');
|
440 |
jQuery(popup_overlay).fadeOut('fast');
|
463 |
jQuery(this).removeAttr('checked');
|
464 |
}
|
465 |
});
|
466 |
+
gawd_hidden_input();
|
467 |
});
|
468 |
+
gawd_hidden_input();
|
469 |
});
|
470 |
|
471 |
jQuery("." + remove_excluded).on('click', function () {
|
472 |
+
var find = jQuery(this).closest('.time_wrap').find("." + excluded_data).html();
|
473 |
jQuery(this).closest('div').remove();
|
474 |
|
475 |
jQuery(popup_body + " .gawd_table input[type='checkbox']:checked").each(function () {
|
477 |
jQuery(this).removeAttr('checked');
|
478 |
}
|
479 |
});
|
480 |
+
|
481 |
+
gawd_hidden_input();
|
482 |
});
|
483 |
|
484 |
+
function gawd_hidden_input() {
|
485 |
+
var elements = [];
|
486 |
+
jQuery(popup_body + " .gawd_table input[type='checkbox']:checked").each(function () {
|
487 |
+
elements.push(jQuery(this).val());
|
488 |
+
});
|
489 |
|
490 |
+
jQuery(hidden_input).val(elements.join());
|
491 |
+
}
|
492 |
}
|
493 |
|
494 |
+
exclude_popup('gawd_exclude_users_popup_overlay', 'gawd_exclude_users_popup', 'gawd_exclude_users_popup_btn', 'exclude_users', 'gawd_add_users', 'excluded_items', 'remove_excluded_user', 'excluded_username', 'gawd_excluded_users_list');
|
495 |
+
exclude_popup('gawd_exclude_roles_popup_overlay', 'gawd_exclude_roles_popup', 'gawd_exclude_roles_popup_btn', 'exclude_roles', 'gawd_add_roles', 'excluded_roles', 'remove_excluded_role', 'excluded_role', 'gawd_excluded_roles_list');
|
496 |
});
|
497 |
|
498 |
function gawd_save_settings() {
|
library/file-generators/gawd-csv-generator-class.php
ADDED
@@ -0,0 +1,400 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: mher
|
5 |
+
* Date: 6/10/18
|
6 |
+
* Time: 2:07 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
include_once 'gawd-file-generator-class.php';
|
10 |
+
|
11 |
+
class GAWD_csv_file_generator extends GAWD_file_generator {
|
12 |
+
|
13 |
+
private $metrics = array();
|
14 |
+
private $dimention = "";
|
15 |
+
private $data;
|
16 |
+
|
17 |
+
private $compare_metrics = array();
|
18 |
+
private $compare_dimention = "";
|
19 |
+
private $compare_data;
|
20 |
+
|
21 |
+
private $site_title = "";
|
22 |
+
private $date_text = "";
|
23 |
+
private $menu_name = "";
|
24 |
+
private $columns = array();
|
25 |
+
private $sec_filter_metrics = array(
|
26 |
+
"Avg Session Duration",
|
27 |
+
"Avg Page Load Time",
|
28 |
+
"Avg Redirection Time",
|
29 |
+
"Avg Server Response Time",
|
30 |
+
"Avg Page Download Time",
|
31 |
+
'Avg Time On Page',
|
32 |
+
);
|
33 |
+
|
34 |
+
private $calc_percent_metrics = array(
|
35 |
+
"Sessions",
|
36 |
+
"Users",
|
37 |
+
"Pageviews",
|
38 |
+
"Unique Pageviews",
|
39 |
+
"Entrances",
|
40 |
+
"New Users",
|
41 |
+
"Transactions"
|
42 |
+
);
|
43 |
+
|
44 |
+
private $add_percent_metrics = array(
|
45 |
+
"Percent New Sessions",
|
46 |
+
"Bounce Rate",
|
47 |
+
"Exit Rate",
|
48 |
+
"Transactions Per Session"
|
49 |
+
);
|
50 |
+
|
51 |
+
public function __construct(){
|
52 |
+
$file_name = GAWD_helper::get_unique_string() . '.csv';
|
53 |
+
parent::__construct($file_name);
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function file_put_content(){
|
57 |
+
|
58 |
+
echo "\xEF\xBB\xBF";
|
59 |
+
|
60 |
+
if(!empty($this->site_title)) {
|
61 |
+
fputcsv($this->output, array($this->site_title), ',');
|
62 |
+
}
|
63 |
+
|
64 |
+
$line2 = (!empty($this->menu_name)) ? $this->menu_name : "";
|
65 |
+
|
66 |
+
if(!empty($this->date_text)) {
|
67 |
+
$line2 .= " (" . $this->date_text . ")";
|
68 |
+
}
|
69 |
+
|
70 |
+
if(!empty($line2)) {
|
71 |
+
fputcsv($this->output, array($line2), ',');
|
72 |
+
fputcsv($this->output, array(""), ',');
|
73 |
+
}
|
74 |
+
|
75 |
+
|
76 |
+
foreach($this->columns as $column) {
|
77 |
+
fputcsv($this->output, $column, ',');
|
78 |
+
}
|
79 |
+
|
80 |
+
}
|
81 |
+
|
82 |
+
|
83 |
+
public function parse_data($data, $args, $compare_data = null, $compare_args = null, $compare_by){
|
84 |
+
|
85 |
+
$this->data = $data;
|
86 |
+
$this->metrics = $this->get_metric($args);
|
87 |
+
|
88 |
+
if(strpos($args['gawd_data']['dimension'], 'dimension') === false) {
|
89 |
+
$this->dimention = $this->get_dimention($args);
|
90 |
+
} else {
|
91 |
+
$this->is_custom_dimention = true;
|
92 |
+
$this->dimention = "custom";
|
93 |
+
|
94 |
+
$custom_dim_metrics = array('No');
|
95 |
+
if(!empty($this->data['chart_data'])) {
|
96 |
+
|
97 |
+
|
98 |
+
$custom_dim_metrics = array_merge($custom_dim_metrics, $this->metrics);
|
99 |
+
|
100 |
+
foreach($this->data['chart_data'][0] as $metric => $val) {
|
101 |
+
if(!in_array($metric, $custom_dim_metrics)) {
|
102 |
+
$custom_dim_metrics[] = $metric;
|
103 |
+
}
|
104 |
+
}
|
105 |
+
|
106 |
+
}
|
107 |
+
|
108 |
+
$this->metrics = $custom_dim_metrics;
|
109 |
+
}
|
110 |
+
|
111 |
+
$this->date_text = $args['gawd_data']['start_date'] . ' - ' . $args['gawd_data']['end_date'];
|
112 |
+
|
113 |
+
if($compare_data !== null) {
|
114 |
+
if($compare_by === "metric") {
|
115 |
+
$this->compare_metrics = $this->get_metric($compare_args);
|
116 |
+
} else {
|
117 |
+
$this->compare_metrics = $this->metrics;
|
118 |
+
}
|
119 |
+
|
120 |
+
$this->compare_dimention = $this->get_dimention($compare_args);
|
121 |
+
$this->compare_data = $compare_data;
|
122 |
+
|
123 |
+
if(isset($compare_args['gawd_data']['start_date']) && isset($compare_args['gawd_data']['end_date'])) {
|
124 |
+
$this->date_text .= ' -compare- ' . $compare_args['gawd_data']['start_date'] . ' - ' . $compare_args['gawd_data']['end_date'];
|
125 |
+
}
|
126 |
+
}
|
127 |
+
|
128 |
+
if($this->dimention === 'Page Path' || $this->dimention === "Landing Page Path") {
|
129 |
+
$this->set_site_content_columns();
|
130 |
+
} elseif($this->dimention === "custom") {
|
131 |
+
$this->set_custom_dimention_columns();
|
132 |
+
} elseif($compare_data === null) {
|
133 |
+
$this->set_columns();
|
134 |
+
} else {
|
135 |
+
$this->set_columns_with_compare_data();
|
136 |
+
}
|
137 |
+
|
138 |
+
}
|
139 |
+
|
140 |
+
private function set_custom_dimention_columns(){
|
141 |
+
$titles = $this->metrics;
|
142 |
+
|
143 |
+
$columns = array($titles);
|
144 |
+
|
145 |
+
foreach($this->data['chart_data'] as $data) {
|
146 |
+
$columns[] = $this->get_row_values($data, array(), $this->metrics, "", false);
|
147 |
+
}
|
148 |
+
|
149 |
+
$this->columns = $columns;
|
150 |
+
}
|
151 |
+
|
152 |
+
private function set_columns(){
|
153 |
+
$titles = array('No', $this->dimention);
|
154 |
+
$titles = array_merge($titles, $this->metrics);
|
155 |
+
|
156 |
+
$columns = array($titles);
|
157 |
+
|
158 |
+
foreach($this->data['chart_data'] as $data) {
|
159 |
+
$columns[] = $this->get_row_values($data, $this->data['data_sum'], $this->metrics, $this->dimention, true);
|
160 |
+
}
|
161 |
+
|
162 |
+
$this->columns = $columns;
|
163 |
+
}
|
164 |
+
|
165 |
+
private function set_columns_with_compare_data(){
|
166 |
+
|
167 |
+
$titles = array(
|
168 |
+
'No',
|
169 |
+
$this->dimention,
|
170 |
+
($this->dimention === $this->compare_dimention) ? $this->dimention . ' compare' : $this->compare_dimention
|
171 |
+
);
|
172 |
+
|
173 |
+
$titles = array_merge($titles, $this->metrics);
|
174 |
+
foreach($this->compare_metrics as $compare_metric) {
|
175 |
+
$titles[] = (in_array($compare_metric, $this->metrics)) ? $compare_metric . ' compare' : $compare_metric;
|
176 |
+
}
|
177 |
+
|
178 |
+
$columns = array($titles);
|
179 |
+
|
180 |
+
$data = $this->data['chart_data'];
|
181 |
+
$compare_data = $this->compare_data['chart_data'];
|
182 |
+
|
183 |
+
$length = (count($data) > count($compare_data)) ? count($data) : count($compare_data);
|
184 |
+
|
185 |
+
for($i = 0; $i < $length; $i++) {
|
186 |
+
|
187 |
+
$rows = $compare_rows = array("", "");
|
188 |
+
|
189 |
+
if(isset($data[$i])) {
|
190 |
+
$rows = $this->get_row_values($data[$i], $this->data['data_sum'], $this->metrics, $this->dimention);
|
191 |
+
}
|
192 |
+
|
193 |
+
if(isset($compare_data[$i])) {
|
194 |
+
$compare_rows = $this->get_row_values($compare_data[$i], $this->compare_data['data_sum'], $this->compare_metrics, $this->compare_dimention);
|
195 |
+
}
|
196 |
+
|
197 |
+
$columns[] = array(
|
198 |
+
$i + 1,
|
199 |
+
$rows[0],
|
200 |
+
$compare_rows[0],
|
201 |
+
$rows[1],
|
202 |
+
$compare_rows[1]
|
203 |
+
);
|
204 |
+
|
205 |
+
}
|
206 |
+
|
207 |
+
$this->columns = $columns;
|
208 |
+
}
|
209 |
+
|
210 |
+
private function get_row_values($data, $data_sum, $metrics, $dimention, $num = false){
|
211 |
+
|
212 |
+
$col = array();
|
213 |
+
|
214 |
+
if($num === true) {
|
215 |
+
$col[] = $data['No'];
|
216 |
+
}
|
217 |
+
if(!empty($dimention)) {
|
218 |
+
$col[] = $data[$dimention];
|
219 |
+
}
|
220 |
+
|
221 |
+
foreach($metrics as $metric) {
|
222 |
+
|
223 |
+
if(!isset($data[$metric])) {
|
224 |
+
$col[] = "";
|
225 |
+
continue;
|
226 |
+
}
|
227 |
+
|
228 |
+
if(in_array($metric, $this->sec_filter_metrics)) {
|
229 |
+
|
230 |
+
$col[] = $this->sec_to_normal($data[$metric]);
|
231 |
+
|
232 |
+
} else if(in_array($metric, $this->calc_percent_metrics) && isset($data_sum[$metric])) {
|
233 |
+
|
234 |
+
$sum_val = floatval($data_sum[$metric]);
|
235 |
+
if($sum_val != 0) {
|
236 |
+
$percent = ($data[$metric] / $sum_val) * 100;
|
237 |
+
$percent = round($percent, 2);
|
238 |
+
} else {
|
239 |
+
$percent = 0;
|
240 |
+
}
|
241 |
+
$col[] = $data[$metric] . '(' . $percent . '%)';
|
242 |
+
|
243 |
+
} else if(in_array($metric, $this->add_percent_metrics)) {
|
244 |
+
|
245 |
+
$col[] = round($data[$metric], 2) . '%';
|
246 |
+
|
247 |
+
} else {
|
248 |
+
|
249 |
+
if($metric === "Pageviews Per Session") {
|
250 |
+
|
251 |
+
$col[] = round($data[$metric], 3);
|
252 |
+
|
253 |
+
} else {
|
254 |
+
|
255 |
+
$col[] = $data[$metric];
|
256 |
+
|
257 |
+
}
|
258 |
+
|
259 |
+
}
|
260 |
+
|
261 |
+
}
|
262 |
+
|
263 |
+
return $col;
|
264 |
+
}
|
265 |
+
|
266 |
+
private function set_site_content_columns(){
|
267 |
+
if($this->dimention === 'Page Path') {
|
268 |
+
$titles = array(
|
269 |
+
'No', 'Page Path', 'Pageviews', 'Unique Pageviews',
|
270 |
+
'Avg Time On Page', 'Entrances', 'Bounce Rate',
|
271 |
+
'Exit Rate', 'Page Value', 'Avg Page Load Time'
|
272 |
+
);
|
273 |
+
} else {
|
274 |
+
//$this->dimention === "Landing Page Path"
|
275 |
+
$titles = array(
|
276 |
+
'No', 'Landing Page', 'Sessions', 'Percent New Sessions',
|
277 |
+
'New Users', 'Bounce Rate', 'Pageviews Per Session',
|
278 |
+
'Avg Session Duration', 'Transactions', 'Transaction Revenue', 'Transactions Per Session'
|
279 |
+
);
|
280 |
+
}
|
281 |
+
|
282 |
+
|
283 |
+
$columns = array($titles);
|
284 |
+
foreach($this->data['chart_data'] as $data) {
|
285 |
+
|
286 |
+
$col = array();
|
287 |
+
foreach($titles as $t) {
|
288 |
+
|
289 |
+
if(in_array($t, $this->sec_filter_metrics)) {
|
290 |
+
$col[] = $this->sec_to_normal($data[$t]);
|
291 |
+
continue;
|
292 |
+
}
|
293 |
+
|
294 |
+
if(in_array($t, $this->calc_percent_metrics)) {
|
295 |
+
|
296 |
+
$sum_val = floatval($this->data['data_sum'][$t]);
|
297 |
+
if($sum_val != 0) {
|
298 |
+
$percent = ($data[$t] / $this->data['data_sum'][$t]) * 100;
|
299 |
+
$percent = round($percent, 2);
|
300 |
+
} else {
|
301 |
+
$percent = 0;
|
302 |
+
}
|
303 |
+
$col[] = $data[$t] . '(' . $percent . '%)';
|
304 |
+
continue;
|
305 |
+
}
|
306 |
+
|
307 |
+
if(in_array($t, $this->add_percent_metrics)) {
|
308 |
+
$col[] = round($data[$t], 2) . '%';
|
309 |
+
continue;
|
310 |
+
}
|
311 |
+
|
312 |
+
if($t === 'Page Value' || $t === 'Transaction Revenue') {
|
313 |
+
|
314 |
+
$sum_val = floatval($this->data['data_sum'][$t]);
|
315 |
+
if($sum_val != 0) {
|
316 |
+
$percent = ($data[$t] / $sum_val) * 100;
|
317 |
+
} else {
|
318 |
+
$percent = 0;
|
319 |
+
}
|
320 |
+
|
321 |
+
$col[] = "$" . round(floatval($data[$t]), 2) . "(" . $percent . "%)";
|
322 |
+
continue;
|
323 |
+
}
|
324 |
+
|
325 |
+
if($t === "Pageviews Per Session") {
|
326 |
+
$col[] = round($data[$t], 3);
|
327 |
+
continue;
|
328 |
+
}
|
329 |
+
|
330 |
+
$col[] = $data[$t];
|
331 |
+
}
|
332 |
+
$columns[] = $col;
|
333 |
+
|
334 |
+
}
|
335 |
+
|
336 |
+
$this->columns = $columns;
|
337 |
+
}
|
338 |
+
|
339 |
+
private function get_metric($args){
|
340 |
+
if(!(isset($args['gawd_data']['metric'][0]))) {
|
341 |
+
return 'Sessions';
|
342 |
+
}
|
343 |
+
|
344 |
+
$metrics = array();
|
345 |
+
foreach($args['gawd_data']['metric'] as $metric_name) {
|
346 |
+
|
347 |
+
$metric = str_replace('ga:', '', $metric_name);
|
348 |
+
$metric = preg_replace_callback('/([A-Z])/', array($this, 'regex_callback'), $metric);
|
349 |
+
$metric = ucfirst($metric);
|
350 |
+
|
351 |
+
$metrics[] = $metric;
|
352 |
+
}
|
353 |
+
|
354 |
+
return $metrics;
|
355 |
+
}
|
356 |
+
|
357 |
+
private function get_dimention($args){
|
358 |
+
|
359 |
+
if(!(isset($args['gawd_data']['dimension']))) {
|
360 |
+
return 'Date';
|
361 |
+
}
|
362 |
+
|
363 |
+
$dim = preg_replace_callback('/([A-Z])/', array($this, 'regex_callback'), $args['gawd_data']['dimension']);
|
364 |
+
$dim = ucfirst($dim);
|
365 |
+
|
366 |
+
if($dim === 'Site Speed' || $dim === "Goals") {
|
367 |
+
$dim = 'Date';
|
368 |
+
}
|
369 |
+
|
370 |
+
if(!empty($args['gawd_data']['filter_type']) && $dim === 'Date') {
|
371 |
+
$dim = ucfirst($args['gawd_data']['filter_type']);
|
372 |
+
}
|
373 |
+
|
374 |
+
return $dim;
|
375 |
+
}
|
376 |
+
|
377 |
+
public function regex_callback($matches){
|
378 |
+
return " " . $matches[0];
|
379 |
+
}
|
380 |
+
|
381 |
+
public function set_site_title($site_title){
|
382 |
+
$this->site_title = $site_title;
|
383 |
+
}
|
384 |
+
|
385 |
+
public function set_menu_name($menu_name){
|
386 |
+
$this->menu_name = $menu_name;
|
387 |
+
}
|
388 |
+
|
389 |
+
protected function sec_to_normal($data){
|
390 |
+
if(strpos($data, ':') !== false) {
|
391 |
+
return $data;
|
392 |
+
}
|
393 |
+
$data = ceil(floatval($data));
|
394 |
+
$hours = strlen(floor($data / 3600)) < 2 ? '0' . floor($data / 3600) : floor($data / 3600);
|
395 |
+
$mins = strlen(floor($data / 60 % 60)) < 2 ? '0' . floor($data / 60 % 60) : floor($data / 60 % 60);
|
396 |
+
$secs = strlen(ceil($data % 60)) < 2 ? '0' . ceil($data % 60) : ceil($data % 60);
|
397 |
+
return $data = $hours . ':' . $mins . ':' . $secs;
|
398 |
+
}
|
399 |
+
|
400 |
+
}
|
library/file-generators/gawd-file-generator-class.php
ADDED
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: mher
|
5 |
+
* Date: 6/10/18
|
6 |
+
* Time: 2:07 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
abstract class GAWD_file_generator {
|
10 |
+
|
11 |
+
protected $file_name;
|
12 |
+
protected $gawd_upload_dir;
|
13 |
+
protected $file_dir;
|
14 |
+
protected $file_url;
|
15 |
+
protected $output;
|
16 |
+
|
17 |
+
abstract protected function file_put_content();
|
18 |
+
|
19 |
+
public function __construct($file_name){
|
20 |
+
$this->file_name = $file_name;
|
21 |
+
|
22 |
+
$upload_dir = wp_get_upload_dir();
|
23 |
+
$this->gawd_upload_dir = $upload_dir['basedir'] . '/wd-google-analytics/export/';
|
24 |
+
$this->file_dir = $this->gawd_upload_dir . $this->file_name;
|
25 |
+
$this->file_url = $upload_dir['baseurl'] . '/wd-google-analytics/export/' . $this->file_name;
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
public function generate(){
|
30 |
+
|
31 |
+
if($this->check_gawd_dir() === false) {
|
32 |
+
GAWD_logs::add('failed_to_create_directory', 'Failed to create directory ' . $this->gawd_upload_dir);
|
33 |
+
return false;
|
34 |
+
}
|
35 |
+
|
36 |
+
$this->create_file();
|
37 |
+
|
38 |
+
|
39 |
+
return true;
|
40 |
+
|
41 |
+
}
|
42 |
+
|
43 |
+
private function create_file(){
|
44 |
+
$this->output = fopen($this->file_dir, "w");
|
45 |
+
|
46 |
+
$this->file_put_content();
|
47 |
+
|
48 |
+
@fclose($this->output);
|
49 |
+
}
|
50 |
+
|
51 |
+
private function check_gawd_dir(){
|
52 |
+
|
53 |
+
if(is_dir($this->gawd_upload_dir)) {
|
54 |
+
return true;
|
55 |
+
}
|
56 |
+
|
57 |
+
if(mkdir($this->gawd_upload_dir, 0777, true) === true) {
|
58 |
+
return true;
|
59 |
+
}
|
60 |
+
|
61 |
+
return false;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function get_file_name(){
|
65 |
+
return $this->file_name;
|
66 |
+
}
|
67 |
+
|
68 |
+
public function get_file_url(){
|
69 |
+
return $this->file_url;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function get_file_dir(){
|
73 |
+
return $this->file_dir;
|
74 |
+
}
|
75 |
+
|
76 |
+
}
|
library/gawd-alert-class.php
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: mher
|
5 |
+
* Date: 6/17/18
|
6 |
+
* Time: 3:05 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
class GAWD_alert {
|
10 |
+
|
11 |
+
private $alert_data;
|
12 |
+
private $date_range = 'Today';
|
13 |
+
|
14 |
+
public function __construct($alert_data){
|
15 |
+
$this->alert_data = $alert_data;
|
16 |
+
}
|
17 |
+
|
18 |
+
public function add_email_data_to_POST(){
|
19 |
+
|
20 |
+
$_POST['security'] = wp_create_nonce('gawd_admin_page_nonce');
|
21 |
+
$_POST['menu_name'] = '';
|
22 |
+
$_POST['compare_by'] = 'metric';
|
23 |
+
$_POST['action'] = 'gawd_send_email';
|
24 |
+
|
25 |
+
|
26 |
+
if($this->alert_data['period'] == 'daily') {
|
27 |
+
$this->date_range = 'Today';
|
28 |
+
} else if($this->alert_data['period'] == 'gawd_weekly') {
|
29 |
+
$this->date_range = 'Last 7 Days';
|
30 |
+
} else if($this->alert_data['period'] == 'gawd_monthly') {
|
31 |
+
$this->date_range = 'This Month';
|
32 |
+
}
|
33 |
+
|
34 |
+
$request_last_args = $this->get_request_last_args();
|
35 |
+
$info = array('date_ranges' => array($this->date_range, 'Previous period'));
|
36 |
+
$email_info = $this->get_email_info();
|
37 |
+
|
38 |
+
$_POST['gawd_request_last_args'] = $request_last_args;
|
39 |
+
$_POST['info'] = $info;
|
40 |
+
$_POST['email_info'] = $email_info;
|
41 |
+
}
|
42 |
+
|
43 |
+
private function get_request_last_args(){
|
44 |
+
|
45 |
+
$gawd_request_last_args = array(
|
46 |
+
'gawd_ajax' => '1',
|
47 |
+
'gawd_nonce' => '',
|
48 |
+
'gawd_nonce_data' => array(
|
49 |
+
'action' => 'gawd_analytics_pages',
|
50 |
+
'nonce' => wp_create_nonce('gawd_analytics_pages'),
|
51 |
+
),
|
52 |
+
'gawd_action' => 'gawd_show_data',
|
53 |
+
'gawd_data' => array(
|
54 |
+
'start_date' => null,
|
55 |
+
'end_date' => null,
|
56 |
+
'metric' => array('ga:' . $this->alert_data['metric']),
|
57 |
+
'dimension' => 'date',
|
58 |
+
'security' => '',
|
59 |
+
'filter_type' => '',
|
60 |
+
'custom' => '',
|
61 |
+
'timezone' => intval(get_option('gmt_offset'))
|
62 |
+
));
|
63 |
+
|
64 |
+
return $gawd_request_last_args;
|
65 |
+
}
|
66 |
+
|
67 |
+
private function get_email_info(){
|
68 |
+
$email_info = array(
|
69 |
+
'period' => 'daily',
|
70 |
+
'email_from' => get_option('admin_email'),
|
71 |
+
'email_to' => $this->alert_data['emails'],
|
72 |
+
'subject' => 'Google Analytics alert',
|
73 |
+
'content' => '',
|
74 |
+
'week_day' => '',
|
75 |
+
'month_day' => '1',
|
76 |
+
'email_time' => '00:00',
|
77 |
+
'view_id' => $this->alert_data['alert_view'],
|
78 |
+
'other_info' => array(
|
79 |
+
'condition_data' => $this->get_condition_data(),
|
80 |
+
'alert_data' => $this->alert_data
|
81 |
+
)
|
82 |
+
);
|
83 |
+
|
84 |
+
return $email_info;
|
85 |
+
}
|
86 |
+
|
87 |
+
private function get_condition_data(){
|
88 |
+
$condition = array(
|
89 |
+
'when' => $this->alert_data['metric'],
|
90 |
+
'condition' => $this->alert_data['condition'],
|
91 |
+
'value' => $this->alert_data['value']
|
92 |
+
);
|
93 |
+
|
94 |
+
return $condition;
|
95 |
+
}
|
96 |
+
}
|
library/gawd-custom-ajax-class.php
CHANGED
@@ -14,16 +14,17 @@ class GAWD_custom_ajax_class {
|
|
14 |
private $user_data = array();
|
15 |
private $expiration_time = array();
|
16 |
private $gawd_google = null;
|
17 |
-
private $
|
|
|
18 |
|
19 |
|
20 |
public function __construct(){
|
21 |
$get_last_viewed_profile = GAWD_helper::get_last_viewed_profile();
|
22 |
-
|
23 |
|
24 |
-
ini_set('display_errors', 1);
|
25 |
-
ini_set('display_startup_errors', 1);
|
26 |
-
error_reporting(E_ALL);
|
27 |
|
28 |
$this->set_expiration_time();
|
29 |
$this->user_data = get_option('gawd_user_data');
|
@@ -46,6 +47,8 @@ class GAWD_custom_ajax_class {
|
|
46 |
$this->send_response(false, 'no_permission');
|
47 |
}
|
48 |
|
|
|
|
|
49 |
switch($this->action) {
|
50 |
case 'get_auth_url':
|
51 |
$this->get_auth_url();
|
@@ -69,7 +72,7 @@ class GAWD_custom_ajax_class {
|
|
69 |
$this->refresh_user_info();
|
70 |
break;
|
71 |
case 'gawd_show_data':
|
72 |
-
$this->gawd_show_data();
|
73 |
break;
|
74 |
case 'gawd_show_post_page_data':
|
75 |
$this->gawd_show_page_post_data();
|
@@ -175,7 +178,6 @@ class GAWD_custom_ajax_class {
|
|
175 |
if(empty($properties)) {
|
176 |
$this->send_response(false, 'no_properties', 'There are no properties.');
|
177 |
}
|
178 |
-
|
179 |
$profiles = $this->get_profiles(true);
|
180 |
if(empty($profiles)) {
|
181 |
$this->send_response(false, 'no_profile', 'There are no profiles.');
|
@@ -577,7 +579,7 @@ class GAWD_custom_ajax_class {
|
|
577 |
$transient_key = $this->get_transient_key("chart-data", array($dimension, $start_date, $end_date, $timezone));
|
578 |
|
579 |
$grid_data_transient = get_transient($transient_key);
|
580 |
-
if($grid_data_transient) {
|
581 |
$grid_data = $grid_data_transient;
|
582 |
} else {
|
583 |
$grid_data = $this->gawd_google->get_page_data($dimension, $start_date, $end_date, $timezone);
|
@@ -592,7 +594,7 @@ class GAWD_custom_ajax_class {
|
|
592 |
$transient_key = $this->get_transient_key("chart-data", array('date', $start_date, $end_date, $timezone, $same_dimension));
|
593 |
|
594 |
$goal_data_transient = get_transient($transient_key);
|
595 |
-
if($goal_data_transient
|
596 |
$goal_data = $goal_data_transient;
|
597 |
} else {
|
598 |
$goal_data = $this->gawd_google->get_goal_data('date', $start_date, $end_date, $timezone, $same_dimension);
|
@@ -606,7 +608,7 @@ class GAWD_custom_ajax_class {
|
|
606 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $country_filter, $geo_type, $timezone));
|
607 |
|
608 |
$chart_data_transient = get_transient($transient_key);
|
609 |
-
if($chart_data_transient) {
|
610 |
$chart_data = $chart_data_transient;
|
611 |
} else {
|
612 |
$chart_data = $this->gawd_google->get_country_data($metric, $dimension, $start_date, $end_date, $country_filter, $geo_type, $timezone);
|
@@ -621,7 +623,7 @@ class GAWD_custom_ajax_class {
|
|
621 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
622 |
|
623 |
$chart_data_transient = get_transient($transient_key);
|
624 |
-
if($chart_data_transient) {
|
625 |
$chart_data = $chart_data_transient;
|
626 |
} else {
|
627 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
@@ -636,7 +638,7 @@ class GAWD_custom_ajax_class {
|
|
636 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
637 |
|
638 |
$siteSpeed_transient = get_transient($transient_key);
|
639 |
-
if($siteSpeed_transient) {
|
640 |
$chart_data = $siteSpeed_transient;
|
641 |
} else {
|
642 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
@@ -650,7 +652,7 @@ class GAWD_custom_ajax_class {
|
|
650 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
651 |
|
652 |
$chart_data_transient = get_transient($transient_key);
|
653 |
-
if($chart_data_transient) {
|
654 |
$chart_data = $chart_data_transient;
|
655 |
} else {
|
656 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
@@ -997,6 +999,9 @@ class GAWD_custom_ajax_class {
|
|
997 |
$this->action = (!empty($_REQUEST['gawd_action'])) ? $_REQUEST['gawd_action'] : "";
|
998 |
$this->request_data = (!empty($_REQUEST['gawd_data'])) ? $_REQUEST['gawd_data'] : array();
|
999 |
$this->nonce_data = (!empty($_REQUEST['gawd_nonce_data'])) ? $_REQUEST['gawd_nonce_data'] : array();
|
|
|
|
|
|
|
1000 |
}
|
1001 |
|
1002 |
private function check_permission(){
|
@@ -1049,10 +1054,17 @@ class GAWD_custom_ajax_class {
|
|
1049 |
return false;
|
1050 |
}
|
1051 |
} else if($this->nonce_data['action'] === 'gawd_analytics_pages') {
|
|
|
1052 |
$gawd_permissions = isset($gawd_settings['gawd_backend_roles']) ? $gawd_settings['gawd_backend_roles'] : array();
|
1053 |
if(
|
|
|
1054 |
wp_verify_nonce($this->nonce_data['nonce'], 'gawd_analytics_pages') !== false &&
|
1055 |
GAWD_helper::check_permission($gawd_permissions)
|
|
|
|
|
|
|
|
|
|
|
1056 |
) {
|
1057 |
return true;
|
1058 |
} else {
|
@@ -1142,6 +1154,9 @@ class GAWD_custom_ajax_class {
|
|
1142 |
} else if(!empty($this->user_data['access_token'])) {
|
1143 |
$this->gawd_google = new GAWD_google($this->user_data['access_token'], $this->user_data['refresh_token'], $this);
|
1144 |
}
|
|
|
|
|
|
|
1145 |
}
|
1146 |
|
1147 |
}
|
14 |
private $user_data = array();
|
15 |
private $expiration_time = array();
|
16 |
private $gawd_google = null;
|
17 |
+
private $view_id = null;
|
18 |
+
//private $gawd_last_viewed_profile = null;
|
19 |
|
20 |
|
21 |
public function __construct(){
|
22 |
$get_last_viewed_profile = GAWD_helper::get_last_viewed_profile();
|
23 |
+
//$this->gawd_last_viewed_profile = $get_last_viewed_profile["profile_id"];
|
24 |
|
25 |
+
// ini_set('display_errors', 1);
|
26 |
+
// ini_set('display_startup_errors', 1);
|
27 |
+
// error_reporting(E_ALL);
|
28 |
|
29 |
$this->set_expiration_time();
|
30 |
$this->user_data = get_option('gawd_user_data');
|
47 |
$this->send_response(false, 'no_permission');
|
48 |
}
|
49 |
|
50 |
+
$reset = (isset($_REQUEST['gawd_refresh_report_cache']));
|
51 |
+
|
52 |
switch($this->action) {
|
53 |
case 'get_auth_url':
|
54 |
$this->get_auth_url();
|
72 |
$this->refresh_user_info();
|
73 |
break;
|
74 |
case 'gawd_show_data':
|
75 |
+
$this->gawd_show_data($reset);
|
76 |
break;
|
77 |
case 'gawd_show_post_page_data':
|
78 |
$this->gawd_show_page_post_data();
|
178 |
if(empty($properties)) {
|
179 |
$this->send_response(false, 'no_properties', 'There are no properties.');
|
180 |
}
|
|
|
181 |
$profiles = $this->get_profiles(true);
|
182 |
if(empty($profiles)) {
|
183 |
$this->send_response(false, 'no_profile', 'There are no profiles.');
|
579 |
$transient_key = $this->get_transient_key("chart-data", array($dimension, $start_date, $end_date, $timezone));
|
580 |
|
581 |
$grid_data_transient = get_transient($transient_key);
|
582 |
+
if($grid_data_transient && $reset === false) {
|
583 |
$grid_data = $grid_data_transient;
|
584 |
} else {
|
585 |
$grid_data = $this->gawd_google->get_page_data($dimension, $start_date, $end_date, $timezone);
|
594 |
$transient_key = $this->get_transient_key("chart-data", array('date', $start_date, $end_date, $timezone, $same_dimension));
|
595 |
|
596 |
$goal_data_transient = get_transient($transient_key);
|
597 |
+
if($goal_data_transient && $reset === false) {
|
598 |
$goal_data = $goal_data_transient;
|
599 |
} else {
|
600 |
$goal_data = $this->gawd_google->get_goal_data('date', $start_date, $end_date, $timezone, $same_dimension);
|
608 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $country_filter, $geo_type, $timezone));
|
609 |
|
610 |
$chart_data_transient = get_transient($transient_key);
|
611 |
+
if($chart_data_transient && $reset === false) {
|
612 |
$chart_data = $chart_data_transient;
|
613 |
} else {
|
614 |
$chart_data = $this->gawd_google->get_country_data($metric, $dimension, $start_date, $end_date, $country_filter, $geo_type, $timezone);
|
623 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
624 |
|
625 |
$chart_data_transient = get_transient($transient_key);
|
626 |
+
if($chart_data_transient && $reset === false) {
|
627 |
$chart_data = $chart_data_transient;
|
628 |
} else {
|
629 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
638 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
639 |
|
640 |
$siteSpeed_transient = get_transient($transient_key);
|
641 |
+
if($siteSpeed_transient && $reset === false) {
|
642 |
$chart_data = $siteSpeed_transient;
|
643 |
} else {
|
644 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
652 |
$transient_key = $this->get_transient_key("chart-data", array($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension));
|
653 |
|
654 |
$chart_data_transient = get_transient($transient_key);
|
655 |
+
if($chart_data_transient && $reset === false) {
|
656 |
$chart_data = $chart_data_transient;
|
657 |
} else {
|
658 |
$chart_data = $this->gawd_google->get_data($metric, $dimension, $start_date, $end_date, $filter_type, $timezone, $same_dimension);
|
999 |
$this->action = (!empty($_REQUEST['gawd_action'])) ? $_REQUEST['gawd_action'] : "";
|
1000 |
$this->request_data = (!empty($_REQUEST['gawd_data'])) ? $_REQUEST['gawd_data'] : array();
|
1001 |
$this->nonce_data = (!empty($_REQUEST['gawd_nonce_data'])) ? $_REQUEST['gawd_nonce_data'] : array();
|
1002 |
+
if(isset($_REQUEST['gawd_view_id'])){
|
1003 |
+
$this->view_id = $_REQUEST['gawd_view_id'];
|
1004 |
+
}
|
1005 |
}
|
1006 |
|
1007 |
private function check_permission(){
|
1054 |
return false;
|
1055 |
}
|
1056 |
} else if($this->nonce_data['action'] === 'gawd_analytics_pages') {
|
1057 |
+
|
1058 |
$gawd_permissions = isset($gawd_settings['gawd_backend_roles']) ? $gawd_settings['gawd_backend_roles'] : array();
|
1059 |
if(
|
1060 |
+
(
|
1061 |
wp_verify_nonce($this->nonce_data['nonce'], 'gawd_analytics_pages') !== false &&
|
1062 |
GAWD_helper::check_permission($gawd_permissions)
|
1063 |
+
) ||
|
1064 |
+
(
|
1065 |
+
isset($_REQUEST['gawd_cron_token']) &&
|
1066 |
+
GAWD_helper::check_cron_token($_REQUEST['gawd_cron_token'])
|
1067 |
+
)
|
1068 |
) {
|
1069 |
return true;
|
1070 |
} else {
|
1154 |
} else if(!empty($this->user_data['access_token'])) {
|
1155 |
$this->gawd_google = new GAWD_google($this->user_data['access_token'], $this->user_data['refresh_token'], $this);
|
1156 |
}
|
1157 |
+
if($this->view_id !== null) {
|
1158 |
+
$this->gawd_google->set_profile_info($this->view_id);
|
1159 |
+
}
|
1160 |
}
|
1161 |
|
1162 |
}
|
library/gawd-email-class.php
ADDED
@@ -0,0 +1,392 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Created by PhpStorm.
|
4 |
+
* User: mher
|
5 |
+
* Date: 6/17/18
|
6 |
+
* Time: 3:05 PM
|
7 |
+
*/
|
8 |
+
|
9 |
+
class GAWD_email {
|
10 |
+
|
11 |
+
private $period = "once";
|
12 |
+
private $email_from = "";
|
13 |
+
private $email_to = "";
|
14 |
+
private $subject = "";
|
15 |
+
private $content = "";
|
16 |
+
private $week_day = "";
|
17 |
+
private $month_day = "1";
|
18 |
+
private $time = "00:00";
|
19 |
+
private $view_id = "";
|
20 |
+
private $error = array();
|
21 |
+
private $attachments = array();
|
22 |
+
private $other_info = array();
|
23 |
+
private $ajax_response = array();
|
24 |
+
|
25 |
+
public function __construct(){
|
26 |
+
|
27 |
+
}
|
28 |
+
|
29 |
+
public function parse_ajax_data(){
|
30 |
+
|
31 |
+
$response = array(
|
32 |
+
'success' => false,
|
33 |
+
'error' => array('code' => 'something_went_wrong', 'msg' => 'something went wrong.'),
|
34 |
+
'data' => ''
|
35 |
+
);
|
36 |
+
|
37 |
+
if(empty($_POST['email_info']['email_to'])) {
|
38 |
+
$this->set_error('no_email_to', 'No email');
|
39 |
+
return false;
|
40 |
+
}
|
41 |
+
|
42 |
+
$this->email_to = $_POST['email_info']['email_to'];
|
43 |
+
$this->email_from = (isset($_POST['email_info']['email_from'])) ? $_POST['email_info']['email_from'] : get_option('admin_email');
|
44 |
+
|
45 |
+
if(empty($this->email_from)) {
|
46 |
+
$this->set_error('no_email_from', 'No email');
|
47 |
+
return false;
|
48 |
+
}
|
49 |
+
|
50 |
+
|
51 |
+
$this->period = (isset($_POST['email_info']['period'])) ? $_POST['email_info']['period'] : "once";
|
52 |
+
$this->subject = (isset($_POST['email_info']['subject'])) ? $_POST['email_info']['subject'] : "";
|
53 |
+
$this->content = (isset($_POST['email_info']['content'])) ? $_POST['email_info']['content'] : "";
|
54 |
+
$this->week_day = (isset($_POST['email_info']['week_day'])) ? $_POST['email_info']['week_day'] : "";
|
55 |
+
$this->month_day = (isset($_POST['email_info']['month_day'])) ? $_POST['email_info']['month_day'] : "1";
|
56 |
+
$this->time = (isset($_POST['email_info']['email_time'])) ? $_POST['email_info']['email_time'] : "00:00";
|
57 |
+
$this->view_id = (isset($_POST['email_info']['view_id'])) ? $_POST['email_info']['view_id'] : "";
|
58 |
+
$this->other_info = (isset($_POST['email_info']['other_info'])) ? $_POST['email_info']['other_info'] : array();
|
59 |
+
|
60 |
+
|
61 |
+
return true;
|
62 |
+
}
|
63 |
+
|
64 |
+
public function set_email_info($info){
|
65 |
+
|
66 |
+
$this->email_to = $info['email_to'];
|
67 |
+
$this->email_from = $info['email_from'];
|
68 |
+
$this->period = $info['period'];
|
69 |
+
$this->subject = $info['subject'];
|
70 |
+
$this->content = $info['content'];
|
71 |
+
$this->week_day = $info['week_day'];
|
72 |
+
$this->month_day = $info['month_day'];
|
73 |
+
$this->time = $info['time'];
|
74 |
+
$this->view_id = $info['view_id'];
|
75 |
+
$this->other_info = (isset($info['other_info'])) ? $info['other_info'] : array();
|
76 |
+
|
77 |
+
}
|
78 |
+
|
79 |
+
public function check_condition($email_info){
|
80 |
+
|
81 |
+
if(!isset($this->other_info['condition_data'])) {
|
82 |
+
return true;
|
83 |
+
}
|
84 |
+
|
85 |
+
$response = GAWD_helper::ajax_request($email_info['ajax_args']['last_args'], $this->view_id);
|
86 |
+
if($response === false) {
|
87 |
+
return false;
|
88 |
+
}
|
89 |
+
|
90 |
+
switch($this->other_info['condition_data']['when']) {
|
91 |
+
case 'sessions':
|
92 |
+
$metric = 'Sessions';
|
93 |
+
$value_type = 'int';
|
94 |
+
break;
|
95 |
+
case 'users':
|
96 |
+
$metric = 'Users';
|
97 |
+
$value_type = 'int';
|
98 |
+
break;
|
99 |
+
case 'bounceRate':
|
100 |
+
$metric = 'Bounce Rate';
|
101 |
+
$value_type = 'float';
|
102 |
+
break;
|
103 |
+
case 'avgSessionDuration':
|
104 |
+
$metric = 'Avg Session Duration';
|
105 |
+
$value_type = 'float';
|
106 |
+
break;
|
107 |
+
default:
|
108 |
+
$metric = 'Sessions';
|
109 |
+
$value_type = 'int';
|
110 |
+
break;
|
111 |
+
}
|
112 |
+
|
113 |
+
if(!isset($response['data_sum'][$metric])) {
|
114 |
+
return false;
|
115 |
+
}
|
116 |
+
|
117 |
+
$this->ajax_response = $response;
|
118 |
+
|
119 |
+
$real_value = ($value_type == 'int') ? intval($response['data_sum'][$metric]) : floatval($response['data_sum'][$metric]);
|
120 |
+
$condition_value = ($value_type == 'int') ? intval($this->other_info['condition_data']['value']) : floatval($this->other_info['condition_data']['value']);
|
121 |
+
|
122 |
+
if($this->other_info['condition_data']['condition'] == 'less') {
|
123 |
+
return ($real_value < $condition_value);
|
124 |
+
} else {
|
125 |
+
return ($real_value > $condition_value);
|
126 |
+
}
|
127 |
+
|
128 |
+
}
|
129 |
+
|
130 |
+
public function add_content(){
|
131 |
+
if(!empty($this->content)) {
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
if(isset($this->other_info['alert_data'])) {
|
136 |
+
|
137 |
+
|
138 |
+
$alert = $this->other_info['alert_data'];
|
139 |
+
$condition = $alert['condition'] == 'less' ? ' is less then ' : ' greater than ';
|
140 |
+
$metric = $alert['metric'];
|
141 |
+
|
142 |
+
if($metric == 'bounceRate') {
|
143 |
+
$metric = 'Bounce Rate';
|
144 |
+
} else if($metric == 'avgSessionDuration') {
|
145 |
+
$metric = 'Avg Session Duration';
|
146 |
+
} else {
|
147 |
+
$metric = ucfirst($metric);
|
148 |
+
}
|
149 |
+
|
150 |
+
$period = (strpos($alert['period'], 'gawd') > -1) ? substr($alert['period'], 5) : $alert['period'];
|
151 |
+
$period = ucfirst($period);
|
152 |
+
|
153 |
+
$this->content = 'Name: ' . $alert['name'] . "<br/>";
|
154 |
+
$this->content .= 'Period: ' . $period . "<br/>";
|
155 |
+
$this->content .= 'Condition: ' . $metric . $condition . $alert['value'] . "<br/>";
|
156 |
+
$this->content .= 'View: ' . $alert['alert_view_name'];
|
157 |
+
|
158 |
+
}
|
159 |
+
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @param $csv GAWD_csv_file_generator
|
164 |
+
* */
|
165 |
+
public function attach_file($csv){
|
166 |
+
$this->attachments[] = $csv->get_file_dir();
|
167 |
+
}
|
168 |
+
|
169 |
+
public function send_mail(){
|
170 |
+
$headers = array(
|
171 |
+
'From: <' . $this->email_from . '>',
|
172 |
+
'content-type: text/html'
|
173 |
+
);
|
174 |
+
$content = (!empty($this->content)) ? $this->content : " ";
|
175 |
+
return wp_mail($this->email_to, $this->subject, $content, $headers, $this->attachments);
|
176 |
+
}
|
177 |
+
|
178 |
+
public function save_email_info($ajax_args, $csv){
|
179 |
+
|
180 |
+
$gawd_emails_info = get_option('gawd_emails_info');
|
181 |
+
if(!is_array($gawd_emails_info)) {
|
182 |
+
$gawd_emails_info = array();
|
183 |
+
}
|
184 |
+
|
185 |
+
$id = uniqid();
|
186 |
+
$email_info = array(
|
187 |
+
'email_info' => $this->get_email_info(),
|
188 |
+
'ajax_args' => $ajax_args,
|
189 |
+
'creation_date' => time(),
|
190 |
+
'next_date' => null
|
191 |
+
);
|
192 |
+
$email_info = self::calc_next_date($email_info);
|
193 |
+
|
194 |
+
if($email_info['ajax_args']['last_args']['gawd_data']['start_date'] === null) {
|
195 |
+
$email_info = self::calc_date_range($email_info);
|
196 |
+
}
|
197 |
+
|
198 |
+
$gawd_emails_info[$id] = $email_info;
|
199 |
+
|
200 |
+
update_option('gawd_emails_info', $gawd_emails_info);
|
201 |
+
self::set_new_scheduled();
|
202 |
+
}
|
203 |
+
|
204 |
+
|
205 |
+
private function set_error($code, $msg){
|
206 |
+
$this->error = array(
|
207 |
+
'code' => $code,
|
208 |
+
'msg' => $msg
|
209 |
+
);
|
210 |
+
}
|
211 |
+
|
212 |
+
public function get_error(){
|
213 |
+
return $this->error;
|
214 |
+
}
|
215 |
+
|
216 |
+
public function get_period(){
|
217 |
+
return $this->period;
|
218 |
+
}
|
219 |
+
|
220 |
+
public function get_email_info(){
|
221 |
+
$info = array(
|
222 |
+
'period' => $this->period,
|
223 |
+
'email_from' => $this->email_from,
|
224 |
+
'email_to' => $this->email_to,
|
225 |
+
'subject' => $this->subject,
|
226 |
+
'content' => $this->content,
|
227 |
+
'week_day' => $this->week_day,
|
228 |
+
'month_day' => $this->month_day,
|
229 |
+
'time' => $this->time,
|
230 |
+
'view_id' => $this->view_id,
|
231 |
+
'other_info' => $this->other_info,
|
232 |
+
);
|
233 |
+
|
234 |
+
return $info;
|
235 |
+
}
|
236 |
+
|
237 |
+
public function get_ajax_response(){
|
238 |
+
return $this->ajax_response;
|
239 |
+
}
|
240 |
+
|
241 |
+
|
242 |
+
public static function calc_next_date($email_info){
|
243 |
+
|
244 |
+
$last_date = ($email_info['next_date'] === null) ? $email_info['creation_date'] : $email_info['next_date'];
|
245 |
+
$time = (!empty($email_info['email_info']['time'])) ? $email_info['email_info']['time'] : "00:00";
|
246 |
+
$now = time();
|
247 |
+
$next_date = null;
|
248 |
+
|
249 |
+
switch($email_info['email_info']['period']) {
|
250 |
+
case "daily":
|
251 |
+
$next_date = (date('Y-m-d', $last_date) . ' ' . $time);
|
252 |
+
|
253 |
+
if($now > strtotime($next_date)) {
|
254 |
+
$next_date = strtotime($next_date . ' +1 day');
|
255 |
+
} else {
|
256 |
+
$next_date = strtotime($next_date);
|
257 |
+
}
|
258 |
+
|
259 |
+
break;
|
260 |
+
case "gawd_weekly":
|
261 |
+
|
262 |
+
$week_day = (!empty($email_info['email_info']['week_day'])) ? $email_info['email_info']['week_day'] : date('l');
|
263 |
+
$next_date = (date('Y-m-d', strtotime("this " . $week_day, $last_date)) . ' ' . $time);
|
264 |
+
|
265 |
+
if($now > strtotime($next_date)) {
|
266 |
+
$next_date = strtotime((date('Y-m-d', strtotime("next " . $week_day)) . ' ' . $time));
|
267 |
+
} else {
|
268 |
+
$next_date = strtotime($next_date);
|
269 |
+
}
|
270 |
+
|
271 |
+
break;
|
272 |
+
case "gawd_monthly":
|
273 |
+
|
274 |
+
$week_day = $email_info['email_info']['month_day'];
|
275 |
+
if($week_day !== 'last') {
|
276 |
+
$next_date = (date('Y-m-' . $week_day, $last_date)) . ' ' . $time;
|
277 |
+
|
278 |
+
if($now > strtotime($next_date)) {
|
279 |
+
$next_date = strtotime($next_date . ' +1 month');
|
280 |
+
} else {
|
281 |
+
$next_date = strtotime($next_date);
|
282 |
+
}
|
283 |
+
|
284 |
+
} else {
|
285 |
+
$next_date = (date('Y-m-t', $last_date)) . ' ' . $time;
|
286 |
+
|
287 |
+
if($now > strtotime($next_date)) {
|
288 |
+
$next_date = (date('Y-m-1', $last_date));
|
289 |
+
$next_date = strtotime($next_date . ' +1 month');
|
290 |
+
$next_date = (date('Y-m-t', $next_date)) . ' ' . $time;
|
291 |
+
} else {
|
292 |
+
$next_date = strtotime($next_date);
|
293 |
+
}
|
294 |
+
|
295 |
+
}
|
296 |
+
|
297 |
+
|
298 |
+
break;
|
299 |
+
}
|
300 |
+
|
301 |
+
$email_info['next_date'] = $next_date;
|
302 |
+
|
303 |
+
return $email_info;
|
304 |
+
}
|
305 |
+
|
306 |
+
public static function calc_date_range($email_info){
|
307 |
+
|
308 |
+
$date_range = 'Last 30 Days';
|
309 |
+
// $compare_date_range = 'Previous period';
|
310 |
+
if(isset($email_info['ajax_args']['info']['date_ranges'])) {
|
311 |
+
$date_range = trim($email_info['ajax_args']['info']['date_ranges'][0]);
|
312 |
+
// $compare_date_range = trim($email_info['ajax_args']['info']['date_ranges'][1]);
|
313 |
+
}
|
314 |
+
|
315 |
+
$next_date = $email_info['next_date'];
|
316 |
+
$date = date('Y-m-d', $next_date);
|
317 |
+
|
318 |
+
switch($date_range) {
|
319 |
+
case "Today";
|
320 |
+
$start_date = date('Y-m-d', time());
|
321 |
+
$end_date = date('Y-m-d', $next_date);
|
322 |
+
break;
|
323 |
+
case "Yesterday";
|
324 |
+
$start_date = date('Y-m-d', strtotime($date . " -1 days"));
|
325 |
+
$end_date = $start_date;
|
326 |
+
break;
|
327 |
+
case "Last 7 Days";
|
328 |
+
$end_date = date('Y-m-d', strtotime($date . " -1 days"));
|
329 |
+
$start_date = date('Y-m-d', strtotime($end_date . " -6 days"));
|
330 |
+
break;
|
331 |
+
case "Last Week";
|
332 |
+
$end_date = date("Y-m-d", strtotime($date . " previous saturday"));
|
333 |
+
$start_date = date('Y-m-d', strtotime($end_date . " -6 days"));
|
334 |
+
break;
|
335 |
+
case "This Month";
|
336 |
+
$start_date = date('Y-m-01', $next_date);
|
337 |
+
$end_date = date('Y-m-d', $next_date);
|
338 |
+
break;
|
339 |
+
case "Last Month";
|
340 |
+
$start_date = date("Y-m-d", strtotime($date . " first day of previous month"));
|
341 |
+
$end_date = date("Y-m-d", strtotime($date . " last day of previous month"));
|
342 |
+
break;
|
343 |
+
default:
|
344 |
+
//Last 30 Days
|
345 |
+
$end_date = date('Y-m-d', strtotime($date . " -1 days"));
|
346 |
+
$start_date = date('Y-m-d', strtotime($end_date . " -29 days"));
|
347 |
+
break;
|
348 |
+
}
|
349 |
+
|
350 |
+
$email_info['ajax_args']['last_args']['gawd_data']['start_date'] = $start_date;
|
351 |
+
$email_info['ajax_args']['last_args']['gawd_data']['end_date'] = $end_date;
|
352 |
+
|
353 |
+
return $email_info;
|
354 |
+
}
|
355 |
+
|
356 |
+
public static function calc_next_mail_date($emails_info){
|
357 |
+
|
358 |
+
if(empty($emails_info)) {
|
359 |
+
return time() + (24 * 60 * 60);
|
360 |
+
}
|
361 |
+
|
362 |
+
$min = null;
|
363 |
+
foreach($emails_info as $info) {
|
364 |
+
if($min === null) {
|
365 |
+
$min = $info['next_date'];
|
366 |
+
continue;
|
367 |
+
}
|
368 |
+
|
369 |
+
if($info['next_date'] < $min) {
|
370 |
+
$min = $info['next_date'];
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return $min;
|
375 |
+
}
|
376 |
+
|
377 |
+
public static function delete_email($index){
|
378 |
+
$gawd_emails_info = get_option('gawd_emails_info');
|
379 |
+
unset($gawd_emails_info[$index]);
|
380 |
+
update_option('gawd_emails_info', $gawd_emails_info);
|
381 |
+
self::set_new_scheduled();
|
382 |
+
}
|
383 |
+
|
384 |
+
public static function set_new_scheduled(){
|
385 |
+
$next_mail_date = GAWD_email::calc_next_mail_date(get_option('gawd_emails_info'));
|
386 |
+
update_option('gawd_next_mail_date', $next_mail_date);
|
387 |
+
|
388 |
+
wp_clear_scheduled_hook('gawd_email_scheduled');
|
389 |
+
wp_schedule_single_event($next_mail_date, 'gawd_email_scheduled');
|
390 |
+
}
|
391 |
+
|
392 |
+
}
|
library/gawd-google-class.php
CHANGED
@@ -8,6 +8,7 @@ class GAWD_google {
|
|
8 |
private $google_client = null;
|
9 |
private $analytics_member = null;
|
10 |
private $exception_handler;
|
|
|
11 |
|
12 |
private $gawd_last_viewed_profile_data = array();
|
13 |
|
@@ -395,25 +396,6 @@ class GAWD_google {
|
|
395 |
return array();
|
396 |
}
|
397 |
|
398 |
-
public function get_profile_id($get_default = true){
|
399 |
-
$gawd_last_viewed_profile = GAWD_helper::get_last_viewed_profile();
|
400 |
-
|
401 |
-
if(!$get_default && isset($gawd_last_viewed_profile['profile_id'])) {
|
402 |
-
return $gawd_last_viewed_profile['profile_id'];
|
403 |
-
}
|
404 |
-
|
405 |
-
return (isset($this->user_data['profile_id']) ? $this->user_data['profile_id'] : null);
|
406 |
-
}
|
407 |
-
|
408 |
-
|
409 |
-
public function get_profile_accountId(){
|
410 |
-
return isset($this->user_data['account_id']) ? $this->user_data['account_id'] : '';
|
411 |
-
}
|
412 |
-
|
413 |
-
public function get_profile_webPropertyId(){
|
414 |
-
return (isset($this->user_data['property_id']) ? $this->user_data['property_id'] : null);
|
415 |
-
}
|
416 |
-
|
417 |
public function add_management_goal($gawd_goal_profile, $goal_id, $gawd_goal_type, $gawd_goal_name, $gawd_goal_comparison = "GREATER_THAN", $gawd_goal_value, $url_case_sensitve = 'false'){
|
418 |
|
419 |
$goal = new Google_Service_Analytics_Goal();
|
@@ -1297,18 +1279,6 @@ class GAWD_google {
|
|
1297 |
$this->user_data = ($user_data !== null) ? $user_data : get_option('gawd_user_data');
|
1298 |
}
|
1299 |
|
1300 |
-
public function get_default_account_id(){
|
1301 |
-
return $this->user_data['account_id'];
|
1302 |
-
}
|
1303 |
-
|
1304 |
-
public function get_default_web_property_id(){
|
1305 |
-
return $this->user_data['property_id'];
|
1306 |
-
}
|
1307 |
-
|
1308 |
-
public function get_account_id(){
|
1309 |
-
return $this->user_data['account_id'];
|
1310 |
-
}
|
1311 |
-
|
1312 |
private function check_metric_compare($metrics1, $metrics2){
|
1313 |
$metrics_array = explode(',', $metrics2);
|
1314 |
|
@@ -1321,6 +1291,7 @@ class GAWD_google {
|
|
1321 |
}
|
1322 |
|
1323 |
private function sort_ga_data($rows, $duration){
|
|
|
1324 |
if($rows === null){
|
1325 |
return $rows;
|
1326 |
}
|
@@ -1394,4 +1365,47 @@ class GAWD_google {
|
|
1394 |
return ($a[0] < $b[0]) ? -1 : 1;
|
1395 |
}
|
1396 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1397 |
}
|
8 |
private $google_client = null;
|
9 |
private $analytics_member = null;
|
10 |
private $exception_handler;
|
11 |
+
private $profile_info = null;
|
12 |
|
13 |
private $gawd_last_viewed_profile_data = array();
|
14 |
|
396 |
return array();
|
397 |
}
|
398 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
399 |
public function add_management_goal($gawd_goal_profile, $goal_id, $gawd_goal_type, $gawd_goal_name, $gawd_goal_comparison = "GREATER_THAN", $gawd_goal_value, $url_case_sensitve = 'false'){
|
400 |
|
401 |
$goal = new Google_Service_Analytics_Goal();
|
1279 |
$this->user_data = ($user_data !== null) ? $user_data : get_option('gawd_user_data');
|
1280 |
}
|
1281 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1282 |
private function check_metric_compare($metrics1, $metrics2){
|
1283 |
$metrics_array = explode(',', $metrics2);
|
1284 |
|
1291 |
}
|
1292 |
|
1293 |
private function sort_ga_data($rows, $duration){
|
1294 |
+
|
1295 |
if($rows === null){
|
1296 |
return $rows;
|
1297 |
}
|
1365 |
return ($a[0] < $b[0]) ? -1 : 1;
|
1366 |
}
|
1367 |
|
1368 |
+
|
1369 |
+
public function get_default_account_id(){
|
1370 |
+
return $this->user_data['account_id'];
|
1371 |
+
}
|
1372 |
+
|
1373 |
+
public function get_default_web_property_id(){
|
1374 |
+
return $this->user_data['property_id'];
|
1375 |
+
}
|
1376 |
+
|
1377 |
+
public function get_account_id(){
|
1378 |
+
return $this->user_data['account_id'];
|
1379 |
+
}
|
1380 |
+
|
1381 |
+
public function get_profile_id($get_default = true){
|
1382 |
+
$gawd_last_viewed_profile = GAWD_helper::get_last_viewed_profile();
|
1383 |
+
|
1384 |
+
if($get_default === false) {
|
1385 |
+
if(isset($this->profile_info['view_id'])) {
|
1386 |
+
return $this->profile_info['view_id'];
|
1387 |
+
} else if(isset($gawd_last_viewed_profile['profile_id'])) {
|
1388 |
+
return $gawd_last_viewed_profile['profile_id'];
|
1389 |
+
}
|
1390 |
+
|
1391 |
+
}
|
1392 |
+
|
1393 |
+
return (isset($this->user_data['profile_id']) ? $this->user_data['profile_id'] : null);
|
1394 |
+
}
|
1395 |
+
|
1396 |
+
|
1397 |
+
public function get_profile_accountId(){
|
1398 |
+
return isset($this->user_data['account_id']) ? $this->user_data['account_id'] : '';
|
1399 |
+
}
|
1400 |
+
|
1401 |
+
public function get_profile_webPropertyId(){
|
1402 |
+
return (isset($this->user_data['property_id']) ? $this->user_data['property_id'] : null);
|
1403 |
+
}
|
1404 |
+
|
1405 |
+
public function set_profile_info($view_id){
|
1406 |
+
$this->profile_info = array(
|
1407 |
+
'view_id' => $view_id
|
1408 |
+
);
|
1409 |
+
}
|
1410 |
+
|
1411 |
}
|
library/gawd-helper-class.php
CHANGED
@@ -85,6 +85,20 @@ class GAWD_helper {
|
|
85 |
return $property_profiles;
|
86 |
}
|
87 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
public static function get_property($property_id){
|
89 |
$properties = self::get_properties();
|
90 |
foreach($properties as $property) {
|
@@ -448,6 +462,103 @@ class GAWD_helper {
|
|
448 |
}
|
449 |
}
|
450 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
451 |
|
452 |
public static function print_pro_popup(){ ?>
|
453 |
<div class="gawd_pro_popup_overlay" style="display: none;"></div>
|
85 |
return $property_profiles;
|
86 |
}
|
87 |
|
88 |
+
public static function get_account_name_by_profile_id($profile_id, $reset = false){
|
89 |
+
$profiles = self::get_profiles($reset);
|
90 |
+
|
91 |
+
foreach($profiles as $name => $profile) {
|
92 |
+
foreach($profile as $pr) {
|
93 |
+
if($pr['id'] === $profile_id){
|
94 |
+
return $name;
|
95 |
+
}
|
96 |
+
}
|
97 |
+
}
|
98 |
+
|
99 |
+
return "";
|
100 |
+
}
|
101 |
+
|
102 |
public static function get_property($property_id){
|
103 |
$properties = self::get_properties();
|
104 |
foreach($properties as $property) {
|
462 |
}
|
463 |
}
|
464 |
|
465 |
+
public static function ajax_request($args, $view_id = null){
|
466 |
+
|
467 |
+
$custom_ajax_nonce = wp_create_nonce('gawd_custom_ajax');
|
468 |
+
$gawd_ajax_nonce_data = array(
|
469 |
+
'action' => $args['gawd_nonce_data']['action'],
|
470 |
+
'nonce' => wp_create_nonce($args['gawd_nonce_data']['action']),
|
471 |
+
);
|
472 |
+
|
473 |
+
$args['gawd_nonce'] = $custom_ajax_nonce;
|
474 |
+
$args['gawd_nonce_data'] = $gawd_ajax_nonce_data;
|
475 |
+
if($view_id !== null) {
|
476 |
+
$args['gawd_view_id'] = $view_id;
|
477 |
+
}
|
478 |
+
|
479 |
+
|
480 |
+
$cron_token = self::add_cron_token();
|
481 |
+
$args['gawd_cron_token'] = $cron_token;
|
482 |
+
$args['gawd_refresh_report_cache'] = '1';
|
483 |
+
|
484 |
+
$args = array(
|
485 |
+
'body' => $args,
|
486 |
+
'cookies' => $_COOKIE
|
487 |
+
);
|
488 |
+
|
489 |
+
$data = wp_remote_get(admin_url('admin-ajax.php'), $args);
|
490 |
+
|
491 |
+
self::remove_cron_token($cron_token);
|
492 |
+
|
493 |
+
if(is_wp_error($data)) {
|
494 |
+
GAWD_logs::add('ajax_request_' . uniqid(), json_encode($data->get_error_messages()));
|
495 |
+
return false;
|
496 |
+
}
|
497 |
+
|
498 |
+
$data = json_decode($data['body'], true);
|
499 |
+
if(!is_array($data)) {
|
500 |
+
GAWD_logs::add('ajax_request_' . uniqid(), 'json decode error.');
|
501 |
+
return false;
|
502 |
+
}
|
503 |
+
|
504 |
+
if(!isset($data['success']) || $data['success'] === false) {
|
505 |
+
GAWD_logs::add('ajax_request_' . uniqid(), 'wrong ajax request.'.json_encode($data));
|
506 |
+
return false;
|
507 |
+
}
|
508 |
+
|
509 |
+
if(!isset($data['data']['gawd_reports_data'])) {
|
510 |
+
GAWD_logs::add('ajax_request_' . uniqid(), 'something went wrong.');
|
511 |
+
return false;
|
512 |
+
}
|
513 |
+
|
514 |
+
return json_decode($data['data']['gawd_reports_data'], true);
|
515 |
+
}
|
516 |
+
|
517 |
+
public static function get_unique_string(){
|
518 |
+
return md5(uniqid('gawd') . time());
|
519 |
+
}
|
520 |
+
|
521 |
+
private static function add_cron_token(){
|
522 |
+
$gawd_cron_tokens = get_option('gawd_cron_tokens');
|
523 |
+
if(!is_array($gawd_cron_tokens)) {
|
524 |
+
$gawd_cron_tokens = array();
|
525 |
+
}
|
526 |
+
|
527 |
+
$token = self::get_unique_string();
|
528 |
+
$gawd_cron_tokens[] = $token;
|
529 |
+
update_option('gawd_cron_tokens', $gawd_cron_tokens);
|
530 |
+
return $token;
|
531 |
+
}
|
532 |
+
|
533 |
+
public static function check_cron_token($token){
|
534 |
+
$gawd_cron_tokens = get_option('gawd_cron_tokens');
|
535 |
+
if(is_array($gawd_cron_tokens) && in_array($token, $gawd_cron_tokens)) {
|
536 |
+
return true;
|
537 |
+
}
|
538 |
+
return false;
|
539 |
+
}
|
540 |
+
|
541 |
+
public static function remove_cron_token($token){
|
542 |
+
$gawd_cron_tokens = get_option('gawd_cron_tokens');
|
543 |
+
|
544 |
+
if(is_array($gawd_cron_tokens)) {
|
545 |
+
|
546 |
+
$index = null;
|
547 |
+
foreach($gawd_cron_tokens as $k => $gawd_cron_token) {
|
548 |
+
|
549 |
+
if($token === $gawd_cron_token) {
|
550 |
+
$index = $k;
|
551 |
+
break;
|
552 |
+
}
|
553 |
+
|
554 |
+
}
|
555 |
+
|
556 |
+
unset($gawd_cron_tokens[$index]);
|
557 |
+
update_option('gawd_cron_tokens', $gawd_cron_tokens);
|
558 |
+
|
559 |
+
}
|
560 |
+
|
561 |
+
}
|
562 |
|
563 |
public static function print_pro_popup(){ ?>
|
564 |
<div class="gawd_pro_popup_overlay" style="display: none;"></div>
|
library/gawd-save-settings-goals.php
CHANGED
@@ -9,20 +9,9 @@
|
|
9 |
function gawd_save_settings($post, &$custom_ajax){
|
10 |
$gawd_alert_remove = isset($post['gawd_alert_remove']) ? intval($post['gawd_alert_remove']) : false;
|
11 |
$gawd_menu_remove = isset($post['gawd_menu_remove']) ? intval($post['gawd_menu_remove']) : false;
|
12 |
-
$gawd_email_remove = isset($post['gawd_email_remove']) ? intval($post['gawd_email_remove']) : false;
|
13 |
$gawd_filter_remove = isset($post['gawd_filter_remove']) ? intval($post['gawd_filter_remove']) : false;
|
14 |
|
15 |
-
if($gawd_alert_remove) {
|
16 |
-
$all_alerts = get_option('gawd_alerts');
|
17 |
-
if($all_alerts) {
|
18 |
-
foreach($all_alerts as $alert) {
|
19 |
-
wp_unschedule_event(wp_next_scheduled('gawd_alert_' . $alert['period']), 'gawd_alert_' . $alert['period']);
|
20 |
-
}
|
21 |
-
unset($all_alerts[$gawd_alert_remove - 1]);
|
22 |
-
update_option('gawd_alerts', $all_alerts);
|
23 |
-
}
|
24 |
-
}
|
25 |
-
|
26 |
if($gawd_menu_remove) {
|
27 |
$all_menues = get_option('gawd_menu_for_user');
|
28 |
if($all_menues) {
|
@@ -31,16 +20,16 @@ function gawd_save_settings($post, &$custom_ajax){
|
|
31 |
}
|
32 |
}
|
33 |
|
34 |
-
if($gawd_email_remove) {
|
35 |
-
$all_emails = get_option('gawd_email');
|
36 |
-
if($all_emails) {
|
37 |
-
foreach($all_emails as $email) {
|
38 |
-
wp_unschedule_event(wp_next_scheduled('gawd_email_' . $email['period']), 'gawd_email_' . $email['period']);
|
39 |
-
}
|
40 |
-
unset($all_emails[$gawd_email_remove - 1]);
|
41 |
-
update_option('gawd_email', $all_emails);
|
42 |
-
}
|
43 |
-
}
|
44 |
|
45 |
if($gawd_filter_remove) {
|
46 |
$custom_ajax->delete_management_filter($gawd_filter_remove);
|
@@ -74,10 +63,7 @@ function gawd_save_settings($post, &$custom_ajax){
|
|
74 |
$alert_view_name = isset($post['alert_view_name']) ? sanitize_text_field($post['alert_view_name']) : '';
|
75 |
|
76 |
if($gawd_alert_name != '' && $gawd_alert_period != '' && $gawd_alert_metric != '' && $gawd_alert_condition != '' && $gawd_alert_value != '' && $gawd_alert_emails != '') {
|
77 |
-
|
78 |
-
if(empty($saved_alerts)) {
|
79 |
-
$saved_alerts = array();
|
80 |
-
}
|
81 |
|
82 |
$gawd_alert_options = array(
|
83 |
'name' => $gawd_alert_name,
|
@@ -85,23 +71,13 @@ function gawd_save_settings($post, &$custom_ajax){
|
|
85 |
'metric' => $gawd_alert_metric,
|
86 |
'condition' => $gawd_alert_condition,
|
87 |
'value' => $gawd_alert_value,
|
88 |
-
'creation_date' => date('Y-m-d'),
|
89 |
'emails' => $gawd_alert_emails,
|
90 |
'alert_view' => $gawd_alert_view,
|
91 |
'alert_view_name' => $alert_view_name
|
92 |
);
|
93 |
|
94 |
-
$
|
95 |
-
|
96 |
-
|
97 |
-
if($saved_alerts) {
|
98 |
-
foreach($saved_alerts as $alert) {
|
99 |
-
if(!wp_next_scheduled('gawd_alert_' . $alert['period'])) {
|
100 |
-
wp_schedule_event(time(), $alert['period'], 'gawd_alert_' . $alert['period']);
|
101 |
-
}
|
102 |
-
}
|
103 |
-
}
|
104 |
-
|
105 |
}
|
106 |
|
107 |
$gawd_pushover_name = isset($post['gawd_pushover_name']) ? sanitize_text_field($post['gawd_pushover_name']) : '';
|
@@ -340,8 +316,16 @@ function gawd_save_tracking($post, &$custom_ajax){
|
|
340 |
$gawd_settings['gawd_custom_dimension_Tags'] = $gawd_cd_Tags;
|
341 |
}
|
342 |
|
343 |
-
$gawd_excluded_roles =
|
344 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
345 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
346 |
$gawd_settings['gawd_anonymize'] = $gawd_anonymize;
|
347 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
9 |
function gawd_save_settings($post, &$custom_ajax){
|
10 |
$gawd_alert_remove = isset($post['gawd_alert_remove']) ? intval($post['gawd_alert_remove']) : false;
|
11 |
$gawd_menu_remove = isset($post['gawd_menu_remove']) ? intval($post['gawd_menu_remove']) : false;
|
12 |
+
// $gawd_email_remove = isset($post['gawd_email_remove']) ? intval($post['gawd_email_remove']) : false;
|
13 |
$gawd_filter_remove = isset($post['gawd_filter_remove']) ? intval($post['gawd_filter_remove']) : false;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
if($gawd_menu_remove) {
|
16 |
$all_menues = get_option('gawd_menu_for_user');
|
17 |
if($all_menues) {
|
20 |
}
|
21 |
}
|
22 |
|
23 |
+
// if($gawd_email_remove) {
|
24 |
+
// $all_emails = get_option('gawd_email');
|
25 |
+
// if($all_emails) {
|
26 |
+
// foreach($all_emails as $email) {
|
27 |
+
// wp_unschedule_event(wp_next_scheduled('gawd_email_' . $email['period']), 'gawd_email_' . $email['period']);
|
28 |
+
// }
|
29 |
+
// unset($all_emails[$gawd_email_remove - 1]);
|
30 |
+
// update_option('gawd_email', $all_emails);
|
31 |
+
// }
|
32 |
+
// }
|
33 |
|
34 |
if($gawd_filter_remove) {
|
35 |
$custom_ajax->delete_management_filter($gawd_filter_remove);
|
63 |
$alert_view_name = isset($post['alert_view_name']) ? sanitize_text_field($post['alert_view_name']) : '';
|
64 |
|
65 |
if($gawd_alert_name != '' && $gawd_alert_period != '' && $gawd_alert_metric != '' && $gawd_alert_condition != '' && $gawd_alert_value != '' && $gawd_alert_emails != '') {
|
66 |
+
|
|
|
|
|
|
|
67 |
|
68 |
$gawd_alert_options = array(
|
69 |
'name' => $gawd_alert_name,
|
71 |
'metric' => $gawd_alert_metric,
|
72 |
'condition' => $gawd_alert_condition,
|
73 |
'value' => $gawd_alert_value,
|
|
|
74 |
'emails' => $gawd_alert_emails,
|
75 |
'alert_view' => $gawd_alert_view,
|
76 |
'alert_view_name' => $alert_view_name
|
77 |
);
|
78 |
|
79 |
+
$gawd = GAWD::get_instance();
|
80 |
+
$gawd->save_alert($gawd_alert_options);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
$gawd_pushover_name = isset($post['gawd_pushover_name']) ? sanitize_text_field($post['gawd_pushover_name']) : '';
|
316 |
$gawd_settings['gawd_custom_dimension_Tags'] = $gawd_cd_Tags;
|
317 |
}
|
318 |
|
319 |
+
$gawd_excluded_roles = array();
|
320 |
+
if(!empty($post['gawd_excluded_roles_list'])) {
|
321 |
+
$gawd_excluded_roles = explode(',', $post['gawd_excluded_roles_list']);
|
322 |
+
}
|
323 |
+
|
324 |
+
$gawd_excluded_users = array();
|
325 |
+
if(!empty($post['gawd_excluded_users_list'])) {
|
326 |
+
$gawd_excluded_users = explode(',', $post['gawd_excluded_users_list']);
|
327 |
+
}
|
328 |
+
|
329 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
330 |
$gawd_settings['gawd_anonymize'] = $gawd_anonymize;
|
331 |
$gawd_settings['gawd_file_formats'] = $gawd_file_formats;
|
readme.txt
CHANGED
@@ -2,98 +2,96 @@
|
|
2 |
Contributors: webdorado,10web
|
3 |
Tags: google analytics, statistics, tracking, analytics dashboard, ga, google analytics dashboard, analytics, stats, googleanalytics, ecommerce tracking, custom reports, custom dimensions
|
4 |
Requires at least: 3.9
|
5 |
-
Tested up to:
|
6 |
-
Stable tag: 1.2.
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
-
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
## Benefits
|
26 |
-
|
27 |
-
* **Control** - With the wide range of the available data you can track and monitor everything on your website, from site audience and traffic, to ecommerce stats. You can also compare data for specific periods and see the progress you’ve made.
|
28 |
-
|
29 |
-
* **Improve your site performance and rankings** -Using the data from the reports you can significantly improve your site performance and help it get better rankings. Track your pageviews and offer content that your visitors actually like.
|
30 |
-
|
31 |
-
* **Centralized dashboard** – All your reports, including the custom analytics reports and Adsense, Adwords and eCommerce stats, are available from the plugin’s reporting page, right in your WordPress dashboard.
|
32 |
-
|
33 |
-
* **Comprehensive reports** - provides comprehensive colorful reports in charts and columns, which are easy to read and analyze. The reports can be exported to different file formats, or sent to multiple recipients via email.
|
34 |
-
|
35 |
-
* **Customization** - You can set data filters and tracking exclusions to filter out specific data or activities from specific users. Just track data that actually matters to you.
|
36 |
-
|
37 |
-
* **Minimal effort** – It will require you just a couple of clicks to set-up the analytics plugin, add the tracking code, and start tracking data.
|
38 |
-
|
39 |
-
* **Timely Support** - The team provides timely and effective support to all its users. We keep standards high and response time low.
|
40 |
-
|
41 |
|
42 |
-
|
43 |
-
|
44 |
-
**ANALYTICS DASHBOARD**
|
45 |
-
|
46 |
-
The overview report page in the plugin called “Analytics Dashboard”, allows users to quickly grasp general data of their website stats. The Analytics Dashboard gives provides real time information on site visitors, audience stats, including new and returning visitors, page views, session duration and more. You can also check out what browsers your visitors used and locations your visitors come from.
|
47 |
-
|
48 |
-
**METRIC COMPARISON**
|
49 |
|
50 |
-
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
**CUSTOM REPORTS** (_Premium version_)
|
57 |
|
58 |
-
You can configure custom reports on any metric and dimension of your choice, and view the relevant reports from the plugin’s reporting page. Custom reports can be set for tracking with any possible combinations of metric and dimension.
|
59 |
|
60 |
-
|
61 |
|
62 |
-
|
|
|
63 |
|
64 |
-
**
|
|
|
65 |
|
66 |
-
|
|
|
67 |
|
68 |
-
**
|
|
|
69 |
|
70 |
-
|
|
|
71 |
|
|
|
|
|
72 |
|
73 |
-
**
|
|
|
74 |
|
75 |
-
|
|
|
76 |
|
|
|
|
|
77 |
|
78 |
-
**
|
|
|
79 |
|
80 |
-
|
81 |
|
82 |
-
**USER AND ROLE PERMISSIONS**
|
83 |
|
84 |
-
|
|
|
|
|
85 |
|
|
|
|
|
86 |
|
87 |
-
**TRACKING EXCLUSIONS** (_Premium version_)
|
88 |
|
89 |
-
|
|
|
|
|
|
|
90 |
|
91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
|
93 |
-
You can get daily, weekly or monthly alerts and Pushover notifications about highest or lowest number of Sessions, Users, Bounces or Session Durations on your website.The alerts are easy to set up.
|
94 |
|
95 |
|
96 |
-
|
97 |
## SETTINGS/CUSTOMIZATION
|
98 |
|
99 |
_*Some customizations described here are available in Premium version. Please refer to premium features below._
|
@@ -105,24 +103,6 @@ For more advanced users, there are advanced setting options, to enable cross dom
|
|
105 |
Under the goals management tab you can set and configure different goal types,and track targeted activities.To configure custom reports you’ll need to choose the metric and the dimension you want to get a report for. It will appear under the reports section shortly.
|
106 |
There are many more features in the plugin that can help you dive deep into the statistics, monitor your site’s performance and actually improve it. To learn more, check out the plugin’s user guide.
|
107 |
|
108 |
-
## Premium version adds
|
109 |
-
|
110 |
-
|
111 |
-
* Analytics reports on Demographics, Interests, Geo, Behavior, Technology, Mobile, Site content, Site Speed, Events, Goals.
|
112 |
-
|
113 |
-
* Tracking Custom Dimensions: Logged in, Post type, Author, Category, Tags, Published Month, Published Year.
|
114 |
-
|
115 |
-
* Custom Reports with any possible configurations of metric and dimension.
|
116 |
-
|
117 |
-
* Six Ecommerce tracking reports based on: Time to Purchase, Transaction ID, Sales Performance, Product SKU, Product Category, Product Name.
|
118 |
-
|
119 |
-
* Link and track your Google AdSense and Google AdWords accounts.
|
120 |
-
|
121 |
-
* Alerts and Pushover notifications to monitor any changes in your website traffic.
|
122 |
-
|
123 |
-
* Set tracking exclusions based on WordPress roles and users.
|
124 |
-
|
125 |
-
|
126 |
= Privacy Notices =
|
127 |
|
128 |
WD Google Analytics plugin adds GA JS code to the site (optionally) and is used to get GA reports from admin area. It sends analytics data to Google. Whether it will send any personal data to Google, depends on how you set up your website. For example, do not expose emails or other personally identifiable information to Google via URLs. Do not send form submissions via analytics to Google. By default, all the IPs of visitors are anonymized. Personal data processing by Google is explained in their privacy policy https://policies.google.com/privacy. The plugin retrieves from Google and caches data of your GA account and analytics reports in WordPress site database to provide optimization. Reports data is stored in DB for some small period of time (less than 24h). Your GA account data is preserved in your website database as long as you decide to keep it. The plugin asks for your consent to collect site administrator’s email address and site URL to offer customer support, deals and discounts on premium products and more.
|
@@ -222,6 +202,11 @@ After toolbox opens, make sure all the necessary AdWords accounts are marked as
|
|
222 |
|
223 |
== Changelog ==
|
224 |
|
|
|
|
|
|
|
|
|
|
|
225 |
= 1.2.2 =
|
226 |
* Fixed: Use of deprecated function in PHP 7.2
|
227 |
* Fixed: Notices in custom reports page
|
2 |
Contributors: webdorado,10web
|
3 |
Tags: google analytics, statistics, tracking, analytics dashboard, ga, google analytics dashboard, analytics, stats, googleanalytics, ecommerce tracking, custom reports, custom dimensions
|
4 |
Requires at least: 3.9
|
5 |
+
Tested up to: 5.1
|
6 |
+
Stable tag: 1.2.3
|
7 |
License: GPLv2 or later
|
8 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
9 |
|
10 |
+
View and customize all Google Analytics reports directly in your WordPress dashboard.
|
11 |
|
12 |
== Description ==
|
13 |
|
14 |
+
View and customize all Google Analytics reports directly in your WordPress dashboard.
|
15 |
+
= Useful Links: =
|
16 |
+
|
17 |
+
[Live Demo](http://wpdemo.web-dorado.com/wp-admin/admin.php?page=gawd_analytics)
|
18 |
+
|
19 |
+
|
20 |
+
[Premium WD Google Analytics](https://web-dorado.com/products/wordpress-google-analytics-plugin.html)
|
21 |
+
|
22 |
+
|
23 |
+
[Special Offer for all Premium Plugins](https://web-dorado.com/wordpress-plugins-bundle.html)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
+
https://www.youtube.com/watch?v=n1f7ECVFNPI
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
|
27 |
+
Having a hard time customizing Google Analytics reports?
|
28 |
|
29 |
+
Need metrics that you can’t find in Google Analytics?
|
30 |
|
31 |
+
Are you tired of going to different websites for website management and stats overview?
|
32 |
|
|
|
33 |
|
|
|
34 |
|
35 |
+
== WD Google Analytics Features ==
|
36 |
|
37 |
+
**Get All Reports from Google Analytics**
|
38 |
+
All types of reports are available in your WordPress dashboard.
|
39 |
|
40 |
+
**Display Reports on Front-End**
|
41 |
+
Get key stats about posts displayed right on the page.
|
42 |
|
43 |
+
**Get E-Commerce Reports\***
|
44 |
+
See how conversions work and how much you earn online.
|
45 |
|
46 |
+
**Manage Goals**
|
47 |
+
Set goals on your WordPress dashboard and constantly manage them.
|
48 |
|
49 |
+
**Integrate Google Ads & AdSense**
|
50 |
+
Get data about ads on your website in the same dashboard.
|
51 |
|
52 |
+
**Customize Reports**
|
53 |
+
Select the metrics you want to see and choose how you want them displayed.
|
54 |
|
55 |
+
**Setup WordPress Dimensions\***
|
56 |
+
Add Tags, Use Types, Post Types, Categories, and Publication Date as custom dimensions.
|
57 |
|
58 |
+
**Receive Notifications and Alerts**
|
59 |
+
Get alerts and pushover notifications when selected metrics reach their highest or lowest points.
|
60 |
|
61 |
+
**Export in CSV and Send Emails**
|
62 |
+
Share reports via automated email and export them in CSV.
|
63 |
|
64 |
+
**Filter Tracked Data\***
|
65 |
+
Exclude certain user types, locations or IP addresses with custom tracking codes.
|
66 |
|
67 |
+
_\* Premium version only_
|
68 |
|
|
|
69 |
|
70 |
+
== Outstanding Customer Care ==
|
71 |
+
* Rapid response
|
72 |
+
We won’t make you wait more than a few hours.
|
73 |
|
74 |
+
* Quick issue resolution
|
75 |
+
We’ll resolve your issue within 24 hours.
|
76 |
|
|
|
77 |
|
78 |
+
== Customize Your Analytics ==
|
79 |
+
1. Buy Google Analytics Plugin
|
80 |
+
2. Login with your Google Account
|
81 |
+
3. Track your traffic
|
82 |
|
83 |
+
> **[Premium features](https://web-dorado.com/products/wordpress-google-analytics-plugin.html)**
|
84 |
+
>
|
85 |
+
> * Permissions for users/roles
|
86 |
+
> * Custom metrics and reports
|
87 |
+
> * E-commerce reports
|
88 |
+
> * Reports on Google AdWords and AdSense
|
89 |
+
> * Tracking filters for users/roles
|
90 |
+
> * Alerts
|
91 |
+
> * Priority support and updates
|
92 |
|
|
|
93 |
|
94 |
|
|
|
95 |
## SETTINGS/CUSTOMIZATION
|
96 |
|
97 |
_*Some customizations described here are available in Premium version. Please refer to premium features below._
|
103 |
Under the goals management tab you can set and configure different goal types,and track targeted activities.To configure custom reports you’ll need to choose the metric and the dimension you want to get a report for. It will appear under the reports section shortly.
|
104 |
There are many more features in the plugin that can help you dive deep into the statistics, monitor your site’s performance and actually improve it. To learn more, check out the plugin’s user guide.
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
= Privacy Notices =
|
107 |
|
108 |
WD Google Analytics plugin adds GA JS code to the site (optionally) and is used to get GA reports from admin area. It sends analytics data to Google. Whether it will send any personal data to Google, depends on how you set up your website. For example, do not expose emails or other personally identifiable information to Google via URLs. Do not send form submissions via analytics to Google. By default, all the IPs of visitors are anonymized. Personal data processing by Google is explained in their privacy policy https://policies.google.com/privacy. The plugin retrieves from Google and caches data of your GA account and analytics reports in WordPress site database to provide optimization. Reports data is stored in DB for some small period of time (less than 24h). Your GA account data is preserved in your website database as long as you decide to keep it. The plugin asks for your consent to collect site administrator’s email address and site URL to offer customer support, deals and discounts on premium products and more.
|
202 |
|
203 |
== Changelog ==
|
204 |
|
205 |
+
= 1.2.3 =
|
206 |
+
* Added: Alerts functionality
|
207 |
+
* Added: Emails functionality
|
208 |
+
* Fixed: Exclude tracking for user
|
209 |
+
|
210 |
= 1.2.2 =
|
211 |
* Fixed: Use of deprecated function in PHP 7.2
|
212 |
* Fixed: Notices in custom reports page
|