Version Description
(09.06.2017) =
This version has 3 bugs fixes.
Bug Fixed - When store admin clicks on the dismissible notice, the notice was not getting dismissed. This issue has been fixed.
Bug Fixed - The dismissible notice was not displaying the 'Allow' & 'No Thanks' button properly. This issue has been fixed.
Bug Fixed - The total Recovered amount was not tracked. This issue has been fixed.
Download this release
Release Info
| Developer | bhavik.kiri |
| Plugin | |
| Version | 3.9.3 |
| Comparing to | |
| See all releases | |
Code changes from version 3.8 to 3.9.3
- assets/images/site-logo-new.jpg +0 -0
- assets/js/wcal_ts_dismiss_notice.js +36 -0
- includes/classes/class-wcal-ts-tracker.php +656 -0
- includes/wcal_ts_tracking.php +59 -0
- readme.txt +58 -0
- woocommerce-ac.php +19 -1
assets/images/site-logo-new.jpg
ADDED
|
Binary file
|
assets/js/wcal_ts_dismiss_notice.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// Make notices dismissible
|
| 2 |
+
jQuery(document).ready( function() {
|
| 3 |
+
jQuery( '.notice.is-dismissible' ).each( function() {
|
| 4 |
+
|
| 5 |
+
//console.log (this.className);
|
| 6 |
+
var wcal_get_name = this.className;
|
| 7 |
+
if (wcal_get_name.indexOf('wcal-tracker') !== -1){
|
| 8 |
+
var $this = jQuery( this ),
|
| 9 |
+
$button = jQuery( '<button type="button" class="notice-dismiss"><span class="wcal screen-reader-text"></span></button>' ),
|
| 10 |
+
btnText = commonL10n.dismiss || '';
|
| 11 |
+
|
| 12 |
+
// Ensure plain text
|
| 13 |
+
$button.find( '.screen-reader-text' ).text( btnText );
|
| 14 |
+
|
| 15 |
+
$this.append( $button );
|
| 16 |
+
$button.on( 'click.notice-dismiss', function( event ) {
|
| 17 |
+
console.log ('here');
|
| 18 |
+
//alert('This');
|
| 19 |
+
event.preventDefault();
|
| 20 |
+
$this.fadeTo( 100 , 0, function() {
|
| 21 |
+
//alert();
|
| 22 |
+
jQuery(this).slideUp( 100, function() {
|
| 23 |
+
jQuery(this).remove();
|
| 24 |
+
var data = {
|
| 25 |
+
action: "wcal_admin_notices"
|
| 26 |
+
};
|
| 27 |
+
var admin_url = jQuery( "#admin_url" ).val();
|
| 28 |
+
jQuery.post( admin_url + "/admin-ajax.php", data, function( response ) {
|
| 29 |
+
});
|
| 30 |
+
});
|
| 31 |
+
});
|
| 32 |
+
});
|
| 33 |
+
|
| 34 |
+
}
|
| 35 |
+
});
|
| 36 |
+
});
|
includes/classes/class-wcal-ts-tracker.php
ADDED
|
@@ -0,0 +1,656 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
/**
|
| 3 |
+
* Abandoned cart data tracker
|
| 4 |
+
*
|
| 5 |
+
* The Abandoned Cart lite tracker class adds functionality to track Abandoned Cart lite Date usage based on if the customer opted in.
|
| 6 |
+
* No personal information is tracked, only general Abandoned Cart lite settings, abandoned orders and recovered orders, abandoned orders amount, recovred orders amount, total templates, total email sent, logged-in users abandoned & recovered amount, guest users abandoned and admin email for discount code.
|
| 7 |
+
*
|
| 8 |
+
* @class Class_Wcal_Ts_Tracker
|
| 9 |
+
* @version 6.8
|
| 10 |
+
*/
|
| 11 |
+
|
| 12 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
| 13 |
+
exit;
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
class Class_Wcal_Ts_Tracker {
|
| 17 |
+
|
| 18 |
+
/**
|
| 19 |
+
* URL to the Tracker API endpoint.
|
| 20 |
+
* @var string
|
| 21 |
+
*/
|
| 22 |
+
private static $wcal_api_url = 'http://tracking.tychesoftwares.com/v1/';
|
| 23 |
+
|
| 24 |
+
/**
|
| 25 |
+
* Hook into cron event.
|
| 26 |
+
*/
|
| 27 |
+
public static function init() {
|
| 28 |
+
add_action( 'wcal_ts_tracker_send_event', array( __CLASS__, 'wcal_ts_send_tracking_data' ) );
|
| 29 |
+
add_filter( 'ts_tracker_data', array( __CLASS__, 'wcal_ts_add_plugin_tracking_data' ), 10, 1);
|
| 30 |
+
add_filter( 'ts_tracker_opt_out_data', array( __CLASS__, 'wcal_get_data_for_opt_out' ), 10, 1);
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
/**
|
| 34 |
+
* Decide whether to send tracking data or not.
|
| 35 |
+
*
|
| 36 |
+
* @param boolean $override
|
| 37 |
+
*/
|
| 38 |
+
public static function wcal_ts_send_tracking_data( $override = false ) {
|
| 39 |
+
|
| 40 |
+
if ( ! apply_filters( 'wcal_ts_tracker_send_override', $override ) ) {
|
| 41 |
+
// Send a maximum of once per week by default.
|
| 42 |
+
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
| 43 |
+
if ( $wcal_last_send && $wcal_last_send > apply_filters( 'wcal_ts_tracker_last_send_interval', strtotime( '-1 week' ) ) ) {
|
| 44 |
+
return;
|
| 45 |
+
}
|
| 46 |
+
} else {
|
| 47 |
+
// Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links.
|
| 48 |
+
$wcal_last_send = self::wcal_ts_get_last_send_time();
|
| 49 |
+
if ( $wcal_last_send && $wcal_last_send > strtotime( '-1 hours' ) ) {
|
| 50 |
+
return;
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
|
| 54 |
+
$allow_tracking = get_option('wcal_allow_tracking');
|
| 55 |
+
if ( 'yes' == $allow_tracking ){
|
| 56 |
+
$override = true;
|
| 57 |
+
}
|
| 58 |
+
|
| 59 |
+
// Update time first before sending to ensure it is set
|
| 60 |
+
update_option( 'wcal_ts_tracker_last_send', time() );
|
| 61 |
+
|
| 62 |
+
if( $override == false ) {
|
| 63 |
+
$params = array();
|
| 64 |
+
$params[ 'tracking_usage' ] = 'no';
|
| 65 |
+
$params[ 'url' ] = home_url();
|
| 66 |
+
$params[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
| 67 |
+
|
| 68 |
+
$params = apply_filters( 'ts_tracker_opt_out_data', $params );
|
| 69 |
+
} else {
|
| 70 |
+
|
| 71 |
+
$params = self::wcal_ts_get_tracking_data();
|
| 72 |
+
}
|
| 73 |
+
|
| 74 |
+
wp_safe_remote_post( self::$wcal_api_url, array(
|
| 75 |
+
'method' => 'POST',
|
| 76 |
+
'timeout' => 45,
|
| 77 |
+
'redirection' => 5,
|
| 78 |
+
'httpversion' => '1.0',
|
| 79 |
+
'blocking' => false,
|
| 80 |
+
'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
|
| 81 |
+
'body' => json_encode( $params ),
|
| 82 |
+
'cookies' => array(),
|
| 83 |
+
)
|
| 84 |
+
);
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
/**
|
| 88 |
+
* Get the last time tracking data was sent.
|
| 89 |
+
* @return int|bool
|
| 90 |
+
*/
|
| 91 |
+
private static function wcal_ts_get_last_send_time() {
|
| 92 |
+
return apply_filters( 'wcal_ts_tracker_last_send_time', get_option( 'wcal_ts_tracker_last_send', false ) );
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
/**
|
| 96 |
+
* Get all the tracking data.
|
| 97 |
+
* @return array
|
| 98 |
+
*/
|
| 99 |
+
private static function wcal_ts_get_tracking_data() {
|
| 100 |
+
$data = array();
|
| 101 |
+
|
| 102 |
+
// General site info
|
| 103 |
+
$data[ 'url' ] = home_url();
|
| 104 |
+
$data[ 'email' ] = apply_filters( 'wcal_ts_tracker_admin_email', get_option( 'admin_email' ) );
|
| 105 |
+
|
| 106 |
+
// WordPress Info
|
| 107 |
+
$data[ 'wp' ] = self::wcal_ts_get_wordpress_info();
|
| 108 |
+
|
| 109 |
+
$data[ 'theme_info' ] = self::wcal_ts_get_theme_info();
|
| 110 |
+
|
| 111 |
+
// Server Info
|
| 112 |
+
$data[ 'server' ] = self::wcal_ts_get_server_info();
|
| 113 |
+
|
| 114 |
+
// Plugin info
|
| 115 |
+
$all_plugins = self::wcal_ts_get_all_plugins();
|
| 116 |
+
$data[ 'active_plugins' ] = $all_plugins[ 'active_plugins' ];
|
| 117 |
+
$data[ 'inactive_plugins' ] = $all_plugins[ 'inactive_plugins' ];
|
| 118 |
+
|
| 119 |
+
//WooCommerce version
|
| 120 |
+
$data[ 'wc_plugin_version' ] = self::wcal_ts_get_wc_plugin_version();
|
| 121 |
+
return apply_filters( 'ts_tracker_data', $data );
|
| 122 |
+
}
|
| 123 |
+
|
| 124 |
+
/**
|
| 125 |
+
* Get plugin related data.
|
| 126 |
+
* @return array
|
| 127 |
+
*/
|
| 128 |
+
public static function wcal_ts_add_plugin_tracking_data ( $data ){
|
| 129 |
+
|
| 130 |
+
|
| 131 |
+
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
| 132 |
+
|
| 133 |
+
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
| 134 |
+
|
| 135 |
+
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
| 136 |
+
|
| 137 |
+
// Store abandoned count info
|
| 138 |
+
$plugin_data[ 'abandoned_orders' ] = self::wcal_ts_get_abandoned_order_counts();
|
| 139 |
+
|
| 140 |
+
// Store recovred count info
|
| 141 |
+
$plugin_data[ 'recovered_orders' ] = self::wcal_ts_get_recovered_order_counts();
|
| 142 |
+
|
| 143 |
+
// store abandoned orders amount
|
| 144 |
+
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
| 145 |
+
|
| 146 |
+
// Store recovered count info
|
| 147 |
+
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
| 148 |
+
|
| 149 |
+
// Store abandoned cart emails sent count info
|
| 150 |
+
$plugin_data[ 'sent_emails' ] = self::wcal_ts_get_sent_emails_total_count();
|
| 151 |
+
|
| 152 |
+
// Store email template count info
|
| 153 |
+
$plugin_data[ 'email_templates_data' ] = self::wcal_ts_get_email_templates_data();
|
| 154 |
+
|
| 155 |
+
// Store only logged-in users abandoned cart count info
|
| 156 |
+
$plugin_data[ 'logged_in_abandoned_orders' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_count();
|
| 157 |
+
|
| 158 |
+
// Store only logged-in users abandoned cart count info
|
| 159 |
+
$plugin_data[ 'guest_abandoned_orders' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_count();
|
| 160 |
+
|
| 161 |
+
// Store only logged-in users abandoned cart amount info
|
| 162 |
+
$plugin_data[ 'logged_in_abandoned_orders_amount' ] = self::wcal_ts_get_logged_in_users_abandoned_cart_total_amount();
|
| 163 |
+
|
| 164 |
+
// store only guest users abandoned cart amount
|
| 165 |
+
$plugin_data[ 'guest_abandoned_orders_amount' ] = self::wcal_ts_get_guest_users_abandoned_cart_total_amount();
|
| 166 |
+
|
| 167 |
+
// Store only logged-in users recovered cart amount info
|
| 168 |
+
$plugin_data[ 'logged_in_recovered_orders_amount' ] = self::wcal_ts_get_logged_in_users_recovered_cart_total_amount();
|
| 169 |
+
|
| 170 |
+
// Store only guest users recovered cart amount
|
| 171 |
+
$plugin_data[ 'guest_recovered_orders_amount' ] = self::wcal_ts_get_guest_users_recovered_cart_total_amount();
|
| 172 |
+
|
| 173 |
+
// Get all plugin options info
|
| 174 |
+
$plugin_data[ 'settings' ] = self::wcal_ts_get_all_plugin_options_values();
|
| 175 |
+
$plugin_data[ 'plugin_version' ] = self::wcal_ts_get_plugin_version();
|
| 176 |
+
$plugin_data[ 'wcal_allow_tracking' ] = get_option ('wcal_allow_tracking');
|
| 177 |
+
|
| 178 |
+
$data [ 'plugin_data' ] = $plugin_data;
|
| 179 |
+
}
|
| 180 |
+
return $data;
|
| 181 |
+
}
|
| 182 |
+
|
| 183 |
+
/**
|
| 184 |
+
* Get data when user dont want to share information.
|
| 185 |
+
* @return array
|
| 186 |
+
*/
|
| 187 |
+
public static function wcal_get_data_for_opt_out( $params ){
|
| 188 |
+
|
| 189 |
+
$plugin_data[ 'ts_meta_data_table_name'] = 'ts_wcal_tracking_meta_data';
|
| 190 |
+
$plugin_data[ 'ts_plugin_name' ] = 'Abandoned Cart Lite for WooCommerce';
|
| 191 |
+
$plugin_data[ 'abandoned_orders_amount' ] = self::wcal_ts_get_abandoned_order_total_amount();
|
| 192 |
+
// Store recovered count info
|
| 193 |
+
$plugin_data[ 'recovered_orders_amount' ] = self::wcal_ts_get_recovered_order_total_amount();
|
| 194 |
+
|
| 195 |
+
$params[ 'plugin_data' ] = $plugin_data;
|
| 196 |
+
|
| 197 |
+
return $params;
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
|
| 201 |
+
/**
|
| 202 |
+
* Get WordPress related data.
|
| 203 |
+
* @return array
|
| 204 |
+
*/
|
| 205 |
+
private static function wcal_ts_get_wordpress_info() {
|
| 206 |
+
$wp_data = array();
|
| 207 |
+
|
| 208 |
+
$memory = wc_let_to_num( WP_MEMORY_LIMIT );
|
| 209 |
+
|
| 210 |
+
if ( function_exists( 'memory_get_usage' ) ) {
|
| 211 |
+
$system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) );
|
| 212 |
+
$memory = max( $memory, $system_memory );
|
| 213 |
+
}
|
| 214 |
+
|
| 215 |
+
$wp_data[ 'memory_limit' ] = size_format( $memory );
|
| 216 |
+
$wp_data[ 'debug_mode' ] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
|
| 217 |
+
$wp_data[ 'locale' ] = get_locale();
|
| 218 |
+
$wp_data[ 'wp_version' ] = get_bloginfo( 'version' );
|
| 219 |
+
$wp_data[ 'multisite' ] = is_multisite() ? 'Yes' : 'No';
|
| 220 |
+
|
| 221 |
+
return $wp_data;
|
| 222 |
+
}
|
| 223 |
+
|
| 224 |
+
/**
|
| 225 |
+
* Get the current theme info, theme name and version.
|
| 226 |
+
* @return array
|
| 227 |
+
*/
|
| 228 |
+
public static function wcal_ts_get_theme_info() {
|
| 229 |
+
$theme_data = wp_get_theme();
|
| 230 |
+
$theme_child_theme = is_child_theme() ? 'Yes' : 'No';
|
| 231 |
+
|
| 232 |
+
return array( 'theme_name' => $theme_data->Name,
|
| 233 |
+
'theme_version' => $theme_data->Version,
|
| 234 |
+
'child_theme' => $theme_child_theme );
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
/**
|
| 238 |
+
* Get server related info.
|
| 239 |
+
* @return array
|
| 240 |
+
*/
|
| 241 |
+
private static function wcal_ts_get_server_info() {
|
| 242 |
+
$server_data = array();
|
| 243 |
+
|
| 244 |
+
if ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) && ! empty( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) {
|
| 245 |
+
$server_data[ 'software' ] = $_SERVER[ 'SERVER_SOFTWARE' ];
|
| 246 |
+
}
|
| 247 |
+
|
| 248 |
+
if ( function_exists( 'phpversion' ) ) {
|
| 249 |
+
$server_data[ 'php_version' ] = phpversion();
|
| 250 |
+
}
|
| 251 |
+
|
| 252 |
+
if ( function_exists( 'ini_get' ) ) {
|
| 253 |
+
$server_data[ 'php_post_max_size' ] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
|
| 254 |
+
$server_data[ 'php_time_limt' ] = ini_get( 'max_execution_time' );
|
| 255 |
+
$server_data[ 'php_max_input_vars' ] = ini_get( 'max_input_vars' );
|
| 256 |
+
$server_data[ 'php_suhosin' ] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
|
| 257 |
+
}
|
| 258 |
+
|
| 259 |
+
global $wpdb;
|
| 260 |
+
$server_data[ 'mysql_version' ] = $wpdb->db_version();
|
| 261 |
+
|
| 262 |
+
$server_data[ 'php_max_upload_size' ] = size_format( wp_max_upload_size() );
|
| 263 |
+
$server_data[ 'php_default_timezone' ] = date_default_timezone_get();
|
| 264 |
+
$server_data[ 'php_soap' ] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
|
| 265 |
+
$server_data[ 'php_fsockopen' ] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
|
| 266 |
+
$server_data[ 'php_curl' ] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
|
| 267 |
+
|
| 268 |
+
return $server_data;
|
| 269 |
+
}
|
| 270 |
+
|
| 271 |
+
/**
|
| 272 |
+
* Get all plugins grouped into activated or not.
|
| 273 |
+
* @return array
|
| 274 |
+
*/
|
| 275 |
+
private static function wcal_ts_get_all_plugins() {
|
| 276 |
+
// Ensure get_plugins function is loaded
|
| 277 |
+
if ( ! function_exists( 'get_plugins' ) ) {
|
| 278 |
+
include ABSPATH . '/wp-admin/includes/plugin.php';
|
| 279 |
+
}
|
| 280 |
+
|
| 281 |
+
$plugins = get_plugins();
|
| 282 |
+
$active_plugins_keys = get_option( 'active_plugins', array() );
|
| 283 |
+
$active_plugins = array();
|
| 284 |
+
|
| 285 |
+
foreach ( $plugins as $k => $v ) {
|
| 286 |
+
// Take care of formatting the data how we want it.
|
| 287 |
+
$formatted = array();
|
| 288 |
+
$formatted[ 'name' ] = strip_tags( $v[ 'Name' ] );
|
| 289 |
+
if ( isset( $v[ 'Version' ] ) ) {
|
| 290 |
+
$formatted[ 'version' ] = strip_tags( $v[ 'Version' ] );
|
| 291 |
+
}
|
| 292 |
+
if ( isset( $v[ 'Author' ] ) ) {
|
| 293 |
+
$formatted[ 'author' ] = strip_tags( $v[ 'Author' ] );
|
| 294 |
+
}
|
| 295 |
+
if ( isset( $v[ 'Network' ] ) ) {
|
| 296 |
+
$formatted[ 'network' ] = strip_tags( $v[ 'Network' ] );
|
| 297 |
+
}
|
| 298 |
+
if ( isset( $v[ 'PluginURI' ] ) ) {
|
| 299 |
+
$formatted[ 'plugin_uri' ] = strip_tags( $v[ 'PluginURI' ] );
|
| 300 |
+
}
|
| 301 |
+
if ( in_array( $k, $active_plugins_keys ) ) {
|
| 302 |
+
// Remove active plugins from list so we can show active and inactive separately
|
| 303 |
+
unset( $plugins[ $k ] );
|
| 304 |
+
$active_plugins[ $k ] = $formatted;
|
| 305 |
+
} else {
|
| 306 |
+
$plugins[ $k ] = $formatted;
|
| 307 |
+
}
|
| 308 |
+
}
|
| 309 |
+
|
| 310 |
+
return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
|
| 311 |
+
}
|
| 312 |
+
|
| 313 |
+
/**
|
| 314 |
+
* Get abandoned orders counts.
|
| 315 |
+
* @return string
|
| 316 |
+
*/
|
| 317 |
+
private static function wcal_ts_get_abandoned_order_counts() {
|
| 318 |
+
global $wpdb;
|
| 319 |
+
$wcal_order_count = 0;
|
| 320 |
+
|
| 321 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 322 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 323 |
+
$current_time = current_time( 'timestamp' );
|
| 324 |
+
$compare_time = $current_time - $cut_off_time;
|
| 325 |
+
|
| 326 |
+
$blank_cart_info = '{"cart":[]}';
|
| 327 |
+
$blank_cart_info_guest = '[]';
|
| 328 |
+
|
| 329 |
+
$wcal_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
| 330 |
+
|
| 331 |
+
$wcal_order_count = $wpdb->get_var( $wcal_query );
|
| 332 |
+
|
| 333 |
+
return $wcal_order_count;
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
|
| 337 |
+
/**
|
| 338 |
+
* Get recovered orders counts.
|
| 339 |
+
* @return string
|
| 340 |
+
*/
|
| 341 |
+
private static function wcal_ts_get_recovered_order_counts(){
|
| 342 |
+
|
| 343 |
+
global $wpdb;
|
| 344 |
+
$wcal_recovered_order_count = 0;
|
| 345 |
+
|
| 346 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 347 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 348 |
+
$current_time = current_time( 'timestamp' );
|
| 349 |
+
$compare_time = $current_time - $cut_off_time;
|
| 350 |
+
|
| 351 |
+
$wcal_recovery_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
| 352 |
+
|
| 353 |
+
$wcal_recovered_order_count = $wpdb->get_var( $wcal_recovery_query );
|
| 354 |
+
|
| 355 |
+
return $wcal_recovered_order_count;
|
| 356 |
+
}
|
| 357 |
+
|
| 358 |
+
/*
|
| 359 |
+
* Get Total abandoned orders amount
|
| 360 |
+
*
|
| 361 |
+
*/
|
| 362 |
+
private static function wcal_ts_get_abandoned_order_total_amount(){
|
| 363 |
+
global $wpdb;
|
| 364 |
+
$wcal_abandoned_orders_amount = 0;
|
| 365 |
+
|
| 366 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 367 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 368 |
+
$current_time = current_time( 'timestamp' );
|
| 369 |
+
$compare_time = $current_time - $cut_off_time;
|
| 370 |
+
|
| 371 |
+
$blank_cart_info = '{"cart":[]}';
|
| 372 |
+
$blank_cart_info_guest = '[]';
|
| 373 |
+
|
| 374 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest'";
|
| 375 |
+
|
| 376 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
| 377 |
+
|
| 378 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
| 379 |
+
|
| 380 |
+
return $wcal_abandoned_orders_amount;
|
| 381 |
+
}
|
| 382 |
+
|
| 383 |
+
private static function wcal_get_abandoned_amount( $wcal_abandoned_query_result ){
|
| 384 |
+
|
| 385 |
+
$wcal_abandoned_orders_amount = 0;
|
| 386 |
+
foreach ( $wcal_abandoned_query_result as $wcal_abandoned_query_key => $wcal_abandoned_query_value ) {
|
| 387 |
+
# code...
|
| 388 |
+
$cart_info = json_decode( $wcal_abandoned_query_value->abandoned_cart_info );
|
| 389 |
+
|
| 390 |
+
$cart_details = array();
|
| 391 |
+
if( isset( $cart_info->cart ) ){
|
| 392 |
+
$cart_details = $cart_info->cart;
|
| 393 |
+
}
|
| 394 |
+
|
| 395 |
+
if( count( $cart_details ) > 0 ) {
|
| 396 |
+
foreach( $cart_details as $k => $v ) {
|
| 397 |
+
if( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
|
| 398 |
+
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total + $v->line_subtotal_tax;
|
| 399 |
+
} else {
|
| 400 |
+
$wcal_abandoned_orders_amount = $wcal_abandoned_orders_amount + $v->line_total;
|
| 401 |
+
}
|
| 402 |
+
}
|
| 403 |
+
}
|
| 404 |
+
}
|
| 405 |
+
return $wcal_abandoned_orders_amount;
|
| 406 |
+
}
|
| 407 |
+
|
| 408 |
+
/*
|
| 409 |
+
* Get recovered orders total amount
|
| 410 |
+
*/
|
| 411 |
+
private static function wcal_ts_get_recovered_order_total_amount(){
|
| 412 |
+
|
| 413 |
+
global $wpdb;
|
| 414 |
+
$wcal_recovered_orders_amount = 0;
|
| 415 |
+
|
| 416 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 417 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 418 |
+
$current_time = current_time( 'timestamp' );
|
| 419 |
+
$compare_time = $current_time - $cut_off_time;
|
| 420 |
+
|
| 421 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time'";
|
| 422 |
+
|
| 423 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
| 424 |
+
|
| 425 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
| 426 |
+
|
| 427 |
+
return $wcal_recovered_orders_amount;
|
| 428 |
+
}
|
| 429 |
+
|
| 430 |
+
private static function wcal_get_recovered_amount ( $wcal_data ){
|
| 431 |
+
|
| 432 |
+
$wcal_recovered_orders_amount = 0;
|
| 433 |
+
|
| 434 |
+
foreach ($wcal_data as $wcal_data_key => $wcal_data_value) {
|
| 435 |
+
|
| 436 |
+
$wcal_order_total = get_post_meta( $wcal_data_value->recovered_cart , '_order_total', true);
|
| 437 |
+
$wcal_recovered_orders_amount = $wcal_recovered_orders_amount + $wcal_order_total;
|
| 438 |
+
}
|
| 439 |
+
return $wcal_recovered_orders_amount;
|
| 440 |
+
}
|
| 441 |
+
|
| 442 |
+
/*
|
| 443 |
+
* Get sent email total count
|
| 444 |
+
*/
|
| 445 |
+
private static function wcal_ts_get_sent_emails_total_count(){
|
| 446 |
+
|
| 447 |
+
global $wpdb;
|
| 448 |
+
$wcal_sent_emails_count = 0;
|
| 449 |
+
$wcal_sent_emails_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite`";
|
| 450 |
+
$wcal_sent_emails_count = $wpdb->get_var( $wcal_sent_emails_query );
|
| 451 |
+
return $wcal_sent_emails_count;
|
| 452 |
+
}
|
| 453 |
+
|
| 454 |
+
/*
|
| 455 |
+
* Get email templates total count
|
| 456 |
+
*/
|
| 457 |
+
private static function wcal_ts_get_email_templates_data(){
|
| 458 |
+
|
| 459 |
+
global $wpdb;
|
| 460 |
+
$wcal_email_templates_count = 0;
|
| 461 |
+
$wcal_email_templates_query = "SELECT id, is_active, is_wc_template,frequency, day_or_hour FROM `" . $wpdb->prefix . "ac_email_templates_lite`";
|
| 462 |
+
$wcal_email_templates_results = $wpdb->get_results( $wcal_email_templates_query );
|
| 463 |
+
|
| 464 |
+
$wcal_email_templates_count = count( $wcal_email_templates_results );
|
| 465 |
+
|
| 466 |
+
$wcal_templates_data = array();
|
| 467 |
+
$wcal_templates_data ['total_templates'] = $wcal_email_templates_count;
|
| 468 |
+
|
| 469 |
+
foreach ($wcal_email_templates_results as $wcal_email_templates_results_key => $wcal_email_templates_results_value ) {
|
| 470 |
+
|
| 471 |
+
$wcal_template_time = $wcal_email_templates_results_value->frequency . ' ' .$wcal_email_templates_results_value->day_or_hour ;
|
| 472 |
+
|
| 473 |
+
$wcal_get_total_email_sent_for_template = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_sent_history_lite` WHERE template_id = ". $wcal_email_templates_results_value->id;
|
| 474 |
+
$wcal_get_total_email_sent_for_template_count = $wpdb->get_var( $wcal_get_total_email_sent_for_template );
|
| 475 |
+
|
| 476 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_activate'] = ( $wcal_email_templates_results_value->is_active == 1 ) ? 'Active' : 'Deactive';
|
| 477 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['is_wc_template'] = ( $wcal_email_templates_results_value->is_wc_template == 1 ) ? 'Yes' : 'No';
|
| 478 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['template_time'] = $wcal_template_time;
|
| 479 |
+
$wcal_templates_data [ "template_id_" . $wcal_email_templates_results_value->id ] ['total_email_sent'] = $wcal_get_total_email_sent_for_template_count;
|
| 480 |
+
}
|
| 481 |
+
|
| 482 |
+
return $wcal_templates_data;
|
| 483 |
+
}
|
| 484 |
+
|
| 485 |
+
/*
|
| 486 |
+
* Get logged-in users total abandoned count
|
| 487 |
+
*/
|
| 488 |
+
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_count (){
|
| 489 |
+
|
| 490 |
+
global $wpdb;
|
| 491 |
+
$wcal_logged_in_user_query_count = 0;
|
| 492 |
+
|
| 493 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 494 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 495 |
+
$current_time = current_time( 'timestamp' );
|
| 496 |
+
$compare_time = $current_time - $cut_off_time;
|
| 497 |
+
|
| 498 |
+
$blank_cart_info = '{"cart":[]}';
|
| 499 |
+
$blank_cart_info_guest = '[]';
|
| 500 |
+
|
| 501 |
+
$wcal_logged_in_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0";
|
| 502 |
+
|
| 503 |
+
$wcal_logged_in_user_query_count = $wpdb->get_var( $wcal_logged_in_user_query );
|
| 504 |
+
|
| 505 |
+
return $wcal_logged_in_user_query_count;
|
| 506 |
+
}
|
| 507 |
+
|
| 508 |
+
/*
|
| 509 |
+
* Get logged-in users total abandoned count
|
| 510 |
+
*/
|
| 511 |
+
private static function wcal_ts_get_guest_users_abandoned_cart_total_count(){
|
| 512 |
+
global $wpdb;
|
| 513 |
+
$wcal_guest_user_query_count = 0;
|
| 514 |
+
|
| 515 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 516 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 517 |
+
$current_time = current_time( 'timestamp' );
|
| 518 |
+
$compare_time = $current_time - $cut_off_time;
|
| 519 |
+
|
| 520 |
+
$blank_cart_info = '{"cart":[]}';
|
| 521 |
+
$blank_cart_info_guest = '[]';
|
| 522 |
+
|
| 523 |
+
$wcal_guest_user_query = "SELECT COUNT(id) FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0";
|
| 524 |
+
|
| 525 |
+
$wcal_guest_user_query_count = $wpdb->get_var( $wcal_guest_user_query );
|
| 526 |
+
|
| 527 |
+
return $wcal_guest_user_query_count;
|
| 528 |
+
}
|
| 529 |
+
|
| 530 |
+
private static function wcal_ts_get_logged_in_users_abandoned_cart_total_amount (){
|
| 531 |
+
|
| 532 |
+
global $wpdb;
|
| 533 |
+
$wcal_abandoned_orders_amount = 0;
|
| 534 |
+
|
| 535 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 536 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 537 |
+
$current_time = current_time( 'timestamp' );
|
| 538 |
+
$compare_time = $current_time - $cut_off_time;
|
| 539 |
+
|
| 540 |
+
$blank_cart_info = '{"cart":[]}';
|
| 541 |
+
$blank_cart_info_guest = '[]';
|
| 542 |
+
|
| 543 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id < 63000000 AND user_id != 0 ";
|
| 544 |
+
|
| 545 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
| 546 |
+
|
| 547 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
| 548 |
+
|
| 549 |
+
return $wcal_abandoned_orders_amount;
|
| 550 |
+
}
|
| 551 |
+
|
| 552 |
+
private static function wcal_ts_get_guest_users_abandoned_cart_total_amount (){
|
| 553 |
+
|
| 554 |
+
global $wpdb;
|
| 555 |
+
$wcal_abandoned_orders_amount = 0;
|
| 556 |
+
|
| 557 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 558 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 559 |
+
$current_time = current_time( 'timestamp' );
|
| 560 |
+
$compare_time = $current_time - $cut_off_time;
|
| 561 |
+
|
| 562 |
+
$blank_cart_info = '{"cart":[]}';
|
| 563 |
+
$blank_cart_info_guest = '[]';
|
| 564 |
+
|
| 565 |
+
$wcal_abandoned_query = "SELECT abandoned_cart_info FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_time <= '$compare_time' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND user_id >= 63000000 AND user_id != 0 ";
|
| 566 |
+
|
| 567 |
+
$wcal_abandoned_query_result = $wpdb->get_results( $wcal_abandoned_query );
|
| 568 |
+
|
| 569 |
+
$wcal_abandoned_orders_amount = self::wcal_get_abandoned_amount( $wcal_abandoned_query_result );
|
| 570 |
+
|
| 571 |
+
return $wcal_abandoned_orders_amount;
|
| 572 |
+
}
|
| 573 |
+
|
| 574 |
+
private static function wcal_ts_get_logged_in_users_recovered_cart_total_amount(){
|
| 575 |
+
|
| 576 |
+
global $wpdb;
|
| 577 |
+
$wcal_recovered_orders_amount = 0;
|
| 578 |
+
|
| 579 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 580 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 581 |
+
$current_time = current_time( 'timestamp' );
|
| 582 |
+
$compare_time = $current_time - $cut_off_time;
|
| 583 |
+
|
| 584 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id < 63000000 AND user_id != 0 ";
|
| 585 |
+
|
| 586 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
| 587 |
+
|
| 588 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
| 589 |
+
|
| 590 |
+
return $wcal_recovered_orders_amount;
|
| 591 |
+
|
| 592 |
+
}
|
| 593 |
+
|
| 594 |
+
|
| 595 |
+
private static function wcal_ts_get_guest_users_recovered_cart_total_amount (){
|
| 596 |
+
|
| 597 |
+
global $wpdb;
|
| 598 |
+
$wcal_recovered_orders_amount = 0;
|
| 599 |
+
|
| 600 |
+
$ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
|
| 601 |
+
$cut_off_time = $ac_cutoff_time * 60;
|
| 602 |
+
$current_time = current_time( 'timestamp' );
|
| 603 |
+
$compare_time = $current_time - $cut_off_time;
|
| 604 |
+
|
| 605 |
+
$wcal_recovery_query_amount = "SELECT recovered_cart FROM `" . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE recovered_cart > 0 AND abandoned_cart_time <= '$compare_time' AND user_id >= 63000000 AND user_id != 0 ";
|
| 606 |
+
|
| 607 |
+
$wcal_recovered_order_amount_result = $wpdb->get_results( $wcal_recovery_query_amount );
|
| 608 |
+
|
| 609 |
+
$wcal_recovered_orders_amount = self::wcal_get_recovered_amount ($wcal_recovered_order_amount_result );
|
| 610 |
+
|
| 611 |
+
return $wcal_recovered_orders_amount;
|
| 612 |
+
|
| 613 |
+
}
|
| 614 |
+
/**
|
| 615 |
+
* Get all options starting with woocommerce_ prefix.
|
| 616 |
+
* @return array
|
| 617 |
+
*/
|
| 618 |
+
private static function wcal_ts_get_all_plugin_options_values() {
|
| 619 |
+
|
| 620 |
+
return array(
|
| 621 |
+
'wcal_cart_cut_off_time' => get_option( 'ac_lite_cart_abandoned_time' ),
|
| 622 |
+
'wcal_admin_recovery_email' => get_option( 'ac_lite_email_admin_on_recovery' ),
|
| 623 |
+
'wcal_capture_visitors_cart' => get_option( 'ac_lite_track_guest_cart_from_cart_page' )
|
| 624 |
+
);
|
| 625 |
+
}
|
| 626 |
+
|
| 627 |
+
private static function wcal_ts_get_wc_plugin_version() {
|
| 628 |
+
return WC()->version;
|
| 629 |
+
}
|
| 630 |
+
|
| 631 |
+
private static function wcal_ts_get_plugin_license_key() {
|
| 632 |
+
return 'Abandoned Cart Lite';
|
| 633 |
+
}
|
| 634 |
+
|
| 635 |
+
private static function wcal_ts_get_plugin_version() {
|
| 636 |
+
$wcal_plugin_version = self::wcal_plugin_get_version();
|
| 637 |
+
return $wcal_plugin_version;
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
+
/**
|
| 641 |
+
* @return string Plugin version
|
| 642 |
+
*/
|
| 643 |
+
|
| 644 |
+
public static function wcal_plugin_get_version() {
|
| 645 |
+
|
| 646 |
+
|
| 647 |
+
$plugin_path = dirname ( dirname ( dirname ( __FILE__ ) ) ) ;
|
| 648 |
+
$plugin_path_with_base_file_name = $plugin_path . "/woocommerce-ac.php";
|
| 649 |
+
$plugin_data = get_plugin_data( $plugin_path_with_base_file_name );
|
| 650 |
+
$plugin_version = $plugin_data['Version'];
|
| 651 |
+
|
| 652 |
+
return $plugin_version;
|
| 653 |
+
}
|
| 654 |
+
|
| 655 |
+
}
|
| 656 |
+
Class_Wcal_Ts_Tracker::init();
|
includes/wcal_ts_tracking.php
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<?php
|
| 2 |
+
include_once( 'classes/class-wcal-ts-tracker.php' );
|
| 3 |
+
class Wcal_TS_Tracking {
|
| 4 |
+
public function __construct() {
|
| 5 |
+
//Tracking Data
|
| 6 |
+
add_action( 'admin_notices', array( &$this, 'wcal_track_usage_data' ), 10 );
|
| 7 |
+
add_action( 'admin_footer', array( &$this, 'wcal_admin_notices_scripts' ) );
|
| 8 |
+
add_action( 'wp_ajax_wcal_admin_notices', array( &$this, 'wcal_admin_notices' ) );
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
public static function wcal_admin_notices_scripts() {
|
| 12 |
+
|
| 13 |
+
|
| 14 |
+
wp_enqueue_script( 'wcal_admin_dismissal_notice', plugins_url() . '/woocommerce-abandoned-cart/assets/js/wcal_ts_dismiss_notice.js' );
|
| 15 |
+
}
|
| 16 |
+
|
| 17 |
+
public static function wcal_admin_notices() {
|
| 18 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
| 19 |
+
update_option( 'wcal_allow_tracking', 'dismissed' );
|
| 20 |
+
die();
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
/**
|
| 24 |
+
* Actions on the final step.
|
| 25 |
+
*/
|
| 26 |
+
private function wcal_ts_tracking_actions() {
|
| 27 |
+
|
| 28 |
+
if ( isset( $_GET[ 'wcal_tracker_optin' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optin' ) ) {
|
| 29 |
+
update_option( 'wcal_allow_tracking', 'yes' );
|
| 30 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( true );
|
| 31 |
+
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
| 32 |
+
} elseif ( isset( $_GET[ 'wcal_tracker_optout' ] ) && isset( $_GET[ 'wcal_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ 'wcal_tracker_nonce' ], 'wcal_tracker_optout' ) ) {
|
| 33 |
+
update_option( 'wcal_allow_tracking', 'no' );
|
| 34 |
+
Class_Wcal_Ts_Tracker::wcal_ts_send_tracking_data( false );
|
| 35 |
+
header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
/**
|
| 40 |
+
* Data Usage tracking notice
|
| 41 |
+
*/
|
| 42 |
+
function wcal_track_usage_data() {
|
| 43 |
+
$wcal_admin_url = get_admin_url();
|
| 44 |
+
echo '<input type="hidden" id="admin_url" value="' . $wcal_admin_url . '"/>';
|
| 45 |
+
$this->wcal_ts_tracking_actions();
|
| 46 |
+
if ( 'unknown' === get_option( 'wcal_allow_tracking', 'unknown' ) ) : ?>
|
| 47 |
+
<div class="wcal-message wcal-tracker notice notice-info is-dismissible" style="position: relative;">
|
| 48 |
+
<div style="position: absolute;"><img class="site-logo" src="<?php echo plugins_url(); ?>/woocommerce-abandoned-cart/assets/images/site-logo-new.jpg"></div>
|
| 49 |
+
<p style="margin: 10px 0 10px 130px; font-size: medium;">
|
| 50 |
+
<?php print( __( 'Want to help make Abandoned Cart even more awesome? Allow Abandoned Cart to collect non-sensitive diagnostic data and usage information and get 20% off on your next purchase. <a href="https://www.tychesoftwares.com/abandoned-cart-lite-usage-tracking/">Find out more</a>. <br><br>', 'woocommerce-ac' ) ); ?></p>
|
| 51 |
+
<p class="submit">
|
| 52 |
+
<a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optin', 'true' ), 'wcal_tracker_optin', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', 'woocommerce-ac' ); ?></a>
|
| 53 |
+
<a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'wcal_tracker_optout', 'true' ), 'wcal_tracker_optout', 'wcal_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', 'woocommerce-ac' ); ?></a>
|
| 54 |
+
</p>
|
| 55 |
+
</div>
|
| 56 |
+
<?php endif;
|
| 57 |
+
}
|
| 58 |
+
}
|
| 59 |
+
$TS_tracking = new Wcal_TS_Tracking();
|
readme.txt
CHANGED
|
@@ -178,6 +178,30 @@ You can refer **[here](https://www.tychesoftwares.com/differences-between-pro-an
|
|
| 178 |
|
| 179 |
== Changelog ==
|
| 180 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
= 3.8 (29.05.2017) =
|
| 182 |
|
| 183 |
* This version has 1 bug fix and 2 enhancements.
|
|
@@ -415,6 +439,40 @@ For existing users, this setting will remain unchecked. For new users of the plu
|
|
| 415 |
|
| 416 |
== Upgrade Notice ==
|
| 417 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 418 |
= 3.7 (10.04.2017) =
|
| 419 |
|
| 420 |
* This version has 1 bug fix.
|
| 178 |
|
| 179 |
== Changelog ==
|
| 180 |
|
| 181 |
+
= 3.9.3 (09.06.2017) =
|
| 182 |
+
|
| 183 |
+
* This version has 3 bugs fixes.
|
| 184 |
+
|
| 185 |
+
* Bug Fixed - When store admin clicks on the dismissible notice, the notice was not getting dismissed. This issue has been fixed.
|
| 186 |
+
|
| 187 |
+
* Bug Fixed - The dismissible notice was not displaying the 'Allow' & 'No Thanks' button properly. This issue has been fixed.
|
| 188 |
+
|
| 189 |
+
* Bug Fixed - The total Recovered amount was not tracked. This issue has been fixed.
|
| 190 |
+
|
| 191 |
+
= 3.9.2 (09.06.2017) =
|
| 192 |
+
|
| 193 |
+
* Added missing java script file.
|
| 194 |
+
|
| 195 |
+
= 3.9.1 (09.06.2017) =
|
| 196 |
+
|
| 197 |
+
* Added missing image.
|
| 198 |
+
|
| 199 |
+
= 3.9 (09.06.2017) =
|
| 200 |
+
|
| 201 |
+
* This version has 1 new feature.
|
| 202 |
+
|
| 203 |
+
* New Feature - A new dismissible notice is added in the WordPress admin, which provides an option to allow usage tracking of the non-sensitive data of our plugin from the website. [Find out more](https://www.tychesoftwares.com/abandoned-cart-lite-usage-tracking/?utm_source=wpplugin&utm_medium=usagelink&utm_campaign=AbandonedCartLite).
|
| 204 |
+
|
| 205 |
= 3.8 (29.05.2017) =
|
| 206 |
|
| 207 |
* This version has 1 bug fix and 2 enhancements.
|
| 439 |
|
| 440 |
== Upgrade Notice ==
|
| 441 |
|
| 442 |
+
= 3.9.3 (09.06.2017) =
|
| 443 |
+
|
| 444 |
+
* This version has 3 bugs fixes.
|
| 445 |
+
|
| 446 |
+
* Bug Fixed - When store admin clicks on the dismissible notice, the notice was not getting dismissed. This issue has been fixed.
|
| 447 |
+
|
| 448 |
+
* Bug Fixed - The dismissible notice was not displaying the 'Allow' & 'No Thanks' button properly. This issue has been fixed.
|
| 449 |
+
|
| 450 |
+
* Bug Fixed - The total Recovered amount was not tracked. This issue has been fixed.
|
| 451 |
+
|
| 452 |
+
= 3.9.2 (09.06.2017) =
|
| 453 |
+
|
| 454 |
+
* Added missing java script file.
|
| 455 |
+
|
| 456 |
+
= 3.9.1 (09.06.2017) =
|
| 457 |
+
|
| 458 |
+
* Added missing image.
|
| 459 |
+
|
| 460 |
+
= 3.9 (09.06.2017) =
|
| 461 |
+
|
| 462 |
+
* This version has 1 new feature.
|
| 463 |
+
|
| 464 |
+
* New Feature - A new dismissible notice is added in the WordPress admin, which provides an option to allow usage tracking of the non-sensitive data of our plugin from the website. [Find out more](https://www.tychesoftwares.com/abandoned-cart-lite-usage-tracking/?utm_source=wpplugin&utm_medium=usagelink&utm_campaign=AbandonedCartLite).
|
| 465 |
+
|
| 466 |
+
= 3.8 (29.05.2017) =
|
| 467 |
+
|
| 468 |
+
* This version has 1 bug fix and 2 enhancements.
|
| 469 |
+
|
| 470 |
+
* Bug Fixed - Earlier Abandoned Cart date and time format were not translated into the WordPress selected language in the plugin. This issue has been fixed.
|
| 471 |
+
|
| 472 |
+
* Enhancement - From this version, the admin can insert the WordPress supported emoji's in the abandoned cart email templates as well as in the subject.
|
| 473 |
+
|
| 474 |
+
* Enhancement - Earlier we had hardcoded date and time format in our plugin. Now, the plugin will use selected WordPress date and time format.
|
| 475 |
+
|
| 476 |
= 3.7 (10.04.2017) =
|
| 477 |
|
| 478 |
* This version has 1 bug fix.
|
woocommerce-ac.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Abandoned Cart Lite for WooCommerce
|
| 4 |
Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
| 5 |
Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
| 6 |
-
Version: 3.
|
| 7 |
Author: Tyche Softwares
|
| 8 |
Author URI: http://www.tychesoftwares.com/
|
| 9 |
Text Domain: woocommerce-ac
|
|
@@ -19,6 +19,8 @@ require_once( "includes/wcal_actions.php" );
|
|
| 19 |
require_once( "includes/classes/class-wcal-aes.php" );
|
| 20 |
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
| 21 |
require_once( "includes/wcal-common.php" );
|
|
|
|
|
|
|
| 22 |
// Add a new interval of 15 minutes
|
| 23 |
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
| 24 |
|
|
@@ -34,6 +36,22 @@ if ( ! wp_next_scheduled( 'woocommerce_ac_send_email_action' ) ) {
|
|
| 34 |
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
| 35 |
}
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
// Hook into that action that'll fire every 15 minutes
|
| 38 |
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
| 39 |
|
| 3 |
Plugin Name: Abandoned Cart Lite for WooCommerce
|
| 4 |
Plugin URI: http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro
|
| 5 |
Description: This plugin captures abandoned carts by logged-in users & emails them about it. <strong><a href="http://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro">Click here to get the PRO Version.</a></strong>
|
| 6 |
+
Version: 3.9.3
|
| 7 |
Author: Tyche Softwares
|
| 8 |
Author URI: http://www.tychesoftwares.com/
|
| 9 |
Text Domain: woocommerce-ac
|
| 19 |
require_once( "includes/classes/class-wcal-aes.php" );
|
| 20 |
require_once( "includes/classes/class-wcal-aes-counter.php" );
|
| 21 |
require_once( "includes/wcal-common.php" );
|
| 22 |
+
require_once( "includes/wcal_ts_tracking.php");
|
| 23 |
+
|
| 24 |
// Add a new interval of 15 minutes
|
| 25 |
add_filter( 'cron_schedules', 'wcal_add_cron_schedule' );
|
| 26 |
|
| 36 |
wp_schedule_event( time(), '15_minutes_lite', 'woocommerce_ac_send_email_action' );
|
| 37 |
}
|
| 38 |
|
| 39 |
+
/**
|
| 40 |
+
* Run a cron once in week to delete old records for lockout
|
| 41 |
+
*/
|
| 42 |
+
function wcal_add_tracking_cron_schedule( $schedules ) {
|
| 43 |
+
$schedules[ 'daily_once' ] = array(
|
| 44 |
+
'interval' => 604800, // one week in seconds
|
| 45 |
+
'display' => __( 'Once in a Week', 'woocommerce-ac' )
|
| 46 |
+
);
|
| 47 |
+
return $schedules;
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
/* To capture the data from the client site */
|
| 51 |
+
if ( ! wp_next_scheduled( 'wcal_ts_tracker_send_event' ) ) {
|
| 52 |
+
wp_schedule_event( time(), 'daily_once', 'wcal_ts_tracker_send_event' );
|
| 53 |
+
}
|
| 54 |
+
|
| 55 |
// Hook into that action that'll fire every 15 minutes
|
| 56 |
add_action( 'woocommerce_ac_send_email_action', 'wcal_send_email_cron' );
|
| 57 |
|
