Abandoned Cart Lite for WooCommerce - Version 5.8.3

Version Description

(06.11.2020) = * Fix - Added more changes related to sanitization of data & SQL queries to make the plugin WPCS compliant. * Tweak - The plugin will no longer support running a cron job manually via cPanel. This has been done to ensure the security standards for WordPress are met. * The plugin uses the Action Scheduler library from WooCommerce to send automated reminder emails since version 5.7.

Download this release

Release Info

Developer tychesoftwares
Plugin Icon 128x128 Abandoned Cart Lite for WooCommerce
Version 5.8.3
Comparing to
See all releases

Code changes from version 5.8.2 to 5.8.3

Files changed (37) hide show
  1. class-wcal-update.php +3 -3
  2. cron/{wcal_send_email.php → class-wcal-cron.php} +24 -38
  3. includes/admin/{class-wcal-privacy-export.php → class-wcal-personal-data-export.php} +80 -66
  4. includes/admin/{wcap_add_cart_popup_modal.php → class-wcap-add-cart-popup-modal.php} +50 -412
  5. includes/admin/class-wcap-pro-settings-callbacks.php +400 -0
  6. includes/admin/{wcap_pro_settings.php → class-wcap-pro-settings.php} +62 -123
  7. includes/admin/wcap_pro_settings_callbacks.php +0 -454
  8. includes/class-wcal-admin-notice.php +23 -6
  9. includes/{wcal_all_component.php → class-wcal-all-component.php} +6 -9
  10. includes/{wcal-common.php → class-wcal-common.php} +23 -18
  11. includes/class-wcal-default-template-settings.php +1 -11
  12. includes/{wcal_class-guest.php → class-wcal-guest-ac.php} +55 -52
  13. includes/{wcal_process_base.php → class-wcal-process-base.php} +20 -5
  14. includes/{wcal_data_tracking_message.php → class-wcal-tracking-msg.php} +16 -12
  15. includes/classes/class-wcal-dashboard-report.php +1 -1
  16. includes/classes/class-wcal-product-report-table.php +38 -30
  17. includes/classes/class-wcal-recover-orders-table.php +89 -87
  18. includes/classes/class-wcal-templates-table.php +53 -54
  19. includes/component/deactivate-survey-popup/class-ts-deactivation.php +104 -70
  20. includes/component/deactivate-survey-popup/template/ts-deactivate-modal.php +360 -360
  21. includes/component/pro-notices-in-lite/ts-pro-notices.php +136 -138
  22. includes/component/tracking-data/class-ts-tracker.php +98 -83
  23. includes/component/tracking-data/ts-tracking.php +68 -63
  24. includes/component/welcome-page/Instructions +0 -37
  25. includes/component/welcome-page/assets/images/abandon-cart-cut-off-time.png +0 -0
  26. includes/component/welcome-page/assets/images/abandoned-cart-lite-email-templates.png +0 -0
  27. includes/component/welcome-page/assets/images/email-templates-send-time.png +0 -0
  28. includes/component/welcome-page/assets/images/icon-256x256.png +0 -0
  29. includes/component/welcome-page/assets/images/site-logo-new.jpg +0 -0
  30. includes/component/welcome-page/templates/social-media-elements.php +0 -24
  31. includes/component/welcome-page/templates/welcome/welcome-page.php +0 -130
  32. includes/component/welcome-page/ts-welcome.php +0 -275
  33. includes/component/woocommerce-check/ts-woo-active.php +22 -19
  34. includes/frontend/{wcal_checkout_process.php → class-wcal-checkout-process.php} +212 -162
  35. includes/frontend/{wcal_frontend.php → class-wcal-frontend.php} +11 -6
  36. readme.txt +6 -1
  37. woocommerce-ac.php +70 -74
class-wcal-update.php CHANGED
@@ -27,7 +27,7 @@ if ( ! class_exists( 'Wcal_Update' ) ) {
27
  */
28
  public static function wcal_schedule_update_action() {
29
  // IMP: The default value for get option should be updated in each release to match the current version to ensure update code is not run for first time installs.
30
- if ( get_option( 'wcal_previous_version', '5.8.2' ) != WCAL_PLUGIN_VERSION && function_exists( 'as_enqueue_async_action' ) && false === as_next_scheduled_action( 'wcal_update_db' ) ) {
31
  as_enqueue_async_action( 'wcal_update_db' );
32
  }
33
  }
@@ -90,7 +90,7 @@ if ( ! class_exists( 'Wcal_Update' ) ) {
90
  $wcal_previous_version = get_option( 'wcal_previous_version' );
91
 
92
  if ( wcal_common::wcal_get_version() !== $wcal_previous_version ) {
93
- update_option( 'wcal_previous_version', '5.7.1' );
94
  }
95
  } else { // multi site - child sites.
96
  $wcal_guest_user_id_altered = get_blog_option( $blog_id, 'wcal_guest_user_id_altered' );
@@ -103,7 +103,7 @@ if ( ! class_exists( 'Wcal_Update' ) ) {
103
  $wcal_previous_version = get_blog_option( $blog_id, 'wcal_previous_version' );
104
 
105
  if ( wcal_common::wcal_get_version() !== $wcal_previous_version ) {
106
- update_blog_option( $blog_id, 'wcal_previous_version', '5.7.1' );
107
  }
108
  }
109
 
27
  */
28
  public static function wcal_schedule_update_action() {
29
  // IMP: The default value for get option should be updated in each release to match the current version to ensure update code is not run for first time installs.
30
+ if ( get_option( 'wcal_previous_version', '5.8.3' ) !== WCAL_PLUGIN_VERSION && function_exists( 'as_enqueue_async_action' ) && false === as_next_scheduled_action( 'wcal_update_db' ) ) {
31
  as_enqueue_async_action( 'wcal_update_db' );
32
  }
33
  }
90
  $wcal_previous_version = get_option( 'wcal_previous_version' );
91
 
92
  if ( wcal_common::wcal_get_version() !== $wcal_previous_version ) {
93
+ update_option( 'wcal_previous_version', '5.8.3' );
94
  }
95
  } else { // multi site - child sites.
96
  $wcal_guest_user_id_altered = get_blog_option( $blog_id, 'wcal_guest_user_id_altered' );
103
  $wcal_previous_version = get_blog_option( $blog_id, 'wcal_previous_version' );
104
 
105
  if ( wcal_common::wcal_get_version() !== $wcal_previous_version ) {
106
+ update_blog_option( $blog_id, 'wcal_previous_version', '5.8.3' );
107
  }
108
  }
109
 
cron/{wcal_send_email.php → class-wcal-cron.php} RENAMED
@@ -1,41 +1,21 @@
1
  <?php
2
  /**
 
 
3
  * It will send the automatic reminder emails to the customers.
4
  *
5
  * @author Tyche Softwares
6
  * @package Abandoned-Cart-Lite-for-WooCommerce/Cron
7
  */
8
 
9
-
10
- static $wp_load; // Since this will be called twice, hold onto it.
11
- if ( ! isset( $wp_load ) ) {
12
- $wp_load = false;
13
- $dir = __FILE__;
14
- while ( '/' != ( $dir = dirname( $dir ) ) ) {
15
- // Comment this "If" condition for generating the developer documentations.
16
- if ( file_exists( $wp_load = "{$dir}/wp-load.php" ) ) {
17
- break;
18
- }
19
- }
20
- // In case wp-content folder is seperated from WP core folders (like Bedrock setup from Roots.io) the above while loop will not find wp-load correctly, so we must use ABSPATH
21
- if ( ! file_exists( $wp_load ) ) {
22
- $wp_load = trailingslashit( ABSPATH ) . 'wp-load.php';
23
- }
24
- }
25
- $wcal_root = dirname( dirname( __FILE__ ) ); // go two level up for directory from this file.
26
- require_once $wp_load;
27
- require_once $wcal_root . '/includes/classes/class-wcal-aes.php';
28
- require_once $wcal_root . '/includes/classes/class-wcal-aes-counter.php';
29
-
30
-
31
- if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
32
 
33
  /**
34
  * It will send the automatic reminder emails to the customers
35
  *
36
  * @since 1.3
37
  */
38
- class woocommerce_abandon_cart_cron {
39
 
40
  /**
41
  * It will send the reminder emails to the cutomers.
@@ -79,6 +59,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
79
  } elseif ( 'Hours' === $value->day_or_hour ) {
80
  $time_to_send_template_after = intval( $value->frequency ) * $hour_seconds;
81
  }
 
82
  $carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time, $value->id );
83
 
84
  $email_frequency = $value->frequency;
@@ -164,14 +145,16 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
164
 
165
  $results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( // phpcs:ignore
166
  $wpdb->prepare(
167
- "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm
168
- LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost
169
  ON wpm.post_id = wpost.ID
170
- WHERE wpm.meta_key = 'wcal_recover_order_placed' AND
171
  wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
172
- wpost.post_type = 'shop_order'
173
- ORDER BY wpm.post_id DESC LIMIT 1",
174
- $value->id
 
 
175
  )
176
  );
177
 
@@ -307,8 +290,9 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
307
  $line_subtotal_header = __( 'Line Subtotal', 'woocommerce-abandoned-cart' );
308
 
309
  if ( class_exists( 'WP_Better_Emails' ) ) {
 
310
  $var = '<table width = 100% style="margin-right: auto; margin-left:auto;">
311
- <tr> <td colspan="5"> <h3>' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
312
  <tr>
313
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
314
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
@@ -317,8 +301,9 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
317
  <th>' . apply_filters( 'wcal_reminder_email_line_subtotal_header', $line_subtotal_header ) . '</th>
318
  </tr>';
319
  } else {
 
320
  $var = '<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable" style="margin-right: auto; margin-left:auto;">
321
- <tr> <td colspan="5"> <h3>' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
322
  <tr>
323
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
324
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
@@ -592,11 +577,13 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
592
  public static function wcal_update_status_of_guest( $cart_id, $abandoned_cart_time, $time_to_send_template_after, $wcal_user_email_address ) {
593
  global $wpdb;
594
 
595
- $results_query_email = $wpdb->get_results(
596
  $wpdb->prepare(
597
- "SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `" . $wpdb->prefix . "postmeta` AS wpm LEFT JOIN `" . $wpdb->prefix . "posts` AS wpost ON wpm.post_id = wpost.ID
598
- WHERE wpm.meta_key = '_billing_email' AND wpm.meta_value = %s AND wpm.post_id = wpost.ID AND wpost.post_type = 'shop_order' Order BY wpm.post_id DESC LIMIT 1",
599
- $wcal_user_email_address
 
 
600
  )
601
  );
602
 
@@ -838,5 +825,4 @@ if ( ! class_exists( 'woocommerce_abandon_cart_cron' ) ) {
838
  }
839
  }
840
  }
841
- $woocommerce_abandon_cart_cron = new woocommerce_abandon_cart_cron();
842
-
1
  <?php
2
  /**
3
+ * Abandon Cart Lite AUtomated Reminder emails.
4
+ *
5
  * It will send the automatic reminder emails to the customers.
6
  *
7
  * @author Tyche Softwares
8
  * @package Abandoned-Cart-Lite-for-WooCommerce/Cron
9
  */
10
 
11
+ if ( ! class_exists( 'Wcal_Cron' ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  /**
14
  * It will send the automatic reminder emails to the customers
15
  *
16
  * @since 1.3
17
  */
18
+ class Wcal_Cron {
19
 
20
  /**
21
  * It will send the reminder emails to the cutomers.
59
  } elseif ( 'Hours' === $value->day_or_hour ) {
60
  $time_to_send_template_after = intval( $value->frequency ) * $hour_seconds;
61
  }
62
+
63
  $carts = $this->wcal_get_carts( $time_to_send_template_after, $cart_abandon_cut_off_time, $value->id );
64
 
65
  $email_frequency = $value->frequency;
145
 
146
  $results_wcal_check_if_cart_is_present_in_post_meta = $wpdb->get_results( // phpcs:ignore
147
  $wpdb->prepare(
148
+ 'SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `' . $wpdb->prefix . 'postmeta` AS wpm
149
+ LEFT JOIN `' . $wpdb->prefix . 'posts` AS wpost
150
  ON wpm.post_id = wpost.ID
151
+ WHERE wpm.meta_key = %s AND
152
  wpm.meta_value = %s AND wpm.post_id = wpost.ID AND
153
+ wpost.post_type = %s
154
+ ORDER BY wpm.post_id DESC LIMIT 1',
155
+ 'wcal_recover_order_placed',
156
+ $value->id,
157
+ 'shop_order'
158
  )
159
  );
160
 
290
  $line_subtotal_header = __( 'Line Subtotal', 'woocommerce-abandoned-cart' );
291
 
292
  if ( class_exists( 'WP_Better_Emails' ) ) {
293
+
294
  $var = '<table width = 100% style="margin-right: auto; margin-left:auto;">
295
+ <tr> <td colspan="5"> <h3 style="text-align:center">' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
296
  <tr>
297
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
298
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
301
  <th>' . apply_filters( 'wcal_reminder_email_line_subtotal_header', $line_subtotal_header ) . '</th>
302
  </tr>';
303
  } else {
304
+
305
  $var = '<table border="0" cellpadding="10" cellspacing="0" class="templateDataTable" style="margin-right: auto; margin-left:auto;">
306
+ <tr> <td colspan="5"> <h3 style="text-align:center">' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
307
  <tr>
308
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
309
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
577
  public static function wcal_update_status_of_guest( $cart_id, $abandoned_cart_time, $time_to_send_template_after, $wcal_user_email_address ) {
578
  global $wpdb;
579
 
580
+ $results_query_email = $wpdb->get_results( // phpcs:ignore
581
  $wpdb->prepare(
582
+ 'SELECT wpm.post_id, wpost.post_date, wpost.post_status FROM `' . $wpdb->prefix . 'postmeta` AS wpm LEFT JOIN `' . $wpdb->prefix . 'posts` AS wpost ON wpm.post_id = wpost.ID
583
+ WHERE wpm.meta_key = %s AND wpm.meta_value = %s AND wpm.post_id = wpost.ID AND wpost.post_type = %s Order BY wpm.post_id DESC LIMIT 1',
584
+ '_billing_email',
585
+ $wcal_user_email_address,
586
+ 'shop_order'
587
  )
588
  );
589
 
825
  }
826
  }
827
  }
828
+ $wcal_cron = new Wcal_Cron();
 
includes/admin/{class-wcal-privacy-export.php → class-wcal-personal-data-export.php} RENAMED
@@ -4,8 +4,10 @@
4
  * Dashboard->Tools->Export Personal Data
5
  *
6
  * @since 4.9
 
7
  */
8
- // Exit if accessed directly
 
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit;
11
  }
@@ -24,22 +26,21 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
24
  * @since 7.8
25
  */
26
  public function __construct() {
27
- // Hook into the WP export process
28
  add_filter( 'wp_privacy_personal_data_exporters', array( &$this, 'wcal_exporter_array' ), 6 );
29
  }
30
 
31
  /**
32
- * Add our export and it's callback function
33
  *
34
- * @param array $exporters - Any exportes that need to be added by 3rd party plugins
35
- * @param array $exporters - Exportes list containing our plugin details
36
  *
37
  * @since 4.9
38
  */
39
  public static function wcal_exporter_array( $exporters = array() ) {
40
 
41
  $exporter_list = array();
42
- // Add our export and it's callback function
43
  $exporter_list['wcal_carts'] = array(
44
  'exporter_friendly_name' => __( 'Abandoned & Recovered Carts', 'woocommerce-abandoned-cart' ),
45
  'callback' => array( 'Wcal_Personal_Data_Export', 'wcal_data_exporter' ),
@@ -53,17 +54,17 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
53
 
54
  /**
55
  * Returns data to be displayed for exporting the
56
- * cart details
57
  *
58
- * @param string $email_address - EMail Address for which personal data is being exported
59
- * @param integer $page - The Export page number
60
- * @return array $data_to_export - Data to be exported
61
  *
62
  * @hook wp_privacy_personal_data_exporters
63
  * @global $wpdb
64
  * @since 4.9
65
  */
66
- static function wcal_data_exporter( $email_address, $page ) {
67
 
68
  global $wpdb;
69
 
@@ -77,20 +78,27 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
77
 
78
  $user_id = $user ? (int) $user->ID : 0;
79
 
80
- if ( $user_id > 0 ) { // registered user
81
-
82
- $cart_query = 'SELECT id FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
83
- WHERE user_id = %d AND
84
- user_type = 'REGISTERED' AND abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart'";
85
 
86
- $cart_ids = $wpdb->get_results( $wpdb->prepare( $cart_query, $user_id ) );
87
- } else { // guest carts
88
- $guest_query = 'SELECT id FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . '`
89
- WHERE email_id = %s';
 
 
 
 
 
 
90
 
91
- $guest_user_ids = $wpdb->get_results( $wpdb->prepare( $guest_query, $email_address ) );
 
 
 
 
 
92
 
93
- if ( 0 == count( $guest_user_ids ) ) {
94
  return array(
95
  'data' => array(),
96
  'done' => true,
@@ -100,12 +108,14 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
100
  $cart_ids = array();
101
 
102
  foreach ( $guest_user_ids as $ids ) {
103
- // get the cart data
104
- $cart_query = 'SELECT id, abandoned_cart_info AS cart_info FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . "`
105
- WHERE user_id = %d AND
106
- user_type = 'GUEST'";
107
-
108
- $cart_data = $wpdb->get_results( $wpdb->prepare( $cart_query, $ids->id ) );
 
 
109
 
110
  $cart_ids = array_merge( $cart_ids, $cart_data );
111
  }
@@ -146,26 +156,29 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
146
  }
147
 
148
  /**
149
- * Returns the personal data for each abandoned cart
150
  *
151
- * @param integer $abandoned_id - Abandoned Cart ID
152
- * @return array $personal_data - Personal data to be displayed
153
  * @global $wpdb
154
  * @since 4.9
155
  */
156
- static function get_cart_data( $abandoned_id ) {
157
  $personal_data = array();
158
 
159
  global $wpdb;
160
 
161
- $cart_query = 'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . '`
162
- WHERE id = %d';
163
- $cart_details = $wpdb->get_results( $wpdb->prepare( $cart_query, $abandoned_id ) );
 
 
 
164
  $cart_details = $cart_details[0];
165
  $user_id = $cart_details->user_id;
166
  $user_type = $cart_details->user_type;
167
 
168
- if ( $user_type == 'GUEST' ) {
169
 
170
  $cart_details_to_export = apply_filters(
171
  'wcal_personal_export_cart_details_prop',
@@ -206,7 +219,7 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
206
  $cart_details_formatted = self::wcal_get_cart_details_export( $cart_info );
207
  }
208
 
209
- if ( 'GUEST' == $user_type ) {
210
  $guest_details = self::wcal_get_guest_personal_info( $user_id );
211
  }
212
  foreach ( $cart_details_to_export as $prop => $name ) {
@@ -216,7 +229,7 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
216
  $value = $cart_details->id;
217
  break;
218
  case 'date_created':
219
- $value = date( 'Y-m-d H:i:s', $cart_details->abandoned_cart_time );
220
  break;
221
  case 'cart_status':
222
  $cart_ignored = $cart_details->cart_ignored;
@@ -253,35 +266,35 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
253
  $product_name = $cart_details_formatted[ $k ]['product_name'];
254
  $qty = $cart_details_formatted[ $k ]['qty'];
255
 
256
- $value .= ( $value == '' ) ? "$product_name x $qty" : ", $product_name x $qty";
257
  }
258
  }
259
  break;
260
  case 'formatted_billing_address':
261
- if ( $user_type == 'REGISTERED' ) { // registered user
262
 
263
  $billing = wcal_common::wcal_get_billing_details( $user_id );
264
- $value = get_user_meta( $user_id, 'billing_first_name', true ); // First Name
265
- $value .= ' ' . get_user_meta( $user_id, 'billing_last_name', true ); // Last Name
266
  if ( count( $billing ) > 0 ) {
267
  foreach ( $billing as $details ) {
268
- if ( '' != $details ) {
269
  $value .= ",$details ";
270
  }
271
  }
272
  }
273
- } elseif ( 'GUEST' == $user_type ) {
274
  if ( count( $guest_details ) > 0 ) {
275
- $value = $guest_details->billing_first_name; // First Name
276
- $value .= ' ' . $guest_details->billing_last_name; // Last Name
277
  }
278
  }
279
  break;
280
 
281
  case 'billing_email':
282
- if ( 'REGISTERED' == $user_type ) { // registered user
283
  $value = get_user_meta( $user_id, $prop, true );
284
- } elseif ( 'GUEST' == $user_type ) {
285
  if ( count( $guest_details ) > 0 ) {
286
  $value = $guest_details->$prop;
287
  }
@@ -307,21 +320,23 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
307
 
308
  /**
309
  * Returns the personal data from the plugin guest cart table
310
- * for guest abandoned carts
311
  *
312
- * @param integer $user_id - User ID
313
- * @return array $guest_details - Guest personal details
314
  * @global $wpdb
315
  * @since 4.9
316
  */
317
- static function wcal_get_guest_personal_info( $user_id ) {
318
  global $wpdb;
319
  $guest_details = array();
320
 
321
- $guest_query = 'SELECT billing_first_name, billing_last_name, email_id AS billing_email, phone AS billing_phone FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . '`
322
- WHERE id = %d';
323
-
324
- $guest_details = $wpdb->get_results( $wpdb->prepare( $guest_query, $user_id ) );
 
 
325
 
326
  if ( is_array( $guest_details ) && count( $guest_details ) > 0 ) {
327
  $guest_details = $guest_details[0];
@@ -334,11 +349,11 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
334
  * Returns the Cart Details such as quantity, product name
335
  * etc.
336
  *
337
- * @param object $cart_info - Abandoned Cart Information
338
- * @return array $cart_details - Array containing product, qty & total for each item
339
  * @since 4.9
340
  */
341
- static function wcal_get_cart_details_export( $cart_info ) {
342
 
343
  $cart_details = array();
344
 
@@ -347,15 +362,15 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
347
  $cart_total = 0;
348
  foreach ( $cart_info as $k => $item_detail ) {
349
 
350
- // Qty
351
  $qty = $item_detail->quantity;
352
 
353
- // Product Name
354
  $product_id = $item_detail->product_id;
355
  $prod_obj = wc_get_product( $product_id );
356
  $product_name = $prod_obj->get_name();
357
 
358
- // Variation Name
359
  if ( isset( $item_detail->variation_id ) && $item_detail->variation_id > 0 ) {
360
  $variation_id = $item_detail->variation_id;
361
  $variation = wc_get_product( $variation_id );
@@ -364,13 +379,13 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
364
  $product_name = $variation_name;
365
  }
366
 
367
- // Total
368
  $item_total = $item_detail->line_total;
369
  if ( $item_detail->line_subtotal_tax > 0 ) {
370
  $item_total += $item_detail->line_subtotal_tax;
371
  }
372
 
373
- // Populate the array
374
  $cart_details[ $k ]['qty'] = $qty;
375
  $cart_details[ $k ]['product_name'] = $product_name;
376
  $cart_details[ $k ]['item_total'] = $item_total;
@@ -384,6 +399,5 @@ if ( ! class_exists( 'Wcal_Personal_Data_Export' ) ) {
384
  return $cart_details;
385
  }
386
  } // end of class
387
- $Wcal_Personal_Data_Export = new Wcal_Personal_Data_Export();
388
  } // end if
389
-
4
  * Dashboard->Tools->Export Personal Data
5
  *
6
  * @since 4.9
7
+ * @package Abandoned-Cart-Lite-for-WooCommerce\Data-Export
8
  */
9
+
10
+ // Exit if accessed directly.
11
  if ( ! defined( 'ABSPATH' ) ) {
12
  exit;
13
  }
26
  * @since 7.8
27
  */
28
  public function __construct() {
29
+ // Hook into the WP export process.
30
  add_filter( 'wp_privacy_personal_data_exporters', array( &$this, 'wcal_exporter_array' ), 6 );
31
  }
32
 
33
  /**
34
+ * Add our export and it's callback function.
35
  *
36
+ * @param array $exporters - Exportes list containing our plugin details.
 
37
  *
38
  * @since 4.9
39
  */
40
  public static function wcal_exporter_array( $exporters = array() ) {
41
 
42
  $exporter_list = array();
43
+ // Add our export and it's callback function.
44
  $exporter_list['wcal_carts'] = array(
45
  'exporter_friendly_name' => __( 'Abandoned & Recovered Carts', 'woocommerce-abandoned-cart' ),
46
  'callback' => array( 'Wcal_Personal_Data_Export', 'wcal_data_exporter' ),
54
 
55
  /**
56
  * Returns data to be displayed for exporting the
57
+ * cart details.
58
  *
59
+ * @param string $email_address - EMail Address for which personal data is being exported.
60
+ * @param integer $page - The Export page number.
61
+ * @return array $data_to_export - Data to be exported.
62
  *
63
  * @hook wp_privacy_personal_data_exporters
64
  * @global $wpdb
65
  * @since 4.9
66
  */
67
+ public static function wcal_data_exporter( $email_address, $page ) {
68
 
69
  global $wpdb;
70
 
78
 
79
  $user_id = $user ? (int) $user->ID : 0;
80
 
81
+ if ( $user_id > 0 ) { // registered user.
 
 
 
 
82
 
83
+ $cart_ids = $wpdb->get_results( // phpcs:ignore
84
+ $wpdb->prepare(
85
+ 'SELECT id FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE user_id = %d AND user_type = %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s', // phpcs:ignore
86
+ $user_id,
87
+ 'REGISTERED',
88
+ "%$blank_cart_info%",
89
+ "%$blank_cart%"
90
+ )
91
+ );
92
+ } else { // guest carts.
93
 
94
+ $guest_user_ids = $wpdb->get_results( // phpcs:ignore
95
+ $wpdb->prepare(
96
+ 'SELECT id FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . '` WHERE email_id = %s', // phpcs:ignore
97
+ $email_address
98
+ )
99
+ );
100
 
101
+ if ( 0 === count( $guest_user_ids ) ) {
102
  return array(
103
  'data' => array(),
104
  'done' => true,
108
  $cart_ids = array();
109
 
110
  foreach ( $guest_user_ids as $ids ) {
111
+ // Get the cart data.
112
+ $cart_data = $wpdb->get_results( // phpcs:ignore
113
+ $wpdb->prepare(
114
+ 'SELECT id, abandoned_cart_info AS cart_info FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE user_id = %d AND user_type = %s', // phpcs:ignore
115
+ $ids->id,
116
+ 'GUEST'
117
+ )
118
+ );
119
 
120
  $cart_ids = array_merge( $cart_ids, $cart_data );
121
  }
156
  }
157
 
158
  /**
159
+ * Returns the personal data for each abandoned cart.
160
  *
161
+ * @param integer $abandoned_id - Abandoned Cart ID.
162
+ * @return array $personal_data - Personal data to be displayed.
163
  * @global $wpdb
164
  * @since 4.9
165
  */
166
+ public static function get_cart_data( $abandoned_id ) {
167
  $personal_data = array();
168
 
169
  global $wpdb;
170
 
171
+ $cart_details = $wpdb->get_results( // phpcs:ignore
172
+ $wpdb->prepare(
173
+ 'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite' . '` WHERE id = %d', // phpcs:ignore
174
+ $abandoned_id
175
+ )
176
+ );
177
  $cart_details = $cart_details[0];
178
  $user_id = $cart_details->user_id;
179
  $user_type = $cart_details->user_type;
180
 
181
+ if ( 'GUEST' === $user_type ) {
182
 
183
  $cart_details_to_export = apply_filters(
184
  'wcal_personal_export_cart_details_prop',
219
  $cart_details_formatted = self::wcal_get_cart_details_export( $cart_info );
220
  }
221
 
222
+ if ( 'GUEST' === $user_type ) {
223
  $guest_details = self::wcal_get_guest_personal_info( $user_id );
224
  }
225
  foreach ( $cart_details_to_export as $prop => $name ) {
229
  $value = $cart_details->id;
230
  break;
231
  case 'date_created':
232
+ $value = date( 'Y-m-d H:i:s', $cart_details->abandoned_cart_time ); // phpcs:ignore
233
  break;
234
  case 'cart_status':
235
  $cart_ignored = $cart_details->cart_ignored;
266
  $product_name = $cart_details_formatted[ $k ]['product_name'];
267
  $qty = $cart_details_formatted[ $k ]['qty'];
268
 
269
+ $value .= ( '' === $value ) ? "$product_name x $qty" : ", $product_name x $qty";
270
  }
271
  }
272
  break;
273
  case 'formatted_billing_address':
274
+ if ( 'REGISTERED' === $user_type ) { // registered user.
275
 
276
  $billing = wcal_common::wcal_get_billing_details( $user_id );
277
+ $value = get_user_meta( $user_id, 'billing_first_name', true ); // First Name.
278
+ $value .= ' ' . get_user_meta( $user_id, 'billing_last_name', true ); // Last Name.
279
  if ( count( $billing ) > 0 ) {
280
  foreach ( $billing as $details ) {
281
+ if ( '' !== $details ) {
282
  $value .= ",$details ";
283
  }
284
  }
285
  }
286
+ } elseif ( 'GUEST' === $user_type ) {
287
  if ( count( $guest_details ) > 0 ) {
288
+ $value = $guest_details->billing_first_name; // First Name.
289
+ $value .= ' ' . $guest_details->billing_last_name; // Last Name.
290
  }
291
  }
292
  break;
293
 
294
  case 'billing_email':
295
+ if ( 'REGISTERED' === $user_type ) { // registered user.
296
  $value = get_user_meta( $user_id, $prop, true );
297
+ } elseif ( 'GUEST' === $user_type ) {
298
  if ( count( $guest_details ) > 0 ) {
299
  $value = $guest_details->$prop;
300
  }
320
 
321
  /**
322
  * Returns the personal data from the plugin guest cart table
323
+ * for guest abandoned carts.
324
  *
325
+ * @param integer $user_id - User ID.
326
+ * @return array $guest_details - Guest personal details.
327
  * @global $wpdb
328
  * @since 4.9
329
  */
330
+ public static function wcal_get_guest_personal_info( $user_id ) {
331
  global $wpdb;
332
  $guest_details = array();
333
 
334
+ $guest_details = $wpdb->get_results( // phpcs:ignore
335
+ $wpdb->prepare(
336
+ 'SELECT billing_first_name, billing_last_name, email_id AS billing_email, phone AS billing_phone FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite' . '` WHERE id = %d', // phpcs:ignore
337
+ $user_id
338
+ )
339
+ );
340
 
341
  if ( is_array( $guest_details ) && count( $guest_details ) > 0 ) {
342
  $guest_details = $guest_details[0];
349
  * Returns the Cart Details such as quantity, product name
350
  * etc.
351
  *
352
+ * @param object $cart_info - Abandoned Cart Information.
353
+ * @return array $cart_details - Array containing product, qty & total for each item.
354
  * @since 4.9
355
  */
356
+ public static function wcal_get_cart_details_export( $cart_info ) {
357
 
358
  $cart_details = array();
359
 
362
  $cart_total = 0;
363
  foreach ( $cart_info as $k => $item_detail ) {
364
 
365
+ // Qty.
366
  $qty = $item_detail->quantity;
367
 
368
+ // Product Name.
369
  $product_id = $item_detail->product_id;
370
  $prod_obj = wc_get_product( $product_id );
371
  $product_name = $prod_obj->get_name();
372
 
373
+ // Variation Name.
374
  if ( isset( $item_detail->variation_id ) && $item_detail->variation_id > 0 ) {
375
  $variation_id = $item_detail->variation_id;
376
  $variation = wc_get_product( $variation_id );
379
  $product_name = $variation_name;
380
  }
381
 
382
+ // Total.
383
  $item_total = $item_detail->line_total;
384
  if ( $item_detail->line_subtotal_tax > 0 ) {
385
  $item_total += $item_detail->line_subtotal_tax;
386
  }
387
 
388
+ // Populate the array.
389
  $cart_details[ $k ]['qty'] = $qty;
390
  $cart_details[ $k ]['product_name'] = $product_name;
391
  $cart_details[ $k ]['item_total'] = $item_total;
399
  return $cart_details;
400
  }
401
  } // end of class
402
+ $wcal_personal_data_export = new Wcal_Personal_Data_Export();
403
  } // end if
 
includes/admin/{wcap_add_cart_popup_modal.php → class-wcap-add-cart-popup-modal.php} RENAMED
@@ -1,701 +1,339 @@
1
  <?php
2
-
3
  /**
4
-
5
  * It will fetch the Add to cart data, generate and populate data in the modal.
6
-
7
  * @author Tyche Softwares
8
-
9
  * @package Abandoned-Cart-Pro-for-WooCommerce/Admin/Settings
10
-
11
  * @since 6.0
12
  */
13
 
14
  if ( ! defined( 'ABSPATH' ) ) {
15
-
16
  exit; // Exit if accessed directly.
17
-
18
  }
19
 
20
  if ( ! class_exists( 'Wcap_Add_Cart_Popup_Modal' ) ) {
21
 
22
-
23
-
24
  /**
25
-
26
  * It will fetch the Add to cart data, generate and populate data in the modal.
27
-
28
  * @since 6.0
29
  */
30
-
31
  class Wcap_Add_Cart_Popup_Modal {
32
-
33
-
34
-
35
  /**
36
-
37
  * This function will add the add to cart popup medal's settings.
38
-
39
  * @since 6.0
40
  */
41
-
42
  public static function wcap_add_to_cart_popup_settings() {
43
 
44
- $wcap_atc_enabled = get_option( 'wcap_atc_enable_modal' );
45
-
46
  $wcap_disabled_field = '';
47
 
48
- if ( 'off' == $wcap_atc_enabled ) {
49
-
50
  $wcap_disabled_field = 'disabled="disabled"';
51
-
52
  }
53
-
54
  ?>
55
 
56
  <div id = "wcap_popup_main_div" class = "wcap_popup_main_div ">
57
-
58
  <table id = "wcap_popup_main_table" class = "wcap_popup_main_table test_borders">
59
-
60
  <tr id = "wcap_popup_main_table_tr" class = "wcap_popup_main_table_tr test_borders">
61
-
62
  <td id = "wcap_popup_main_table_td_settings" class = "wcap_popup_main_table_td_settings test_borders">
63
-
64
  <?php self::wcap_enable_modal_section( $wcap_disabled_field ); ?>
65
-
66
  <?php self::wcap_custom_pages_section( $wcap_disabled_field ); ?>
67
-
68
  <div class = "wcap_atc_all_fields_container" >
69
-
70
  <?php self::wcap_add_heading_section( $wcap_disabled_field ); ?>
71
-
72
  <?php self::wcap_add_text_section( $wcap_disabled_field ); ?>
73
-
74
  <?php self::wcap_email_placeholder_section( $wcap_disabled_field ); ?>
75
-
76
  <?php self::wcap_button_section( $wcap_disabled_field ); ?>
77
-
78
  <?php self::wcap_mandatory_modal_section( $wcap_disabled_field ); ?>
79
-
80
  <?php self::wcap_non_mandatory_modal_section_field( $wcap_disabled_field ); ?>
81
-
82
  </div>
83
-
84
  </td>
85
-
86
  <td id = "wcap_popup_main_table_td_preview" class = "wcap_popup_main_table_td_preview test_borders">
87
-
88
  <div class = "wcap_atc_all_fields_container" >
89
-
90
  <?php self::wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ); ?>
91
-
92
  </div>
93
-
94
  </td>
95
-
96
  </tr>
97
-
98
  <tr>
99
-
100
  <td>
101
-
102
  <div class = "wcap_atc_all_fields_container" >
103
-
104
  <p class = "submit">
105
-
106
- <input type = "submit" name = "submit" id = "submit" disabled class = "button button-primary" value = "Save Changes" <?php echo $wcap_disabled_field; ?> >
107
-
108
- <input type = "submit" name = "submit" id = "submit" disabled class = "wcap_reset_button button button-primary" value = "Reset to default configuration" <?php echo $wcap_disabled_field; ?> >
109
-
110
  </p>
111
-
112
  </div>
113
-
114
  </td>
115
-
116
  </tr>
117
-
118
  </table>
119
-
120
  </div>
121
-
122
  <?php
123
-
124
  }
125
 
126
-
127
-
128
  /**
129
-
130
  * It will add the "Enable Add to cart popup modal" setting on the add to cart modal settings page.
131
-
132
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
133
-
134
  * @since 6.0
135
  */
136
-
137
  public static function wcap_enable_modal_section( $wcap_disabled_field ) {
138
-
139
  ?>
140
-
141
  <table class = "wcap_enable_atc wcap_atc_between_fields_space" id = "wcap_enable_atc" >
142
-
143
- <th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> <?php _e( 'Enable Add to cart popup modal', 'woocommerce-abandoned-cart' ); ?> </th>
144
-
145
  <tr>
146
-
147
  <td>
148
-
149
- <?php
150
-
151
- $wcap_atc_enabled = get_option( 'wcap_atc_enable_modal' );
152
-
153
- $active_text = $wcap_atc_enabled;
154
-
155
- ?>
156
-
157
- <button type = "button" class = "wcap-enable-atc-modal wcap-toggle-atc-modal-enable-status" wcap-atc-switch-modal-enable = 'off' ?> readonly>
158
-
159
- <?php echo $active_text; ?>
160
-
161
- </button>
162
-
163
  </td>
164
-
165
  </tr>
166
-
167
  </table>
168
-
169
  <?php
170
-
171
  }
172
 
173
-
174
-
175
  /**
176
-
177
  * Adds a multi select searchable dropdown from where
178
-
179
  * the admin can select custom pages on which the
180
-
181
  * Add to Cart Popup modal should be displayed.
182
  *
183
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
184
-
185
  * @since 7.10.0
186
  */
187
-
188
  public static function wcap_custom_pages_section( $wcap_disabled_field ) {
189
 
190
- global $woocommerce;
191
-
192
  $post_title_array = array();
193
-
194
  ?>
195
 
196
  <table class = "wcap_custom_pages wcap_atc_between_fields_space" id = "wcap_custom_pages" >
197
-
198
  <tr>
199
-
200
- <th id="wcap_button_section_table_heading" class="wcap_button_section_table_heading"> <?php _e( 'Custom pages to display the pop-up modal on', 'woocommerce-abandoned-cart' ); ?> </th>
201
-
202
  </tr>
203
-
204
  <tr>
205
-
206
  <td>
207
-
208
  <?php
209
-
210
  $custom_pages = get_option( 'wcap_custom_pages_list' );
211
-
212
  ?>
213
-
214
  <?php if ( $woocommerce->version >= '3.0' ) { ?>
215
-
216
  <select style="width:80%" multiple="multiple" class="wcap_page_select wc-product-search" name="wcap_page_select[]" data-placeholder='<?php esc_attr__( 'Search for a Page&hellip;', 'woocommerce-abandoned-cart' ); ?>' data-action='wcap_json_find_pages' disabled>
217
-
218
-
219
-
220
- <?php
221
-
222
- if ( is_array( $custom_pages ) && count( $custom_pages ) > 0 ) {
223
-
224
- foreach ( $custom_pages as $page_ids ) {
225
-
226
- $post_id = $page_ids;
227
-
228
- $post_title = get_the_title( $post_id );
229
-
230
- printf( "<option value='%s' selected>%s</option>\n", $post_id, $post_title );
231
-
232
- }
233
- }
234
-
235
- ?>
236
-
237
  </select>
238
-
239
  <?php
240
  } else {
241
-
242
- if ( is_array( $post_title_array ) && is_array( $custom_pages ) && count( $custom_pages ) > 0 ) {
243
-
244
- foreach ( $custom_pages as $page_ids ) {
245
-
246
- $post_id = $page_ids;
247
-
248
- $post_title = get_the_title( $post_id );
249
-
250
- $post_title_array[ $post_title ] = $post_title;
251
-
252
- }
253
- }
254
-
255
  ?>
256
-
257
-
258
-
259
- <input type="hidden" style="width:80%" id = "wcap_page_select" class="wc-product-search" name="wcap_page_select[]" data-placeholder='<?php esc_attr_e( 'Search for a Page&hellip;', 'woocommerce-abandoned-cart' ); ?>' data-multiple="true" data-action='wcap_json_find_pages' data-selected=" <?php echo esc_attr( json_encode( $post_title_array ) ); ?>" value="<?php echo implode( ',', array_keys( $post_title_array ) ); ?>" readonly/>
260
-
261
-
262
-
263
- <?php } ?>
264
-
265
-
266
-
267
- <?php $toolTip = __( 'Please add any custom pages (not created by WooCommerce) where you wish to display the Add to cart Pop-up Modal.', 'woocommerce-abandoned-cart' ); ?>
268
-
269
- <?php echo wc_help_tip( $toolTip ); ?>
270
-
271
  </td>
272
-
273
  </tr>
274
-
275
  <tr>
276
-
277
  <td colspan="2" style="text-align: justify;">
278
-
279
- <?php _e( '<b>Note:</b> Please ensure that the Add to Cart button links on these pages are added with the correct classes and attributes to ensure the plugin can capture the cart data correctly. For further guidance, please check the documentation.', 'woocommerce-abandoned-cart' ); ?>
280
-
281
  </td>
282
-
283
  </tr>
284
-
285
  </table>
286
 
287
  <?php
288
-
289
  }
290
 
291
  /**
292
-
293
  * It will add the setting for Heading section on the add to cart modal settings page.
294
-
295
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
296
-
297
  * @since 6.0
298
  */
299
-
300
  public static function wcap_add_heading_section( $wcap_disabled_field ) {
301
-
302
  ?>
303
 
304
  <div id = "wcap_heading_section_div" class = "wcap_heading_section_div wcap_atc_between_fields_space">
305
-
306
  <table id = "wcap_heading_section_table" class = "wcap_heading_section_table">
307
-
308
  <th id = "wcap_heading_section_table_heading" class ="wcap_heading_section_table_heading"> Modal Heading </th>
309
-
310
  <tr id = "wcap_heading_section_tr" class = "wcap_heading_section_tr" >
311
-
312
  <td id = "wcap_heading_section_text_field" class = "wcap_heading_section_text_field test_borders">
313
-
314
  <input id = "wcap_heading_section_text_email" v-model = "wcap_heading_section_text_email" name = "wcap_heading_section_text_email"class = "wcap_heading_section_text_email"
315
-
316
- <?php echo $wcap_disabled_field; ?> readonly value="<?php _e( 'Please enter your email address', 'woocommerce-abandoned-cart' ); ?>">
317
-
318
  </td>
319
-
320
  <td id = "wcap_heading_section_text_field_color" class = "wcap_heading_section_text_field_color test_borders">
321
-
322
- <?php $wcap_popup_heading_color_picker = get_option( 'wcap_popup_heading_color_picker' ); ?>
323
-
324
- <span class = "colorpickpreview" style = "background:<?php echo $wcap_popup_heading_color_picker; ?>"></span>
325
-
326
- <input class = "wcap_popup_heading_color_picker colorpick" name = "wcap_popup_heading_color_picker" value = "#737f97" v-model = "wcap_popup_heading_color" v-on:input = "wcap_atc_popup_heading.color = $event.target.value"
327
-
328
- <?php echo $wcap_disabled_field; ?> readonly >
329
-
330
  </td>
331
-
332
- </tr>
333
-
334
  </table>
335
-
336
  </div>
337
-
338
  <?php
339
-
340
  }
341
 
342
-
343
-
344
  /**
345
-
346
  * It will add the setting for Text displayed below heading section on the add to cart modal settings page.
347
-
348
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
349
-
350
  * @since 6.0
351
  */
352
-
353
  public static function wcap_add_text_section( $wcap_disabled_field ) {
354
-
355
  ?>
356
-
357
  <div id = "wcap_text_section_div" class = "wcap_text_section_div wcap_atc_between_fields_space">
358
-
359
  <table id = "wcap_text_section_table" class = "wcap_text_section_table">
360
-
361
  <th id = "wcap_text_section_table_heading" class = "wcap_text_section_table_heading"> Modal Text </th>
362
-
363
  <tr id = "wcap_text_section_tr" class = "wcap_text_section_tr" >
364
-
365
  <td id = "wcap_text_section_text_field" class = "wcap_text_section_text_field test_borders">
366
-
367
- <input id = "wcap_text_section_text" v-model = "wcap_text_section_text_field" class="wcap_text_section_input_text" name = "wcap_text_section_text"
368
-
369
- <?php echo $wcap_disabled_field; ?> readonly value="<?php _e( 'To add this item to your cart, please enter your email address.', 'woocommerce-abandoned-cart' ); ?>">
370
-
371
  </td>
372
-
373
  <td id = "wcap_text_section_field_color" class = "wcap_text_section_field_color test_borders">
374
-
375
- <?php $wcap_atc_popup_text_color = get_option( 'wcap_popup_text_color_picker' ); ?>
376
-
377
- <span class = "colorpickpreview" style = "background:<?php echo $wcap_atc_popup_text_color; ?>"></span>
378
-
379
- <input class = "wcap_popup_text_color_picker colorpick" name = "wcap_popup_text_color_picker" value = "#bbc9d2" v-model = "wcap_popup_text_color" v-on:input = "wcap_atc_popup_text.color = $event.target.value"
380
-
381
- <?php echo $wcap_disabled_field; ?> readonly>
382
-
383
  </td>
384
-
385
  </tr>
386
-
387
  </table>
388
-
389
  </div>
390
-
391
  <?php
392
-
393
  }
394
 
395
-
396
-
397
  /**
398
-
399
  * It will add the setting for email placeholder on the add to cart modal settings page.
400
-
401
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
402
-
403
  * @since 6.0
404
  */
405
-
406
  public static function wcap_email_placeholder_section( $wcap_disabled_field ) {
407
-
408
  ?>
409
 
410
  <div id = "wcap_email_placeholder_section_div" class = "wcap_email_placeholder_section_div wcap_atc_between_fields_space">
411
-
412
  <table id = "wcap_email_placeholder_section_table" class = "wcap_email_placeholder_section_table">
413
-
414
- <th id = "wcap_email_placeholder_section_table_heading" class = "wcap_email_placeholder_section_table_heading"> Email placeholder </th>
415
-
416
  <tr id = "wcap_email_placeholder_section_tr" class = "wcap_email_placeholder_section_tr" >
417
-
418
  <td id = "wcap_email_placeholder_section_text_field" class = "wcap_email_placeholder_section_text_field test_borders">
419
-
420
  <input id = "wcap_email_placeholder_section_input_text" v-model = "wcap_email_placeholder_section_input_text" class="wcap_email_placeholder_section_input_text" name = "wcap_email_placeholder_section_input_text"
421
-
422
- <?php echo $wcap_disabled_field; ?> readonly value="<?php _e( 'Email address', 'woocommerce-abandoned-cart' ); ?>">
423
-
424
  </td>
425
-
426
  </tr>
427
-
428
  </table>
429
-
430
  </div>
431
-
432
  <?php
433
-
434
  }
435
 
436
-
437
-
438
  /**
439
-
440
  * It will add the setting for Add to cart button on the add to cart modal settings page.
441
-
442
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
443
-
444
  * @since 6.0
445
  */
446
-
447
  public static function wcap_button_section( $wcap_disabled_field ) {
448
-
449
  ?>
450
 
451
  <div id = "wcap_button_section_div" class = "wcap_button_section_div wcap_atc_between_fields_space">
452
 
453
  <table id = "wcap_button_section_table" class = "wcap_button_section_table">
454
-
455
- <th id = "wcap_button_section_table_heading" class="wcap_button_section_table_heading"> Add to cart button text </th>
456
-
457
  <tr>
458
-
459
  <td id = "wcap_button_section_text_field" class = "wcap_button_section_text_field test_borders">
460
-
461
  <input id = "wcap_button_section_input_text" v-model = "wcap_button_section_input_text" class="wcap_button_section_input_text" name = "wcap_button_section_input_text"
462
-
463
- <?php echo $wcap_disabled_field; ?> readonly value="<?php _e( 'Add to Cart', 'woocommerce-abandoned-cart' ); ?>">
464
-
465
  </td>
466
-
467
  </tr>
468
 
469
  <tr id = "wcap_button_color_section_tr" class = "wcap_button_color_section_tr">
470
-
471
  <td id = "wcap_button_color_section_text_field" class = "wcap_button_color_section_text_field test_borders">
472
-
473
- <?php $wcap_atc_button_bg_color = get_option( 'wcap_button_color_picker' ); ?>
474
-
475
- <span class = "colorpickpreview" style = "background:<?php echo $wcap_atc_button_bg_color; ?>"></span>
476
-
477
- <input id = "wcap_button_color_picker" value = "#0085ba" v-model ="wcap_button_bg_color" v-on:input="wcap_atc_button.backgroundColor = $event.target.value" class="wcap_button_color_picker colorpick" name = "wcap_button_color_picker"
478
-
479
- <?php echo $wcap_disabled_field; ?> readonly >
480
-
481
  </td>
482
-
483
  <td id = "wcap_button_text_color_section_text_field" class = "wcap_button_text_color_section_text_field test_borders">
484
-
485
- <?php $wcap_button_text_color_picker = get_option( 'wcap_button_text_color_picker' ); ?>
486
-
487
- <span class = "colorpickpreview" style = "background:<?php echo $wcap_button_text_color_picker; ?>"></span>
488
-
489
- <input id = "wcap_button_text_color_picker" value = "#ffffff" v-model = "wcap_button_text_color" v-on:input = "wcap_atc_button.color = $event.target.value" class="wcap_button_text_color_picker colorpick" name = "wcap_button_text_color_picker"
490
-
491
- <?php echo $wcap_disabled_field; ?> readonly>
492
-
493
  </td>
494
-
495
  </tr>
496
-
497
  </table>
498
-
499
  </div>
500
-
501
  <?php
502
-
503
  }
504
 
505
-
506
-
507
  /**
508
-
509
  * It will add the setting for Email address mandatory field on the add to cart modal settings page.
510
-
511
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
512
-
513
  * @since 6.0
514
  */
515
-
516
  public static function wcap_mandatory_modal_section( $wcap_disabled_field ) {
517
-
518
  ?>
519
 
520
  <table class = "wcap_atc_between_fields_space">
521
-
522
  <th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> Email address is mandatory ? </th>
523
-
524
  <tr>
525
-
526
  <td>
527
-
528
- <?php
529
-
530
- $wcap_atc_email_mandatory = get_option( 'wcap_atc_mandatory_email' );
531
-
532
- $active_text = $wcap_atc_email_mandatory;
533
-
534
- ?>
535
-
536
- <button type = "button" class = "wcap-switch-atc-modal-mandatory wcap-toggle-atc-modal-mandatory" wcap-atc-switch-modal-mandatory = <?php echo $wcap_atc_email_mandatory; ?>
537
-
538
- <?php echo $wcap_disabled_field; ?> readonly >
539
-
540
- <?php echo $active_text; ?> </button>
541
-
542
  </td>
543
-
544
  </tr>
545
-
546
  </table>
547
-
548
  <?php
549
-
550
  }
551
 
552
-
553
-
554
  /**
555
-
556
  * It will add the setting for Email address non mandatory field on the add to cart modal settings page.
557
-
558
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
559
-
560
  * @since 6.0
561
  */
562
-
563
  public static function wcap_non_mandatory_modal_section_field( $wcap_disabled_field ) {
564
-
565
- $wcap_get_mandatory_field = get_option( 'wcap_atc_mandatory_email' );
566
-
567
- $wcap_disabled_email_field = '';
568
-
569
- if ( 'on' == $wcap_get_mandatory_field ) {
570
-
571
- $wcap_disabled_email_field = 'disabled="disabled"';
572
-
573
- }
574
-
575
  ?>
576
-
577
  <div id = "wcap_non_mandatory_modal_section_fields_div" class = "wcap_non_mandatory_modal_section_fields_div wcap_atc_between_fields_space">
578
-
579
  <table id = "wcap_non_mandatory_modal_section_fields_div_table" class = "wcap_non_mandatory_modal_section_fields_div_table">
580
-
581
  <th id = "wcap_non_mandatory_modal_section_fields_table_heading"
582
-
583
  class="wcap_non_mandatory_modal_section_fields_table_heading"> Not mandatory text </th>
584
-
585
  <tr id = "wcap_non_mandatory_modal_section_fields_tr" class = "wcap_non_mandatory_modal_section_fields_tr" >
586
-
587
  <td id = "wcap_non_mandatory_modal_section_fields_text_field" class = "wcap_non_mandatory_modal_section_fields_text_field test_borders">
588
-
589
- <input id = "wcap_non_mandatory_modal_section_fields_input_text" v-model = "wcap_non_mandatory_modal_input_text" class = "wcap_non_mandatory_modal_section_fields_input_text" name = "wcap_non_mandatory_modal_section_fields_input_text" readonly value="<?php _e( 'No Thanks', 'woocommerce-abandoned-cart' ); ?>"
590
-
591
- <?php
592
- echo $wcap_disabled_field;
593
-
594
- echo $wcap_disabled_email_field;
595
-
596
- ?>
597
- >
598
-
599
  </td>
600
-
601
  </tr>
602
-
603
  </table>
604
-
605
  </div>
606
-
607
  <?php
608
-
609
  }
610
 
611
-
612
-
613
  /**
614
-
615
  * It will will show th preview of the Add To cart Popup modal with the changes made on any of the settings for it.
616
-
617
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
618
-
619
  * @since 6.0
620
  */
621
-
622
  public static function wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ) {
623
-
624
  ?>
625
 
626
  <div class = "wcap_container">
627
-
628
  <div class = "wcap_popup_wrapper">
629
-
630
  <div class = "wcap_popup_content">
631
 
632
  <div class = "wcap_popup_heading_container">
633
-
634
  <div class = "wcap_popup_icon_container" >
635
-
636
  <span class = "wcap_popup_icon" >
637
-
638
  <span class = "wcap_popup_plus_sign" v-bind:style = "wcap_atc_button">
639
-
640
  </span>
641
-
642
  </span>
643
-
644
  </div>
645
-
646
  <div class = "wcap_popup_text_container">
647
-
648
- <h2 class = "wcap_popup_heading" v-bind:style = "wcap_atc_popup_heading" ><?php _e( 'Please enter your email address.', 'woocommerce-abandoned-cart' ); ?></h2>
649
-
650
- <div class = "wcap_popup_text" v-bind:style = "wcap_atc_popup_text" ><?php _e( 'To add this item to your cart, please enter your email address.', 'woocommerce-abandoned-cart' ); ?></div>
651
-
652
  </div>
653
-
654
  </div>
655
 
656
  <div class = "wcap_popup_form">
657
-
658
  <form action = "" name = "wcap_modal_form">
659
-
660
  <div class = "wcap_popup_input_field_container" >
661
-
662
- <input class = "wcap_popup_input" type = "text" value = "" name = "email" placeholder ="<?php _e( 'Email address', 'woocommerce-abandoned-cart' ); ?>"
663
-
664
- <?php echo $wcap_disabled_field; ?> readonly >
665
-
666
  </div>
667
-
668
- <button class = "wcap_popup_button" v-bind:style = "wcap_atc_button"
669
-
670
- <?php echo $wcap_disabled_field; ?> ><?php _e( 'Add to Cart', 'woocommerce-abandoned-cart' ); ?></button>
671
-
672
  <br>
673
-
674
  <br>
675
-
676
  <div id = "wcap_non_mandatory_text_wrapper" class = "wcap_non_mandatory_text_wrapper">
677
-
678
- <a class = "wcap_popup_non_mandatory_button" href = "" > <?php _e( 'No Thanks', 'woocommerce-abandoned-cart' ); ?></a>
679
-
680
  </div>
681
-
682
  </form>
683
-
684
  </div>
685
-
686
  <div class = "wcap_popup_close" ></div>
687
-
688
  </div>
689
-
690
  </div>
691
-
692
  </div>
693
-
694
  <?php
695
-
696
  }
697
-
698
  }
699
-
700
  }
701
-
1
  <?php
 
2
  /**
 
3
  * It will fetch the Add to cart data, generate and populate data in the modal.
4
+ *
5
  * @author Tyche Softwares
 
6
  * @package Abandoned-Cart-Pro-for-WooCommerce/Admin/Settings
 
7
  * @since 6.0
8
  */
9
 
10
  if ( ! defined( 'ABSPATH' ) ) {
 
11
  exit; // Exit if accessed directly.
 
12
  }
13
 
14
  if ( ! class_exists( 'Wcap_Add_Cart_Popup_Modal' ) ) {
15
 
 
 
16
  /**
 
17
  * It will fetch the Add to cart data, generate and populate data in the modal.
18
+ *
19
  * @since 6.0
20
  */
 
21
  class Wcap_Add_Cart_Popup_Modal {
 
 
 
22
  /**
 
23
  * This function will add the add to cart popup medal's settings.
24
+ *
25
  * @since 6.0
26
  */
 
27
  public static function wcap_add_to_cart_popup_settings() {
28
 
29
+ $wcap_atc_enabled = get_option( 'wcap_atc_enable_modal', '' );
 
30
  $wcap_disabled_field = '';
31
 
32
+ if ( 'off' === $wcap_atc_enabled ) {
 
33
  $wcap_disabled_field = 'disabled="disabled"';
 
34
  }
 
35
  ?>
36
 
37
  <div id = "wcap_popup_main_div" class = "wcap_popup_main_div ">
 
38
  <table id = "wcap_popup_main_table" class = "wcap_popup_main_table test_borders">
 
39
  <tr id = "wcap_popup_main_table_tr" class = "wcap_popup_main_table_tr test_borders">
 
40
  <td id = "wcap_popup_main_table_td_settings" class = "wcap_popup_main_table_td_settings test_borders">
 
41
  <?php self::wcap_enable_modal_section( $wcap_disabled_field ); ?>
 
42
  <?php self::wcap_custom_pages_section( $wcap_disabled_field ); ?>
 
43
  <div class = "wcap_atc_all_fields_container" >
 
44
  <?php self::wcap_add_heading_section( $wcap_disabled_field ); ?>
 
45
  <?php self::wcap_add_text_section( $wcap_disabled_field ); ?>
 
46
  <?php self::wcap_email_placeholder_section( $wcap_disabled_field ); ?>
 
47
  <?php self::wcap_button_section( $wcap_disabled_field ); ?>
 
48
  <?php self::wcap_mandatory_modal_section( $wcap_disabled_field ); ?>
 
49
  <?php self::wcap_non_mandatory_modal_section_field( $wcap_disabled_field ); ?>
 
50
  </div>
 
51
  </td>
 
52
  <td id = "wcap_popup_main_table_td_preview" class = "wcap_popup_main_table_td_preview test_borders">
 
53
  <div class = "wcap_atc_all_fields_container" >
 
54
  <?php self::wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ); ?>
 
55
  </div>
 
56
  </td>
 
57
  </tr>
 
58
  <tr>
 
59
  <td>
 
60
  <div class = "wcap_atc_all_fields_container" >
 
61
  <p class = "submit">
62
+ <input type="submit" name="submit" id="submit" disabled class="button button-primary" value="<?php echo esc_html_e( 'Save Changes', 'woocommerce-abandoned-cart' ); ?>" >
63
+ <input type="submit" name="submit" id="submit" disabled class="wcap_reset_button button button-primary" value="<?php echo esc_html_e( 'Reset to default configuration', 'woocommerce-abandoned-cart' ); ?>" >
 
 
 
64
  </p>
 
65
  </div>
 
66
  </td>
 
67
  </tr>
 
68
  </table>
 
69
  </div>
 
70
  <?php
 
71
  }
72
 
 
 
73
  /**
 
74
  * It will add the "Enable Add to cart popup modal" setting on the add to cart modal settings page.
75
+ *
76
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
77
  * @since 6.0
78
  */
 
79
  public static function wcap_enable_modal_section( $wcap_disabled_field ) {
 
80
  ?>
 
81
  <table class = "wcap_enable_atc wcap_atc_between_fields_space" id = "wcap_enable_atc" >
82
+ <th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> <?php echo esc_html_e( 'Enable Add to cart popup modal', 'woocommerce-abandoned-cart' ); ?> </th>
 
 
83
  <tr>
 
84
  <td>
85
+ <button type = "button" class = "wcap-enable-atc-modal wcap-toggle-atc-modal-enable-status" wcap-atc-switch-modal-enable = 'off' ?> disabled readonly>
86
+ </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  </td>
 
88
  </tr>
 
89
  </table>
 
90
  <?php
 
91
  }
92
 
 
 
93
  /**
 
94
  * Adds a multi select searchable dropdown from where
 
95
  * the admin can select custom pages on which the
 
96
  * Add to Cart Popup modal should be displayed.
97
  *
98
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
99
  * @since 7.10.0
100
  */
 
101
  public static function wcap_custom_pages_section( $wcap_disabled_field ) {
102
 
103
+ global $woocommerce;
 
104
  $post_title_array = array();
 
105
  ?>
106
 
107
  <table class = "wcap_custom_pages wcap_atc_between_fields_space" id = "wcap_custom_pages" >
 
108
  <tr>
109
+ <th id="wcap_button_section_table_heading" class="wcap_button_section_table_heading"> <?php echo esc_html_e( 'Custom pages to display the pop-up modal on', 'woocommerce-abandoned-cart' ); ?> </th>
 
 
110
  </tr>
 
111
  <tr>
 
112
  <td>
 
113
  <?php
 
114
  $custom_pages = get_option( 'wcap_custom_pages_list' );
 
115
  ?>
 
116
  <?php if ( $woocommerce->version >= '3.0' ) { ?>
 
117
  <select style="width:80%" multiple="multiple" class="wcap_page_select wc-product-search" name="wcap_page_select[]" data-placeholder='<?php esc_attr__( 'Search for a Page&hellip;', 'woocommerce-abandoned-cart' ); ?>' data-action='wcap_json_find_pages' disabled>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
  </select>
 
119
  <?php
120
  } else {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  ?>
122
+ <input type="hidden" style="width:80%" id = "wcap_page_select" class="wc-product-search" name="wcap_page_select[]" data-placeholder='<?php esc_attr_e( 'Search for a Page&hellip;', 'woocommerce-abandoned-cart' ); ?>' data-multiple="true" data-action='wcap_json_find_pages' data-selected="" value="" readonly/>
123
+ <?php
124
+ }
125
+ ?>
126
+ <?php $tool_tip = __( 'Please add any custom pages (not created by WooCommerce) where you wish to display the Add to cart Pop-up Modal.', 'woocommerce-abandoned-cart' ); ?>
127
+ <?php echo wp_kses_post( wc_help_tip( $tool_tip ) ); ?>
 
 
 
 
 
 
 
 
 
128
  </td>
 
129
  </tr>
 
130
  <tr>
 
131
  <td colspan="2" style="text-align: justify;">
132
+ <b><?php echo esc_html_e( 'Note: ', 'woocommerce-abandoned-cart' ); ?></b><?php echo esc_html_e( 'Please ensure that the Add to Cart button links on these pages are added with the correct classes and attributes to ensure the plugin can capture the cart data correctly. For further guidance, please check the documentation.', 'woocommerce-abandoned-cart' ); ?>
 
 
133
  </td>
 
134
  </tr>
 
135
  </table>
136
 
137
  <?php
 
138
  }
139
 
140
  /**
 
141
  * It will add the setting for Heading section on the add to cart modal settings page.
142
+ *
143
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
144
  * @since 6.0
145
  */
 
146
  public static function wcap_add_heading_section( $wcap_disabled_field ) {
 
147
  ?>
148
 
149
  <div id = "wcap_heading_section_div" class = "wcap_heading_section_div wcap_atc_between_fields_space">
 
150
  <table id = "wcap_heading_section_table" class = "wcap_heading_section_table">
 
151
  <th id = "wcap_heading_section_table_heading" class ="wcap_heading_section_table_heading"> Modal Heading </th>
 
152
  <tr id = "wcap_heading_section_tr" class = "wcap_heading_section_tr" >
 
153
  <td id = "wcap_heading_section_text_field" class = "wcap_heading_section_text_field test_borders">
 
154
  <input id = "wcap_heading_section_text_email" v-model = "wcap_heading_section_text_email" name = "wcap_heading_section_text_email"class = "wcap_heading_section_text_email"
155
+ readonly value="<?php echo esc_html_e( 'Please enter your email address', 'woocommerce-abandoned-cart' ); ?>">
 
 
156
  </td>
 
157
  <td id = "wcap_heading_section_text_field_color" class = "wcap_heading_section_text_field_color test_borders">
158
+ <span class = "colorpickpreview" style = "background: #737f97"></span>
159
+ <input class = "wcap_popup_heading_color_picker colorpick" name = "wcap_popup_heading_color_picker" value = "#737f97" v-model = "wcap_popup_heading_color" v-on:input = "wcap_atc_popup_heading.color = $event.target.value" readonly >
 
 
 
 
 
 
 
160
  </td>
161
+ </tr>
 
 
162
  </table>
 
163
  </div>
 
164
  <?php
 
165
  }
166
 
 
 
167
  /**
 
168
  * It will add the setting for Text displayed below heading section on the add to cart modal settings page.
169
+ *
170
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
171
  * @since 6.0
172
  */
 
173
  public static function wcap_add_text_section( $wcap_disabled_field ) {
 
174
  ?>
 
175
  <div id = "wcap_text_section_div" class = "wcap_text_section_div wcap_atc_between_fields_space">
 
176
  <table id = "wcap_text_section_table" class = "wcap_text_section_table">
 
177
  <th id = "wcap_text_section_table_heading" class = "wcap_text_section_table_heading"> Modal Text </th>
 
178
  <tr id = "wcap_text_section_tr" class = "wcap_text_section_tr" >
 
179
  <td id = "wcap_text_section_text_field" class = "wcap_text_section_text_field test_borders">
180
+ <input id = "wcap_text_section_text" v-model = "wcap_text_section_text_field" class="wcap_text_section_input_text" name = "wcap_text_section_text" readonly value="<?php echo esc_html_e( 'To add this item to your cart, please enter your email address.', 'woocommerce-abandoned-cart' ); ?>">
 
 
 
 
181
  </td>
 
182
  <td id = "wcap_text_section_field_color" class = "wcap_text_section_field_color test_borders">
183
+ <span class = "colorpickpreview" style = "background: #bbc9d2"></span>
184
+ <input class = "wcap_popup_text_color_picker colorpick" name = "wcap_popup_text_color_picker" value = "#bbc9d2" v-model = "wcap_popup_text_color" v-on:input = "wcap_atc_popup_text.color = $event.target.value" readonly>
 
 
 
 
 
 
 
185
  </td>
 
186
  </tr>
 
187
  </table>
 
188
  </div>
 
189
  <?php
 
190
  }
191
 
 
 
192
  /**
 
193
  * It will add the setting for email placeholder on the add to cart modal settings page.
194
+ *
195
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
196
  * @since 6.0
197
  */
 
198
  public static function wcap_email_placeholder_section( $wcap_disabled_field ) {
 
199
  ?>
200
 
201
  <div id = "wcap_email_placeholder_section_div" class = "wcap_email_placeholder_section_div wcap_atc_between_fields_space">
 
202
  <table id = "wcap_email_placeholder_section_table" class = "wcap_email_placeholder_section_table">
203
+ <th id = "wcap_email_placeholder_section_table_heading" class = "wcap_email_placeholder_section_table_heading"> Email placeholder </th>
 
 
204
  <tr id = "wcap_email_placeholder_section_tr" class = "wcap_email_placeholder_section_tr" >
 
205
  <td id = "wcap_email_placeholder_section_text_field" class = "wcap_email_placeholder_section_text_field test_borders">
 
206
  <input id = "wcap_email_placeholder_section_input_text" v-model = "wcap_email_placeholder_section_input_text" class="wcap_email_placeholder_section_input_text" name = "wcap_email_placeholder_section_input_text"
207
+ readonly value="<?php echo esc_html_e( 'Email address', 'woocommerce-abandoned-cart' ); ?>">
 
 
208
  </td>
 
209
  </tr>
 
210
  </table>
 
211
  </div>
 
212
  <?php
 
213
  }
214
 
 
 
215
  /**
 
216
  * It will add the setting for Add to cart button on the add to cart modal settings page.
217
+ *
218
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
219
  * @since 6.0
220
  */
 
221
  public static function wcap_button_section( $wcap_disabled_field ) {
 
222
  ?>
223
 
224
  <div id = "wcap_button_section_div" class = "wcap_button_section_div wcap_atc_between_fields_space">
225
 
226
  <table id = "wcap_button_section_table" class = "wcap_button_section_table">
227
+ <th id = "wcap_button_section_table_heading" class="wcap_button_section_table_heading"> Add to cart button text </th>
 
 
228
  <tr>
 
229
  <td id = "wcap_button_section_text_field" class = "wcap_button_section_text_field test_borders">
 
230
  <input id = "wcap_button_section_input_text" v-model = "wcap_button_section_input_text" class="wcap_button_section_input_text" name = "wcap_button_section_input_text"
231
+ readonly value="<?php echo esc_html_e( 'Add to Cart', 'woocommerce-abandoned-cart' ); ?>">
 
 
232
  </td>
 
233
  </tr>
234
 
235
  <tr id = "wcap_button_color_section_tr" class = "wcap_button_color_section_tr">
 
236
  <td id = "wcap_button_color_section_text_field" class = "wcap_button_color_section_text_field test_borders">
237
+ <span class = "colorpickpreview" style = "background: #0085ba"></span>
238
+ <input id = "wcap_button_color_picker" value = "#0085ba" v-model ="wcap_button_bg_color" v-on:input="wcap_atc_button.backgroundColor = $event.target.value" class="wcap_button_color_picker colorpick" name = "wcap_button_color_picker" readonly >
 
 
 
 
 
 
 
239
  </td>
 
240
  <td id = "wcap_button_text_color_section_text_field" class = "wcap_button_text_color_section_text_field test_borders">
241
+ <span class = "colorpickpreview" style = "background: #ffffff"></span>
242
+ <input id = "wcap_button_text_color_picker" value = "#ffffff" v-model = "wcap_button_text_color" v-on:input = "wcap_atc_button.color = $event.target.value" class="wcap_button_text_color_picker colorpick" name = "wcap_button_text_color_picker" readonly>
 
 
 
 
 
 
 
243
  </td>
 
244
  </tr>
 
245
  </table>
 
246
  </div>
 
247
  <?php
 
248
  }
249
 
 
 
250
  /**
 
251
  * It will add the setting for Email address mandatory field on the add to cart modal settings page.
252
+ *
253
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
254
  * @since 6.0
255
  */
 
256
  public static function wcap_mandatory_modal_section( $wcap_disabled_field ) {
 
257
  ?>
258
 
259
  <table class = "wcap_atc_between_fields_space">
 
260
  <th id = "wcap_button_section_table_heading" class = "wcap_button_section_table_heading"> Email address is mandatory ? </th>
 
261
  <tr>
 
262
  <td>
263
+ <button type = "button" class = "wcap-switch-atc-modal-mandatory wcap-toggle-atc-modal-mandatory" wcap-atc-switch-modal-mandatory = 'off' readonly >
264
+ </button>
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  </td>
 
266
  </tr>
 
267
  </table>
 
268
  <?php
 
269
  }
270
 
 
 
271
  /**
 
272
  * It will add the setting for Email address non mandatory field on the add to cart modal settings page.
273
+ *
274
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
275
  * @since 6.0
276
  */
 
277
  public static function wcap_non_mandatory_modal_section_field( $wcap_disabled_field ) {
 
 
 
 
 
 
 
 
 
 
 
278
  ?>
 
279
  <div id = "wcap_non_mandatory_modal_section_fields_div" class = "wcap_non_mandatory_modal_section_fields_div wcap_atc_between_fields_space">
 
280
  <table id = "wcap_non_mandatory_modal_section_fields_div_table" class = "wcap_non_mandatory_modal_section_fields_div_table">
 
281
  <th id = "wcap_non_mandatory_modal_section_fields_table_heading"
 
282
  class="wcap_non_mandatory_modal_section_fields_table_heading"> Not mandatory text </th>
 
283
  <tr id = "wcap_non_mandatory_modal_section_fields_tr" class = "wcap_non_mandatory_modal_section_fields_tr" >
 
284
  <td id = "wcap_non_mandatory_modal_section_fields_text_field" class = "wcap_non_mandatory_modal_section_fields_text_field test_borders">
285
+ <input id = "wcap_non_mandatory_modal_section_fields_input_text" v-model = "wcap_non_mandatory_modal_input_text" class = "wcap_non_mandatory_modal_section_fields_input_text" name = "wcap_non_mandatory_modal_section_fields_input_text" readonly value="<?php echo esc_html_e( 'No Thanks', 'woocommerce-abandoned-cart' ); ?>" >
 
 
 
 
 
 
 
 
 
 
286
  </td>
 
287
  </tr>
 
288
  </table>
 
289
  </div>
 
290
  <?php
 
291
  }
292
 
 
 
293
  /**
 
294
  * It will will show th preview of the Add To cart Popup modal with the changes made on any of the settings for it.
295
+ *
296
  * @param string $wcap_disabled_field It will indicate if field need to be disabled or not.
 
297
  * @since 6.0
298
  */
 
299
  public static function wcap_add_to_cart_popup_modal_preview( $wcap_disabled_field ) {
 
300
  ?>
301
 
302
  <div class = "wcap_container">
 
303
  <div class = "wcap_popup_wrapper">
 
304
  <div class = "wcap_popup_content">
305
 
306
  <div class = "wcap_popup_heading_container">
 
307
  <div class = "wcap_popup_icon_container" >
 
308
  <span class = "wcap_popup_icon" >
 
309
  <span class = "wcap_popup_plus_sign" v-bind:style = "wcap_atc_button">
 
310
  </span>
 
311
  </span>
 
312
  </div>
 
313
  <div class = "wcap_popup_text_container">
314
+ <h2 class = "wcap_popup_heading" v-bind:style = "wcap_atc_popup_heading" ><?php echo esc_html_e( 'Please enter your email address.', 'woocommerce-abandoned-cart' ); ?></h2>
315
+ <div class = "wcap_popup_text" v-bind:style = "wcap_atc_popup_text" ><?php echo esc_html_e( 'To add this item to your cart, please enter your email address.', 'woocommerce-abandoned-cart' ); ?></div>
 
 
 
316
  </div>
 
317
  </div>
318
 
319
  <div class = "wcap_popup_form">
 
320
  <form action = "" name = "wcap_modal_form">
 
321
  <div class = "wcap_popup_input_field_container" >
322
+ <input class = "wcap_popup_input" type = "text" value = "" name = "email" placeholder ="<?php echo esc_html_e( 'Email address', 'woocommerce-abandoned-cart' ); ?>" readonly >
 
 
 
 
323
  </div>
324
+ <button class = "wcap_popup_button" v-bind:style = "wcap_atc_button"><?php echo esc_html_e( 'Add to Cart', 'woocommerce-abandoned-cart' ); ?></button>
 
 
 
 
325
  <br>
 
326
  <br>
 
327
  <div id = "wcap_non_mandatory_text_wrapper" class = "wcap_non_mandatory_text_wrapper">
328
+ <a class = "wcap_popup_non_mandatory_button" href = "" > <?php echo esc_html_e( 'No Thanks', 'woocommerce-abandoned-cart' ); ?></a>
 
 
329
  </div>
 
330
  </form>
 
331
  </div>
 
332
  <div class = "wcap_popup_close" ></div>
 
333
  </div>
 
334
  </div>
 
335
  </div>
 
336
  <?php
 
337
  }
 
338
  }
 
339
  }
 
includes/admin/class-wcap-pro-settings-callbacks.php ADDED
@@ -0,0 +1,400 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Callbacks for all the settings present in the PRO version
4
+ *
5
+ * @package Abandoned-Cart-Pro-for-WooCommerce/Admin/Settings
6
+ * @since 2.4
7
+ */
8
+
9
+ // Exit if accessed directly.
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit;
12
+ }
13
+
14
+ if ( ! class_exists( 'WCAP_Pro_Settings_Callbacks' ) ) {
15
+
16
+ /**
17
+ * AC pro Settings callback functions.
18
+ */
19
+ class WCAP_Pro_Settings_Callbacks {
20
+
21
+ /**
22
+ * Construct
23
+ *
24
+ * @since 4.9
25
+ */
26
+ public function __construct() {
27
+ }
28
+
29
+ /**
30
+ * SMS Settings section.
31
+ */
32
+ public static function wcap_sms_settings_section_callback() {
33
+ echo esc_html_e( 'Configure your Twilio account settings below. Please note that due to some restrictions from Twilio, customers <i>may sometimes</i> receive delayed messages', 'woocommerce-abandoned-cart' );
34
+ }
35
+
36
+ /**
37
+ * Callback for enable SMS reminders
38
+ *
39
+ * @param array $args Argument given while adding the field.
40
+ * @since 7.9
41
+ */
42
+ public static function wcap_enable_sms_reminders_callback( $args ) {
43
+
44
+ $wcap_enable_sms = 'off';
45
+
46
+ printf(
47
+ '<input type="checkbox" id="wcap_enable_sms_reminders" name="wcap_enable_sms_reminders" value="on" ' . checked( 'on', $wcap_enable_sms, false ) . ' readonly disabled/>'
48
+ );
49
+
50
+ $html = '<label for="wcap_enable_sms_reminders"> ' . $args[0] . '</label>';
51
+ echo wp_kses_post( $html );
52
+ }
53
+
54
+ /**
55
+ * Callback for From Phone Number
56
+ *
57
+ * @param array $args Argument given while adding the field.
58
+ * @since 7.9
59
+ */
60
+ public static function wcap_sms_from_phone_callback( $args ) {
61
+
62
+ print(
63
+ "<input type='text' id='wcap_sms_from_phone' name='wcap_sms_from_phone' value='' readonly />"
64
+ );
65
+
66
+ $html = '<label for="wcap_from_phone"> ' . $args[0] . '</label>';
67
+ echo wp_kses_post( $html );
68
+ }
69
+
70
+ /**
71
+ * Callback for Account SID.
72
+ *
73
+ * @param array $args Argument given while adding the field.
74
+ * @since 7.9
75
+ */
76
+ public static function wcap_sms_account_sid_callback( $args ) {
77
+
78
+ print(
79
+ "<input type='text' style='width:60%;' id='wcap_sms_account_sid' name='wcap_sms_account_sid' value='' readonly />"
80
+ );
81
+
82
+ $html = '<label for="wcap_sms_account_sid"> ' . $args[0] . '</label>';
83
+ echo wp_kses_post( $html );
84
+ }
85
+
86
+ /**
87
+ * Callback for Auth Token.
88
+ *
89
+ * @param array $args Argument given while adding the field.
90
+ * @since 7.9
91
+ */
92
+ public static function wcap_sms_auth_token_callback( $args ) {
93
+
94
+ print(
95
+ "<input type='text' style='width:60%;' id='wcap_sms_auth_token' name='wcap_sms_auth_token' value='' readonly />"
96
+ );
97
+
98
+ $html = '<label for="wcap_sms_auth_token"> ' . $args[0] . '</label>';
99
+ echo wp_kses_post( $html );
100
+ }
101
+
102
+ /**
103
+ * FB Section.
104
+ */
105
+ public static function wcap_fb_description() {
106
+ echo esc_html_e( 'Configure the plugin to send notifications to Facebook Messenger using the settings below. Please refer the <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/send-abandoned-cart-reminder-notifications-using-facebook-messenger" target="_blank">following documentation</a> to complete the setup.', 'woocommerce-abandoned-cart' );
107
+ }
108
+
109
+ /**
110
+ * FB checkbox.
111
+ *
112
+ * @param array $args - Arguments.
113
+ */
114
+ public static function wcap_fb_checkbox_callback( $args ) {
115
+
116
+ if ( isset( $args[2] ) ) {
117
+ $checkbox_value = get_option( $args[2] );
118
+ $args_2 = $args[2];
119
+ } else {
120
+ $checkbox_value = '';
121
+ $args_2 = 'wcap_fb_check';
122
+ }
123
+
124
+ if ( isset( $checkbox_value ) && '' === $checkbox_value ) {
125
+ $checkbox_value = 'off';
126
+ }
127
+
128
+ printf(
129
+ '<input type="checkbox" id="%1$s" name="%1$s" value="on" readonly disabled/>',
130
+ esc_html( $args_2 )
131
+ );
132
+
133
+ $html = '<label for="$args_2"> ' . $args[0] . '</label>';
134
+ echo wp_kses_post( $html );
135
+
136
+ }
137
+
138
+ /**
139
+ * FB Text Callback.
140
+ *
141
+ * @param array $args - Arguments.
142
+ */
143
+ public static function wcap_fb_text_callback( $args ) {
144
+
145
+ $saved_value = isset( $args[2] ) ? get_option( $args[2] ) : '';
146
+ if ( isset( $args[2] ) ) {
147
+ printf(
148
+ '<input type="text" id="%1$s" name="%1$s" value="" readonly />',
149
+ esc_html( $args[2] )
150
+ );
151
+ } else {
152
+ print( "<input type='text' id='wcap_fb' name='wcap_fb' readonly />" );
153
+ }
154
+
155
+ $html = '<label for="$args[2]"> ' . $args[0] . '</label>';
156
+ echo wp_kses_post( $html );
157
+ }
158
+
159
+ /**
160
+ * FB Dropdown Callback.
161
+ *
162
+ * @param array $args - Arguments.
163
+ */
164
+ public static function wcap_fb_dropdown_callback( $args ) {
165
+
166
+ $selected_value = isset( $args[1] ) ? get_option( $args[1], '' ) : '';
167
+ $selected = '';
168
+
169
+ if ( is_array( $args ) && isset( $args[1] ) && isset( $args[2] ) ) {
170
+ printf(
171
+ '<select name="%1$s" id="%1$s" disabled>',
172
+ esc_html( $args[1] )
173
+ );
174
+ $icon_array = $args[2];
175
+ } else {
176
+ print( "<select name='wcap_fb_user_icon' id='wcap_fb_user_icon' disabled>" );
177
+ $icon_array = array(
178
+ 'small' => 'Small',
179
+ 'medium' => 'Medium',
180
+ );
181
+ }
182
+
183
+ foreach ( $icon_array as $key => $value ) {
184
+ $selected = $selected_value === $key ? 'selected="selected"' : '';
185
+ printf(
186
+ '<option value="%s" %s >%s</option>',
187
+ esc_html( $key ),
188
+ esc_html( $selected ),
189
+ esc_html( $value )
190
+ );
191
+ }
192
+ print( '</select>' );
193
+ $html = '<label for="$args[1]"> ' . $args[0] . '</label>';
194
+
195
+ echo wp_kses_post( $html );
196
+
197
+ }
198
+
199
+ /**
200
+ * Guest Time cutoff callback.
201
+ *
202
+ * @param array $args - Arguments.
203
+ */
204
+ public static function wcap_cart_abandoned_time_guest_callback( $args ) {
205
+
206
+ $cart_abandoned_time_guest = get_option( 'ac_cart_abandoned_time_guest' );
207
+
208
+ printf(
209
+ '<input type="text" id="ac_cart_abandoned_time_guest" name="ac_cart_abandoned_time_guest" value="%s" readonly />',
210
+ isset( $cart_abandoned_time_guest ) ? esc_attr( $cart_abandoned_time_guest ) : ''
211
+ );
212
+
213
+ $html = '<label for="ac_cart_abandoned_time_guest"> ' . $args[0] . '</label>';
214
+ echo wp_kses_post( $html );
215
+ }
216
+
217
+ /**
218
+ * Disable Guest cart tracking.
219
+ *
220
+ * @param array $args - Arguments.
221
+ */
222
+ public static function wcap_disable_guest_cart_email_callback( $args ) {
223
+
224
+ $disable_guest_cart_email = get_option( 'ac_disable_guest_cart_email' );
225
+
226
+ if ( isset( $disable_guest_cart_email ) && '' === $disable_guest_cart_email ) {
227
+ $disable_guest_cart_email = 'off';
228
+ }
229
+
230
+ printf(
231
+ '<input type="checkbox" id="ac_disable_guest_cart_email" name="ac_disable_guest_cart_email" value="on"
232
+ ' . checked( 'on', $disable_guest_cart_email, false ) . ' readonly disabled/>'
233
+ );
234
+
235
+ $html = '<label for="ac_disable_guest_cart_email"> ' . $args[0] . '</label> <br> <div id ="wcap_atc_disable_msg" class="wcap_atc_disable_msg"></div>';
236
+ echo wp_kses_post( $html );
237
+ }
238
+
239
+ /**
240
+ * Disable registered user cart capture.
241
+ *
242
+ * @param array $args - Arguments.
243
+ */
244
+ public static function wcap_disable_logged_in_cart_email_callback( $args ) {
245
+
246
+ $disable_logged_in_cart_email = get_option( 'ac_disable_logged_in_cart_email' );
247
+ if ( isset( $disable_logged_in_cart_email ) && '' === $disable_logged_in_cart_email ) {
248
+ $disable_logged_in_cart_email = 'off';
249
+ }
250
+
251
+ printf(
252
+ '<input type="checkbox" id="ac_disable_logged_in_cart_email" name="ac_disable_logged_in_cart_email" value="on"
253
+ ' . checked( 'on', $disable_logged_in_cart_email, false ) . ' readonly disabled/>'
254
+ );
255
+
256
+ $html = '<label for="ac_disable_logged_in_cart_email"> ' . $args[0] . '</label>';
257
+ echo wp_kses_post( $html );
258
+
259
+ }
260
+
261
+ /**
262
+ * Capture email from URL callback.
263
+ *
264
+ * @param array $args - Arguments.
265
+ */
266
+ public static function wcap_capture_email_address_from_url( $args ) {
267
+
268
+ $ac_capture_email_address_from_url = get_option( 'ac_capture_email_address_from_url' );
269
+
270
+ printf(
271
+ '<input type="text" id="ac_capture_email_address_from_url" name="ac_capture_email_address_from_url" value="%s" readonly />',
272
+ isset( $ac_capture_email_address_from_url ) ? esc_attr( $ac_capture_email_address_from_url ) : ''
273
+ );
274
+
275
+ $html = '<label for="ac_capture_email_address_from_url_label"> ' . $args[0] . '</label>';
276
+ echo wp_kses_post( $html );
277
+
278
+ }
279
+
280
+ /**
281
+ * Product Image Size callback.
282
+ *
283
+ * @param array $args - Arguments.
284
+ */
285
+ public static function wcap_product_image_size_callback( $args ) {
286
+
287
+ $wcap_product_image_height = get_option( 'wcap_product_image_height' );
288
+ $wcap_product_image_width = get_option( 'wcap_product_image_width' );
289
+ ?>
290
+ <input type="text" id="wcap_product_image_height" style="width:50px" name="wcap_product_image_height" value="<?php echo esc_html( $wcap_product_image_height ); ?>" readonly />
291
+ <?php
292
+ echo esc_html( 'x' );
293
+ ?>
294
+ <input type="text" id="wcap_product_image_width" style="width:50px" name="wcap_product_image_width" value="<?php echo esc_html( $wcap_product_image_width ); ?>" readonly />
295
+ <?php
296
+ echo esc_html( ' px' );
297
+
298
+ $html = '<label for="wcap_product_image_size"> ' . $args[0] . '</label>';
299
+ echo wp_kses_post( $html );
300
+ }
301
+
302
+ /**
303
+ * Cron Job Section.
304
+ */
305
+ public static function wcap_cron_job_callback() {}
306
+
307
+ /**
308
+ * Cron Job callback.
309
+ *
310
+ * @param array $args - Arguments.
311
+ */
312
+ public static function wcap_use_auto_cron_callback( $args ) {
313
+
314
+ $enable_auto_cron = get_option( 'wcap_use_auto_cron', '' );
315
+ if ( isset( $enable_auto_cron ) && '' === $enable_auto_cron ) {
316
+ $enable_auto_cron = 'off';
317
+ }
318
+
319
+ printf(
320
+ '<input type="checkbox" id="wcap_use_auto_cron" name="wcap_use_auto_cron" value="on"
321
+ ' . checked( 'on', $enable_auto_cron, false ) . ' readonly disabled/>'
322
+ );
323
+
324
+ $html = '<label for="wcap_use_auto_cron_label"> ' . $args[0] . '</label>';
325
+ echo wp_kses_post( $html );
326
+ }
327
+
328
+ /**
329
+ * Cron Duration callback.
330
+ *
331
+ * @param array $args - Arguments.
332
+ */
333
+ public static function wcap_cron_time_duration_callback( $args ) {
334
+
335
+ $wcap_cron_time_duration = get_option( 'wcap_cron_time_duration' );
336
+
337
+ printf(
338
+ '<input type="text" id="wcap_cron_time_duration" name="wcap_cron_time_duration" value="%s" readonly/>',
339
+ isset( $wcap_cron_time_duration ) ? esc_attr( $wcap_cron_time_duration ) : ''
340
+ );
341
+
342
+ $html = '<label for="wcap_cron_time_duration"> ' . $args[0] . '</label>';
343
+ echo wp_kses_post( $html );
344
+ }
345
+
346
+ /**
347
+ * Custom Restrict Section.
348
+ */
349
+ public static function wcap_custom_restrict_callback() {}
350
+
351
+ /**
352
+ * Restrict by IP.
353
+ *
354
+ * @param array $args - Argumemnts.
355
+ */
356
+ public static function wcap_restrict_ip_address_callback( $args ) {
357
+
358
+ printf(
359
+ '<textarea rows="4" cols="50" id="wcap_restrict_ip_address" name="wcap_restrict_ip_address" placeholder="Add an IP address" readonly /></textarea>'
360
+ );
361
+
362
+ $html = '<label for="wcap_restrict_ip_address_label"> ' . $args[0] . '</label>';
363
+ echo wp_kses_post( $html );
364
+ }
365
+
366
+ /**
367
+ * Restrict by Email.
368
+ *
369
+ * @param array $args - Arguments.
370
+ */
371
+ public static function wcap_restrict_email_address_callback( $args ) {
372
+
373
+ printf(
374
+ '<textarea rows="4" cols="50" id="wcap_restrict_email_address" name="wcap_restrict_email_address" placeholder="Add an email address" readonly /></textarea>'
375
+ );
376
+
377
+ $html = '<label for="wcap_restrict_email_address_label"> ' . $args[0] . '</label>';
378
+ echo wp_kses_post( $html );
379
+ }
380
+
381
+ /**
382
+ * Restrict by Domain.
383
+ *
384
+ * @param array $args - Arguments.
385
+ */
386
+ public static function wcap_restrict_domain_address_callback( $args ) {
387
+
388
+ printf(
389
+ '<textarea rows="4" cols="50" id="wcap_restrict_domain_address" name="wcap_restrict_domain_address" placeholder="Add an email domain name (Ex. hotmail.com)" readonly/></textarea>'
390
+ );
391
+
392
+ $html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
393
+ echo wp_kses_post( $html );
394
+ }
395
+
396
+ } // end of class.
397
+
398
+ $wcap_pro_settings_callbacks = new WCAP_Pro_Settings_Callbacks();
399
+
400
+ } // end if.
includes/admin/{wcap_pro_settings.php → class-wcap-pro-settings.php} RENAMED
@@ -1,105 +1,79 @@
1
  <?php
2
-
3
  /**
4
-
5
  * Display all the settings in PRO
6
  *
 
7
  * @since 2.4
8
  */
9
 
10
- // Exit if accessed directly
11
-
12
  if ( ! defined( 'ABSPATH' ) ) {
13
  exit;
14
  }
15
 
16
-
17
-
18
  if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
19
 
20
-
21
-
 
22
  class WCAP_Pro_Settings {
23
-
24
-
25
-
26
  /**
27
-
28
  * Construct
29
-
30
  * @since 2.4
31
  */
32
-
33
  public function __construct() {
34
-
35
  add_action( 'admin_init', array( &$this, 'wcal_pro_settings' ) );
36
-
37
  add_action( 'wcal_add_new_settings', array( &$this, 'wcap_pro_general_settings' ) );
38
-
39
  }
40
 
 
 
 
 
41
 
42
-
43
- static function wcap_atc_settings() {
44
-
45
- wp_enqueue_style( 'wcap_modal_preview', WCAL_PLUGIN_URL . '/assets/css/admin/wcap_preview_modal.css' );
46
-
47
- wp_enqueue_style( 'wcap_add_to_cart_popup_modal', WCAL_PLUGIN_URL . '/assets/css/admin/wcap_add_to_cart_popup_modal.min.css' );
48
-
49
  $purchase_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite';
50
-
51
  ?>
52
 
53
  <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcap_atc_settings">
54
-
55
  <p style="font-size:15px;">
56
-
57
  <b><i>
58
  <?php
59
- /* translators: %s Purchase Link */
60
- printf( __( "Upgrade to <a href='%s' target='_blank'>Abandoned Cart Pro for WooCommerce</a> to enable the feature.", 'woocommerce-abandoned-cart' ), $purchase_link );
61
  ?>
62
  </i></b>
63
-
64
  </p>
65
 
66
  <?php Wcap_Add_Cart_Popup_Modal::wcap_add_to_cart_popup_settings(); ?>
67
-
68
  </form>
69
 
70
  <?php
71
-
72
  }
73
 
74
-
75
-
76
- static function wcap_fb_settings() {
77
-
78
  ?>
79
 
80
- <form method="post" action="options.php">
81
-
82
  <?php
83
-
84
- // settings_errors();
85
-
86
  settings_fields( 'woocommerce_fb_settings' );
87
-
88
  do_settings_sections( 'woocommerce_ac_fb_page' );
89
-
90
  submit_button( __( 'Save Changes', 'woocommerce-abandoned-cart' ), 'primary', 'submit', true, array( 'disabled' => 'disabled' ) );
91
-
92
  ?>
93
-
94
  </form>
95
 
96
  <?php
97
-
98
  }
99
 
100
-
101
-
102
- static function wcap_pro_general_settings() {
 
103
 
104
  $upgrade_pro_msg = '<br><b><i>Upgrade to <a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">Abandoned Cart Pro for WooCommerce</a> to enable the setting.</i></b>';
105
 
@@ -179,10 +153,10 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
179
  );
180
 
181
  add_settings_section(
182
- 'ac_cron_job_settings_section', // ID used to identify this section and with which to register options
183
- __( 'Setting for sending Emails & SMS using Action Scheduler', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
184
- array( 'WCAP_Pro_Settings_Callbacks', 'wcap_cron_job_callback' ), // Callback used to render the description of the section
185
- 'woocommerce_ac_page' // Page on which to add this section of options
186
  );
187
 
188
  add_settings_field(
@@ -204,10 +178,10 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
204
  );
205
 
206
  add_settings_section(
207
- 'ac_restrict_settings_section', // ID used to identify this section and with which to register options
208
- __( 'Rules to exclude capturing abandoned carts', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
209
- array( 'WCAP_Pro_Settings_Callbacks', 'wcap_custom_restrict_callback' ), // Callback used to render the description of the section
210
- 'woocommerce_ac_page' // Page on which to add this section of options
211
  );
212
 
213
  add_settings_field(
@@ -239,83 +213,60 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
239
 
240
  }
241
 
242
- static function wcap_sms_settings() {
 
 
 
243
  ?>
244
 
245
  <form method="post" action="options.php">
246
-
247
  <?php
248
-
249
  settings_fields( 'woocommerce_sms_settings' );
250
-
251
  do_settings_sections( 'woocommerce_ac_sms_page' );
252
-
253
  submit_button( __( 'Save Changes', 'woocommerce-abandoned-cart' ), 'primary', 'submit', true, array( 'disabled' => 'disabled' ) );
254
-
255
  ?>
256
-
257
  </form>
258
 
259
  <div id="test_fields">
260
 
261
- <h2><?php _e( 'Send Test SMS', 'woocommerce-abandoned-cart' ); ?></h2>
262
-
263
  <div id="status_msg" style="background: white;border-left: #6389DA 4px solid;padding: 10px;display: none;width: 90%;"></div>
264
-
265
  <table class="form-table">
266
-
267
  <tr>
268
-
269
- <th><?php _e( 'Recipient', 'woocommerce-abandoned-cart' ); ?></th>
270
-
271
  <td>
272
-
273
  <input id="test_number" name="test_number" type=text readonly />
274
-
275
- <i><?php _e( 'Must be a valid phone number in E.164 format.', 'woocommerce-abandoned-cart' ); ?></i>
276
-
277
  </td>
278
-
279
  </tr>
280
 
281
  <tr>
282
-
283
- <th><?php _e( 'Message', 'woocommerce-abandoned-cart' ); ?></th>
284
-
285
- <td><textarea id="test_msg" rows="4" cols="70" readonly ><?php _e( 'Hello World!', 'woocommerce-abandoned-cart' ); ?></textarea></td>
286
-
287
  </tr>
288
 
289
  <tr>
290
-
291
- <td colspan="2"><input type="button" id="wcap_test_sms" class="button-primary" value="<?php _e( 'Send', 'wocommerce-ac' ); ?>" /></td>
292
-
293
  </tr>
294
-
295
  </table>
296
-
297
  </div>
298
 
299
  <?php
300
-
301
  }
302
 
303
-
304
-
305
- function wcal_pro_settings() {
 
306
 
307
  $upgrade_pro_msg = '<br><b><i>Upgrade to <a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">Abandoned Cart Pro for WooCommerce</a> to enable the setting.</i></b>';
308
 
309
- /**
310
-
311
- * New Settings for SMS Notifications
312
- */
313
-
314
  add_settings_section(
315
- 'wcap_sms_settings_section', // ID used to identify this section and with which to register options
316
- __( 'Twilio', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page
317
- array( 'WCAP_Pro_Settings_Callbacks', 'wcap_sms_settings_section_callback' ), // Callback used to render the description of the section
318
- 'woocommerce_ac_sms_page' // Page on which to add this section of options
319
  );
320
 
321
  add_settings_field(
@@ -324,7 +275,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
324
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_enable_sms_reminders_callback' ),
325
  'woocommerce_ac_sms_page',
326
  'wcap_sms_settings_section',
327
- array( __( '<i>Enable the ability to send reminder SMS for abandoned carts.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg )
328
  );
329
 
330
  add_settings_field(
@@ -333,7 +284,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
333
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_sms_from_phone_callback' ),
334
  'woocommerce_ac_sms_page',
335
  'wcap_sms_settings_section',
336
- array( __( '<i>Must be a Twilio phone number (in E.164 format) or alphanumeric sender ID.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg )
337
  );
338
 
339
  add_settings_field(
@@ -387,7 +338,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
387
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_checkbox_callback' ),
388
  'woocommerce_ac_fb_page',
389
  'wcap_fb_settings_section',
390
- array( __( '<i>This option will display a checkbox after the Add to cart button for user consent to connect with Facebook.</i>', 'woocommerce-abandoned-cart', 'wcap_enable_fb_reminders' ) . $upgrade_pro_msg )
391
  );
392
 
393
  add_settings_field(
@@ -396,7 +347,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
396
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_checkbox_callback' ),
397
  'woocommerce_ac_fb_page',
398
  'wcap_fb_settings_section',
399
- array( __( '<i>This option will display a checkbox on the pop-up modal to connect with Facebook.</i>', 'woocommerce-abandoned-cart', 'wcap_enable_fb_reminders_popup' ) . $upgrade_pro_msg )
400
  );
401
 
402
  add_settings_field(
@@ -406,25 +357,15 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
406
  'woocommerce_ac_fb_page',
407
  'wcap_fb_settings_section',
408
  array(
409
-
410
- __( '<i>Select the size of user icon which shall be displayed below the checkbox in case the user is logged in.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg,
411
-
412
  'wcap_fb_user_icon',
413
-
414
  array(
415
-
416
  'small' => __( 'Small', 'woocommerce-abandoned-cart' ),
417
-
418
  'medium' => __( 'Medium', 'woocommerce-abandoned-cart' ),
419
-
420
  'large' => __( 'Large', 'woocommerce-abandoned-cart' ),
421
-
422
  'standard' => __( 'Standard', 'woocommerce-abandoned-cart' ),
423
-
424
  'xlarge' => __( 'Extra Large', 'woocommerce-abandoned-cart' ),
425
-
426
  ),
427
-
428
  )
429
  );
430
 
@@ -434,7 +375,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
434
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
435
  'woocommerce_ac_fb_page',
436
  'wcap_fb_settings_section',
437
- array( __( '<i>Text that will appear above the consent checkbox. HTML tags are also allowed.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_consent_text' )
438
  );
439
 
440
  add_settings_field(
@@ -452,7 +393,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
452
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
453
  'woocommerce_ac_fb_page',
454
  'wcap_fb_settings_section',
455
- array( __( '<i>Enter your Messenger App ID</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_app_id' )
456
  );
457
 
458
  add_settings_field(
@@ -461,7 +402,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
461
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
462
  'woocommerce_ac_fb_page',
463
  'wcap_fb_settings_section',
464
- array( __( '<i>Enter your Facebook Page Token</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_page_token' )
465
  );
466
 
467
  add_settings_field(
@@ -470,7 +411,7 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
470
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
471
  'woocommerce_ac_fb_page',
472
  'wcap_fb_settings_section',
473
- array( __( '<i>Enter your Verify Token</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_verify_token' )
474
  );
475
 
476
  register_setting(
@@ -515,10 +456,8 @@ if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
515
 
516
  }
517
 
518
- } // end of class
519
-
520
- $WCAP_Pro_Settings = new WCAP_Pro_Settings();
521
 
522
- } // end if
523
 
524
- ?>
1
  <?php
 
2
  /**
 
3
  * Display all the settings in PRO
4
  *
5
+ * @package Abandoned-Cart-Pro-for-WooCommerce/Admin/Settings
6
  * @since 2.4
7
  */
8
 
9
+ // Exit if accessed directly.
 
10
  if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
13
 
 
 
14
  if ( ! class_exists( 'WCAP_Pro_Settings' ) ) {
15
 
16
+ /**
17
+ * AC pro Settings Class.
18
+ */
19
  class WCAP_Pro_Settings {
 
 
 
20
  /**
 
21
  * Construct
22
+ *
23
  * @since 2.4
24
  */
 
25
  public function __construct() {
 
26
  add_action( 'admin_init', array( &$this, 'wcal_pro_settings' ) );
 
27
  add_action( 'wcal_add_new_settings', array( &$this, 'wcap_pro_general_settings' ) );
 
28
  }
29
 
30
+ /**
31
+ * ATC Settings.
32
+ */
33
+ public static function wcap_atc_settings() {
34
 
35
+ wp_enqueue_style( 'wcap_modal_preview', WCAL_PLUGIN_URL . '/assets/css/admin/wcap_preview_modal.css', '', WCAL_PLUGIN_VERSION );
36
+ wp_enqueue_style( 'wcap_add_to_cart_popup_modal', WCAL_PLUGIN_URL . '/assets/css/admin/wcap_add_to_cart_popup_modal.min.css', '', WCAL_PLUGIN_VERSION );
 
 
 
 
 
37
  $purchase_link = 'https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite';
 
38
  ?>
39
 
40
  <form method="post" action="admin.php?page=woocommerce_ac_page&action=emailsettings&wcal_section=wcap_atc_settings">
 
41
  <p style="font-size:15px;">
 
42
  <b><i>
43
  <?php
44
+ // translators: %s Purchase Link.
45
+ printf( wp_kses_post( __( "Upgrade to <a href='%s' target='_blank'>Abandoned Cart Pro for WooCommerce</a> to enable the feature.", 'woocommerce-abandoned-cart' ) ), esc_url( $purchase_link ) );
46
  ?>
47
  </i></b>
 
48
  </p>
49
 
50
  <?php Wcap_Add_Cart_Popup_Modal::wcap_add_to_cart_popup_settings(); ?>
 
51
  </form>
52
 
53
  <?php
 
54
  }
55
 
56
+ /**
57
+ * FB Settings for AC Pro.
58
+ */
59
+ public static function wcap_fb_settings() {
60
  ?>
61
 
62
+ <form method="post" action="options.php">
 
63
  <?php
 
 
 
64
  settings_fields( 'woocommerce_fb_settings' );
 
65
  do_settings_sections( 'woocommerce_ac_fb_page' );
 
66
  submit_button( __( 'Save Changes', 'woocommerce-abandoned-cart' ), 'primary', 'submit', true, array( 'disabled' => 'disabled' ) );
 
67
  ?>
 
68
  </form>
69
 
70
  <?php
 
71
  }
72
 
73
+ /**
74
+ * General Settings for AC Pro.
75
+ */
76
+ public static function wcap_pro_general_settings() {
77
 
78
  $upgrade_pro_msg = '<br><b><i>Upgrade to <a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">Abandoned Cart Pro for WooCommerce</a> to enable the setting.</i></b>';
79
 
153
  );
154
 
155
  add_settings_section(
156
+ 'ac_cron_job_settings_section', // ID used to identify this section and with which to register options.
157
+ __( 'Setting for sending Emails & SMS using Action Scheduler', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page.
158
+ array( 'WCAP_Pro_Settings_Callbacks', 'wcap_cron_job_callback' ), // Callback used to render the description of the section.
159
+ 'woocommerce_ac_page' // Page on which to add this section of options.
160
  );
161
 
162
  add_settings_field(
178
  );
179
 
180
  add_settings_section(
181
+ 'ac_restrict_settings_section', // ID used to identify this section and with which to register options.
182
+ __( 'Rules to exclude capturing abandoned carts', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page.
183
+ array( 'WCAP_Pro_Settings_Callbacks', 'wcap_custom_restrict_callback' ), // Callback used to render the description of the section.
184
+ 'woocommerce_ac_page' // Page on which to add this section of options.
185
  );
186
 
187
  add_settings_field(
213
 
214
  }
215
 
216
+ /**
217
+ * SMS Settings for AC Pro
218
+ */
219
+ public static function wcap_sms_settings() {
220
  ?>
221
 
222
  <form method="post" action="options.php">
 
223
  <?php
 
224
  settings_fields( 'woocommerce_sms_settings' );
 
225
  do_settings_sections( 'woocommerce_ac_sms_page' );
 
226
  submit_button( __( 'Save Changes', 'woocommerce-abandoned-cart' ), 'primary', 'submit', true, array( 'disabled' => 'disabled' ) );
 
227
  ?>
 
228
  </form>
229
 
230
  <div id="test_fields">
231
 
232
+ <h2><?php echo esc_html_e( 'Send Test SMS', 'woocommerce-abandoned-cart' ); ?></h2>
 
233
  <div id="status_msg" style="background: white;border-left: #6389DA 4px solid;padding: 10px;display: none;width: 90%;"></div>
 
234
  <table class="form-table">
 
235
  <tr>
236
+ <th><?php echo esc_html_e( 'Recipient', 'woocommerce-abandoned-cart' ); ?></th>
 
 
237
  <td>
 
238
  <input id="test_number" name="test_number" type=text readonly />
239
+ <i><?php echo esc_html_e( 'Must be a valid phone number in E.164 format.', 'woocommerce-abandoned-cart' ); ?></i>
 
 
240
  </td>
 
241
  </tr>
242
 
243
  <tr>
244
+ <th><?php echo esc_html_e( 'Message', 'woocommerce-abandoned-cart' ); ?></th>
245
+ <td><textarea id="test_msg" rows="4" cols="70" readonly ><?php echo esc_html_e( 'Hello World!', 'woocommerce-abandoned-cart' ); ?></textarea></td>
 
 
 
246
  </tr>
247
 
248
  <tr>
249
+ <td colspan="2"><input type="button" id="wcap_test_sms" class="button-primary" value="<?php echo esc_html_e( 'Send', 'wocommerce-ac' ); ?>" /></td>
 
 
250
  </tr>
 
251
  </table>
 
252
  </div>
253
 
254
  <?php
 
255
  }
256
 
257
+ /**
258
+ * Pro Settings for SMS.
259
+ */
260
+ public function wcal_pro_settings() {
261
 
262
  $upgrade_pro_msg = '<br><b><i>Upgrade to <a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=acupgradetopro&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">Abandoned Cart Pro for WooCommerce</a> to enable the setting.</i></b>';
263
 
264
+ // New Settings for SMS Notifications.
 
 
 
 
265
  add_settings_section(
266
+ 'wcap_sms_settings_section', // ID used to identify this section and with which to register options.
267
+ __( 'Twilio', 'woocommerce-abandoned-cart' ), // Title to be displayed on the administration page.
268
+ array( 'WCAP_Pro_Settings_Callbacks', 'wcap_sms_settings_section_callback' ), // Callback used to render the description of the section.
269
+ 'woocommerce_ac_sms_page' // Page on which to add this section of options.
270
  );
271
 
272
  add_settings_field(
275
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_enable_sms_reminders_callback' ),
276
  'woocommerce_ac_sms_page',
277
  'wcap_sms_settings_section',
278
+ array( __( '<i>Enable the ability to send reminder SMS for abandoned carts.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg ) // phpcs:ignore
279
  );
280
 
281
  add_settings_field(
284
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_sms_from_phone_callback' ),
285
  'woocommerce_ac_sms_page',
286
  'wcap_sms_settings_section',
287
+ array( __( '<i>Must be a Twilio phone number (in E.164 format) or alphanumeric sender ID.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg ) // phpcs:ignore
288
  );
289
 
290
  add_settings_field(
338
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_checkbox_callback' ),
339
  'woocommerce_ac_fb_page',
340
  'wcap_fb_settings_section',
341
+ array( wp_kses_post( __( '<i>This option will display a checkbox after the Add to cart button for user consent to connect with Facebook.</i>', 'woocommerce-abandoned-cart' ), 'wcap_enable_fb_reminders' ) . $upgrade_pro_msg ) // phpcs:ignore
342
  );
343
 
344
  add_settings_field(
347
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_checkbox_callback' ),
348
  'woocommerce_ac_fb_page',
349
  'wcap_fb_settings_section',
350
+ array( wp_kses_post( __( '<i>This option will display a checkbox on the pop-up modal to connect with Facebook.</i>', 'woocommerce-abandoned-cart' ), 'wcap_enable_fb_reminders_popup' ) . $upgrade_pro_msg ) // phpcs:ignore
351
  );
352
 
353
  add_settings_field(
357
  'woocommerce_ac_fb_page',
358
  'wcap_fb_settings_section',
359
  array(
360
+ __( '<i>Select the size of user icon which shall be displayed below the checkbox in case the user is logged in.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, // phpcs:ignore
 
 
361
  'wcap_fb_user_icon',
 
362
  array(
 
363
  'small' => __( 'Small', 'woocommerce-abandoned-cart' ),
 
364
  'medium' => __( 'Medium', 'woocommerce-abandoned-cart' ),
 
365
  'large' => __( 'Large', 'woocommerce-abandoned-cart' ),
 
366
  'standard' => __( 'Standard', 'woocommerce-abandoned-cart' ),
 
367
  'xlarge' => __( 'Extra Large', 'woocommerce-abandoned-cart' ),
 
368
  ),
 
369
  )
370
  );
371
 
375
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
376
  'woocommerce_ac_fb_page',
377
  'wcap_fb_settings_section',
378
+ array( __( '<i>Text that will appear above the consent checkbox. HTML tags are also allowed.</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_consent_text' ) // phpcs:ignore
379
  );
380
 
381
  add_settings_field(
393
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
394
  'woocommerce_ac_fb_page',
395
  'wcap_fb_settings_section',
396
+ array( __( '<i>Enter your Messenger App ID</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_app_id' ) // phpcs:ignore
397
  );
398
 
399
  add_settings_field(
402
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
403
  'woocommerce_ac_fb_page',
404
  'wcap_fb_settings_section',
405
+ array( __( '<i>Enter your Facebook Page Token</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_page_token' ) // phpcs:ignore
406
  );
407
 
408
  add_settings_field(
411
  array( 'WCAP_Pro_Settings_Callbacks', 'wcap_fb_text_callback' ),
412
  'woocommerce_ac_fb_page',
413
  'wcap_fb_settings_section',
414
+ array( __( '<i>Enter your Verify Token</i>', 'woocommerce-abandoned-cart' ) . $upgrade_pro_msg, 'wcap_fb_verify_token' ) // phpcs:ignore
415
  );
416
 
417
  register_setting(
456
 
457
  }
458
 
459
+ } // end of class.
 
 
460
 
461
+ $wcap_pro_settings = new WCAP_Pro_Settings();
462
 
463
+ } // end if.
includes/admin/wcap_pro_settings_callbacks.php DELETED
@@ -1,454 +0,0 @@
1
- <?php
2
-
3
- /**
4
-
5
- * Callbacks for all the settings present in the PRO version
6
- *
7
- * @since 2.4
8
- */
9
-
10
- // Exit if accessed directly
11
-
12
- if ( ! defined( 'ABSPATH' ) ) {
13
- exit;
14
- }
15
-
16
-
17
-
18
- if ( ! class_exists( 'WCAP_Pro_Settings_Callbacks' ) ) {
19
-
20
-
21
-
22
- class WCAP_Pro_Settings_Callbacks {
23
-
24
-
25
-
26
- /**
27
-
28
- * Construct
29
-
30
- * @since 4.9
31
- */
32
-
33
- public function __construct() {
34
-
35
- }
36
-
37
-
38
-
39
-
40
-
41
- public static function wcap_sms_settings_section_callback() {
42
-
43
- _e( 'Configure your Twilio account settings below. Please note that due to some restrictions from Twilio, customers <i>may sometimes</i> receive delayed messages', 'woocommerce-abandoned-cart' );
44
-
45
- }
46
-
47
-
48
-
49
- /**
50
-
51
- * Callback for enable SMS reminders
52
-
53
- * @param array $args Argument given while adding the field
54
-
55
- * @since 7.9
56
- */
57
-
58
- public static function wcap_enable_sms_reminders_callback( $args ) {
59
-
60
- $wcap_enable_sms = get_option( 'wcap_enable_sms_reminders' );
61
-
62
- if ( isset( $wcap_enable_sms ) && $wcap_enable_sms == '' ) {
63
-
64
- $wcap_enable_sms = 'off';
65
-
66
- }
67
-
68
- $html = '<input type="checkbox" id="wcap_enable_sms_reminders" name="wcap_enable_sms_reminders" value="on" ' . checked( 'on', $wcap_enable_sms, false ) . ' readonly disabled/>';
69
-
70
- $html .= '<label for="wcap_enable_sms_reminders"> ' . $args[0] . '</label>';
71
-
72
- echo $html;
73
-
74
- }
75
-
76
-
77
-
78
- /**
79
-
80
- * Callback for From Phone Number
81
-
82
- * @param array $args Argument given while adding the field
83
-
84
- * @since 7.9
85
- */
86
-
87
- public static function wcap_sms_from_phone_callback( $args ) {
88
-
89
- $wcap_from_phone = get_option( 'wcap_sms_from_phone' );
90
-
91
- $html = "<input type='text' id='wcap_sms_from_phone' name='wcap_sms_from_phone' value='$wcap_from_phone' readonly />";
92
-
93
- $html .= '<label for="wcap_from_phone"> ' . $args[0] . '</label>';
94
-
95
- echo $html;
96
-
97
- }
98
-
99
-
100
-
101
- /**
102
-
103
- * Callback for Account SID
104
-
105
- * @param array $args Argument given while adding the field
106
-
107
- * @since 7.9
108
- */
109
-
110
- public static function wcap_sms_account_sid_callback( $args ) {
111
-
112
- $wcap_sms_account_sid = get_option( 'wcap_sms_account_sid' );
113
-
114
- $html = "<input type='text' style='width:60%;' id='wcap_sms_account_sid' name='wcap_sms_account_sid' value='$wcap_sms_account_sid' readonly />";
115
-
116
- $html .= '<label for="wcap_sms_account_sid"> ' . $args[0] . '</label>';
117
-
118
- echo $html;
119
-
120
- }
121
-
122
-
123
-
124
- /**
125
-
126
- * Callback for Auth Token
127
-
128
- * @param array $args Argument given while adding the field
129
-
130
- * @since 7.9
131
- */
132
-
133
- public static function wcap_sms_auth_token_callback( $args ) {
134
-
135
- $wcap_sms_auth_token = get_option( 'wcap_sms_auth_token' );
136
-
137
- $html = "<input type='text' style='width:60%;' id='wcap_sms_auth_token' name='wcap_sms_auth_token' value='$wcap_sms_auth_token' readonly />";
138
-
139
- $html .= '<label for="wcap_sms_auth_token"> ' . $args[0] . '</label>';
140
-
141
- echo $html;
142
-
143
- }
144
-
145
-
146
-
147
- static function wcap_fb_description() {
148
-
149
- _e( 'Configure the plugin to send notifications to Facebook Messenger using the settings below. Please refer the <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/send-abandoned-cart-reminder-notifications-using-facebook-messenger" target="_blank">following documentation</a> to complete the setup.', 'woocommerce-abandoned-cart' );
150
- }
151
-
152
-
153
-
154
- static function wcap_fb_checkbox_callback( $args ) {
155
-
156
- if ( isset( $args[2] ) ) {
157
- $checkbox_value = get_option( $args[2] );
158
- $args_2 = $args[2];
159
- } else {
160
- $checkbox_value = '';
161
- $args_2 = 'wcap_fb_check';
162
- }
163
-
164
- if ( isset( $checkbox_value ) && $checkbox_value == '' ) {
165
-
166
- $checkbox_value = 'off';
167
-
168
- }
169
-
170
- $html = "<input type='checkbox' id='$args_2' name='$args_2' value='on' " . checked( 'on', $checkbox_value, false ) . ' readonly disabled/>';
171
-
172
- $html .= '<label for="$args_2"> ' . $args[0] . '</label>';
173
-
174
- echo $html;
175
-
176
- }
177
-
178
-
179
-
180
- static function wcap_fb_text_callback( $args ) {
181
-
182
- $saved_value = isset( $args[2] ) ? get_option( $args[2] ) : '';
183
-
184
- if ( isset( $args[2] ) ) {
185
- $html = "<input type='text' id='$args[2]' name='$args[2]' value='$saved_value' readonly />";
186
- } else {
187
- $html = "<input type='text' id='wcap_fb' name='wcap_fb' readonly />";
188
- }
189
-
190
- $html .= '<label for="$args[2]"> ' . $args[0] . '</label>';
191
-
192
- echo $html;
193
-
194
- }
195
-
196
-
197
-
198
- static function wcap_fb_dropdown_callback( $args ) {
199
-
200
- $selected_value = isset( $args[1] ) ? get_option( $args[1], '' ) : '';
201
-
202
- $selected = '';
203
-
204
- if ( is_array( $args ) && isset( $args[1] ) && isset( $args[2] ) ) {
205
- $html = "<select name='$args[1]' id='$args[1]' disabled>";
206
- $icon_array = $args[2];
207
- } else {
208
- $html = "<select name='wcap_fb_user_icon' id='wcap_fb_user_icon' disabled>";
209
- $icon_array = array(
210
- 'small' => 'Small',
211
- 'medium' => 'Medium',
212
- );
213
- }
214
-
215
- foreach ( $icon_array as $key => $value ) {
216
-
217
- $selected = $selected_value === $key ? 'selected="selected"' : '';
218
-
219
- $html .= "<option value='$key' " . $selected . ">$value</option>";
220
-
221
- }
222
-
223
- $html .= '</select>';
224
-
225
- $html .= '<label for="$args[1]"> ' . $args[0] . '</label>';
226
-
227
- echo $html;
228
-
229
- }
230
-
231
- public static function wcap_cart_abandoned_time_guest_callback( $args ) {
232
-
233
- $cart_abandoned_time_guest = get_option( 'ac_cart_abandoned_time_guest' );
234
-
235
- printf(
236
- '<input type="text" id="ac_cart_abandoned_time_guest" name="ac_cart_abandoned_time_guest" value="%s" readonly />',
237
- isset( $cart_abandoned_time_guest ) ? esc_attr( $cart_abandoned_time_guest ) : ''
238
- );
239
-
240
- $html = '<label for="ac_cart_abandoned_time_guest"> ' . $args[0] . '</label>';
241
-
242
- echo $html;
243
-
244
- }
245
-
246
-
247
-
248
- public static function wcap_disable_guest_cart_email_callback( $args ) {
249
-
250
- $disable_guest_cart_email = get_option( 'ac_disable_guest_cart_email' );
251
-
252
- if ( isset( $disable_guest_cart_email ) && $disable_guest_cart_email == '' ) {
253
-
254
- $disable_guest_cart_email = 'off';
255
-
256
- }
257
-
258
- $html = '';
259
-
260
- printf(
261
- '<input type="checkbox" id="ac_disable_guest_cart_email" name="ac_disable_guest_cart_email" value="on"
262
-
263
- ' . checked( 'on', $disable_guest_cart_email, false ) . ' readonly disabled/>'
264
- );
265
-
266
- $html .= '<label for="ac_disable_guest_cart_email"> ' . $args[0] . '</label> <br> <div id ="wcap_atc_disable_msg" class="wcap_atc_disable_msg"></div>';
267
-
268
- echo $html;
269
-
270
- }
271
-
272
-
273
-
274
- public static function wcap_disable_logged_in_cart_email_callback( $args ) {
275
-
276
- $disable_logged_in_cart_email = get_option( 'ac_disable_logged_in_cart_email' );
277
-
278
- if ( isset( $disable_logged_in_cart_email ) && $disable_logged_in_cart_email == '' ) {
279
-
280
- $disable_logged_in_cart_email = 'off';
281
-
282
- }
283
-
284
- $html = '';
285
-
286
- printf(
287
- '<input type="checkbox" id="ac_disable_logged_in_cart_email" name="ac_disable_logged_in_cart_email" value="on"
288
-
289
- ' . checked( 'on', $disable_logged_in_cart_email, false ) . ' readonly disabled/>'
290
- );
291
-
292
- $html .= '<label for="ac_disable_logged_in_cart_email"> ' . $args[0] . '</label>';
293
-
294
- echo $html;
295
-
296
- }
297
-
298
-
299
-
300
- public static function wcap_capture_email_address_from_url( $args ) {
301
-
302
- $ac_capture_email_address_from_url = get_option( 'ac_capture_email_address_from_url' );
303
-
304
- printf(
305
- '<input type="text" id="ac_capture_email_address_from_url" name="ac_capture_email_address_from_url" value="%s" readonly />',
306
- isset( $ac_capture_email_address_from_url ) ? esc_attr( $ac_capture_email_address_from_url ) : ''
307
- );
308
-
309
- $html = '<label for="ac_capture_email_address_from_url_label"> ' . $args[0] . '</label>';
310
-
311
- echo $html;
312
-
313
- }
314
-
315
-
316
-
317
- public static function wcap_product_image_size_callback( $args ) {
318
-
319
- $wcap_product_image_height = get_option( 'wcap_product_image_height' );
320
-
321
- $wcap_product_image_width = get_option( 'wcap_product_image_width' );
322
-
323
- ?> <input type="text" id = "wcap_product_image_height" style= "width:50px" name="wcap_product_image_height" value="<?php echo $wcap_product_image_height; ?>" readonly />
324
-
325
- <?php echo 'x'; ?>
326
-
327
- <input type="text" id = "wcap_product_image_width" style = "width:50px" name="wcap_product_image_width" value="<?php echo $wcap_product_image_width; ?>" readonly />
328
-
329
- px
330
-
331
- <?php
332
-
333
- $html = '<label for="wcap_product_image_size"> ' . $args[0] . '</label>';
334
-
335
- echo $html;
336
-
337
- }
338
-
339
-
340
-
341
- public static function wcap_cron_job_callback() {}
342
-
343
-
344
-
345
- public static function wcap_use_auto_cron_callback( $args ) {
346
-
347
- $enable_auto_cron = get_option( 'wcap_use_auto_cron' );
348
-
349
- if ( isset( $enable_auto_cron ) && '' == $enable_auto_cron ) {
350
-
351
- $enable_auto_cron = 'off';
352
-
353
- }
354
-
355
- $html = '';
356
-
357
- printf(
358
- '<input type="checkbox" id="wcap_use_auto_cron" name="wcap_use_auto_cron" value="on"
359
-
360
- ' . checked( 'on', $enable_auto_cron, false ) . ' readonly disabled/>'
361
- );
362
-
363
- $html .= '<label for="wcap_use_auto_cron_label"> ' . $args[0] . '</label>';
364
-
365
- echo $html;
366
-
367
- }
368
-
369
-
370
-
371
- public static function wcap_cron_time_duration_callback( $args ) {
372
-
373
- $wcap_cron_time_duration = get_option( 'wcap_cron_time_duration' );
374
-
375
- printf(
376
- '<input type="text" id="wcap_cron_time_duration" name="wcap_cron_time_duration" value="%s" readonly/>',
377
- isset( $wcap_cron_time_duration ) ? esc_attr( $wcap_cron_time_duration ) : ''
378
- );
379
-
380
- $html = '<label for="wcap_cron_time_duration"> ' . $args[0] . '</label>';
381
-
382
- echo $html;
383
-
384
- }
385
-
386
-
387
-
388
- public static function wcap_custom_restrict_callback() {}
389
-
390
-
391
-
392
- public static function wcap_restrict_ip_address_callback( $args ) {
393
-
394
- $wcap_restrict_ip_address = get_option( 'wcap_restrict_ip_address' );
395
-
396
- $value = isset( $wcap_restrict_ip_address ) ? esc_attr( $wcap_restrict_ip_address ) : '';
397
-
398
- printf(
399
- '<textarea rows="4" cols="50" id="wcap_restrict_ip_address" name="wcap_restrict_ip_address" placeholder="Add an IP address" readonly />' . $value . '</textarea>'
400
- );
401
-
402
- $html = '<label for="wcap_restrict_ip_address_label"> ' . $args[0] . '</label>';
403
-
404
- echo $html;
405
-
406
- }
407
-
408
-
409
-
410
- public static function wcap_restrict_email_address_callback( $args ) {
411
-
412
- $wcap_restrict_email_address = get_option( 'wcap_restrict_email_address' );
413
-
414
- $email_value = isset( $wcap_restrict_email_address ) ? esc_attr( $wcap_restrict_email_address ) : '';
415
-
416
- printf(
417
- '<textarea rows="4" cols="50" id="wcap_restrict_email_address" name="wcap_restrict_email_address" placeholder="Add an email address" readonly />' . $email_value . '</textarea>'
418
- );
419
-
420
- $html = '<label for="wcap_restrict_email_address_label"> ' . $args[0] . '</label>';
421
-
422
- echo $html;
423
-
424
- }
425
-
426
-
427
-
428
- public static function wcap_restrict_domain_address_callback( $args ) {
429
-
430
- $wcap_restrict_domain_address = get_option( 'wcap_restrict_domain_address' );
431
-
432
- $domain_value = isset( $wcap_restrict_domain_address ) ? esc_attr( $wcap_restrict_domain_address ) : '';
433
-
434
- printf(
435
- '<textarea rows="4" cols="50" id="wcap_restrict_domain_address" name="wcap_restrict_domain_address" placeholder="Add an email domain name (Ex. hotmail.com)" readonly/>' . $domain_value . '</textarea>'
436
- );
437
-
438
- $html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
439
-
440
- echo $html;
441
-
442
- }
443
-
444
-
445
-
446
-
447
-
448
- } // end of class
449
-
450
- $WCAP_Pro_Settings_Callbacks = new WCAP_Pro_Settings_Callbacks();
451
-
452
- } // end if
453
-
454
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/class-wcal-admin-notice.php CHANGED
@@ -29,19 +29,28 @@ class Wcal_Admin_Notice {
29
  */
30
  public static function wcal_show_db_update_notice() {
31
 
32
- if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' === $_GET['page'] ) {
33
 
34
  if ( ! get_option( 'wcal_scheduler_update_dismiss', false ) ) {
35
  $post_link = '<a href="https://www.tychesoftwares.com/moving-to-the-action-scheduler-library/?utm_source=AcLiteNotice&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">here</a>';
36
  ?>
37
  <div id='wcal_cron_notice' class='is-dismissible notice notice-info wcal-cron-notice'>
38
- <p><?php _e( "The <b>Abandoned Cart Lite for WooCommerce</b> now uses the Action Scheduler library to send reminders. For further details, please visit $post_link.", 'woocommerce-abandoned-cart' ); ?></p>
 
 
 
 
 
 
 
 
 
39
  </div>
40
  <?php
41
  }
42
  }
43
 
44
- if ( isset( $_GET['ac_update'] ) && 'email_templates' === $_GET['ac_update'] ) {
45
  return;
46
  }
47
 
@@ -53,9 +62,17 @@ class Wcal_Admin_Notice {
53
  );
54
 
55
  foreach ( $results as $key => $value ) {
56
- if ( 'utf8mb4_unicode_ci' !== $value->Collation ) {
57
- /* translators: %s Link to Email Templates page */
58
- printf( __( '<div id="wcal_update" class="updated woocommerce-message" style="padding:15px;"><span>We need to update your email template database for some improvements. Please take a backup of your databases for your piece of mind</span><span class="submit"><a href="%s" class="button-primary" style="float:right;">Update</a></span></div>', 'woocommerce-abandoned-cart' ), 'admin.php?page=woocommerce_ac_page&action=listcart&ac_update=email_templates' );
 
 
 
 
 
 
 
 
59
  break;
60
  }
61
  }
29
  */
30
  public static function wcal_show_db_update_notice() {
31
 
32
+ if ( isset( $_GET['page'] ) && 'woocommerce_ac_page' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification
33
 
34
  if ( ! get_option( 'wcal_scheduler_update_dismiss', false ) ) {
35
  $post_link = '<a href="https://www.tychesoftwares.com/moving-to-the-action-scheduler-library/?utm_source=AcLiteNotice&utm_medium=link&utm_campaign=AbandonCartLite" target="_blank">here</a>';
36
  ?>
37
  <div id='wcal_cron_notice' class='is-dismissible notice notice-info wcal-cron-notice'>
38
+ <p>
39
+ <?php
40
+ printf(
41
+ // Translators: Plugin Name and URL.
42
+ esc_html__( 'The %1$s now uses the Action Scheduler library to send reminders. For further details, please visit %2$s.', 'woocommerce-abandoned-cart' ),
43
+ wp_kses_post( '<b>Abandoned Cart Lite for WooCommerce</b>' ),
44
+ esc_url( $post_link )
45
+ );
46
+ ?>
47
+ </p>
48
  </div>
49
  <?php
50
  }
51
  }
52
 
53
+ if ( isset( $_GET['ac_update'] ) && 'email_templates' === $_GET['ac_update'] ) { // phpcs:ignore WordPress.Security.NonceVerification
54
  return;
55
  }
56
 
62
  );
63
 
64
  foreach ( $results as $key => $value ) {
65
+ if ( 'utf8mb4_unicode_ci' !== $value->Collation ) { // phpcs:ignore
66
+ ?>
67
+ <div id="wcal_update" class="updated woocommerce-message" style="padding:15px;">
68
+ <span>
69
+ <?php echo esc_html__( 'We need to update your email template database for some improvements. Please take a backup of your databases for your piece of mind.', 'woocommerce-abandoned-cart' ); ?>
70
+ </span>
71
+ <span class="submit">
72
+ <a href="<?php echo esc_url( 'admin.php?page=woocommerce_ac_page&action=listcart&ac_update=email_templates' ); ?>" class="button-primary" style="float:right;"><?php echo esc_html__( 'Update', 'woocommerce-abandoned-cart' ); ?></a>
73
+ </span>
74
+ </div>
75
+ <?php
76
  break;
77
  }
78
  }
includes/{wcal_all_component.php → class-wcal-all-component.php} RENAMED
@@ -5,6 +5,7 @@
5
  * @author Tyche Softwares
6
  * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Component
7
  */
 
8
  if ( ! defined( 'ABSPATH' ) ) {
9
  exit; // Exit if accessed directly.
10
  }
@@ -29,7 +30,6 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
29
  require_once 'component/tracking-data/ts-tracking.php';
30
  require_once 'component/deactivate-survey-popup/class-ts-deactivation.php';
31
 
32
- require_once 'component/welcome-page/ts-welcome.php';
33
  require_once 'component/faq-support/ts-faq-support.php';
34
  require_once 'component/pro-notices-in-lite/ts-pro-notices.php';
35
 
@@ -64,15 +64,9 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
64
  $wcal_deativate = new Wcal_TS_deactivate();
65
  $wcal_deativate->init( $wcal_file_name, $wcal_plugin_name );
66
 
67
- /*new Wcal_TS_Welcome ( $wcal_plugin_name, $wcal_plugin_prefix, $wcal_locale, $wcal_plugin_folder_name, $wcal_plugin_dir_name, $wcal_get_previous_version );*/
68
-
69
  $ts_pro_faq = self::wcal_get_faq();
70
  new Wcal_TS_Faq_Support( $wcal_plugin_name, $wcal_plugin_prefix, $wcal_plugins_page, $wcal_locale, $wcal_plugin_folder_name, $wcal_plugin_slug, $ts_pro_faq );
71
 
72
- /*
73
- $ts_pro_notices = self::wcal_get_notice_text ();
74
- new Wcal_ts_pro_notices( $wcal_plugin_name, $wcal_lite_plugin_prefix, $wcal_plugin_prefix, $ts_pro_notices, $wcal_file_name, $wcal_pro_file_name );*/
75
-
76
  }
77
  }
78
 
@@ -105,6 +99,7 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
105
  /* translators: %s Link to Abandoned Cart Pro */
106
  $message_five = wp_kses_post(
107
  sprintf(
 
108
  __(
109
  'Increase your store sales by recovering your abandoned carts for just $119. No profit sharing, no monthly fees. Our Abandoned Cart Pro plugin comes with a 30 day money back guarantee as well. :) Use coupon code ACPRO20 & save $24!<br>
110
  <strong><a target="_blank" href= "%s">Grab your copy now!</a></strong>',
@@ -122,6 +117,7 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
122
  /* translators: %s Link to Order Delivery Date Pro */
123
  $message_seven = wp_kses_post(
124
  sprintf(
 
125
  __(
126
  'Allow your customers to select the Delivery Date on Single Product Page using our Product Delivery Date pro for WooCommerce Plugin. <br>
127
  <strong><a target="_blank" href= "%s">Shop now</a></strong> & be one of the 20 customers to get 20% discount on the plugin price. Use the code "PRDPRO20". Hurry!!',
@@ -139,6 +135,7 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
139
  /* translators: %s Link to Deposits for WooCommerce */
140
  $message_nine = wp_kses_post(
141
  sprintf(
 
142
  __(
143
  ' Allow your customers to pay deposits on products using our Deposits for WooCommerce plugin. <br>
144
  <strong><a target="_blank" href= "%s">Purchase now</a></strong> & Grab 20% discount with the code "DFWP20". The discount code is valid only for the first 20 customers.',
@@ -207,7 +204,7 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
207
  <br/><br/>
208
  For example, if you are using cPanel, it has a section Named as "Cron Jobs" which allows you to create the cron job.
209
  <br/><br/>
210
- /usr/bin/wget -q -c {your_site_path}/wp-content/plugins/woocommerce-abandoned-cart/cron/wcal_send_email.php
211
  <br/><br/>
212
  You can refer to this document for creating a <a href="https://documentation.cpanel.net/display/68Docs/Cron+Jobs">cron job</a> in cPanel.',
213
  ),
@@ -233,5 +230,5 @@ if ( ! class_exists( 'Wcal_All_Component' ) ) {
233
  return $ts_faq;
234
  }
235
  }
236
- $Wcal_All_Component = new Wcal_All_Component();
237
  }
5
  * @author Tyche Softwares
6
  * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/Component
7
  */
8
+
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit; // Exit if accessed directly.
11
  }
30
  require_once 'component/tracking-data/ts-tracking.php';
31
  require_once 'component/deactivate-survey-popup/class-ts-deactivation.php';
32
 
 
33
  require_once 'component/faq-support/ts-faq-support.php';
34
  require_once 'component/pro-notices-in-lite/ts-pro-notices.php';
35
 
64
  $wcal_deativate = new Wcal_TS_deactivate();
65
  $wcal_deativate->init( $wcal_file_name, $wcal_plugin_name );
66
 
 
 
67
  $ts_pro_faq = self::wcal_get_faq();
68
  new Wcal_TS_Faq_Support( $wcal_plugin_name, $wcal_plugin_prefix, $wcal_plugins_page, $wcal_locale, $wcal_plugin_folder_name, $wcal_plugin_slug, $ts_pro_faq );
69
 
 
 
 
 
70
  }
71
  }
72
 
99
  /* translators: %s Link to Abandoned Cart Pro */
100
  $message_five = wp_kses_post(
101
  sprintf(
102
+ // translators: Pro version link.
103
  __(
104
  'Increase your store sales by recovering your abandoned carts for just $119. No profit sharing, no monthly fees. Our Abandoned Cart Pro plugin comes with a 30 day money back guarantee as well. :) Use coupon code ACPRO20 & save $24!<br>
105
  <strong><a target="_blank" href= "%s">Grab your copy now!</a></strong>',
117
  /* translators: %s Link to Order Delivery Date Pro */
118
  $message_seven = wp_kses_post(
119
  sprintf(
120
+ // translators: Order Delivery Date Pro link.
121
  __(
122
  'Allow your customers to select the Delivery Date on Single Product Page using our Product Delivery Date pro for WooCommerce Plugin. <br>
123
  <strong><a target="_blank" href= "%s">Shop now</a></strong> & be one of the 20 customers to get 20% discount on the plugin price. Use the code "PRDPRO20". Hurry!!',
135
  /* translators: %s Link to Deposits for WooCommerce */
136
  $message_nine = wp_kses_post(
137
  sprintf(
138
+ // translators: Deposits for WC pro plugin link.
139
  __(
140
  ' Allow your customers to pay deposits on products using our Deposits for WooCommerce plugin. <br>
141
  <strong><a target="_blank" href= "%s">Purchase now</a></strong> & Grab 20% discount with the code "DFWP20". The discount code is valid only for the first 20 customers.',
204
  <br/><br/>
205
  For example, if you are using cPanel, it has a section Named as "Cron Jobs" which allows you to create the cron job.
206
  <br/><br/>
207
+ /usr/bin/wget -q -c {your_site_path}/wp-content/plugins/woocommerce-abandoned-cart/cron/class-wcal-cron.php
208
  <br/><br/>
209
  You can refer to this document for creating a <a href="https://documentation.cpanel.net/display/68Docs/Cron+Jobs">cron job</a> in cPanel.',
210
  ),
230
  return $ts_faq;
231
  }
232
  }
233
+ $wcal_all_component = new Wcal_All_Component();
234
  }
includes/{wcal-common.php → class-wcal-common.php} RENAMED
@@ -11,7 +11,7 @@
11
  *
12
  * @since 2.5.2
13
  */
14
- class wcal_common {
15
 
16
  /**
17
  * Get abandoned orders counts.
@@ -26,7 +26,7 @@ class wcal_common {
26
 
27
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
28
  $cut_off_time = $ac_cutoff_time * 60;
29
- $current_time = current_time( 'timestamp' );
30
  $compare_time = $current_time - $cut_off_time;
31
 
32
  $blank_cart_info = '{"cart":[]}';
@@ -60,7 +60,7 @@ class wcal_common {
60
 
61
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
62
  $cut_off_time = $ac_cutoff_time * 60;
63
- $current_time = current_time( 'timestamp' );
64
  $compare_time = $current_time - $cut_off_time;
65
 
66
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
@@ -87,7 +87,7 @@ class wcal_common {
87
 
88
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
89
  $cut_off_time = $ac_cutoff_time * 60;
90
- $current_time = current_time( 'timestamp' );
91
  $compare_time = $current_time - $cut_off_time;
92
 
93
  $blank_cart_info = '{"cart":[]}';
@@ -154,7 +154,7 @@ class wcal_common {
154
 
155
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
156
  $cut_off_time = $ac_cutoff_time * 60;
157
- $current_time = current_time( 'timestamp' );
158
  $compare_time = $current_time - $cut_off_time;
159
 
160
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
@@ -260,7 +260,7 @@ class wcal_common {
260
 
261
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
262
  $cut_off_time = $ac_cutoff_time * 60;
263
- $current_time = current_time( 'timestamp' );
264
  $compare_time = $current_time - $cut_off_time;
265
 
266
  $blank_cart_info = '{"cart":[]}';
@@ -292,7 +292,7 @@ class wcal_common {
292
 
293
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
294
  $cut_off_time = $ac_cutoff_time * 60;
295
- $current_time = current_time( 'timestamp' );
296
  $compare_time = $current_time - $cut_off_time;
297
 
298
  $blank_cart_info = '{"cart":[]}';
@@ -325,7 +325,7 @@ class wcal_common {
325
 
326
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
327
  $cut_off_time = $ac_cutoff_time * 60;
328
- $current_time = current_time( 'timestamp' );
329
  $compare_time = $current_time - $cut_off_time;
330
 
331
  $blank_cart_info = '{"cart":[]}';
@@ -360,7 +360,7 @@ class wcal_common {
360
 
361
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
362
  $cut_off_time = $ac_cutoff_time * 60;
363
- $current_time = current_time( 'timestamp' );
364
  $compare_time = $current_time - $cut_off_time;
365
 
366
  $blank_cart_info = '{"cart":[]}';
@@ -395,7 +395,7 @@ class wcal_common {
395
 
396
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
397
  $cut_off_time = $ac_cutoff_time * 60;
398
- $current_time = current_time( 'timestamp' );
399
  $compare_time = $current_time - $cut_off_time;
400
 
401
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
@@ -425,7 +425,7 @@ class wcal_common {
425
 
426
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
427
  $cut_off_time = $ac_cutoff_time * 60;
428
- $current_time = current_time( 'timestamp' );
429
  $compare_time = $current_time - $cut_off_time;
430
 
431
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
@@ -552,7 +552,7 @@ class wcal_common {
552
  $blank_cart = '""';
553
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
554
  $cut_off_time = intval( $ac_cutoff_time ) * 60;
555
- $current_time = current_time( 'timestamp' );
556
  $compare_time = $current_time - $cut_off_time;
557
 
558
  switch ( $get_section_result ) {
@@ -932,14 +932,14 @@ class wcal_common {
932
  /**
933
  * Returns formatted price.
934
  *
935
- * @param float $price - Price to be formatted
936
  * @param string $currency - Currency.
937
  * @return string $price - Formatted price with currency symbol.
938
  * @since 5.6
939
  */
940
  public static function wcal_get_price( $price, $currency ) {
941
 
942
- if ( function_exists( 'icl_object_id' ) && isset( $currency ) && $currency !== '' ) {
943
  return wc_price( $price, array( 'currency' => $currency ) );
944
  } else {
945
  return wc_price( $price );
@@ -955,19 +955,25 @@ class wcal_common {
955
  */
956
  public static function wcal_get_user_role( $uid ) {
957
  global $wpdb;
958
- $role = $wpdb->get_var( "SELECT meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'wp_capabilities' AND user_id = {$uid}" );
 
 
 
 
 
 
959
 
960
  if ( ! $role ) {
961
  return '';
962
  }
963
- $rarr = unserialize( $role );
964
 
965
  $roles = is_array( $rarr ) ? array_keys( $rarr ) : array( 'non-user' );
966
 
967
  /**
968
  * When store have the wpml it have so many user roles to fix the user role for admin we have applied this fix.
969
  */
970
- if ( in_array( 'administrator', $roles ) ) {
971
 
972
  $roles[0] = 'administrator';
973
  }
@@ -1010,4 +1016,3 @@ class wcal_common {
1010
  );
1011
  }
1012
  }
1013
- ?>
11
  *
12
  * @since 2.5.2
13
  */
14
+ class wcal_common { // phpcs:ignore
15
 
16
  /**
17
  * Get abandoned orders counts.
26
 
27
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
28
  $cut_off_time = $ac_cutoff_time * 60;
29
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
30
  $compare_time = $current_time - $cut_off_time;
31
 
32
  $blank_cart_info = '{"cart":[]}';
60
 
61
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
62
  $cut_off_time = $ac_cutoff_time * 60;
63
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
64
  $compare_time = $current_time - $cut_off_time;
65
 
66
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
87
 
88
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
89
  $cut_off_time = $ac_cutoff_time * 60;
90
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
91
  $compare_time = $current_time - $cut_off_time;
92
 
93
  $blank_cart_info = '{"cart":[]}';
154
 
155
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
156
  $cut_off_time = $ac_cutoff_time * 60;
157
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
158
  $compare_time = $current_time - $cut_off_time;
159
 
160
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
260
 
261
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
262
  $cut_off_time = $ac_cutoff_time * 60;
263
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
264
  $compare_time = $current_time - $cut_off_time;
265
 
266
  $blank_cart_info = '{"cart":[]}';
292
 
293
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
294
  $cut_off_time = $ac_cutoff_time * 60;
295
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
296
  $compare_time = $current_time - $cut_off_time;
297
 
298
  $blank_cart_info = '{"cart":[]}';
325
 
326
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
327
  $cut_off_time = $ac_cutoff_time * 60;
328
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
329
  $compare_time = $current_time - $cut_off_time;
330
 
331
  $blank_cart_info = '{"cart":[]}';
360
 
361
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
362
  $cut_off_time = $ac_cutoff_time * 60;
363
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
364
  $compare_time = $current_time - $cut_off_time;
365
 
366
  $blank_cart_info = '{"cart":[]}';
395
 
396
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
397
  $cut_off_time = $ac_cutoff_time * 60;
398
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
399
  $compare_time = $current_time - $cut_off_time;
400
 
401
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
425
 
426
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
427
  $cut_off_time = $ac_cutoff_time * 60;
428
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
429
  $compare_time = $current_time - $cut_off_time;
430
 
431
  // phpcs:ignore WordPress.DB.DirectDatabaseQuery
552
  $blank_cart = '""';
553
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
554
  $cut_off_time = intval( $ac_cutoff_time ) * 60;
555
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
556
  $compare_time = $current_time - $cut_off_time;
557
 
558
  switch ( $get_section_result ) {
932
  /**
933
  * Returns formatted price.
934
  *
935
+ * @param float $price - Price to be formatted.
936
  * @param string $currency - Currency.
937
  * @return string $price - Formatted price with currency symbol.
938
  * @since 5.6
939
  */
940
  public static function wcal_get_price( $price, $currency ) {
941
 
942
+ if ( function_exists( 'icl_object_id' ) && isset( $currency ) && '' !== $currency ) {
943
  return wc_price( $price, array( 'currency' => $currency ) );
944
  } else {
945
  return wc_price( $price );
955
  */
956
  public static function wcal_get_user_role( $uid ) {
957
  global $wpdb;
958
+ $role = $wpdb->get_var( // phpcs:ignore
959
+ $wpdb->prepare(
960
+ 'SELECT meta_value FROM ' . $wpdb->usermeta . ' WHERE meta_key = %s AND user_id = %d',
961
+ 'wp_capabilities',
962
+ (int) $uid
963
+ )
964
+ );
965
 
966
  if ( ! $role ) {
967
  return '';
968
  }
969
+ $rarr = unserialize( $role ); // phpcs:ignore
970
 
971
  $roles = is_array( $rarr ) ? array_keys( $rarr ) : array( 'non-user' );
972
 
973
  /**
974
  * When store have the wpml it have so many user roles to fix the user role for admin we have applied this fix.
975
  */
976
+ if ( in_array( 'administrator', $roles, true ) ) {
977
 
978
  $roles[0] = 'administrator';
979
  }
1016
  );
1017
  }
1018
  }
 
includes/class-wcal-default-template-settings.php CHANGED
@@ -45,17 +45,7 @@ class Wcal_Default_Template_Settings {
45
  $wpdb->prepare(
46
  'INSERT INTO `' . $db_prefix . 'ac_email_templates_lite`
47
  ( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
48
- VALUES (
49
- %s,
50
- %s,
51
- %s,
52
- %s,
53
- %s,
54
- %s,
55
- %s,
56
- %s,
57
- %s
58
- )',
59
  $template_subject_array,
60
  $body_content_array,
61
  $active_post_array,
45
  $wpdb->prepare(
46
  'INSERT INTO `' . $db_prefix . 'ac_email_templates_lite`
47
  ( subject, body, is_active, frequency, day_or_hour, template_name, is_wc_template, default_template, wc_email_header )
48
+ VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s )',
 
 
 
 
 
 
 
 
 
 
49
  $template_subject_array,
50
  $body_content_array,
51
  $active_post_array,
includes/{wcal_class-guest.php → class-wcal-guest-ac.php} RENAMED
@@ -8,7 +8,7 @@
8
  * @package abandoned-cart-lite
9
  */
10
 
11
- if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
12
 
13
  /**
14
  * It will add the js, ajax for capturing the guest cart.
@@ -16,7 +16,7 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
16
  *
17
  * @since 2.2
18
  */
19
- class woocommerce_guest_ac {
20
 
21
  /**
22
  * Default Constructor function for guest tracking.
@@ -64,7 +64,7 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
64
  $guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
65
 
66
  $session_gdpr = wcal_common::wcal_get_cart_session( 'wcal_cart_tracking_refused' );
67
- $show_gdpr = isset( $session_gdpr ) && 'yes' === $session_gdpr ? false : true;
68
 
69
  $vars = array();
70
  if ( isset( $guest_msg ) && '' !== $guest_msg ) {
@@ -112,64 +112,64 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
112
  if ( isset( $_POST['billing_company'] ) && '' !== $_POST['billing_company'] ) {
113
  wcal_common::wcal_set_cart_session( 'billing_company', sanitize_text_field( wp_unslash( $_POST['billing_company'] ) ) );
114
  }
115
- if ( isset( $_POST['billing_address_1'] ) && $_POST['billing_address_1'] != '' ) {
116
  wcal_common::wcal_set_cart_session( 'billing_address_1', sanitize_text_field( wp_unslash( $_POST['billing_address_1'] ) ) );
117
  }
118
- if ( isset( $_POST['billing_address_2'] ) && $_POST['billing_address_2'] != '' ) {
119
  wcal_common::wcal_set_cart_session( 'billing_address_2', sanitize_text_field( wp_unslash( $_POST['billing_address_2'] ) ) );
120
  }
121
- if ( isset( $_POST['billing_city'] ) && $_POST['billing_city'] != '' ) {
122
  wcal_common::wcal_set_cart_session( 'billing_city', sanitize_text_field( wp_unslash( $_POST['billing_city'] ) ) );
123
  }
124
- if ( isset( $_POST['billing_state'] ) && $_POST['billing_state'] != '' ) {
125
  wcal_common::wcal_set_cart_session( 'billing_state', sanitize_text_field( wp_unslash( $_POST['billing_state'] ) ) );
126
  }
127
- if ( isset( $_POST['billing_postcode'] ) && $_POST['billing_postcode'] != '' ) {
128
  wcal_common::wcal_set_cart_session( 'billing_postcode', sanitize_text_field( wp_unslash( $_POST['billing_postcode'] ) ) );
129
  }
130
- if ( isset( $_POST['billing_country'] ) && $_POST['billing_country'] != '' ) {
131
  wcal_common::wcal_set_cart_session( 'billing_country', sanitize_text_field( wp_unslash( $_POST['billing_country'] ) ) );
132
  }
133
- if ( isset( $_POST['billing_email'] ) && $_POST['billing_email'] != '' ) {
134
  wcal_common::wcal_set_cart_session( 'billing_email', sanitize_text_field( wp_unslash( $_POST['billing_email'] ) ) );
135
  }
136
- if ( isset( $_POST['billing_phone'] ) && $_POST['billing_phone'] != '' ) {
137
  wcal_common::wcal_set_cart_session( 'billing_phone', sanitize_text_field( wp_unslash( $_POST['billing_phone'] ) ) );
138
  }
139
- if ( isset( $_POST['order_notes'] ) && $_POST['order_notes'] != '' ) {
140
  wcal_common::wcal_set_cart_session( 'order_notes', sanitize_text_field( wp_unslash( $_POST['order_notes'] ) ) );
141
  }
142
- if ( isset( $_POST['ship_to_billing'] ) && $_POST['ship_to_billing'] != '' ) {
143
  wcal_common::wcal_set_cart_session( 'ship_to_billing', sanitize_text_field( wp_unslash( $_POST['ship_to_billing'] ) ) );
144
  }
145
- if ( isset( $_POST['shipping_first_name'] ) && $_POST['shipping_first_name'] != '' ) {
146
  wcal_common::wcal_set_cart_session( 'shipping_first_name', sanitize_text_field( wp_unslash( $_POST['shipping_first_name'] ) ) );
147
  }
148
- if ( isset( $_POST['shipping_last_name'] ) && $_POST['shipping_last_name'] != '' ) {
149
  wcal_common::wcal_set_cart_session( 'shipping_last_name', sanitize_text_field( wp_unslash( $_POST['shipping_last_name'] ) ) );
150
  }
151
- if ( isset( $_POST['shipping_company'] ) && $_POST['shipping_company'] != '' ) {
152
  wcal_common::wcal_set_cart_session( 'shipping_company', sanitize_text_field( wp_unslash( $_POST['shipping_company'] ) ) );
153
  }
154
- if ( isset( $_POST['shipping_address_1'] ) && $_POST['shipping_address_1'] != '' ) {
155
  wcal_common::wcal_set_cart_session( 'shipping_address_1', sanitize_text_field( wp_unslash( $_POST['shipping_address_1'] ) ) );
156
  }
157
- if ( isset( $_POST['shipping_address_2'] ) && $_POST['shipping_address_2'] != '' ) {
158
  wcal_common::wcal_set_cart_session( 'shipping_address_2', sanitize_text_field( wp_unslash( $_POST['shipping_address_2'] ) ) );
159
  }
160
- if ( isset( $_POST['shipping_city'] ) && $_POST['shipping_city'] != '' ) {
161
  wcal_common::wcal_set_cart_session( 'shipping_city', sanitize_text_field( wp_unslash( $_POST['shipping_city'] ) ) );
162
  }
163
- if ( isset( $_POST['shipping_state'] ) && $_POST['shipping_state'] != '' ) {
164
  wcal_common::wcal_set_cart_session( 'shipping_state', sanitize_text_field( wp_unslash( $_POST['shipping_state'] ) ) );
165
  }
166
- if ( isset( $_POST['shipping_postcode'] ) && $_POST['shipping_postcode'] != '' ) {
167
  wcal_common::wcal_set_cart_session( 'shipping_postcode', sanitize_text_field( wp_unslash( $_POST['shipping_postcode'] ) ) );
168
  }
169
- if ( isset( $_POST['shipping_country'] ) && $_POST['shipping_country'] != '' ) {
170
  wcal_common::wcal_set_cart_session( 'shipping_country', sanitize_text_field( wp_unslash( $_POST['shipping_country'] ) ) );
171
  }
172
- // If a record is present in the guest cart history table for the same email id, then delete the previous records
173
  $results_guest = $wpdb->get_results( // phpcs:ignore
174
  $wpdb->prepare(
175
  'SELECT id FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite` WHERE email_id = %s',
@@ -179,6 +179,7 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
179
 
180
  if ( $results_guest ) {
181
  foreach ( $results_guest as $key => $value ) {
 
182
  $result = $wpdb->get_results(
183
  $wpdb->prepare(
184
  'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE user_id = %d AND recovered_cart = %s',
@@ -199,17 +200,19 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
199
  }
200
  }
201
  }
202
- // Insert record in guest table
203
  $billing_first_name = wcal_common::wcal_get_cart_session( 'billing_first_name' );
204
 
205
  $billing_last_name = wcal_common::wcal_get_cart_session( 'billing_last_name' );
206
 
207
- $shipping_zipcode = $billing_zipcode = '';
 
208
 
209
- if ( wcal_common::wcal_get_cart_session( 'shipping_postcode' ) != '' ) {
210
  $shipping_zipcode = wcal_common::wcal_get_cart_session( 'shipping_postcode' );
211
- } elseif ( wcal_common::wcal_get_cart_session( 'billing_postcode' ) != '' ) {
212
- $shipping_zipcode = $billing_zipcode = wcal_common::wcal_get_cart_session( 'billing_postcode' );
 
213
  }
214
  $shipping_charges = $woocommerce->cart->shipping_total;
215
  $wpdb->query( // phpcs:ignore
@@ -224,10 +227,10 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
224
  )
225
  );
226
 
227
- // Insert record in abandoned cart table for the guest user
228
  $user_id = $wpdb->insert_id;
229
  wcal_common::wcal_set_cart_session( 'user_id', $user_id );
230
- $current_time = current_time( 'timestamp' );
231
  $cut_off_time = get_option( 'ac_cart_abandoned_time' );
232
  $cart_cut_off_time = $cut_off_time * 60;
233
  $compare_time = $current_time - $cart_cut_off_time;
@@ -250,11 +253,11 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
250
  $cart['cart'] = $woocommerce->session->cart;
251
  }
252
 
253
- if ( 0 == count( $results ) ) {
254
  $get_cookie = WC()->session->get_session_cookie();
255
- //$cart_info = addslashes( json_encode( $cart ) );
256
- $cart_info = json_encode( $cart );
257
 
 
 
258
  $results = $wpdb->get_results(
259
  $wpdb->prepare(
260
  'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = %s AND recovered_cart = %s',
@@ -263,8 +266,9 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
263
  0
264
  )
265
  );
266
- if ( 0 == count( $results ) ) {
267
- $wpdb->query( // phpcs:ignore
 
268
  $wpdb->prepare(
269
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id ) VALUES ( %s, %s, %s, %s, %s, %s, %s )',
270
  $user_id,
@@ -280,15 +284,13 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
280
  $abandoned_cart_id = $wpdb->insert_id;
281
  wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
282
 
283
- // $insert_persistent_cart = "INSERT INTO `".$wpdb->prefix."usermeta`( user_id, meta_key, meta_value )
284
- // VALUES ( '".$user_id."', '_woocommerce_persistent_cart', '".$cart_info."' )";
285
- // $wpdb->query( $insert_persistent_cart );
286
  if ( is_multisite() ) {
287
- // get main site's table prefix
288
- $main_prefix = $wpdb->get_blog_prefix( 1 );
289
- $wpdb->query( // phpcS:ignore
 
290
  $wpdb->prepare(
291
- 'INSERT INTO `' . $main_prefix . 'usermeta`( user_id, meta_key, meta_value ) VALUES ( %s, %s, %s )',
292
  $user_id,
293
  '_woocommerce_persistent_cart',
294
  $cart_info
@@ -339,11 +341,12 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
339
  )
340
  );
341
  if ( is_multisite() ) {
342
- // get main site's table prefix
343
- $main_prefix = $wpdb->get_blog_prefix( 1 );
344
- $wpdb->query( // phpcs:ignore
 
345
  $wpdb->prepare(
346
- 'INSERT INTO `' . $main_prefix . 'usermeta`( user_id, meta_key, meta_value ) VALUES ( %s, %s, %s )',
347
  $user_id,
348
  '_woocommerce_persistent_cart',
349
  $cart_info
@@ -369,24 +372,24 @@ if ( ! class_exists( 'woocommerce_guest_ac' ) ) {
369
  * It will populate the data on the chekout field if user comes from the abandoned cart reminder emails.
370
  *
371
  * @hook woocommerce_checkout_fields
372
- * @param array $fields All fields of checkout page
373
  * @return array $fields
374
  * @since 2.2
375
  */
376
  function guest_checkout_fields( $fields ) {
377
- if ( wcal_common::wcal_get_cart_session( 'guest_first_name' ) != '' ) {
378
  $_POST['billing_first_name'] = wcal_common::wcal_get_cart_session( 'guest_first_name' );
379
  }
380
- if ( wcal_common::wcal_get_cart_session( 'guest_last_name' ) != '' ) {
381
  $_POST['billing_last_name'] = wcal_common::wcal_get_cart_session( 'guest_last_name' );
382
  }
383
- if ( wcal_common::wcal_get_cart_session( 'guest_email' ) != '' ) {
384
  $_POST['billing_email'] = wcal_common::wcal_get_cart_session( 'guest_email' );
385
  }
386
- if ( wcal_common::wcal_get_cart_session( 'guest_phone' ) != '' ) {
387
  $_POST['billing_phone'] = wcal_common::wcal_get_cart_session( 'guest_phone' );
388
  }
389
  return $fields;
390
  }
391
  }
392
- $woocommerce_guest_ac = new woocommerce_guest_ac();
8
  * @package abandoned-cart-lite
9
  */
10
 
11
+ if ( ! class_exists( 'Wcal_Guest_Ac' ) ) {
12
 
13
  /**
14
  * It will add the js, ajax for capturing the guest cart.
16
  *
17
  * @since 2.2
18
  */
19
+ class Wcal_Guest_Ac {
20
 
21
  /**
22
  * Default Constructor function for guest tracking.
64
  $guest_msg = get_option( 'wcal_guest_cart_capture_msg' );
65
 
66
  $session_gdpr = wcal_common::wcal_get_cart_session( 'wcal_cart_tracking_refused' );
67
+ $show_gdpr = isset( $session_gdpr ) && 'yes' == $session_gdpr ? false : true; // phpcs:ignore
68
 
69
  $vars = array();
70
  if ( isset( $guest_msg ) && '' !== $guest_msg ) {
112
  if ( isset( $_POST['billing_company'] ) && '' !== $_POST['billing_company'] ) {
113
  wcal_common::wcal_set_cart_session( 'billing_company', sanitize_text_field( wp_unslash( $_POST['billing_company'] ) ) );
114
  }
115
+ if ( isset( $_POST['billing_address_1'] ) && '' !== $_POST['billing_address_1'] ) {
116
  wcal_common::wcal_set_cart_session( 'billing_address_1', sanitize_text_field( wp_unslash( $_POST['billing_address_1'] ) ) );
117
  }
118
+ if ( isset( $_POST['billing_address_2'] ) && '' !== $_POST['billing_address_2'] ) {
119
  wcal_common::wcal_set_cart_session( 'billing_address_2', sanitize_text_field( wp_unslash( $_POST['billing_address_2'] ) ) );
120
  }
121
+ if ( isset( $_POST['billing_city'] ) && '' !== $_POST['billing_city'] ) {
122
  wcal_common::wcal_set_cart_session( 'billing_city', sanitize_text_field( wp_unslash( $_POST['billing_city'] ) ) );
123
  }
124
+ if ( isset( $_POST['billing_state'] ) && '' !== $_POST['billing_state'] ) {
125
  wcal_common::wcal_set_cart_session( 'billing_state', sanitize_text_field( wp_unslash( $_POST['billing_state'] ) ) );
126
  }
127
+ if ( isset( $_POST['billing_postcode'] ) && '' !== $_POST['billing_postcode'] ) {
128
  wcal_common::wcal_set_cart_session( 'billing_postcode', sanitize_text_field( wp_unslash( $_POST['billing_postcode'] ) ) );
129
  }
130
+ if ( isset( $_POST['billing_country'] ) && '' !== $_POST['billing_country'] ) {
131
  wcal_common::wcal_set_cart_session( 'billing_country', sanitize_text_field( wp_unslash( $_POST['billing_country'] ) ) );
132
  }
133
+ if ( isset( $_POST['billing_email'] ) && '' !== $_POST['billing_email'] ) {
134
  wcal_common::wcal_set_cart_session( 'billing_email', sanitize_text_field( wp_unslash( $_POST['billing_email'] ) ) );
135
  }
136
+ if ( isset( $_POST['billing_phone'] ) && '' !== $_POST['billing_phone'] ) {
137
  wcal_common::wcal_set_cart_session( 'billing_phone', sanitize_text_field( wp_unslash( $_POST['billing_phone'] ) ) );
138
  }
139
+ if ( isset( $_POST['order_notes'] ) && '' !== $_POST['order_notes'] ) {
140
  wcal_common::wcal_set_cart_session( 'order_notes', sanitize_text_field( wp_unslash( $_POST['order_notes'] ) ) );
141
  }
142
+ if ( isset( $_POST['ship_to_billing'] ) && '' !== $_POST['ship_to_billing'] ) {
143
  wcal_common::wcal_set_cart_session( 'ship_to_billing', sanitize_text_field( wp_unslash( $_POST['ship_to_billing'] ) ) );
144
  }
145
+ if ( isset( $_POST['shipping_first_name'] ) && '' !== $_POST['shipping_first_name'] ) {
146
  wcal_common::wcal_set_cart_session( 'shipping_first_name', sanitize_text_field( wp_unslash( $_POST['shipping_first_name'] ) ) );
147
  }
148
+ if ( isset( $_POST['shipping_last_name'] ) && '' !== $_POST['shipping_last_name'] ) {
149
  wcal_common::wcal_set_cart_session( 'shipping_last_name', sanitize_text_field( wp_unslash( $_POST['shipping_last_name'] ) ) );
150
  }
151
+ if ( isset( $_POST['shipping_company'] ) && '' !== $_POST['shipping_company'] ) {
152
  wcal_common::wcal_set_cart_session( 'shipping_company', sanitize_text_field( wp_unslash( $_POST['shipping_company'] ) ) );
153
  }
154
+ if ( isset( $_POST['shipping_address_1'] ) && '' !== $_POST['shipping_address_1'] ) {
155
  wcal_common::wcal_set_cart_session( 'shipping_address_1', sanitize_text_field( wp_unslash( $_POST['shipping_address_1'] ) ) );
156
  }
157
+ if ( isset( $_POST['shipping_address_2'] ) && '' !== $_POST['shipping_address_2'] ) {
158
  wcal_common::wcal_set_cart_session( 'shipping_address_2', sanitize_text_field( wp_unslash( $_POST['shipping_address_2'] ) ) );
159
  }
160
+ if ( isset( $_POST['shipping_city'] ) && '' !== $_POST['shipping_city'] ) {
161
  wcal_common::wcal_set_cart_session( 'shipping_city', sanitize_text_field( wp_unslash( $_POST['shipping_city'] ) ) );
162
  }
163
+ if ( isset( $_POST['shipping_state'] ) && '' !== $_POST['shipping_state'] ) {
164
  wcal_common::wcal_set_cart_session( 'shipping_state', sanitize_text_field( wp_unslash( $_POST['shipping_state'] ) ) );
165
  }
166
+ if ( isset( $_POST['shipping_postcode'] ) && '' !== $_POST['shipping_postcode'] ) {
167
  wcal_common::wcal_set_cart_session( 'shipping_postcode', sanitize_text_field( wp_unslash( $_POST['shipping_postcode'] ) ) );
168
  }
169
+ if ( isset( $_POST['shipping_country'] ) && '' !== $_POST['shipping_country'] ) {
170
  wcal_common::wcal_set_cart_session( 'shipping_country', sanitize_text_field( wp_unslash( $_POST['shipping_country'] ) ) );
171
  }
172
+ // If a record is present in the guest cart history table for the same email id, then delete the previous records.
173
  $results_guest = $wpdb->get_results( // phpcs:ignore
174
  $wpdb->prepare(
175
  'SELECT id FROM `' . $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite` WHERE email_id = %s',
179
 
180
  if ( $results_guest ) {
181
  foreach ( $results_guest as $key => $value ) {
182
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
183
  $result = $wpdb->get_results(
184
  $wpdb->prepare(
185
  'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE user_id = %d AND recovered_cart = %s',
200
  }
201
  }
202
  }
203
+ // Insert record in guest table.
204
  $billing_first_name = wcal_common::wcal_get_cart_session( 'billing_first_name' );
205
 
206
  $billing_last_name = wcal_common::wcal_get_cart_session( 'billing_last_name' );
207
 
208
+ $shipping_zipcode = '';
209
+ $billing_zipcode = '';
210
 
211
+ if ( '' != wcal_common::wcal_get_cart_session( 'shipping_postcode' ) ) { // phpcs:ignore
212
  $shipping_zipcode = wcal_common::wcal_get_cart_session( 'shipping_postcode' );
213
+ } elseif ( '' != wcal_common::wcal_get_cart_session( 'billing_postcode' ) ) { // phpcs:ignore
214
+ $billing_zipcode = wcal_common::wcal_get_cart_session( 'billing_postcode' );
215
+ $shipping_zipcode = $billing_zipcode;
216
  }
217
  $shipping_charges = $woocommerce->cart->shipping_total;
218
  $wpdb->query( // phpcs:ignore
227
  )
228
  );
229
 
230
+ // Insert record in abandoned cart table for the guest user.
231
  $user_id = $wpdb->insert_id;
232
  wcal_common::wcal_set_cart_session( 'user_id', $user_id );
233
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
234
  $cut_off_time = get_option( 'ac_cart_abandoned_time' );
235
  $cart_cut_off_time = $cut_off_time * 60;
236
  $compare_time = $current_time - $cart_cut_off_time;
253
  $cart['cart'] = $woocommerce->session->cart;
254
  }
255
 
256
+ if ( 0 === count( $results ) ) {
257
  $get_cookie = WC()->session->get_session_cookie();
 
 
258
 
259
+ $cart_info = wp_json_encode( $cart );
260
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
261
  $results = $wpdb->get_results(
262
  $wpdb->prepare(
263
  'SELECT * FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE session_id LIKE %s AND cart_ignored = %s AND recovered_cart = %s',
266
  0
267
  )
268
  );
269
+ if ( 0 === count( $results ) ) {
270
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
271
+ $wpdb->query(
272
  $wpdb->prepare(
273
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite`( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, recovered_cart, user_type, session_id ) VALUES ( %s, %s, %s, %s, %s, %s, %s )',
274
  $user_id,
284
  $abandoned_cart_id = $wpdb->insert_id;
285
  wcal_common::wcal_set_cart_session( 'abandoned_cart_id_lite', $abandoned_cart_id );
286
 
 
 
 
287
  if ( is_multisite() ) {
288
+ // get main site's table prefix.
289
+ $main_prefix = $wpdb->get_blog_prefix( 1 );
290
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
291
+ $wpdb->query(
292
  $wpdb->prepare(
293
+ 'INSERT INTO `' . $main_prefix . 'usermeta`( user_id, meta_key, meta_value ) VALUES ( %s, %s, %s )', // phpcs:ignore
294
  $user_id,
295
  '_woocommerce_persistent_cart',
296
  $cart_info
341
  )
342
  );
343
  if ( is_multisite() ) {
344
+ // get main site's table prefix.
345
+ $main_prefix = $wpdb->get_blog_prefix( 1 );
346
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
347
+ $wpdb->query(
348
  $wpdb->prepare(
349
+ 'INSERT INTO `' . $main_prefix . 'usermeta`( user_id, meta_key, meta_value ) VALUES ( %s, %s, %s )', // phpcs:ignore
350
  $user_id,
351
  '_woocommerce_persistent_cart',
352
  $cart_info
372
  * It will populate the data on the chekout field if user comes from the abandoned cart reminder emails.
373
  *
374
  * @hook woocommerce_checkout_fields
375
+ * @param array $fields All fields of checkout page.
376
  * @return array $fields
377
  * @since 2.2
378
  */
379
  function guest_checkout_fields( $fields ) {
380
+ if ( '' != wcal_common::wcal_get_cart_session( 'guest_first_name' ) ) { // phpcs:ignore
381
  $_POST['billing_first_name'] = wcal_common::wcal_get_cart_session( 'guest_first_name' );
382
  }
383
+ if ( '' != wcal_common::wcal_get_cart_session( 'guest_last_name' ) ) { // phpcs:ignore
384
  $_POST['billing_last_name'] = wcal_common::wcal_get_cart_session( 'guest_last_name' );
385
  }
386
+ if ( '' != wcal_common::wcal_get_cart_session( 'guest_email' ) ) { // phpcs:ignore
387
  $_POST['billing_email'] = wcal_common::wcal_get_cart_session( 'guest_email' );
388
  }
389
+ if ( '' != wcal_common::wcal_get_cart_session( 'guest_phone' ) ) { // phpcs:ignore
390
  $_POST['billing_phone'] = wcal_common::wcal_get_cart_session( 'guest_phone' );
391
  }
392
  return $fields;
393
  }
394
  }
395
+ $woocommerce_guest_ac = new Wcal_Guest_Ac();
includes/{wcal_process_base.php → class-wcal-process-base.php} RENAMED
@@ -1,22 +1,38 @@
1
  <?php
2
-
 
 
 
 
 
 
 
 
 
 
3
  class Wcal_Process_Base {
4
 
 
 
 
5
  public function __construct() {
6
- // Hook into that action that'll fire every 15 minutes
7
  add_action( 'woocommerce_ac_send_email_action', array( &$this, 'wcal_process_handler' ), 11 );
8
 
9
  }
10
 
 
 
 
11
  public function wcal_process_handler() {
12
- // add any new reminder methods added in the future for cron here
13
  $reminders_list = array( 'emails' );
14
 
15
  if ( is_array( $reminders_list ) && count( $reminders_list ) > 0 ) {
16
  foreach ( $reminders_list as $reminder_type ) {
17
  switch ( $reminder_type ) {
18
  case 'emails':
19
- $wcal_cron = new woocommerce_abandon_cart_cron();
20
  $wcal_cron->wcal_send_email_notification();
21
  break;
22
  }
@@ -27,4 +43,3 @@ class Wcal_Process_Base {
27
 
28
  }
29
  new Wcal_Process_Base();
30
-
1
  <?php
2
+ /**
3
+ * Abandoned Cart Lite for WooCommerce
4
+ *
5
+ * @author Tyche Softwares
6
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Background Processing
7
+ * @since 4.9
8
+ */
9
+
10
+ /**
11
+ * This class will help run automated scheduler actions to send reminders.
12
+ */
13
  class Wcal_Process_Base {
14
 
15
+ /**
16
+ * Construct.
17
+ */
18
  public function __construct() {
19
+ // Hook into that action that'll fire every 15 minutes.
20
  add_action( 'woocommerce_ac_send_email_action', array( &$this, 'wcal_process_handler' ), 11 );
21
 
22
  }
23
 
24
+ /**
25
+ * Process handler. Call the reminder functions.
26
+ */
27
  public function wcal_process_handler() {
28
+ // Add any new reminder methods added in the future for cron here.
29
  $reminders_list = array( 'emails' );
30
 
31
  if ( is_array( $reminders_list ) && count( $reminders_list ) > 0 ) {
32
  foreach ( $reminders_list as $reminder_type ) {
33
  switch ( $reminder_type ) {
34
  case 'emails':
35
+ $wcal_cron = new Wcal_Cron();
36
  $wcal_cron->wcal_send_email_notification();
37
  break;
38
  }
43
 
44
  }
45
  new Wcal_Process_Base();
 
includes/{wcal_data_tracking_message.php → class-wcal-tracking-msg.php} RENAMED
@@ -6,20 +6,24 @@
6
  * @package Abandoned-Cart-Lite-for-WooCommerce/Tracking
7
  * @since 4.9
8
  */
 
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit; // Exit if accessed directly.
11
  }
12
- if ( ! class_exists( 'Wcal_Tracking_msg' ) ) {
13
 
14
  /**
15
  * It will add messages as needed informing users of data being tracked.
16
  *
17
  * @since 4.9
18
  */
19
- class Wcal_Tracking_msg {
20
 
 
 
 
21
  public function __construct() {
22
- // Product page notice for logged in users
23
  add_action( 'woocommerce_after_add_to_cart_button', array( &$this, 'wcal_add_logged_msg' ), 10 );
24
  add_action( 'wp_ajax_wcal_gdpr_refused', array( 'wcal_common', 'wcal_gdpr_refused' ) );
25
  }
@@ -32,22 +36,22 @@ if ( ! class_exists( 'Wcal_Tracking_msg' ) ) {
32
  * woocommerce_before_shop_loop
33
  * @since 4.9
34
  */
35
- static function wcal_add_logged_msg() {
36
  if ( is_user_logged_in() ) {
37
 
38
- $registered_msg = get_option( 'wcal_logged_cart_capture_msg' );
39
  $gdpr_consent = get_user_meta( get_current_user_id(), 'wcal_gdpr_tracking_choice', true );
40
 
41
- if ( $gdpr_consent === '' ) {
42
  $gdpr_consent = true;
43
  }
44
 
45
- if ( isset( $registered_msg ) && '' != $registered_msg && $gdpr_consent ) {
46
  wp_enqueue_script(
47
  'wcal_registered_capture',
48
  plugins_url( '../assets/js/wcal_registered_user_capture.js', __FILE__ ),
49
  '',
50
- '',
51
  true
52
  );
53
 
@@ -63,11 +67,11 @@ if ( ! class_exists( 'Wcal_Tracking_msg' ) ) {
63
  );
64
 
65
  $registered_msg .= " <span id='wcal_gdpr_no_thanks'><a style='cursor: pointer' id='wcal_gdpr_no_thanks'>" . htmlspecialchars( get_option( 'wcal_gdpr_allow_opt_out' ), ENT_QUOTES ) . '</a></span>';
66
- echo "<span id='wcal_gdpr_message_block'><p><small>" . $registered_msg . '</small></p></span>';
67
  }
68
  }
69
  }
70
 
71
- } // end of class
72
- $Wcal_Tracking_msg = new Wcal_Tracking_msg();
73
- } // end IF
6
  * @package Abandoned-Cart-Lite-for-WooCommerce/Tracking
7
  * @since 4.9
8
  */
9
+
10
  if ( ! defined( 'ABSPATH' ) ) {
11
  exit; // Exit if accessed directly.
12
  }
13
+ if ( ! class_exists( 'Wcal_Tracking_Msg' ) ) {
14
 
15
  /**
16
  * It will add messages as needed informing users of data being tracked.
17
  *
18
  * @since 4.9
19
  */
20
+ class Wcal_Tracking_Msg {
21
 
22
+ /**
23
+ * Construct.
24
+ */
25
  public function __construct() {
26
+ // Product page notice for logged in users.
27
  add_action( 'woocommerce_after_add_to_cart_button', array( &$this, 'wcal_add_logged_msg' ), 10 );
28
  add_action( 'wp_ajax_wcal_gdpr_refused', array( 'wcal_common', 'wcal_gdpr_refused' ) );
29
  }
36
  * woocommerce_before_shop_loop
37
  * @since 4.9
38
  */
39
+ public static function wcal_add_logged_msg() {
40
  if ( is_user_logged_in() ) {
41
 
42
+ $registered_msg = get_option( 'wcal_logged_cart_capture_msg', '' );
43
  $gdpr_consent = get_user_meta( get_current_user_id(), 'wcal_gdpr_tracking_choice', true );
44
 
45
+ if ( '' === $gdpr_consent ) {
46
  $gdpr_consent = true;
47
  }
48
 
49
+ if ( isset( $registered_msg ) && '' !== $registered_msg && $gdpr_consent ) {
50
  wp_enqueue_script(
51
  'wcal_registered_capture',
52
  plugins_url( '../assets/js/wcal_registered_user_capture.js', __FILE__ ),
53
  '',
54
+ WCAL_PLUGIN_VERSION,
55
  true
56
  );
57
 
67
  );
68
 
69
  $registered_msg .= " <span id='wcal_gdpr_no_thanks'><a style='cursor: pointer' id='wcal_gdpr_no_thanks'>" . htmlspecialchars( get_option( 'wcal_gdpr_allow_opt_out' ), ENT_QUOTES ) . '</a></span>';
70
+ echo wp_kses_post( "<span id='wcal_gdpr_message_block'><p><small>" . $registered_msg . '</small></p></span>' );
71
  }
72
  }
73
  }
74
 
75
+ } // end of class.
76
+ $wcal_tracking_msg = new Wcal_Tracking_Msg();
77
+ } // end IF.
includes/classes/class-wcal-dashboard-report.php CHANGED
@@ -324,7 +324,7 @@ if ( ! class_exists( 'Wcal_Dashoard_Report' ) ) {
324
 
325
  $duration_select = isset( $_GET['duration_select'] ) ? sanitize_text_field( wp_unslash( $_GET['duration_select'] ) ) : 'this_month'; //phpcs:ignore
326
 
327
- $current_time = current_time( 'timestamp' );
328
  $current_month = date( 'n' ); //phpcs:ignore
329
  $current_year = date( 'Y' ); //phpcs:ignore
330
 
324
 
325
  $duration_select = isset( $_GET['duration_select'] ) ? sanitize_text_field( wp_unslash( $_GET['duration_select'] ) ) : 'this_month'; //phpcs:ignore
326
 
327
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
328
  $current_month = date( 'n' ); //phpcs:ignore
329
  $current_year = date( 'Y' ); //phpcs:ignore
330
 
includes/classes/class-wcal-product-report-table.php CHANGED
@@ -1,24 +1,26 @@
1
  <?php
 
 
 
 
 
 
 
 
 
2
 
3
  if ( session_id() === '' ) {
4
- // session has not started
5
  session_start();
6
  }
7
- // Load WP_List_Table if not loaded
8
  if ( ! class_exists( 'WP_List_Table' ) ) {
9
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10
  }
11
 
12
  /**
13
- * Abandoned Cart Lite for WooCommerce
14
- *
15
- * It will handle the common action for the plugin.
16
- *
17
- * @author Tyche Softwares
18
- * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/List-Class
19
- * @since 2.5.3
20
  */
21
-
22
  class WCAL_Product_Report_Table extends WP_List_Table {
23
 
24
  /**
@@ -53,11 +55,11 @@ class WCAL_Product_Report_Table extends WP_List_Table {
53
  */
54
  public function __construct() {
55
  global $status, $page;
56
- // Set parent defaults
57
  parent::__construct(
58
  array(
59
- 'singular' => __( 'product_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records
60
- 'plural' => __( 'product_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records
61
  'ajax' => false, // Does this table support ajax?
62
  )
63
  );
@@ -71,16 +73,16 @@ class WCAL_Product_Report_Table extends WP_List_Table {
71
  */
72
  public function wcal_product_report_prepare_items() {
73
  $columns = $this->get_columns();
74
- $hidden = array(); // No hidden columns
75
  $data = $this->wcal_product_report_data();
76
  $total_items = $this->total_count;
77
  $this->items = $data;
78
  $this->_column_headers = array( $columns, $hidden );
79
  $this->set_pagination_args(
80
  array(
81
- 'total_items' => $total_items, // WE have to calculate the total number of items
82
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
83
- 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages
84
  )
85
  );
86
  }
@@ -116,8 +118,15 @@ class WCAL_Product_Report_Table extends WP_List_Table {
116
  $blank_cart_info = '{"cart":[]}';
117
  $blank_cart_info_guest = '[]';
118
  $blank_cart = '""';
119
- $query = 'SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `' . $wpdb->prefix . "ac_abandoned_cart_history_lite` WHERE abandoned_cart_info NOT LIKE '%$blank_cart_info%' AND abandoned_cart_info NOT LIKE '$blank_cart_info_guest' AND abandoned_cart_info NOT LIKE '$blank_cart' ORDER BY recovered_cart DESC";
120
- $recover_query = $wpdb->get_results( $query );
 
 
 
 
 
 
 
121
  $rec_carts_array = array();
122
  $recover_product_array = array();
123
  $return_product_report = array();
@@ -139,7 +148,7 @@ class WCAL_Product_Report_Table extends WP_List_Table {
139
 
140
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
141
  $cut_off_time = $ac_cutoff_time * 60;
142
- $current_time = current_time( 'timestamp' );
143
  $compare_time = $current_time - $cart_update_time;
144
  if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
145
  foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
@@ -148,7 +157,7 @@ class WCAL_Product_Report_Table extends WP_List_Table {
148
  if ( $compare_time > $cut_off_time ) {
149
  $rec_carts_array [] = $product_id;
150
  }
151
- if ( $recovered_cart_dat != 0 ) {
152
  $recover_product_array[] = $product_id;
153
  }
154
  }
@@ -168,13 +177,13 @@ class WCAL_Product_Report_Table extends WP_List_Table {
168
  foreach ( $chunck_array_value as $k => $v ) {
169
  $return_product_report[ $i ] = new stdClass();
170
  $prod_name = get_post( $k );
171
- if ( null != $prod_name || '' != $prod_name ) {
172
  $product_name = $prod_name->post_title;
173
  $abandoned_count = $v;
174
  $recover = array_count_values( $recover_product_array );
175
  foreach ( $recover as $ke => $ve ) {
176
  if ( array_key_exists( $ke, $count ) ) {
177
- if ( $ke == $k ) {
178
  $recover_cart = $ve;
179
  }
180
  }
@@ -193,9 +202,9 @@ class WCAL_Product_Report_Table extends WP_List_Table {
193
  }
194
  $this->total_count = count( $return_product_report ) > 0 ? count( $return_product_report ) : 0;
195
 
196
- // Pagination per page
197
- if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
198
- $page_number = $_GET['paged'] - 1;
199
  $k = $per_page * $page_number;
200
  } else {
201
  $k = 0;
@@ -214,9 +223,9 @@ class WCAL_Product_Report_Table extends WP_List_Table {
214
  /**
215
  * It will display the data for product column
216
  *
217
- * @param array | object $wcal_sent_emails All data of the list
218
- * @param stirng $column_name Name of the column
219
- * @return string $value Data of the column
220
  * @since 2.5.3
221
  */
222
  public function column_default( $wcal_sent_emails, $column_name ) {
@@ -248,4 +257,3 @@ class WCAL_Product_Report_Table extends WP_List_Table {
248
  return apply_filters( 'wcal_product_report_column_default', $value, $wcal_sent_emails, $column_name );
249
  }
250
  }
251
-
1
  <?php
2
+ /**
3
+ * Abandoned Cart Lite for WooCommerce
4
+ *
5
+ * It will handle the Product Report Table.
6
+ *
7
+ * @author Tyche Softwares
8
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Admin/List-Class
9
+ * @since 2.5.3
10
+ */
11
 
12
  if ( session_id() === '' ) {
13
+ // session has not started.
14
  session_start();
15
  }
16
+ // Load WP_List_Table if not loaded.
17
  if ( ! class_exists( 'WP_List_Table' ) ) {
18
  require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
19
  }
20
 
21
  /**
22
+ * Product Report Table Class.
 
 
 
 
 
 
23
  */
 
24
  class WCAL_Product_Report_Table extends WP_List_Table {
25
 
26
  /**
55
  */
56
  public function __construct() {
57
  global $status, $page;
58
+ // Set parent defaults.
59
  parent::__construct(
60
  array(
61
+ 'singular' => __( 'product_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records.
62
+ 'plural' => __( 'product_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records.
63
  'ajax' => false, // Does this table support ajax?
64
  )
65
  );
73
  */
74
  public function wcal_product_report_prepare_items() {
75
  $columns = $this->get_columns();
76
+ $hidden = array(); // No hidden columns.
77
  $data = $this->wcal_product_report_data();
78
  $total_items = $this->total_count;
79
  $this->items = $data;
80
  $this->_column_headers = array( $columns, $hidden );
81
  $this->set_pagination_args(
82
  array(
83
+ 'total_items' => $total_items, // WE have to calculate the total number of items.
84
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page.
85
+ 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages.
86
  )
87
  );
88
  }
118
  $blank_cart_info = '{"cart":[]}';
119
  $blank_cart_info_guest = '[]';
120
  $blank_cart = '""';
121
+
122
+ $recover_query = $wpdb->get_results( // phpcs:ignore
123
+ $wpdb->prepare(
124
+ 'SELECT abandoned_cart_time, abandoned_cart_info, recovered_cart FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s ORDER BY recovered_cart DESC', // phpcs:ignore
125
+ "%$blank_cart_info%",
126
+ $blank_cart_info_guest,
127
+ $blank_cart
128
+ )
129
+ );
130
  $rec_carts_array = array();
131
  $recover_product_array = array();
132
  $return_product_report = array();
148
 
149
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
150
  $cut_off_time = $ac_cutoff_time * 60;
151
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
152
  $compare_time = $current_time - $cart_update_time;
153
  if ( is_array( $recovered_cart_info ) || is_object( $recovered_cart_info ) ) {
154
  foreach ( $recovered_cart_info as $rec_cart_key => $rec_cart_value ) {
157
  if ( $compare_time > $cut_off_time ) {
158
  $rec_carts_array [] = $product_id;
159
  }
160
+ if ( 0 != $recovered_cart_dat ) { // phpcs:ignore
161
  $recover_product_array[] = $product_id;
162
  }
163
  }
177
  foreach ( $chunck_array_value as $k => $v ) {
178
  $return_product_report[ $i ] = new stdClass();
179
  $prod_name = get_post( $k );
180
+ if ( null !== $prod_name || '' !== $prod_name ) {
181
  $product_name = $prod_name->post_title;
182
  $abandoned_count = $v;
183
  $recover = array_count_values( $recover_product_array );
184
  foreach ( $recover as $ke => $ve ) {
185
  if ( array_key_exists( $ke, $count ) ) {
186
+ if ( $ke == $k ) { // phpcs:ignore
187
  $recover_cart = $ve;
188
  }
189
  }
202
  }
203
  $this->total_count = count( $return_product_report ) > 0 ? count( $return_product_report ) : 0;
204
 
205
+ // Pagination per page.
206
+ if ( isset( $_GET['paged'] ) && sanitize_text_field( wp_unslash( $_GET['paged'] ) ) > 1 ) { // phpcs:ignore WordPress.Security.NonceVerification
207
+ $page_number = sanitize_text_field( wp_unslash( $_GET['paged'] ) ) - 1; // phpcs:ignore WordPress.Security.NonceVerification
208
  $k = $per_page * $page_number;
209
  } else {
210
  $k = 0;
223
  /**
224
  * It will display the data for product column
225
  *
226
+ * @param array | object $wcal_sent_emails All data of the list.
227
+ * @param stirng $column_name Name of the column.
228
+ * @return string $value Data of the column.
229
  * @since 2.5.3
230
  */
231
  public function column_default( $wcal_sent_emails, $column_name ) {
257
  return apply_filters( 'wcal_product_report_column_default', $value, $wcal_sent_emails, $column_name );
258
  }
259
  }
 
includes/classes/class-wcal-recover-orders-table.php CHANGED
@@ -1,9 +1,4 @@
1
  <?php
2
-
3
- // Load WP_List_Table if not loaded
4
- if ( ! class_exists( 'WP_List_Table' ) ) {
5
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
- }
7
  /**
8
  * Abandoned Cart Lite for WooCommerce
9
  *
@@ -14,7 +9,15 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
14
  * @since 2.5.2
15
  */
16
 
17
- class wcal_Recover_Orders_Table extends WP_List_Table {
 
 
 
 
 
 
 
 
18
 
19
  /**
20
  * Number of results to show per page
@@ -81,11 +84,11 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
81
  */
82
  public function __construct() {
83
  global $status, $page;
84
- // Set parent defaults
85
  parent::__construct(
86
  array(
87
- 'singular' => __( 'rec_abandoned_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records
88
- 'plural' => __( 'rec_abandoned_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records
89
  'ajax' => false, // Does this table support ajax?
90
  )
91
  );
@@ -99,7 +102,7 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
99
  */
100
  public function wcal_recovered_orders_prepare_items() {
101
  $columns = $this->get_columns();
102
- $hidden = array(); // No hidden columns
103
  $sortable = $this->recovered_orders_get_sortable_columns();
104
  $data = $this->wcal_recovered_orders_data();
105
  $total_items = $this->total_count;
@@ -111,9 +114,9 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
111
  $this->_column_headers = array( $columns, $hidden, $sortable );
112
  $this->set_pagination_args(
113
  array(
114
- 'total_items' => $total_items, // WE have to calculate the total number of items
115
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
116
- 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages
117
  )
118
  );
119
  }
@@ -154,8 +157,8 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
154
  * We will add the view detials hover link.
155
  *
156
  * @since 2.5.2
157
- * @param array $recovered_orders_row_info Contains all the data of the recovered order row
158
- * @return string $value shown in the User name
159
  */
160
  public function column_user_name( $recovered_orders_row_info ) {
161
  $row_actions = array();
@@ -184,41 +187,21 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
184
  $wcal_class = new woocommerce_abandon_cart_lite();
185
  $number_decimal = wc_get_price_decimals();
186
 
187
- if ( isset( $_POST['duration_select'] ) ) {
188
- $duration_range = $_POST['duration_select'];
189
- } else {
190
- $duration_range = '';
191
- }
192
-
193
- if ( $duration_range == '' ) {
194
- if ( isset( $_GET['duration_select'] ) ) {
195
- $duration_range = $_GET['duration_select'];
196
- }
197
- }
198
 
199
- if ( $duration_range == '' ) {
200
- $duration_range = 'last_seven';
201
- } else {
202
- $duration_range = '';
203
  }
204
 
205
- if ( isset( $_POST['start_date'] ) ) {
206
- $start_date_range = $_POST['start_date'];
207
- } else {
208
- $start_date_range = '';
209
- }
210
 
211
- if ( $start_date_range == '' ) {
212
  $start_date_range = $wcal_class->start_end_dates[ $duration_range ]['start_date'];
213
  }
214
 
215
- if ( isset( $_POST['end_date'] ) ) {
216
- $end_date_range = $_POST['end_date'];
217
- } else {
218
- $end_date_range = '';
219
- }
220
-
221
- if ( $end_date_range == '' ) {
222
  $end_date_range = $wcal_class->start_end_dates[ $duration_range ]['end_date'];
223
  }
224
 
@@ -226,26 +209,47 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
226
  $end_date = strtotime( $end_date_range . ' 23:59:59' );
227
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
228
  $cut_off_time = $ac_cutoff_time * 60;
229
- $current_time = current_time( 'timestamp' );
230
  $compare_time = $current_time - $cut_off_time;
231
  $blank_cart_info = '{"cart":[]}';
232
  $blank_cart_info_guest = '[]';
233
  $blank_cart = '""';
234
 
235
- $query_ac = 'SELECT * FROM ' . $wpdb->prefix . "ac_abandoned_cart_history_lite
236
- WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 AND 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 abandoned_cart_info NOT LIKE '$blank_cart' ORDER BY recovered_cart desc";
237
- $ac_results = $wpdb->get_results( $wpdb->prepare( $query_ac, $start_date, $end_date ) );
 
 
 
 
 
 
 
 
238
 
239
- $query_ac_carts = 'SELECT * FROM ' . $wpdb->prefix . "ac_abandoned_cart_history_lite
240
- WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND 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 abandoned_cart_info NOT LIKE '$blank_cart' AND cart_ignored <> '1'";
241
- $ac_carts_results = $wpdb->get_results( $wpdb->prepare( $query_ac_carts, $start_date, $end_date ) );
 
 
 
 
 
 
 
 
 
242
 
243
- $recovered_item = $recovered_total = $count_carts = $total_value = $order_total = 0;
 
 
 
 
244
  $return_recovered_orders = array();
245
  $per_page = $this->per_page;
246
  $i = 0;
247
  foreach ( $ac_carts_results as $key => $value ) {
248
- $count_carts += 1;
249
  $cart_detail = json_decode( $value->abandoned_cart_info );
250
  $product_details = new stdClass();
251
  if ( isset( $cart_detail->cart ) ) {
@@ -253,9 +257,9 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
253
  }
254
  $line_total = 0;
255
 
256
- if ( false != $product_details && is_object( $product_details ) && count( get_object_vars( $product_details ) ) > 0 ) {
257
  foreach ( $product_details as $k => $v ) {
258
- if ( $v->line_subtotal_tax != 0 && $v->line_subtotal_tax > 0 ) {
259
  $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
260
  } else {
261
  $line_total = $line_total + $v->line_total;
@@ -264,7 +268,7 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
264
  }
265
  $total_value += $line_total;
266
  }
267
- // $total_value = wc_price( $total_value );
268
  $this->total_order_amount = $total_value;
269
  $this->total_abandoned_cart_count = $count_carts;
270
  $recovered_order_total = 0;
@@ -273,7 +277,7 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
273
  $table_data = '';
274
 
275
  foreach ( $ac_results as $key => $value ) {
276
- if ( $value->recovered_cart != 0 ) {
277
  $return_recovered_orders[ $i ] = new stdClass();
278
  $recovered_id = $value->recovered_cart;
279
  $rec_order = get_post_meta( $recovered_id );
@@ -292,16 +296,18 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
292
  $recovered_time_format = date_i18n( get_option( 'time_format' ), $recovered_date );
293
  $recovered_date_new = $recovered_date_format . ' ' . $recovered_time_format;
294
  }
295
- $recovered_item += 1;
296
 
297
- if ( isset( $rec_order ) && $rec_order != false ) {
298
  $recovered_total += $rec_order['_order_total'][0];
299
  }
300
  $date_format = date_i18n( get_option( 'date_format' ), $value->abandoned_cart_time );
301
  $time_format = date_i18n( get_option( 'time_format' ), $value->abandoned_cart_time );
302
  $abandoned_date = $date_format . ' ' . $time_format;
303
  $abandoned_order_id = $value->id;
304
- $billing_first_name = $billing_last_name = $billing_email = '';
 
 
305
  $recovered_order_total = 0;
306
 
307
  if ( isset( $rec_order['_billing_first_name'][0] ) ) {
@@ -332,8 +338,8 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
332
  $this->recovered_item = $recovered_item;
333
  $this->total_recover_amount = round( ( $recovered_order_total + $this->total_recover_amount ), $number_decimal );
334
  $i++;
335
- } catch ( Exception $e ) {
336
-
337
  }
338
  }
339
  }
@@ -341,25 +347,23 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
341
  $this->total_abandoned_cart_count = $this->total_abandoned_cart_count + $this->recovered_item;
342
  $templates_count = count( $return_recovered_orders );
343
  $this->total_count = $templates_count;
344
- // sort for order date
345
- if ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'created_on' ) {
346
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
347
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_created_on_asc' ) );
348
  } else {
349
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_created_on_dsc' ) );
350
  }
351
- }
352
- // sort for customer name
353
- elseif ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'recovered_date' ) {
354
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
355
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_date_asc' ) );
356
  } else {
357
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_date_dsc' ) );
358
  }
359
  }
360
- // Pagination per page
361
- if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
362
- $page_number = $_GET['paged'] - 1;
363
  $k = $per_page * $page_number;
364
  } else {
365
  $k = 0;
@@ -378,37 +382,37 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
378
  /**
379
  * It will sort the ascending data based on the abandoned cart date.
380
  *
381
- * @param array | object $value1 All data of the list
382
- * @param array | object $value2 All data of the list
383
  * @return timestamp
384
  * @since 2.5.2
385
  */
386
- function wcal_class_recovered_created_on_asc( $value1, $value2 ) {
387
  return $value1->abandoned_date - $value2->abandoned_date;
388
  }
389
 
390
  /**
391
  * It will sort the descending data based on the abandoned cart date.
392
  *
393
- * @param array | object $value1 All data of the list
394
- * @param array | object $value2 All data of the list
395
  * @return timestamp
396
  * @since 2.5.2
397
  */
398
- function wcal_class_recovered_created_on_dsc( $value1, $value2 ) {
399
  return $value2->abandoned_date - $value1->abandoned_date;
400
  }
401
 
402
  /**
403
  * It will sort the ascending data based on the recovered cart date.
404
  *
405
- * @param array | object $value1 All data of the list
406
- * @param array | object $value2 All data of the list
407
  * @globals mixed $woocommerce
408
  * @return timestamp
409
  * @since 2.5.2
410
  */
411
- function wcal_class_recovered_date_asc( $value1, $value2 ) {
412
 
413
  global $woocommerce;
414
  if ( version_compare( $woocommerce->version, '3.0.0', '>=' ) ) {
@@ -424,14 +428,13 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
424
  /**
425
  * It will sort the descending data based on the recovered cart date.
426
  *
427
- * @param array | object $value1 All data of the list
428
- * @param array | object $value2 All data of the list
429
  * @globals mixed $woocommerce
430
  * @return timestamp
431
  * @since 2.5.2
432
  */
433
-
434
- function wcal_class_recovered_date_dsc( $value1, $value2 ) {
435
  global $woocommerce;
436
  if ( version_compare( $woocommerce->version, '3.0.0', '>=' ) ) {
437
  $value1 = $value1->recover_order_date;
@@ -446,8 +449,8 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
446
  /**
447
  * It will display the data for the recovered column.
448
  *
449
- * @param array | object $wcal_abandoned_orders All data of the list
450
- * @param stirng $column_name Name of the column
451
  * @return string $value Data of the column
452
  * @since 2.5.2
453
  */
@@ -483,4 +486,3 @@ class wcal_Recover_Orders_Table extends WP_List_Table {
483
  return apply_filters( 'wcal_recovered_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
484
  }
485
  }
486
-
1
  <?php
 
 
 
 
 
2
  /**
3
  * Abandoned Cart Lite for WooCommerce
4
  *
9
  * @since 2.5.2
10
  */
11
 
12
+ // Load WP_List_Table if not loaded.
13
+ if ( ! class_exists( 'WP_List_Table' ) ) {
14
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
15
+ }
16
+
17
+ /**
18
+ * Recovered Orders table list.
19
+ */
20
+ class Wcal_Recover_Orders_Table extends WP_List_Table {
21
 
22
  /**
23
  * Number of results to show per page
84
  */
85
  public function __construct() {
86
  global $status, $page;
87
+ // Set parent defaults.
88
  parent::__construct(
89
  array(
90
+ 'singular' => __( 'rec_abandoned_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records.
91
+ 'plural' => __( 'rec_abandoned_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records.
92
  'ajax' => false, // Does this table support ajax?
93
  )
94
  );
102
  */
103
  public function wcal_recovered_orders_prepare_items() {
104
  $columns = $this->get_columns();
105
+ $hidden = array(); // No hidden columns.
106
  $sortable = $this->recovered_orders_get_sortable_columns();
107
  $data = $this->wcal_recovered_orders_data();
108
  $total_items = $this->total_count;
114
  $this->_column_headers = array( $columns, $hidden, $sortable );
115
  $this->set_pagination_args(
116
  array(
117
+ 'total_items' => $total_items, // WE have to calculate the total number of items.
118
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page.
119
+ 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages.
120
  )
121
  );
122
  }
157
  * We will add the view detials hover link.
158
  *
159
  * @since 2.5.2
160
+ * @param array $recovered_orders_row_info Contains all the data of the recovered order row.
161
+ * @return string $value shown in the User name.
162
  */
163
  public function column_user_name( $recovered_orders_row_info ) {
164
  $row_actions = array();
187
  $wcal_class = new woocommerce_abandon_cart_lite();
188
  $number_decimal = wc_get_price_decimals();
189
 
190
+ $duration_range = isset( $_POST['duration_select'] ) ? sanitize_text_field( wp_unslash( $_POST['duration_select'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
 
 
 
 
 
 
 
 
 
 
191
 
192
+ if ( '' === $duration_range ) {
193
+ $duration_range = isset( $_GET['duration_select'] ) ? sanitize_text_field( wp_unslash( $_GET['duration_select'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
 
 
194
  }
195
 
196
+ $duration_range = '' === $duration_range ? 'last_seven' : '';
197
+ $start_date_range = isset( $_POST['start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
198
+ $end_date_range = isset( $_POST['end_date'] ) ? sanitize_text_field( wp_unslash( $_POST['end_date'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
 
 
199
 
200
+ if ( '' === $start_date_range ) {
201
  $start_date_range = $wcal_class->start_end_dates[ $duration_range ]['start_date'];
202
  }
203
 
204
+ if ( '' === $end_date_range ) {
 
 
 
 
 
 
205
  $end_date_range = $wcal_class->start_end_dates[ $duration_range ]['end_date'];
206
  }
207
 
209
  $end_date = strtotime( $end_date_range . ' 23:59:59' );
210
  $ac_cutoff_time = get_option( 'ac_lite_cart_abandoned_time' );
211
  $cut_off_time = $ac_cutoff_time * 60;
212
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
213
  $compare_time = $current_time - $cut_off_time;
214
  $blank_cart_info = '{"cart":[]}';
215
  $blank_cart_info_guest = '[]';
216
  $blank_cart = '""';
217
 
218
+ $ac_results = $wpdb->get_results( // phpcs:ignore
219
+ $wpdb->prepare(
220
+ 'SELECT * FROM ' . $wpdb->prefix . 'ac_abandoned_cart_history_lite WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND recovered_cart > 0 AND abandoned_cart_time <= %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s ORDER BY recovered_cart desc', // phpcS:ignore
221
+ $start_date,
222
+ $end_date,
223
+ $compare_time,
224
+ "%$blank_cart_info%",
225
+ $blank_cart_info_guest,
226
+ $blank_cart
227
+ )
228
+ );
229
 
230
+ $ac_carts_results = $wpdb->get_results( // phpcs:ignore
231
+ $wpdb->prepare(
232
+ 'SELECT * FROM ' . $wpdb->prefix . 'ac_abandoned_cart_history_lite WHERE abandoned_cart_time >= %d AND abandoned_cart_time <= %d AND abandoned_cart_time <= %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s AND abandoned_cart_info NOT LIKE %s AND cart_ignored <> %s', // phpcs:ignore
233
+ $start_date,
234
+ $end_date,
235
+ $compare_time,
236
+ "%$blank_cart_info%",
237
+ $blank_cart_info_guest,
238
+ $blank_cart,
239
+ '1'
240
+ )
241
+ );
242
 
243
+ $recovered_item = 0;
244
+ $recovered_total = 0;
245
+ $count_carts = 0;
246
+ $total_value = 0;
247
+ $order_total = 0;
248
  $return_recovered_orders = array();
249
  $per_page = $this->per_page;
250
  $i = 0;
251
  foreach ( $ac_carts_results as $key => $value ) {
252
+ $count_carts++;
253
  $cart_detail = json_decode( $value->abandoned_cart_info );
254
  $product_details = new stdClass();
255
  if ( isset( $cart_detail->cart ) ) {
257
  }
258
  $line_total = 0;
259
 
260
+ if ( false !== $product_details && is_object( $product_details ) && count( get_object_vars( $product_details ) ) > 0 ) {
261
  foreach ( $product_details as $k => $v ) {
262
+ if ( $v->line_subtotal_tax > 0 ) {
263
  $line_total = $line_total + $v->line_total + $v->line_subtotal_tax;
264
  } else {
265
  $line_total = $line_total + $v->line_total;
268
  }
269
  $total_value += $line_total;
270
  }
271
+
272
  $this->total_order_amount = $total_value;
273
  $this->total_abandoned_cart_count = $count_carts;
274
  $recovered_order_total = 0;
277
  $table_data = '';
278
 
279
  foreach ( $ac_results as $key => $value ) {
280
+ if ( 0 != $value->recovered_cart ) { // phpcs:ignore
281
  $return_recovered_orders[ $i ] = new stdClass();
282
  $recovered_id = $value->recovered_cart;
283
  $rec_order = get_post_meta( $recovered_id );
296
  $recovered_time_format = date_i18n( get_option( 'time_format' ), $recovered_date );
297
  $recovered_date_new = $recovered_date_format . ' ' . $recovered_time_format;
298
  }
299
+ $recovered_item++;
300
 
301
+ if ( isset( $rec_order ) && false !== $rec_order ) {
302
  $recovered_total += $rec_order['_order_total'][0];
303
  }
304
  $date_format = date_i18n( get_option( 'date_format' ), $value->abandoned_cart_time );
305
  $time_format = date_i18n( get_option( 'time_format' ), $value->abandoned_cart_time );
306
  $abandoned_date = $date_format . ' ' . $time_format;
307
  $abandoned_order_id = $value->id;
308
+ $billing_first_name = '';
309
+ $billing_last_name = '';
310
+ $billing_email = '';
311
  $recovered_order_total = 0;
312
 
313
  if ( isset( $rec_order['_billing_first_name'][0] ) ) {
338
  $this->recovered_item = $recovered_item;
339
  $this->total_recover_amount = round( ( $recovered_order_total + $this->total_recover_amount ), $number_decimal );
340
  $i++;
341
+ } catch ( Exception $e ) { // phpcs:ignore
342
+ // nothing needs to be done here, simply ignore the record.
343
  }
344
  }
345
  }
347
  $this->total_abandoned_cart_count = $this->total_abandoned_cart_count + $this->recovered_item;
348
  $templates_count = count( $return_recovered_orders );
349
  $this->total_count = $templates_count;
350
+ // sort for order date.
351
+ if ( isset( $_GET['orderby'] ) && 'created_on' === $_GET['orderby'] ) { // phpcs:ignore WordPress.Security.NonceVerification
352
+ if ( isset( $_GET['order'] ) && 'asc' === $_GET['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification
353
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_created_on_asc' ) );
354
  } else {
355
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_created_on_dsc' ) );
356
  }
357
+ } elseif ( isset( $_GET['orderby'] ) && 'recovered_date' === $_GET['orderby'] ) { // phpcs:ignore WordPress.Security.NonceVerification, sort for customer name.
358
+ if ( isset( $_GET['order'] ) && 'asc' === $_GET['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification
 
 
359
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_date_asc' ) );
360
  } else {
361
  usort( $return_recovered_orders, array( __CLASS__, 'wcal_class_recovered_date_dsc' ) );
362
  }
363
  }
364
+ // Pagination per page.
365
+ if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) { // phpcs:ignore WordPress.Security.NonceVerification
366
+ $page_number = (int) sanitize_text_field( wp_unslash( $_GET['paged'] ) ) - 1; // phpcs:ignore WordPress.Security.NonceVerification
367
  $k = $per_page * $page_number;
368
  } else {
369
  $k = 0;
382
  /**
383
  * It will sort the ascending data based on the abandoned cart date.
384
  *
385
+ * @param array | object $value1 All data of the list.
386
+ * @param array | object $value2 All data of the list.
387
  * @return timestamp
388
  * @since 2.5.2
389
  */
390
+ public function wcal_class_recovered_created_on_asc( $value1, $value2 ) {
391
  return $value1->abandoned_date - $value2->abandoned_date;
392
  }
393
 
394
  /**
395
  * It will sort the descending data based on the abandoned cart date.
396
  *
397
+ * @param array | object $value1 All data of the list.
398
+ * @param array | object $value2 All data of the list.
399
  * @return timestamp
400
  * @since 2.5.2
401
  */
402
+ public function wcal_class_recovered_created_on_dsc( $value1, $value2 ) {
403
  return $value2->abandoned_date - $value1->abandoned_date;
404
  }
405
 
406
  /**
407
  * It will sort the ascending data based on the recovered cart date.
408
  *
409
+ * @param array | object $value1 All data of the list.
410
+ * @param array | object $value2 All data of the list.
411
  * @globals mixed $woocommerce
412
  * @return timestamp
413
  * @since 2.5.2
414
  */
415
+ public function wcal_class_recovered_date_asc( $value1, $value2 ) {
416
 
417
  global $woocommerce;
418
  if ( version_compare( $woocommerce->version, '3.0.0', '>=' ) ) {
428
  /**
429
  * It will sort the descending data based on the recovered cart date.
430
  *
431
+ * @param array | object $value1 All data of the list.
432
+ * @param array | object $value2 All data of the list.
433
  * @globals mixed $woocommerce
434
  * @return timestamp
435
  * @since 2.5.2
436
  */
437
+ public function wcal_class_recovered_date_dsc( $value1, $value2 ) {
 
438
  global $woocommerce;
439
  if ( version_compare( $woocommerce->version, '3.0.0', '>=' ) ) {
440
  $value1 = $value1->recover_order_date;
449
  /**
450
  * It will display the data for the recovered column.
451
  *
452
+ * @param array | object $wcal_abandoned_orders All data of the list.
453
+ * @param stirng $column_name Name of the column.
454
  * @return string $value Data of the column
455
  * @since 2.5.2
456
  */
486
  return apply_filters( 'wcal_recovered_orders_column_default', $value, $wcal_abandoned_orders, $column_name );
487
  }
488
  }
 
includes/classes/class-wcal-templates-table.php CHANGED
@@ -1,9 +1,4 @@
1
  <?php
2
-
3
- // Load WP_List_Table if not loaded
4
- if ( ! class_exists( 'WP_List_Table' ) ) {
5
- require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
6
- }
7
  /**
8
  * Abandoned Cart Lite for WooCommerce
9
  *
@@ -14,6 +9,14 @@ if ( ! class_exists( 'WP_List_Table' ) ) {
14
  * @since 2.5.2
15
  */
16
 
 
 
 
 
 
 
 
 
17
  class WCAL_Templates_Table extends WP_List_Table {
18
 
19
  /**
@@ -48,11 +51,11 @@ class WCAL_Templates_Table extends WP_List_Table {
48
  */
49
  public function __construct() {
50
  global $status, $page;
51
- // Set parent defaults
52
  parent::__construct(
53
  array(
54
- 'singular' => __( 'template_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records
55
- 'plural' => __( 'template_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records
56
  'ajax' => false, // Does this table support ajax?
57
  )
58
  );
@@ -67,7 +70,7 @@ class WCAL_Templates_Table extends WP_List_Table {
67
  */
68
  public function wcal_templates_prepare_items() {
69
  $columns = $this->get_columns();
70
- $hidden = array(); // No hidden columns
71
  $sortable = $this->templates_get_sortable_columns();
72
  $data = $this->wcal_templates_data();
73
 
@@ -77,9 +80,9 @@ class WCAL_Templates_Table extends WP_List_Table {
77
 
78
  $this->set_pagination_args(
79
  array(
80
- 'total_items' => $total_items, // WE have to calculate the total number of items
81
- 'per_page' => $this->per_page, // WE have to determine how many items to show on a page
82
- 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages
83
  )
84
  );
85
  }
@@ -100,16 +103,17 @@ class WCAL_Templates_Table extends WP_List_Table {
100
  );
101
  return apply_filters( 'wcal_templates_columns', $columns );
102
  }
 
103
  /**
104
  * It is used to add the check box for the items.
105
  *
106
- * @param string $item
107
- * @return string
108
  * @since 2.5.2
109
  */
110
- function column_cb( $item ) {
111
  $template_id = '';
112
- if ( isset( $item->id ) && '' != $item->id ) {
113
  $template_id = $item->id;
114
  }
115
  return sprintf(
@@ -138,8 +142,8 @@ class WCAL_Templates_Table extends WP_List_Table {
138
  * This function used for individual delete, edit of row.
139
  *
140
  * @since 2.5.2
141
- * @param array $template_row_info Contains all the data of the template row
142
- * @return string $value All hover links, here we have edit and delete
143
  */
144
  public function column_template_name( $template_row_info ) {
145
  $row_actions = array();
@@ -188,8 +192,9 @@ class WCAL_Templates_Table extends WP_List_Table {
188
  $return_templates_data = array();
189
  $per_page = $this->per_page;
190
  $results = array();
191
- $query = 'SELECT wpet . * FROM `' . $wpdb->prefix . 'ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc';
192
- $results = $wpdb->get_results( $query );
 
193
  $i = 0;
194
 
195
  foreach ( $results as $key => $value ) {
@@ -200,42 +205,37 @@ class WCAL_Templates_Table extends WP_List_Table {
200
  $body = $value->body;
201
  $is_active = $value->is_active;
202
 
203
- if ( $is_active == '1' ) {
204
- $active = 'Deactivate';
205
- } else {
206
- $active = 'Activate';
207
- }
208
  $frequency = $value->frequency;
209
  $day_or_hour = $value->day_or_hour;
210
  $return_templates_data[ $i ]->sr = $i + 1;
211
  $return_templates_data[ $i ]->id = $id;
212
  $return_templates_data[ $i ]->template_name = $value->template_name;
213
- $return_templates_data[ $i ]->sent_time = __( $frequency . ' ' . $day_or_hour . 'After Abandonment', 'woocommerce-abandoned-cart' );
214
  $return_templates_data[ $i ]->activate = $active;
215
  $return_templates_data[ $i ]->is_active = $is_active;
216
  $i++;
217
  }
218
  $templates_count = count( $return_templates_data );
219
  $this->total_count = $templates_count;
220
- // sort for order date
221
- if ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'template_name' ) {
222
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
223
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_template_name_asc' ) );
224
  } else {
225
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_template_name_dsc' ) );
226
  }
227
- }
228
- // sort for customer name
229
- elseif ( isset( $_GET['orderby'] ) && $_GET['orderby'] == 'sent_time' ) {
230
- if ( isset( $_GET['order'] ) && $_GET['order'] == 'asc' ) {
231
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_sent_time_asc' ) );
232
  } else {
233
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_sent_time_dsc' ) );
234
  }
235
  }
236
- // Pagination per page
237
- if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) {
238
- $page_number = $_GET['paged'] - 1;
239
  $k = $per_page * $page_number;
240
  } else {
241
  $k = 0;
@@ -255,57 +255,57 @@ class WCAL_Templates_Table extends WP_List_Table {
255
  /**
256
  * It will sort the data alphabetally ascending on the template name.
257
  *
258
- * @param array | object $value1 All data of the list
259
- * @param array | object $value2 All data of the list
260
  * @return sorted array
261
  * @since 2.5.2
262
  */
263
- function wcal_class_template_name_asc( $value1, $value2 ) {
264
  return strcasecmp( $value1->template_name, $value2->template_name );
265
  }
266
 
267
  /**
268
  * It will sort the data alphabetally descending on the template name.
269
  *
270
- * @param array | object $value1 All data of the list
271
- * @param array | object $value2 All data of the list
272
  * @return sorted array
273
  * @since 2.5.2
274
  */
275
- function wcal_class_template_name_dsc( $value1, $value2 ) {
276
  return strcasecmp( $value2->template_name, $value1->template_name );
277
  }
278
 
279
  /**
280
  * It will sort the data alphanumeric ascending on the template time.
281
  *
282
- * @param array | object $value1 All data of the list
283
- * @param array | object $value2 All data of the list
284
  * @return sorted array
285
  * @since 2.5.2
286
  */
287
- function wcal_class_sent_time_asc( $value1, $value2 ) {
288
  return strnatcasecmp( $value1->sent_time, $value2->sent_time );
289
  }
290
 
291
  /**
292
  * It will sort the data alphanumeric descending on the template time.
293
  *
294
- * @param array | object $value1 All data of the list
295
- * @param array | object $value2 All data of the list
296
  * @return sorted array
297
  * @since 2.5.2
298
  */
299
- function wcal_class_sent_time_dsc( $value1, $value2 ) {
300
  return strnatcasecmp( $value2->sent_time, $value1->sent_time );
301
  }
302
 
303
  /**
304
  * It will display the data for the templates list
305
  *
306
- * @param array | object $wcal_abandoned_orders All data of the list
307
- * @param stirng $column_name Name of the column
308
- * @return string $value Data of the column
309
  * @since 2.5.2
310
  */
311
  public function column_default( $wcal_abandoned_orders, $column_name ) {
@@ -333,14 +333,14 @@ class WCAL_Templates_Table extends WP_List_Table {
333
  $is_active = $wcal_abandoned_orders->is_active;
334
  $active = '';
335
  $active_text = '';
336
- if ( $is_active == '1' ) {
337
  $active = 'on';
338
  $active_text = __( 'on', 'woocommerce-abandoned-cart' );
339
  } else {
340
  $active = 'off';
341
  $active_text = __( 'off', 'woocommerce-abandoned-cart' );
342
  }
343
- // $value = '<a href="#" onclick="wcal_activate_email_template('. $id.', '.$is_active.' )"> '.$active_text.'</a>';
344
  $value = '<button type="button" class="wcal-switch wcal-toggle-template-status" '
345
  . 'wcal-template-id="' . $id . '" '
346
  . 'wcal-template-switch="' . ( $active ) . '">'
@@ -366,4 +366,3 @@ class WCAL_Templates_Table extends WP_List_Table {
366
  );
367
  }
368
  }
369
-
1
  <?php
 
 
 
 
 
2
  /**
3
  * Abandoned Cart Lite for WooCommerce
4
  *
9
  * @since 2.5.2
10
  */
11
 
12
+ // Load WP_List_Table if not loaded.
13
+ if ( ! class_exists( 'WP_List_Table' ) ) {
14
+ require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
15
+ }
16
+
17
+ /**
18
+ * Email Templates List.
19
+ */
20
  class WCAL_Templates_Table extends WP_List_Table {
21
 
22
  /**
51
  */
52
  public function __construct() {
53
  global $status, $page;
54
+ // Set parent defaults.
55
  parent::__construct(
56
  array(
57
+ 'singular' => __( 'template_id', 'woocommerce-abandoned-cart' ), // singular name of the listed records.
58
+ 'plural' => __( 'template_ids', 'woocommerce-abandoned-cart' ), // plural name of the listed records.
59
  'ajax' => false, // Does this table support ajax?
60
  )
61
  );
70
  */
71
  public function wcal_templates_prepare_items() {
72
  $columns = $this->get_columns();
73
+ $hidden = array(); // No hidden columns.
74
  $sortable = $this->templates_get_sortable_columns();
75
  $data = $this->wcal_templates_data();
76
 
80
 
81
  $this->set_pagination_args(
82
  array(
83
+ 'total_items' => $total_items, // WE have to calculate the total number of items.
84
+ 'per_page' => $this->per_page, // WE have to determine how many items to show on a page.
85
+ 'total_pages' => ceil( $total_items / $this->per_page ), // WE have to calculate the total number of pages.
86
  )
87
  );
88
  }
103
  );
104
  return apply_filters( 'wcal_templates_columns', $columns );
105
  }
106
+
107
  /**
108
  * It is used to add the check box for the items.
109
  *
110
+ * @param string $item - Row data.
111
+ * @return string HTML for display.
112
  * @since 2.5.2
113
  */
114
+ public function column_cb( $item ) {
115
  $template_id = '';
116
+ if ( isset( $item->id ) && '' !== $item->id ) {
117
  $template_id = $item->id;
118
  }
119
  return sprintf(
142
  * This function used for individual delete, edit of row.
143
  *
144
  * @since 2.5.2
145
+ * @param array $template_row_info Contains all the data of the template row.
146
+ * @return string $value All hover links, here we have edit and delete.
147
  */
148
  public function column_template_name( $template_row_info ) {
149
  $row_actions = array();
192
  $return_templates_data = array();
193
  $per_page = $this->per_page;
194
  $results = array();
195
+ $results = $wpdb->get_results( // phpcs:ignore
196
+ 'SELECT wpet . * FROM `' . $wpdb->prefix . 'ac_email_templates_lite` AS wpet ORDER BY day_or_hour desc , frequency asc'
197
+ );
198
  $i = 0;
199
 
200
  foreach ( $results as $key => $value ) {
205
  $body = $value->body;
206
  $is_active = $value->is_active;
207
 
208
+ $active = '1' === $is_active ? 'Deactivate' : 'Activate';
209
+
 
 
 
210
  $frequency = $value->frequency;
211
  $day_or_hour = $value->day_or_hour;
212
  $return_templates_data[ $i ]->sr = $i + 1;
213
  $return_templates_data[ $i ]->id = $id;
214
  $return_templates_data[ $i ]->template_name = $value->template_name;
215
+ $return_templates_data[ $i ]->sent_time = "$frequency $day_or_hour" . __( 'After Abandonment', 'woocommerce-abandoned-cart' );
216
  $return_templates_data[ $i ]->activate = $active;
217
  $return_templates_data[ $i ]->is_active = $is_active;
218
  $i++;
219
  }
220
  $templates_count = count( $return_templates_data );
221
  $this->total_count = $templates_count;
222
+ // sort for order date.
223
+ if ( isset( $_GET['orderby'] ) && 'template_name' === $_GET['orderby'] ) { // phpcs:ignore WordPress.Security.NonceVerification
224
+ if ( isset( $_GET['order'] ) && 'asc' === $_GET['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification
225
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_template_name_asc' ) );
226
  } else {
227
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_template_name_dsc' ) );
228
  }
229
+ } elseif ( isset( $_GET['orderby'] ) && 'sent_time' === $_GET['orderby'] ) { // phpcs:ignore WordPress.Security.NonceVerification, sort for customer name.
230
+ if ( isset( $_GET['order'] ) && 'asc' === $_GET['order'] ) { // phpcs:ignore WordPress.Security.NonceVerification
 
 
231
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_sent_time_asc' ) );
232
  } else {
233
  usort( $return_templates_data, array( __CLASS__, 'wcal_class_sent_time_dsc' ) );
234
  }
235
  }
236
+ // Pagination per page.
237
+ if ( isset( $_GET['paged'] ) && $_GET['paged'] > 1 ) { // phpcs:ignore WordPress.Security.NonceVerification
238
+ $page_number = (int) sanitize_text_field( wp_unslash( $_GET['paged'] ) ) - 1; // phpcs:ignore WordPress.Security.NonceVerification
239
  $k = $per_page * $page_number;
240
  } else {
241
  $k = 0;
255
  /**
256
  * It will sort the data alphabetally ascending on the template name.
257
  *
258
+ * @param array | object $value1 All data of the list.
259
+ * @param array | object $value2 All data of the list.
260
  * @return sorted array
261
  * @since 2.5.2
262
  */
263
+ public function wcal_class_template_name_asc( $value1, $value2 ) {
264
  return strcasecmp( $value1->template_name, $value2->template_name );
265
  }
266
 
267
  /**
268
  * It will sort the data alphabetally descending on the template name.
269
  *
270
+ * @param array | object $value1 All data of the list.
271
+ * @param array | object $value2 All data of the list.
272
  * @return sorted array
273
  * @since 2.5.2
274
  */
275
+ public function wcal_class_template_name_dsc( $value1, $value2 ) {
276
  return strcasecmp( $value2->template_name, $value1->template_name );
277
  }
278
 
279
  /**
280
  * It will sort the data alphanumeric ascending on the template time.
281
  *
282
+ * @param array | object $value1 All data of the list.
283
+ * @param array | object $value2 All data of the list.
284
  * @return sorted array
285
  * @since 2.5.2
286
  */
287
+ public function wcal_class_sent_time_asc( $value1, $value2 ) {
288
  return strnatcasecmp( $value1->sent_time, $value2->sent_time );
289
  }
290
 
291
  /**
292
  * It will sort the data alphanumeric descending on the template time.
293
  *
294
+ * @param array | object $value1 All data of the list.
295
+ * @param array | object $value2 All data of the list.
296
  * @return sorted array
297
  * @since 2.5.2
298
  */
299
+ public function wcal_class_sent_time_dsc( $value1, $value2 ) {
300
  return strnatcasecmp( $value2->sent_time, $value1->sent_time );
301
  }
302
 
303
  /**
304
  * It will display the data for the templates list
305
  *
306
+ * @param array | object $wcal_abandoned_orders All data of the list.
307
+ * @param stirng $column_name Name of the column.
308
+ * @return string $value Data of the column.
309
  * @since 2.5.2
310
  */
311
  public function column_default( $wcal_abandoned_orders, $column_name ) {
333
  $is_active = $wcal_abandoned_orders->is_active;
334
  $active = '';
335
  $active_text = '';
336
+ if ( '1' === $is_active ) {
337
  $active = 'on';
338
  $active_text = __( 'on', 'woocommerce-abandoned-cart' );
339
  } else {
340
  $active = 'off';
341
  $active_text = __( 'off', 'woocommerce-abandoned-cart' );
342
  }
343
+
344
  $value = '<button type="button" class="wcal-switch wcal-toggle-template-status" '
345
  . 'wcal-template-id="' . $id . '" '
346
  . 'wcal-template-switch="' . ( $active ) . '">'
366
  );
367
  }
368
  }
 
includes/component/deactivate-survey-popup/class-ts-deactivation.php CHANGED
@@ -1,37 +1,63 @@
1
  <?php
2
-
3
  /**
 
4
  * Contains the logic for deactivation popups
 
5
  * @since 1.0.0
 
 
 
 
 
6
  */
7
  class Wcal_TS_deactivate {
 
 
 
 
 
8
  public static $ts_deactivation_str;
9
 
 
 
 
 
 
10
  public static $ts_generic_questions;
11
 
 
 
 
 
 
12
  public static $ts_plugin_specific_questions;
13
 
14
  /**
15
  * URL to the Tracker API endpoint.
 
16
  * @var string
17
  */
18
-
19
  private static $api_url = 'http://tracking.tychesoftwares.com/v1/';
20
 
21
  /**
22
- * @var string Plugin name
23
- * @access public
24
- */
25
-
 
26
  public static $plugin_name = '';
27
 
28
  /**
 
 
29
  * @var string Plugin file name
30
  * @access public
31
  */
32
  public static $ts_plugin_file_name = '';
33
 
34
  /**
 
 
35
  * @var string Plugin URL
36
  * @access public
37
  */
@@ -39,14 +65,17 @@ class Wcal_TS_deactivate {
39
 
40
  /**
41
  * Initialization of hooks where we prepare the functionality to ask use for survey
 
 
 
42
  */
43
  public static function init( $ts_plugin_file_name = '', $ts_plugin_name = '' ) {
44
  self::$ts_plugin_file_name = $ts_plugin_file_name;
45
  self::$plugin_name = $ts_plugin_name;
46
- self::$ts_plugin_url = untrailingslashit( plugin_dir_path ( __FILE__ ) );
47
-
48
  self::ts_load_all_str();
49
- add_action( 'admin_footer', array( __CLASS__, 'maybe_load_deactivate_options' ) );
50
  add_action( 'wp_ajax_ts_submit_uninstall_reason', array( __CLASS__, '_submit_uninstall_reason_action' ) );
51
 
52
  add_filter( 'plugin_action_links_' . self::$ts_plugin_file_name, array( __CLASS__, 'ts_plugin_settings_link' ) );
@@ -54,15 +83,15 @@ class Wcal_TS_deactivate {
54
 
55
  /**
56
  * Settings link on Plugins page
57
- *
58
  * @access public
59
- * @param array $links
60
  * @return array
61
  */
62
  public static function ts_plugin_settings_link( $links ) {
63
-
64
- if ( isset ( $links['deactivate'] ) ) {
65
- $links['deactivate'] .= '<i class="ts-slug" data-slug="' . self::$ts_plugin_file_name . '"></i>';
66
  }
67
  return $links;
68
  }
@@ -72,104 +101,107 @@ class Wcal_TS_deactivate {
72
  */
73
  public static function ts_load_all_str() {
74
  self::$ts_deactivation_str = array(
75
- "deactivation-share-reason" => __( "If you have a moment, please let us know why you are deactivating", "ts-deactivation-survey" ),
76
- "deactivation-modal-button-submit" => __( "Submit & Deactivate", "ts-deactivation-survey" ),
77
- "deactivation-modal-button-deactivate" => __( "Deactivate", "ts-deactivation-survey" ),
78
- "deactivation-modal-button-cancel" => __( "Cancel", "ts-deactivation-survey" ),
79
- "deactivation-modal-button-confirm" => __( 'Yes - Deactivate', 'ts-deactivation-survey' ),
80
  );
81
 
82
  self::$ts_generic_questions = array(
83
- "reason-found-a-better-plugin" => __( "I found a better plugin", "ts-deactivation-survey" ),
84
- "placeholder-plugin-name" => __( "What's the plugin's name?", "ts-deactivation-survey" ),
85
- "reason-needed-for-a-short-period" => __( "I only needed the plugin for a short period", "ts-deactivation-survey" ),
86
- "reason-not-working" => __( "The plugin is not working", "ts-deactivation-survey" ),
87
- "placeholder-share-what-didnt-work" => __( "Kindly share what didn't work so we can fix it for future users...", "ts-deactivation-survey" ),
88
- "reason-great-but-need-specific-feature" => __( "The plugin is great, but I need specific feature that you don't support", "ts-deactivation-survey" ),
89
- "placeholder-feature" => __( "What feature?", "ts-deactivation-survey" ),
90
- "reason-dont-like-to-share-my-information" => __( "I don't like to share my information with you", "ts-deactivation-survey" ),
91
- "reason-other" => _x( "Other", "the text of the 'other' reason for deactivating the plugin that is shown in the modal box.", "ts-deactivation-survey" ),
92
  );
93
  }
94
 
95
  /**
96
  * Checking current page and pushing html, js and css for this task
 
97
  * @global string $pagenow current admin page
98
  * @global array $VARS global vars to pass to view file
99
  */
100
  public static function maybe_load_deactivate_options() {
101
  global $pagenow;
102
- if ( $pagenow == "plugins.php" ) {
103
  global $VARS;
104
- $VARS = array( 'slug' => "asvbsd", 'reasons' => self::deactivate_options() );
105
- include_once self::$ts_plugin_url . "/template/ts-deactivate-modal.php";
 
 
 
106
  }
107
  }
108
 
109
  /**
110
- * deactivation reasons in array format
 
111
  * @return array reasons array
112
  * @since 1.0.0
113
  */
114
  public static function deactivate_options() {
115
 
116
- self::$ts_plugin_specific_questions = apply_filters( 'ts_deativate_plugin_questions', array () );
117
-
118
 
119
  $reason_found_better_plugin = array(
120
  'id' => 2,
121
- 'text' => self::$ts_generic_questions[ 'reason-found-a-better-plugin' ],
122
  'input_type' => 'textfield',
123
- 'input_placeholder' => self::$ts_generic_questions[ 'placeholder-plugin-name' ]
124
  );
125
 
126
  $reason_not_working = array(
127
  'id' => 3,
128
- 'text' => self::$ts_generic_questions[ 'reason-not-working' ],
129
  'input_type' => 'textfield',
130
- 'input_placeholder' => self::$ts_generic_questions[ 'placeholder-share-what-didnt-work' ]
131
  );
132
 
133
  $reason_great_but_need_specific_feature = array(
134
  'id' => 8,
135
- 'text' => self::$ts_generic_questions[ 'reason-great-but-need-specific-feature' ],
136
  'input_type' => 'textfield',
137
- 'input_placeholder' => self::$ts_generic_questions[ 'placeholder-feature' ]
138
- );
139
 
140
- $reason_plugin_not_compatible = isset ( self::$ts_plugin_specific_questions[ 3 ] ) ? self::$ts_plugin_specific_questions[ 3 ] : '' ;
141
 
142
  $reason_other = array(
143
  'id' => 10,
144
- 'text' => self::$ts_generic_questions[ 'reason-other' ],
145
  'input_type' => 'textfield',
146
- 'input_placeholder' => ''
147
  );
148
 
149
  $long_term_user_reasons = array(
150
  array(
151
  'id' => 1,
152
- 'text' => self::$ts_generic_questions[ 'reason-needed-for-a-short-period' ],
153
  'input_type' => '',
154
- 'input_placeholder' => ''
155
  ),
156
  $reason_found_better_plugin,
157
  $reason_not_working,
158
- isset ( self::$ts_plugin_specific_questions[ 0 ] ) ? self::$ts_plugin_specific_questions[ 0 ] : '',
159
- isset ( self::$ts_plugin_specific_questions[ 1 ] ) ? self::$ts_plugin_specific_questions[ 1 ] : '',
160
- isset ( self::$ts_plugin_specific_questions[ 2 ] ) ? self::$ts_plugin_specific_questions[ 2 ] : '',
161
  $reason_plugin_not_compatible,
162
  $reason_great_but_need_specific_feature,
163
  array(
164
  'id' => 9,
165
- 'text' => self::$ts_generic_questions[ 'reason-dont-like-to-share-my-information' ],
166
  'input_type' => '',
167
- 'input_placeholder' => ''
168
- )
169
  );
170
 
171
-
172
- $uninstall_reasons[ 'default' ] = $long_term_user_reasons;
173
 
174
  $uninstall_reasons = apply_filters( 'ts_uninstall_reasons', $uninstall_reasons );
175
  array_push( $uninstall_reasons['default'], $reason_other );
@@ -178,9 +210,9 @@ class Wcal_TS_deactivate {
178
  }
179
 
180
  /**
181
- * get exact str against the slug
182
  *
183
- * @param type $slug
184
  *
185
  * @return type
186
  */
@@ -193,33 +225,35 @@ class Wcal_TS_deactivate {
193
  *
194
  * @since 1.1.2
195
  */
196
- public static function _submit_uninstall_reason_action() {
197
- if ( ! isset( $_POST[ 'reason_id' ] ) ) {
198
  exit;
199
  }
200
 
201
  $plugin_data = array();
202
-
203
- $plugin_data[ 'url' ] = home_url();
204
- $plugin_data[ 'email' ] = apply_filters( 'ts_tracker_admin_email', get_option( 'admin_email' ) );
205
 
206
- $reason_info = isset( $_REQUEST[ 'reason_info' ] ) ? trim( stripslashes( $_REQUEST[ 'reason_info' ] ) ) : '';
 
207
 
208
- $plugin_data[ 'reason_id' ] = $_POST[ 'reason_id' ];
209
- $plugin_data[ 'reason_info' ] = substr( $reason_info, 0, 128 );
210
- $plugin_data[ 'reason_text' ] = $_POST[ 'reason_text' ];
211
 
212
- $plugin_data[ 'ts_meta_data_table_name' ] = 'ts_deactivation_survey';
213
- $plugin_data[ 'ts_plugin_name' ] = self::$plugin_name;
 
214
 
215
- wp_safe_remote_post( self::$api_url, array(
 
 
 
 
 
216
  'method' => 'POST',
217
  'timeout' => 45,
218
  'redirection' => 5,
219
  'httpversion' => '1.0',
220
  'blocking' => false,
221
  'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
222
- 'body' => json_encode( $plugin_data ),
223
  'cookies' => array(),
224
  )
225
  );
@@ -228,4 +262,4 @@ class Wcal_TS_deactivate {
228
  exit;
229
  }
230
 
231
- }
1
  <?php
 
2
  /**
3
+ * Deactivate Survey Popup.
4
  * Contains the logic for deactivation popups
5
+ *
6
  * @since 1.0.0
7
+ * @package BoilerPlate
8
+ */
9
+
10
+ /**
11
+ * Deactiavte Survey Class.
12
  */
13
  class Wcal_TS_deactivate {
14
+ /**
15
+ * Deactivate String.
16
+ *
17
+ * @var string
18
+ */
19
  public static $ts_deactivation_str;
20
 
21
+ /**
22
+ * Generic questions.
23
+ *
24
+ * @var string
25
+ */
26
  public static $ts_generic_questions;
27
 
28
+ /**
29
+ * Plugin specific questions.
30
+ *
31
+ * @var string
32
+ */
33
  public static $ts_plugin_specific_questions;
34
 
35
  /**
36
  * URL to the Tracker API endpoint.
37
+ *
38
  * @var string
39
  */
 
40
  private static $api_url = 'http://tracking.tychesoftwares.com/v1/';
41
 
42
  /**
43
+ * Plugin Name.
44
+ *
45
+ * @var string Plugin name
46
+ * @access public
47
+ */
48
  public static $plugin_name = '';
49
 
50
  /**
51
+ * Plugin file name.
52
+ *
53
  * @var string Plugin file name
54
  * @access public
55
  */
56
  public static $ts_plugin_file_name = '';
57
 
58
  /**
59
+ * Plugin URL.
60
+ *
61
  * @var string Plugin URL
62
  * @access public
63
  */
65
 
66
  /**
67
  * Initialization of hooks where we prepare the functionality to ask use for survey
68
+ *
69
+ * @param string $ts_plugin_file_name - Plugin File name.
70
+ * @param string $ts_plugin_name - Plugin name.
71
  */
72
  public static function init( $ts_plugin_file_name = '', $ts_plugin_name = '' ) {
73
  self::$ts_plugin_file_name = $ts_plugin_file_name;
74
  self::$plugin_name = $ts_plugin_name;
75
+ self::$ts_plugin_url = untrailingslashit( plugin_dir_path( __FILE__ ) );
76
+
77
  self::ts_load_all_str();
78
+ add_action( 'admin_footer', array( __CLASS__, 'maybe_load_deactivate_options' ) );
79
  add_action( 'wp_ajax_ts_submit_uninstall_reason', array( __CLASS__, '_submit_uninstall_reason_action' ) );
80
 
81
  add_filter( 'plugin_action_links_' . self::$ts_plugin_file_name, array( __CLASS__, 'ts_plugin_settings_link' ) );
83
 
84
  /**
85
  * Settings link on Plugins page
86
+ *
87
  * @access public
88
+ * @param array $links - Links.
89
  * @return array
90
  */
91
  public static function ts_plugin_settings_link( $links ) {
92
+
93
+ if ( isset( $links['deactivate'] ) ) {
94
+ $links['deactivate'] .= '<i class="ts-slug" data-slug="' . self::$ts_plugin_file_name . '"></i>';
95
  }
96
  return $links;
97
  }
101
  */
102
  public static function ts_load_all_str() {
103
  self::$ts_deactivation_str = array(
104
+ 'deactivation-share-reason' => __( 'If you have a moment, please let us know why you are deactivating', 'ts-deactivation-survey' ),
105
+ 'deactivation-modal-button-submit' => __( 'Submit & Deactivate', 'ts-deactivation-survey' ),
106
+ 'deactivation-modal-button-deactivate' => __( 'Deactivate', 'ts-deactivation-survey' ),
107
+ 'deactivation-modal-button-cancel' => __( 'Cancel', 'ts-deactivation-survey' ),
108
+ 'deactivation-modal-button-confirm' => __( 'Yes - Deactivate', 'ts-deactivation-survey' ),
109
  );
110
 
111
  self::$ts_generic_questions = array(
112
+ 'reason-found-a-better-plugin' => __( 'I found a better plugin', 'ts-deactivation-survey' ),
113
+ 'placeholder-plugin-name' => __( "What's the plugin's name?", 'ts-deactivation-survey' ),
114
+ 'reason-needed-for-a-short-period' => __( 'I only needed the plugin for a short period', 'ts-deactivation-survey' ),
115
+ 'reason-not-working' => __( 'The plugin is not working', 'ts-deactivation-survey' ),
116
+ 'placeholder-share-what-didnt-work' => __( "Kindly share what didn't work so we can fix it for future users...", 'ts-deactivation-survey' ),
117
+ 'reason-great-but-need-specific-feature' => __( "The plugin is great, but I need specific feature that you don't support", 'ts-deactivation-survey' ),
118
+ 'placeholder-feature' => __( 'What feature?', 'ts-deactivation-survey' ),
119
+ 'reason-dont-like-to-share-my-information' => __( "I don't like to share my information with you", 'ts-deactivation-survey' ),
120
+ 'reason-other' => _x( 'Other', "the text of the 'other' reason for deactivating the plugin that is shown in the modal box.", 'ts-deactivation-survey' ),
121
  );
122
  }
123
 
124
  /**
125
  * Checking current page and pushing html, js and css for this task
126
+ *
127
  * @global string $pagenow current admin page
128
  * @global array $VARS global vars to pass to view file
129
  */
130
  public static function maybe_load_deactivate_options() {
131
  global $pagenow;
132
+ if ( 'plugins.php' === $pagenow ) {
133
  global $VARS;
134
+ $VARS = array(
135
+ 'slug' => 'asvbsd',
136
+ 'reasons' => self::deactivate_options(),
137
+ );
138
+ include_once self::$ts_plugin_url . '/template/ts-deactivate-modal.php';
139
  }
140
  }
141
 
142
  /**
143
+ * Deactivation reasons in array format.
144
+ *
145
  * @return array reasons array
146
  * @since 1.0.0
147
  */
148
  public static function deactivate_options() {
149
 
150
+ self::$ts_plugin_specific_questions = apply_filters( 'ts_deativate_plugin_questions', array() );
 
151
 
152
  $reason_found_better_plugin = array(
153
  'id' => 2,
154
+ 'text' => self::$ts_generic_questions['reason-found-a-better-plugin'],
155
  'input_type' => 'textfield',
156
+ 'input_placeholder' => self::$ts_generic_questions['placeholder-plugin-name'],
157
  );
158
 
159
  $reason_not_working = array(
160
  'id' => 3,
161
+ 'text' => self::$ts_generic_questions['reason-not-working'],
162
  'input_type' => 'textfield',
163
+ 'input_placeholder' => self::$ts_generic_questions['placeholder-share-what-didnt-work'],
164
  );
165
 
166
  $reason_great_but_need_specific_feature = array(
167
  'id' => 8,
168
+ 'text' => self::$ts_generic_questions['reason-great-but-need-specific-feature'],
169
  'input_type' => 'textfield',
170
+ 'input_placeholder' => self::$ts_generic_questions['placeholder-feature'],
171
+ );
172
 
173
+ $reason_plugin_not_compatible = isset( self::$ts_plugin_specific_questions[3] ) ? self::$ts_plugin_specific_questions[3] : '';
174
 
175
  $reason_other = array(
176
  'id' => 10,
177
+ 'text' => self::$ts_generic_questions['reason-other'],
178
  'input_type' => 'textfield',
179
+ 'input_placeholder' => '',
180
  );
181
 
182
  $long_term_user_reasons = array(
183
  array(
184
  'id' => 1,
185
+ 'text' => self::$ts_generic_questions['reason-needed-for-a-short-period'],
186
  'input_type' => '',
187
+ 'input_placeholder' => '',
188
  ),
189
  $reason_found_better_plugin,
190
  $reason_not_working,
191
+ isset( self::$ts_plugin_specific_questions[0] ) ? self::$ts_plugin_specific_questions[0] : '',
192
+ isset( self::$ts_plugin_specific_questions[1] ) ? self::$ts_plugin_specific_questions[1] : '',
193
+ isset( self::$ts_plugin_specific_questions[2] ) ? self::$ts_plugin_specific_questions[2] : '',
194
  $reason_plugin_not_compatible,
195
  $reason_great_but_need_specific_feature,
196
  array(
197
  'id' => 9,
198
+ 'text' => self::$ts_generic_questions['reason-dont-like-to-share-my-information'],
199
  'input_type' => '',
200
+ 'input_placeholder' => '',
201
+ ),
202
  );
203
 
204
+ $uninstall_reasons['default'] = $long_term_user_reasons;
 
205
 
206
  $uninstall_reasons = apply_filters( 'ts_uninstall_reasons', $uninstall_reasons );
207
  array_push( $uninstall_reasons['default'], $reason_other );
210
  }
211
 
212
  /**
213
+ * Get exact str against the slug.
214
  *
215
+ * @param type $slug - Slug.
216
  *
217
  * @return type
218
  */
225
  *
226
  * @since 1.1.2
227
  */
228
+ public static function _submit_uninstall_reason_action() { // phpcs:ignore
229
+ if ( ! isset( $_POST['reason_id'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
230
  exit;
231
  }
232
 
233
  $plugin_data = array();
 
 
 
234
 
235
+ $plugin_data['url'] = home_url();
236
+ $plugin_data['email'] = apply_filters( 'ts_tracker_admin_email', get_option( 'admin_email' ) );
237
 
238
+ $reason_info = isset( $_REQUEST['reason_info'] ) ? trim( stripslashes( sanitize_text_field( wp_unslash( $_REQUEST['reason_info'] ) ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
 
 
239
 
240
+ $plugin_data['reason_id'] = sanitize_text_field( wp_unslash( $_POST['reason_id'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
241
+ $plugin_data['reason_info'] = substr( $reason_info, 0, 128 );
242
+ $plugin_data['reason_text'] = isset( $_POST['reason_text'] ) ? sanitize_text_field( wp_unslash( $_POST['reason_text'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
243
 
244
+ $plugin_data['ts_meta_data_table_name'] = 'ts_deactivation_survey';
245
+ $plugin_data['ts_plugin_name'] = self::$plugin_name;
246
+
247
+ wp_safe_remote_post(
248
+ self::$api_url,
249
+ array(
250
  'method' => 'POST',
251
  'timeout' => 45,
252
  'redirection' => 5,
253
  'httpversion' => '1.0',
254
  'blocking' => false,
255
  'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
256
+ 'body' => wp_json_encode( $plugin_data ),
257
  'cookies' => array(),
258
  )
259
  );
262
  exit;
263
  }
264
 
265
+ }
includes/component/deactivate-survey-popup/template/ts-deactivate-modal.php CHANGED
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
5
 
6
- $slug = $VARS[ 'slug' ];
7
  $confirmation_message = '';
8
  $reasons = $VARS['reasons']['default'];
9
  $reasons_list_items_html = '';
@@ -11,377 +11,377 @@ $plugin_customized_reasons = array();
11
  $incr = 0;
12
 
13
  foreach ( $reasons as $reason ) {
14
- $list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' ) . ( ( isset( $reason[ 'html' ] ) && ( ! empty( $reason[ 'html' ] ) ) ) ? ' has_html' : '' );
15
-
16
- $reason_html = ( isset( $reason['html'] ) && ( ! empty( $reason['html'] ) ) ) ? '<div class="reason_html">' . $reason['html'] . '</div>' : '';
17
 
18
- $ts_reason_input_type = ( isset( $reason['input_type'] ) && ( ! empty( $reason['input_type'] ) ) ) ? $reason['input_type'] : '';
19
 
20
- $ts_reason_input_placeholder = ( isset( $reason['input_placeholder'] ) && ( ! empty( $reason['input_placeholder'] ) ) ) ? $reason['input_placeholder'] : '';
21
 
22
- $ts_reason_id = ( isset( $reason['id'] ) && ( ! empty( $reason['id'] ) ) ) ? $reason['id'] : '';
23
 
24
- $ts_reason_text = ( isset( $reason['text'] ) && ( ! empty( $reason['text'] ) ) ) ? $reason['text'] : '';
25
-
26
- $selected = "";
27
- if ( $incr == 0 ) {
28
- $selected = "checked";
29
- }
 
 
30
 
31
  $reasons_list_items_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $ts_reason_input_type . '" data-input-placeholder="' . $ts_reason_input_placeholder . '"><label><span><input type="radio" name="selected-reason" value="' . $ts_reason_id . '" ' . $selected . '/></span><span>' . $ts_reason_text . '</span></label>' . $reason_html . '</li>';
32
  $incr ++;
33
  }
34
-
35
  ?>
36
  <style>
37
- .ts-modal {
38
- position: fixed;
39
- overflow: auto;
40
- height: 100%;
41
- width: 100%;
42
- top: 0;
43
- z-index: 100000;
44
- display: none;
45
- background: rgba(0, 0, 0, 0.6)
46
- }
47
-
48
- .ts-modal .ts-modal-dialog {
49
- background: transparent;
50
- position: absolute;
51
- left: 50%;
52
- margin-left: -298px;
53
- padding-bottom: 30px;
54
- top: -100%;
55
- z-index: 100001;
56
- width: 596px
57
- }
58
-
59
- .ts-modal li.reason.has_html .reason_html {
60
- display: none;
61
- border: 1px solid #ddd;
62
- padding: 4px 6px;
63
- margin: 6px 0 0 20px;
64
- }
65
-
66
- .ts-modal li.reason.has_html.li-active .reason_html {
67
- display: block;
68
- }
69
-
70
- @media (max-width: 650px) {
71
- .ts-modal .ts-modal-dialog {
72
- margin-left: -50%;
73
- box-sizing: border-box;
74
- padding-left: 10px;
75
- padding-right: 10px;
76
- width: 100%
77
- }
78
-
79
- .ts-modal .ts-modal-dialog .ts-modal-panel > h3 > strong {
80
- font-size: 1.3em
81
- }
82
-
83
- .ts-modal .ts-modal-dialog li.reason {
84
- margin-bottom: 10px
85
- }
86
-
87
- .ts-modal .ts-modal-dialog li.reason .reason-input {
88
- margin-left: 29px
89
- }
90
-
91
- .ts-modal .ts-modal-dialog li.reason label {
92
- display: table
93
- }
94
-
95
- .ts-modal .ts-modal-dialog li.reason label > span {
96
- display: table-cell;
97
- font-size: 1.3em
98
- }
99
- }
100
-
101
- .ts-modal.active {
102
- display: block
103
- }
104
-
105
- .ts-modal.active:before {
106
- display: block
107
- }
108
-
109
- .ts-modal.active .ts-modal-dialog {
110
- top: 10%
111
- }
112
-
113
- .ts-modal .ts-modal-body, .ts-modal .ts-modal-footer {
114
- border: 0;
115
- background: #fefefe;
116
- padding: 20px
117
- }
118
-
119
- .ts-modal .ts-modal-body {
120
- border-bottom: 0
121
- }
122
-
123
- .ts-modal .ts-modal-body h2 {
124
- font-size: 20px
125
- }
126
-
127
- .ts-modal .ts-modal-body > div {
128
- margin-top: 10px
129
- }
130
-
131
- .ts-modal .ts-modal-body > div h2 {
132
- font-weight: bold;
133
- font-size: 20px;
134
- margin-top: 0
135
- }
136
-
137
- .ts-modal .ts-modal-footer {
138
- border-top: #eeeeee solid 1px;
139
- text-align: right
140
- }
141
-
142
- .ts-modal .ts-modal-footer > .button {
143
- margin: 0 7px
144
- }
145
-
146
- .ts-modal .ts-modal-footer > .button:first-child {
147
- margin: 0
148
- }
149
-
150
- .ts-modal .ts-modal-panel:not(.active) {
151
- display: none
152
- }
153
-
154
- .ts-modal .reason-input {
155
- margin: 3px 0 3px 22px
156
- }
157
-
158
- .ts-modal .reason-input input, .ts-modal .reason-input textarea {
159
- width: 100%
160
- }
161
-
162
- body.has-ts-modal {
163
- overflow: hidden
164
- }
165
-
166
- #the-list .deactivate > .ts-slug {
167
- display: none
168
- }
169
-
170
- .ts-modal li.reason-hide {
171
- display: none;
172
- }
173
 
174
  </style>
175
  <script type="text/javascript">
176
- var currentPluginName = "";
177
- var TSCustomReasons = {};
178
- var TSDefaultReason = {};
179
- ( function ($) {
180
- var $deactivateLinks = {};
181
- var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
182
- modalHtml =
183
- '<div class="ts-modal<?php echo ( $confirmation_message == "" ) ? ' no-confirmation-message' : ''; ?>">'
184
- + ' <div class="ts-modal-dialog">'
185
- + ' <div class="ts-modal-body">'
186
- + ' <div class="ts-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
187
- + ' <div class="ts-modal-panel active" data-panel-id="reasons"><h3><strong><?php printf( Wcal_TS_deactivate::load_str( 'deactivation-share-reason' ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
188
- + ' </div>'
189
- + ' <div class="ts-modal-footer">'
190
- + ' <a href="#" class="button button-secondary button-deactivate"></a>'
191
- + ' <a href="#" class="button button-primary button-close"><?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-cancel' ) ); ?></a>'
192
- + ' </div>'
193
- + ' </div>'
194
- + '</div>',
195
- $modal = $(modalHtml),
196
-
197
- $deactivateLink = $('#the-list .deactivate > .ts-slug').prev();
198
-
199
- for( var i = 0; i < $deactivateLink.length; i++ ) {
200
- $deactivateLinks[ $( $deactivateLink[i] ).siblings( ".ts-slug" ).attr( 'data-slug' ) ] = $deactivateLink[i].href;
201
- }
202
 
203
- $modal.appendTo( $( 'body' ) );
204
-
205
- registerEventHandlers();
206
-
207
- function registerEventHandlers() {
208
- $deactivateLink.on( "click", function (evt) {
209
- evt.preventDefault();
210
- currentPluginName = $(this).siblings( ".ts-slug" ).attr( 'data-slug' );
211
- showModal();
212
- });
213
-
214
- $modal.on( 'click', '.button', function (evt) {
215
- evt.preventDefault();
216
- if ($(this).hasClass( 'disabled' ) ) {
217
- return;
218
- }
219
-
220
- var _parent = $(this).parents( '.ts-modal:first' );
221
- var _this = $(this);
222
-
223
- if( _this.hasClass( 'allow-deactivate' ) ) {
224
- var $radio = $('input[type="radio"]:checked');
225
- var $selected_reason = $radio.parents('li:first'),
226
- $input = $selected_reason.find('textarea, input[type="text"]');
227
- if( $radio.length == 0 ) {
228
- var data = {
229
- 'action': 'ts_submit_uninstall_reason',
230
- 'reason_id': 0,
231
- 'reason_text': "Deactivated without any option",
232
- 'plugin_basename': currentPluginName,
233
- };
234
- } else {
235
- var data = {
236
- 'action': 'ts_submit_uninstall_reason',
237
- 'reason_id': (0 !== $radio.length) ? $radio.val() : '',
238
- 'reason_text': $selected_reason.text(),
239
- 'reason_info': (0 !== $input.length) ? $input.val().trim() : '',
240
- 'plugin_basename': currentPluginName,
241
- };
242
- }
243
-
244
- $.ajax({
245
- url: ajaxurl,
246
- method: 'POST',
247
- data: data,
248
- beforeSend: function () {
249
- _parent.find('.button').addClass('disabled');
250
- _parent.find('.button-secondary').text('Processing...');
251
- },
252
- complete: function () {
253
- // Do not show the dialog box, deactivate the plugin.
254
- window.location.href = $deactivateLinks[currentPluginName];
255
- }
256
- });
257
- }
258
- });
259
-
260
- $modal.on('click', 'input[type="radio"]', function () {
261
- console.log( this );
262
- var _parent = $(this).parents('li:first');
263
- var _parent_ul = $(this).parents('ul#reasons-list');
264
-
265
- _parent_ul.children("li.li-active").removeClass("li-active");
266
-
267
- $modal.find('.reason-input').remove();
268
- $modal.find('.button-deactivate').text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-submit' ) ); ?>');
269
-
270
- if (_parent.hasClass('has_html')) {
271
- _parent.addClass('li-active');
272
- }
273
- if (_parent.hasClass('has-input')) {
274
- var inputType = _parent.data('input-type'),
275
- inputPlaceholder = _parent.data('input-placeholder'),
276
- reasonInputHtml = '<div class="reason-input">' + (('textfield' === inputType) ? '<input type="text" />' : '<textarea rows="5"></textarea>') + '</div>';
277
-
278
- _parent.append($(reasonInputHtml));
279
- _parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
280
- }
281
- });
282
-
283
- // If the user has clicked outside the window, cancel it.
284
- $modal.on('click', function (evt) {
285
- var $target = $(evt.target);
286
-
287
- // If the user has clicked anywhere in the modal dialog, just return.
288
- if ($target.hasClass('ts-modal-body') || $target.hasClass('ts-modal-footer')) {
289
- return;
290
- }
291
-
292
- // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
293
- if (!$target.hasClass('button-close') && ($target.parents('.ts-modal-body').length > 0 || $target.parents('.ts-modal-footer').length > 0)) {
294
- return;
295
- }
296
-
297
- closeModal();
298
- });
299
- }
300
-
301
- function showModal() {
302
- resetModal();
303
-
304
- // Display the dialog box.
305
- $modal.addClass('active');
306
-
307
- $('body').addClass('has-ts-modal');
308
- }
309
-
310
- function closeModal() {
311
- $modal.removeClass('active');
312
-
313
- $('body').removeClass('has-ts-modal');
314
- }
315
-
316
- function resetModal() {
317
- if (TSCustomReasons.hasOwnProperty(currentPluginName) === true) {
318
- $modal.find("ul#reasons-list").html(TSCustomReasons[currentPluginName]);
319
- } else {
320
- $modal.find("ul#reasons-list").html(reasonsHtml);
321
-
322
- }
323
- var defaultSelect = TSDefaultReason[currentPluginName];
324
- $modal.find('.button').removeClass('disabled');
325
-
326
- // Remove all input fields ( textfield, textarea ).
327
- $modal.find('.reason-input').remove();
328
-
329
- var $deactivateButton = $modal.find('.button-deactivate');
330
- $modal.find(".reason-hide").hide();
331
- /*
332
- * If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
333
- * that clicking the deactivate button will actually deactivate the plugin.
334
- */
335
- if ($modal.hasClass('no-confirmation-message')) {
336
- $deactivateButton.addClass('allow-deactivate');
337
- showPanel('reasons');
338
- }
339
- }
340
-
341
- function showPanel(panelType) {
342
- $modal.find('.ts-modal-panel').removeClass('active ');
343
- $modal.find('[data-panel-id="' + panelType + '"]').addClass('active');
344
-
345
- updateButtonLabels();
346
- }
347
-
348
- function updateButtonLabels() {
349
- var $deactivateButton = $modal.find('.button-deactivate');
350
-
351
- // Reset the deactivate button's text.
352
- if ('confirm' === getCurrentPanel()) {
353
- $deactivateButton.text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-confirm' ) ); ?>');
354
- } else {
355
- var $radio = $('input[type="radio"]:checked');
356
- if( $radio.length == 0 ) {
357
- $deactivateButton.text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-deactivate' ) ); ?>');
358
- } else {
359
- var _parent = $( $radio ).parents('li:first');
360
- var _parent_ul = $( $radio ).parents('ul#reasons-list');
361
-
362
- _parent_ul.children("li.li-active").removeClass("li-active");
363
-
364
- $modal.find('.reason-input').remove();
365
- $modal.find('.button-deactivate').text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-submit' ) ); ?>');
366
-
367
- if (_parent.hasClass('has_html')) {
368
- _parent.addClass('li-active');
369
- }
370
-
371
- if (_parent.hasClass('has-input')) {
372
- var inputType = _parent.data('input-type'),
373
- inputPlaceholder = _parent.data('input-placeholder'),
374
- reasonInputHtml = '<div class="reason-input">' + (('textfield' === inputType) ? '<input type="text" />' : '<textarea rows="5"></textarea>') + '</div>';
375
-
376
- _parent.append($(reasonInputHtml));
377
- _parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
378
- }
379
- }
380
- }
381
- }
382
-
383
- function getCurrentPanel() {
384
- return $modal.find('.ts-modal-panel.active').attr('data-panel-id');
385
- }
386
- })(jQuery);
387
  </script>
3
  exit;
4
  }
5
 
6
+ $slug = $VARS['slug'];
7
  $confirmation_message = '';
8
  $reasons = $VARS['reasons']['default'];
9
  $reasons_list_items_html = '';
11
  $incr = 0;
12
 
13
  foreach ( $reasons as $reason ) {
14
+ $list_item_classes = 'reason' . ( ! empty( $reason['input_type'] ) ? ' has-input' : '' ) . ( ( isset( $reason['html'] ) && ( ! empty( $reason['html'] ) ) ) ? ' has_html' : '' );
 
 
15
 
16
+ $reason_html = ( isset( $reason['html'] ) && ( ! empty( $reason['html'] ) ) ) ? '<div class="reason_html">' . $reason['html'] . '</div>' : '';
17
 
18
+ $ts_reason_input_type = ( isset( $reason['input_type'] ) && ( ! empty( $reason['input_type'] ) ) ) ? $reason['input_type'] : '';
19
 
20
+ $ts_reason_input_placeholder = ( isset( $reason['input_placeholder'] ) && ( ! empty( $reason['input_placeholder'] ) ) ) ? $reason['input_placeholder'] : '';
21
 
22
+ $ts_reason_id = ( isset( $reason['id'] ) && ( ! empty( $reason['id'] ) ) ) ? $reason['id'] : '';
23
+
24
+ $ts_reason_text = ( isset( $reason['text'] ) && ( ! empty( $reason['text'] ) ) ) ? $reason['text'] : '';
25
+
26
+ $selected = '';
27
+ if ( 0 === $incr ) {
28
+ $selected = 'checked';
29
+ }
30
 
31
  $reasons_list_items_html .= '<li class="' . $list_item_classes . '" data-input-type="' . $ts_reason_input_type . '" data-input-placeholder="' . $ts_reason_input_placeholder . '"><label><span><input type="radio" name="selected-reason" value="' . $ts_reason_id . '" ' . $selected . '/></span><span>' . $ts_reason_text . '</span></label>' . $reason_html . '</li>';
32
  $incr ++;
33
  }
34
+
35
  ?>
36
  <style>
37
+ .ts-modal {
38
+ position: fixed;
39
+ overflow: auto;
40
+ height: 100%;
41
+ width: 100%;
42
+ top: 0;
43
+ z-index: 100000;
44
+ display: none;
45
+ background: rgba(0, 0, 0, 0.6)
46
+ }
47
+
48
+ .ts-modal .ts-modal-dialog {
49
+ background: transparent;
50
+ position: absolute;
51
+ left: 50%;
52
+ margin-left: -298px;
53
+ padding-bottom: 30px;
54
+ top: -100%;
55
+ z-index: 100001;
56
+ width: 596px
57
+ }
58
+
59
+ .ts-modal li.reason.has_html .reason_html {
60
+ display: none;
61
+ border: 1px solid #ddd;
62
+ padding: 4px 6px;
63
+ margin: 6px 0 0 20px;
64
+ }
65
+
66
+ .ts-modal li.reason.has_html.li-active .reason_html {
67
+ display: block;
68
+ }
69
+
70
+ @media (max-width: 650px) {
71
+ .ts-modal .ts-modal-dialog {
72
+ margin-left: -50%;
73
+ box-sizing: border-box;
74
+ padding-left: 10px;
75
+ padding-right: 10px;
76
+ width: 100%
77
+ }
78
+
79
+ .ts-modal .ts-modal-dialog .ts-modal-panel > h3 > strong {
80
+ font-size: 1.3em
81
+ }
82
+
83
+ .ts-modal .ts-modal-dialog li.reason {
84
+ margin-bottom: 10px
85
+ }
86
+
87
+ .ts-modal .ts-modal-dialog li.reason .reason-input {
88
+ margin-left: 29px
89
+ }
90
+
91
+ .ts-modal .ts-modal-dialog li.reason label {
92
+ display: table
93
+ }
94
+
95
+ .ts-modal .ts-modal-dialog li.reason label > span {
96
+ display: table-cell;
97
+ font-size: 1.3em
98
+ }
99
+ }
100
+
101
+ .ts-modal.active {
102
+ display: block
103
+ }
104
+
105
+ .ts-modal.active:before {
106
+ display: block
107
+ }
108
+
109
+ .ts-modal.active .ts-modal-dialog {
110
+ top: 10%
111
+ }
112
+
113
+ .ts-modal .ts-modal-body, .ts-modal .ts-modal-footer {
114
+ border: 0;
115
+ background: #fefefe;
116
+ padding: 20px
117
+ }
118
+
119
+ .ts-modal .ts-modal-body {
120
+ border-bottom: 0
121
+ }
122
+
123
+ .ts-modal .ts-modal-body h2 {
124
+ font-size: 20px
125
+ }
126
+
127
+ .ts-modal .ts-modal-body > div {
128
+ margin-top: 10px
129
+ }
130
+
131
+ .ts-modal .ts-modal-body > div h2 {
132
+ font-weight: bold;
133
+ font-size: 20px;
134
+ margin-top: 0
135
+ }
136
+
137
+ .ts-modal .ts-modal-footer {
138
+ border-top: #eeeeee solid 1px;
139
+ text-align: right
140
+ }
141
+
142
+ .ts-modal .ts-modal-footer > .button {
143
+ margin: 0 7px
144
+ }
145
+
146
+ .ts-modal .ts-modal-footer > .button:first-child {
147
+ margin: 0
148
+ }
149
+
150
+ .ts-modal .ts-modal-panel:not(.active) {
151
+ display: none
152
+ }
153
+
154
+ .ts-modal .reason-input {
155
+ margin: 3px 0 3px 22px
156
+ }
157
+
158
+ .ts-modal .reason-input input, .ts-modal .reason-input textarea {
159
+ width: 100%
160
+ }
161
+
162
+ body.has-ts-modal {
163
+ overflow: hidden
164
+ }
165
+
166
+ #the-list .deactivate > .ts-slug {
167
+ display: none
168
+ }
169
+
170
+ .ts-modal li.reason-hide {
171
+ display: none;
172
+ }
173
 
174
  </style>
175
  <script type="text/javascript">
176
+ var currentPluginName = "";
177
+ var TSCustomReasons = {};
178
+ var TSDefaultReason = {};
179
+ ( function ($) {
180
+ var $deactivateLinks = {};
181
+ var reasonsHtml = <?php echo json_encode( $reasons_list_items_html ); ?>,
182
+ modalHtml =
183
+ '<div class="ts-modal<?php echo ( '' === $confirmation_message ) ? ' no-confirmation-message' : ''; ?>">'
184
+ + ' <div class="ts-modal-dialog">'
185
+ + ' <div class="ts-modal-body">'
186
+ + ' <div class="ts-modal-panel" data-panel-id="confirm"><p><?php echo $confirmation_message; ?></p></div>'
187
+ + ' <div class="ts-modal-panel active" data-panel-id="reasons"><h3><strong><?php printf( Wcal_TS_deactivate::load_str( 'deactivation-share-reason' ) ); ?>:</strong></h3><ul id="reasons-list">' + reasonsHtml + '</ul></div>'
188
+ + ' </div>'
189
+ + ' <div class="ts-modal-footer">'
190
+ + ' <a href="#" class="button button-secondary button-deactivate"></a>'
191
+ + ' <a href="#" class="button button-primary button-close"><?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-cancel' ) ); ?></a>'
192
+ + ' </div>'
193
+ + ' </div>'
194
+ + '</div>',
195
+ $modal = $(modalHtml),
196
+
197
+ $deactivateLink = $('#the-list .deactivate > .ts-slug').prev();
198
+
199
+ for( var i = 0; i < $deactivateLink.length; i++ ) {
200
+ $deactivateLinks[ $( $deactivateLink[i] ).siblings( ".ts-slug" ).attr( 'data-slug' ) ] = $deactivateLink[i].href;
201
+ }
202
 
203
+ $modal.appendTo( $( 'body' ) );
204
+
205
+ registerEventHandlers();
206
+
207
+ function registerEventHandlers() {
208
+ $deactivateLink.on( "click", function (evt) {
209
+ evt.preventDefault();
210
+ currentPluginName = $(this).siblings( ".ts-slug" ).attr( 'data-slug' );
211
+ showModal();
212
+ });
213
+
214
+ $modal.on( 'click', '.button', function (evt) {
215
+ evt.preventDefault();
216
+ if ($(this).hasClass( 'disabled' ) ) {
217
+ return;
218
+ }
219
+
220
+ var _parent = $(this).parents( '.ts-modal:first' );
221
+ var _this = $(this);
222
+
223
+ if( _this.hasClass( 'allow-deactivate' ) ) {
224
+ var $radio = $('input[type="radio"]:checked');
225
+ var $selected_reason = $radio.parents('li:first'),
226
+ $input = $selected_reason.find('textarea, input[type="text"]');
227
+ if( $radio.length == 0 ) {
228
+ var data = {
229
+ 'action': 'ts_submit_uninstall_reason',
230
+ 'reason_id': 0,
231
+ 'reason_text': "Deactivated without any option",
232
+ 'plugin_basename': currentPluginName,
233
+ };
234
+ } else {
235
+ var data = {
236
+ 'action': 'ts_submit_uninstall_reason',
237
+ 'reason_id': (0 !== $radio.length) ? $radio.val() : '',
238
+ 'reason_text': $selected_reason.text(),
239
+ 'reason_info': (0 !== $input.length) ? $input.val().trim() : '',
240
+ 'plugin_basename': currentPluginName,
241
+ };
242
+ }
243
+
244
+ $.ajax({
245
+ url: ajaxurl,
246
+ method: 'POST',
247
+ data: data,
248
+ beforeSend: function () {
249
+ _parent.find('.button').addClass('disabled');
250
+ _parent.find('.button-secondary').text('Processing...');
251
+ },
252
+ complete: function () {
253
+ // Do not show the dialog box, deactivate the plugin.
254
+ window.location.href = $deactivateLinks[currentPluginName];
255
+ }
256
+ });
257
+ }
258
+ });
259
+
260
+ $modal.on('click', 'input[type="radio"]', function () {
261
+ console.log( this );
262
+ var _parent = $(this).parents('li:first');
263
+ var _parent_ul = $(this).parents('ul#reasons-list');
264
+
265
+ _parent_ul.children("li.li-active").removeClass("li-active");
266
+
267
+ $modal.find('.reason-input').remove();
268
+ $modal.find('.button-deactivate').text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-submit' ) ); ?>');
269
+
270
+ if (_parent.hasClass('has_html')) {
271
+ _parent.addClass('li-active');
272
+ }
273
+ if (_parent.hasClass('has-input')) {
274
+ var inputType = _parent.data('input-type'),
275
+ inputPlaceholder = _parent.data('input-placeholder'),
276
+ reasonInputHtml = '<div class="reason-input">' + (('textfield' === inputType) ? '<input type="text" />' : '<textarea rows="5"></textarea>') + '</div>';
277
+
278
+ _parent.append($(reasonInputHtml));
279
+ _parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
280
+ }
281
+ });
282
+
283
+ // If the user has clicked outside the window, cancel it.
284
+ $modal.on('click', function (evt) {
285
+ var $target = $(evt.target);
286
+
287
+ // If the user has clicked anywhere in the modal dialog, just return.
288
+ if ($target.hasClass('ts-modal-body') || $target.hasClass('ts-modal-footer')) {
289
+ return;
290
+ }
291
+
292
+ // If the user has not clicked the close button and the clicked element is inside the modal dialog, just return.
293
+ if (!$target.hasClass('button-close') && ($target.parents('.ts-modal-body').length > 0 || $target.parents('.ts-modal-footer').length > 0)) {
294
+ return;
295
+ }
296
+
297
+ closeModal();
298
+ });
299
+ }
300
+
301
+ function showModal() {
302
+ resetModal();
303
+
304
+ // Display the dialog box.
305
+ $modal.addClass('active');
306
+
307
+ $('body').addClass('has-ts-modal');
308
+ }
309
+
310
+ function closeModal() {
311
+ $modal.removeClass('active');
312
+
313
+ $('body').removeClass('has-ts-modal');
314
+ }
315
+
316
+ function resetModal() {
317
+ if (TSCustomReasons.hasOwnProperty(currentPluginName) === true) {
318
+ $modal.find("ul#reasons-list").html(TSCustomReasons[currentPluginName]);
319
+ } else {
320
+ $modal.find("ul#reasons-list").html(reasonsHtml);
321
+
322
+ }
323
+ var defaultSelect = TSDefaultReason[currentPluginName];
324
+ $modal.find('.button').removeClass('disabled');
325
+
326
+ // Remove all input fields ( textfield, textarea ).
327
+ $modal.find('.reason-input').remove();
328
+
329
+ var $deactivateButton = $modal.find('.button-deactivate');
330
+ $modal.find(".reason-hide").hide();
331
+ /*
332
+ * If the modal dialog has no confirmation message, that is, it has only one panel, then ensure
333
+ * that clicking the deactivate button will actually deactivate the plugin.
334
+ */
335
+ if ($modal.hasClass('no-confirmation-message')) {
336
+ $deactivateButton.addClass('allow-deactivate');
337
+ showPanel('reasons');
338
+ }
339
+ }
340
+
341
+ function showPanel(panelType) {
342
+ $modal.find('.ts-modal-panel').removeClass('active ');
343
+ $modal.find('[data-panel-id="' + panelType + '"]').addClass('active');
344
+
345
+ updateButtonLabels();
346
+ }
347
+
348
+ function updateButtonLabels() {
349
+ var $deactivateButton = $modal.find('.button-deactivate');
350
+
351
+ // Reset the deactivate button's text.
352
+ if ('confirm' === getCurrentPanel()) {
353
+ $deactivateButton.text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-confirm' ) ); ?>');
354
+ } else {
355
+ var $radio = $('input[type="radio"]:checked');
356
+ if( $radio.length == 0 ) {
357
+ $deactivateButton.text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-deactivate' ) ); ?>');
358
+ } else {
359
+ var _parent = $( $radio ).parents('li:first');
360
+ var _parent_ul = $( $radio ).parents('ul#reasons-list');
361
+
362
+ _parent_ul.children("li.li-active").removeClass("li-active");
363
+
364
+ $modal.find('.reason-input').remove();
365
+ $modal.find('.button-deactivate').text('<?php printf( Wcal_TS_deactivate::load_str( 'deactivation-modal-button-submit' ) ); ?>');
366
+
367
+ if (_parent.hasClass('has_html')) {
368
+ _parent.addClass('li-active');
369
+ }
370
+
371
+ if (_parent.hasClass('has-input')) {
372
+ var inputType = _parent.data('input-type'),
373
+ inputPlaceholder = _parent.data('input-placeholder'),
374
+ reasonInputHtml = '<div class="reason-input">' + (('textfield' === inputType) ? '<input type="text" />' : '<textarea rows="5"></textarea>') + '</div>';
375
+
376
+ _parent.append($(reasonInputHtml));
377
+ _parent.find('input, textarea').attr('placeholder', inputPlaceholder).focus();
378
+ }
379
+ }
380
+ }
381
+ }
382
+
383
+ function getCurrentPanel() {
384
+ return $modal.find('.ts-modal-panel.active').attr('data-panel-id');
385
+ }
386
+ })(jQuery);
387
  </script>
includes/component/pro-notices-in-lite/ts-pro-notices.php CHANGED
@@ -3,28 +3,28 @@
3
  class Wcal_ts_pro_notices {
4
 
5
  /**
6
- * Plugin's Name
7
- *
8
- * @access public
9
- * @since 3.5
10
- */
11
- public static $plugin_name = "";
12
 
13
  /**
14
- * Plugin's unique prefix
15
- *
16
- * @access public
17
- * @since 3.5
18
- */
19
 
20
  public static $plugin_prefix = '';
21
 
22
  /**
23
- * Pro plugin's unique prefix
24
- *
25
- * @access public
26
- * @since 3.5
27
- */
28
 
29
  public static $pro_plugin_prefix = '';
30
 
@@ -32,7 +32,7 @@ class Wcal_ts_pro_notices {
32
  * @var array Collection of all messages.
33
  * @access public
34
  */
35
- public static $ts_pro_notices = array ();
36
 
37
  /**
38
  * @var string file name
@@ -46,140 +46,139 @@ class Wcal_ts_pro_notices {
46
  */
47
  public static $ts_pro_file_name = '';
48
 
49
- /**
50
- * Default Constructor
51
- *
52
- * @since 3.5
53
- */
54
  public function __construct( $ts_plugin_name = '', $ts_plugin_prefix = '', $ts_pro_plugin_prefix = '', $ts_notices = array(), $ts_file = '', $ts_pro_file = '' ) {
55
- self::$plugin_name = $ts_plugin_name;
56
- self::$plugin_prefix = $ts_plugin_prefix;
57
  self::$pro_plugin_prefix = $ts_pro_plugin_prefix;
58
  self::$ts_pro_notices = $ts_notices;
59
  self::$ts_file_name = $ts_file;
60
  self::$ts_pro_file_name = $ts_pro_file;
61
 
62
- //Initialize settings
63
- register_activation_hook( __FILE__, array( __CLASS__, 'ts_activate_time' ) );
 
 
 
 
64
 
65
- //Add pro notices
66
- add_action( 'admin_notices', array( __CLASS__ , 'ts_notices_of_pro' ) );
67
- add_action( 'admin_init', array( __CLASS__ , 'ts_ignore_pro_notices' ) );
68
-
69
  add_action( self::$plugin_prefix . '_activate', array( __CLASS__, 'ts_activate_time' ) );
70
  }
71
 
72
  /**
73
  * It will add the activation time on activation and plugin prefix activate hook.
74
  */
75
- public static function ts_activate_time () {
76
 
77
- if( !get_option( self::$plugin_prefix . '_activate_time' ) ) {
78
  add_option( self::$plugin_prefix . '_activate_time', current_time( 'timestamp' ) );
79
  }
80
  }
81
 
82
  /**
83
  * It will display notices for the pro version of the plugin.
84
- *
85
  */
86
  public static function ts_notices_of_pro() {
87
 
88
  global $current_screen;
89
  $current_screen = get_current_screen();
90
- if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() )
91
- || ( function_exists('is_gutenberg_page') && is_gutenberg_page() ) ) {
92
  return;
93
  }
94
 
95
- $activate_time = get_option ( self::$plugin_prefix . '_activate_time' );
96
- $sixty_days = strtotime ( '+60 Days', $activate_time );
97
- $current_time = current_time ( 'timestamp' );
98
  $add_query_arguments = '';
99
  $message = '';
100
- $user_id = get_current_user_id();
101
- $class = 'updated notice-info point-notice one';
102
- $style = 'position:relative';
103
-
104
- if( !is_plugin_active( self::$ts_pro_file_name ) &&
105
- ( false === $activate_time || ( $activate_time > 0 && $current_time >= $sixty_days ) ) ) {
106
-
107
- if( ! get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) ) {
108
-
109
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_first_notice_ignore', '0' );
110
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
111
-
112
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[1], $cancel_button );
113
  }
114
 
115
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
116
- ! get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' )
117
  ) {
118
 
119
  $first_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore_time' );
120
- $fifteen_days = strtotime( '+15 Days', $first_ignore_time[0] );
121
 
122
- //$fifteen_days = strtotime( '+2 Minutes', $first_ignore_time[0] );
123
 
124
  if ( $current_time > $fifteen_days ) {
125
-
126
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_second_notice_ignore', '0' );
127
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
128
-
129
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[2], $cancel_button );
130
  }
131
  }
132
-
133
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
134
- get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
135
- ! get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' )
136
  ) {
137
 
138
- $second_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore_time' );
139
- $ts_fifteen_days = strtotime( '+15 Days', $second_ignore_time[0] );
140
 
141
  if ( $current_time > $ts_fifteen_days ) {
142
-
143
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_third_notice_ignore', '0' );
144
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
145
-
146
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[3], $cancel_button );
147
  }
148
  }
149
 
150
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
151
- get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
152
- get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
153
- ! get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' )
154
  ) {
155
 
156
- $third_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore_time' );
157
- $ts_fifteen_days = strtotime( '+15 Days', $third_ignore_time[0] );
158
 
159
  if ( $current_time > $ts_fifteen_days ) {
160
-
161
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_fourth_notice_ignore', '0' );
162
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
163
-
164
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[4], $cancel_button );
165
  }
166
  }
167
 
168
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
169
- get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
170
- get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
171
- get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' ) &&
172
- ! get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore' )
173
  ) {
174
 
175
- $fourth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore_time' );
176
- $ts_fifteen_days = strtotime( '+15 Days', $fourth_ignore_time[0] );
177
 
178
  if ( $current_time > $ts_fifteen_days ) {
179
-
180
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_fifth_notice_ignore', '0' );
181
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
182
-
183
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[5], $cancel_button );
184
  }
185
  }
@@ -188,20 +187,20 @@ class Wcal_ts_pro_notices {
188
  * Display Other plugin notices.
189
  */
190
 
191
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
192
- get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
193
- get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
194
- get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' ) &&
195
- get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore' )
196
  ) {
197
- $fifth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore_time' );
198
 
199
- self::ts_display_other_pro_plugin_notices( $current_time, $activate_time, $fifth_ignore_time [ 0 ] );
200
- }
201
  }
202
 
203
- $seven_days = strtotime ( '+7 Days', $activate_time );
204
- if( is_plugin_active( self::$ts_pro_file_name ) &&
205
  ( false === $activate_time || ( $activate_time > 0 && $current_time >= $seven_days ) ) ) {
206
 
207
  self::ts_display_other_pro_plugin_notices( $current_time, $activate_time );
@@ -210,74 +209,73 @@ class Wcal_ts_pro_notices {
210
 
211
  /**
212
  * It will display the all other pro plugin notices
213
- *
214
  */
215
- public static function ts_display_other_pro_plugin_notices ( $current_time, $activate_time, $ts_consider_time = '' ) {
216
  $user_id = get_current_user_id();
217
  $class = 'updated notice-info point-notice';
218
  $style = 'position:relative';
219
-
220
- if ( ! get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' )
221
  ) {
222
 
223
- if ( '' != $ts_consider_time ) {
224
- /**
225
- * This is fifth ignore notice time plus 7 days
226
- */
227
- $ts_consider_time = strtotime( '+7 Days', $ts_consider_time );
228
- }
229
- if ( $current_time > $ts_consider_time ) {
230
- $add_query_arguments = add_query_arg( self::$plugin_prefix . '_sixth_notice_ignore', '0' );
231
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
232
-
233
- printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[6], $cancel_button );
234
- }
235
  }
236
 
237
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
238
- ! get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' )
239
  ) {
240
 
241
- $sixth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore_time' );
242
- $ts_seven_days = strtotime( '+7 Days', $sixth_ignore_time[0] );
243
  if ( $current_time > $ts_seven_days ) {
244
-
245
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_seventh_notice_ignore', '0' );
246
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
247
-
248
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[7], $cancel_button );
249
  }
250
  }
251
 
252
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
253
- get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' ) &&
254
- ! get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore' )
255
  ) {
256
 
257
- $seventh_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore_time' );
258
- $ts_seven_days = strtotime( '+7 Days', $seventh_ignore_time[0] );
259
  if ( $current_time > $ts_seven_days ) {
260
-
261
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_eigth_notice_ignore', '0' );
262
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
263
-
264
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[8], $cancel_button );
265
  }
266
  }
267
 
268
- if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
269
- get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' ) &&
270
- get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore' ) &&
271
- ! get_user_meta( $user_id, self::$plugin_prefix . '_ninth_notice_ignore' )
272
  ) {
273
 
274
- $eigth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore_time' );
275
- $ts_seven_days = strtotime( '+7 Days', $eigth_ignore_time[0] );
276
  if ( $current_time > $ts_seven_days ) {
277
-
278
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_ninth_notice_ignore', '0' );
279
- $cancel_button = '<a href="'.$add_query_arguments.'" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
280
-
281
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[9], $cancel_button );
282
  }
283
  }
@@ -296,13 +294,13 @@ class Wcal_ts_pro_notices {
296
 
297
  }
298
 
299
- if ( isset( $_GET[ self::$plugin_prefix . '_second_notice_ignore'] ) && '0' === $_GET[ self::$plugin_prefix . '_second_notice_ignore'] ) {
300
  add_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore', 'true', true );
301
  add_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore_time', current_time( 'timestamp' ), true );
302
- wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_second_notice_ignore' ) );
303
  }
304
 
305
- if ( isset( $_GET[ self::$plugin_prefix . '_third_notice_ignore'] ) && '0' === $_GET[ self::$plugin_prefix . '_third_notice_ignore'] ) {
306
  add_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore', 'true', true );
307
  add_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore_time', current_time( 'timestamp' ), true );
308
  wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_third_notice_ignore' ) );
@@ -344,4 +342,4 @@ class Wcal_ts_pro_notices {
344
  wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_ninth_notice_ignore' ) );
345
  }
346
  }
347
- }
3
  class Wcal_ts_pro_notices {
4
 
5
  /**
6
+ * Plugin's Name
7
+ *
8
+ * @access public
9
+ * @since 3.5
10
+ */
11
+ public static $plugin_name = '';
12
 
13
  /**
14
+ * Plugin's unique prefix
15
+ *
16
+ * @access public
17
+ * @since 3.5
18
+ */
19
 
20
  public static $plugin_prefix = '';
21
 
22
  /**
23
+ * Pro plugin's unique prefix
24
+ *
25
+ * @access public
26
+ * @since 3.5
27
+ */
28
 
29
  public static $pro_plugin_prefix = '';
30
 
32
  * @var array Collection of all messages.
33
  * @access public
34
  */
35
+ public static $ts_pro_notices = array();
36
 
37
  /**
38
  * @var string file name
46
  */
47
  public static $ts_pro_file_name = '';
48
 
49
+ /**
50
+ * Default Constructor
51
+ *
52
+ * @since 3.5
53
+ */
54
  public function __construct( $ts_plugin_name = '', $ts_plugin_prefix = '', $ts_pro_plugin_prefix = '', $ts_notices = array(), $ts_file = '', $ts_pro_file = '' ) {
55
+ self::$plugin_name = $ts_plugin_name;
56
+ self::$plugin_prefix = $ts_plugin_prefix;
57
  self::$pro_plugin_prefix = $ts_pro_plugin_prefix;
58
  self::$ts_pro_notices = $ts_notices;
59
  self::$ts_file_name = $ts_file;
60
  self::$ts_pro_file_name = $ts_pro_file;
61
 
62
+ // Initialize settings
63
+ register_activation_hook( __FILE__, array( __CLASS__, 'ts_activate_time' ) );
64
+
65
+ // Add pro notices
66
+ add_action( 'admin_notices', array( __CLASS__, 'ts_notices_of_pro' ) );
67
+ add_action( 'admin_init', array( __CLASS__, 'ts_ignore_pro_notices' ) );
68
 
 
 
 
 
69
  add_action( self::$plugin_prefix . '_activate', array( __CLASS__, 'ts_activate_time' ) );
70
  }
71
 
72
  /**
73
  * It will add the activation time on activation and plugin prefix activate hook.
74
  */
75
+ public static function ts_activate_time() {
76
 
77
+ if ( ! get_option( self::$plugin_prefix . '_activate_time' ) ) {
78
  add_option( self::$plugin_prefix . '_activate_time', current_time( 'timestamp' ) );
79
  }
80
  }
81
 
82
  /**
83
  * It will display notices for the pro version of the plugin.
 
84
  */
85
  public static function ts_notices_of_pro() {
86
 
87
  global $current_screen;
88
  $current_screen = get_current_screen();
89
+ if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() )
90
+ || ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) ) {
91
  return;
92
  }
93
 
94
+ $activate_time = get_option( self::$plugin_prefix . '_activate_time' );
95
+ $sixty_days = strtotime( '+60 Days', $activate_time );
96
+ $current_time = current_time( 'timestamp' );
97
  $add_query_arguments = '';
98
  $message = '';
99
+ $user_id = get_current_user_id();
100
+ $class = 'updated notice-info point-notice one';
101
+ $style = 'position:relative';
102
+
103
+ if ( ! is_plugin_active( self::$ts_pro_file_name ) &&
104
+ ( false === $activate_time || ( $activate_time > 0 && $current_time >= $sixty_days ) ) ) {
105
+
106
+ if ( ! get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) ) {
107
+
108
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_first_notice_ignore', '0' );
109
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
110
+
111
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[1], $cancel_button );
112
  }
113
 
114
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
115
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' )
116
  ) {
117
 
118
  $first_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore_time' );
119
+ $fifteen_days = strtotime( '+15 Days', $first_ignore_time[0] );
120
 
121
+ // $fifteen_days = strtotime( '+2 Minutes', $first_ignore_time[0] );
122
 
123
  if ( $current_time > $fifteen_days ) {
124
+
125
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_second_notice_ignore', '0' );
126
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
127
+
128
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[2], $cancel_button );
129
  }
130
  }
131
+
132
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
133
+ get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
134
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' )
135
  ) {
136
 
137
+ $second_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore_time' );
138
+ $ts_fifteen_days = strtotime( '+15 Days', $second_ignore_time[0] );
139
 
140
  if ( $current_time > $ts_fifteen_days ) {
141
+
142
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_third_notice_ignore', '0' );
143
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
144
+
145
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[3], $cancel_button );
146
  }
147
  }
148
 
149
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
150
+ get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
151
+ get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
152
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' )
153
  ) {
154
 
155
+ $third_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore_time' );
156
+ $ts_fifteen_days = strtotime( '+15 Days', $third_ignore_time[0] );
157
 
158
  if ( $current_time > $ts_fifteen_days ) {
159
+
160
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_fourth_notice_ignore', '0' );
161
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
162
+
163
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[4], $cancel_button );
164
  }
165
  }
166
 
167
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
168
+ get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
169
+ get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
170
+ get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' ) &&
171
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore' )
172
  ) {
173
 
174
+ $fourth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore_time' );
175
+ $ts_fifteen_days = strtotime( '+15 Days', $fourth_ignore_time[0] );
176
 
177
  if ( $current_time > $ts_fifteen_days ) {
178
+
179
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_fifth_notice_ignore', '0' );
180
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
181
+
182
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[5], $cancel_button );
183
  }
184
  }
187
  * Display Other plugin notices.
188
  */
189
 
190
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_first_notice_ignore' ) &&
191
+ get_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore' ) &&
192
+ get_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore' ) &&
193
+ get_user_meta( $user_id, self::$plugin_prefix . '_fourth_notice_ignore' ) &&
194
+ get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore' )
195
  ) {
196
+ $fifth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_fifth_notice_ignore_time' );
197
 
198
+ self::ts_display_other_pro_plugin_notices( $current_time, $activate_time, $fifth_ignore_time [0] );
199
+ }
200
  }
201
 
202
+ $seven_days = strtotime( '+7 Days', $activate_time );
203
+ if ( is_plugin_active( self::$ts_pro_file_name ) &&
204
  ( false === $activate_time || ( $activate_time > 0 && $current_time >= $seven_days ) ) ) {
205
 
206
  self::ts_display_other_pro_plugin_notices( $current_time, $activate_time );
209
 
210
  /**
211
  * It will display the all other pro plugin notices
 
212
  */
213
+ public static function ts_display_other_pro_plugin_notices( $current_time, $activate_time, $ts_consider_time = '' ) {
214
  $user_id = get_current_user_id();
215
  $class = 'updated notice-info point-notice';
216
  $style = 'position:relative';
217
+
218
+ if ( ! get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' )
219
  ) {
220
 
221
+ if ( '' != $ts_consider_time ) {
222
+ /**
223
+ * This is fifth ignore notice time plus 7 days
224
+ */
225
+ $ts_consider_time = strtotime( '+7 Days', $ts_consider_time );
226
+ }
227
+ if ( $current_time > $ts_consider_time ) {
228
+ $add_query_arguments = add_query_arg( self::$plugin_prefix . '_sixth_notice_ignore', '0' );
229
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
230
+
231
+ printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[6], $cancel_button );
232
+ }
233
  }
234
 
235
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
236
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' )
237
  ) {
238
 
239
+ $sixth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore_time' );
240
+ $ts_seven_days = strtotime( '+7 Days', $sixth_ignore_time[0] );
241
  if ( $current_time > $ts_seven_days ) {
242
+
243
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_seventh_notice_ignore', '0' );
244
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
245
+
246
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[7], $cancel_button );
247
  }
248
  }
249
 
250
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
251
+ get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' ) &&
252
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore' )
253
  ) {
254
 
255
+ $seventh_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore_time' );
256
+ $ts_seven_days = strtotime( '+7 Days', $seventh_ignore_time[0] );
257
  if ( $current_time > $ts_seven_days ) {
258
+
259
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_eigth_notice_ignore', '0' );
260
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
261
+
262
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[8], $cancel_button );
263
  }
264
  }
265
 
266
+ if ( get_user_meta( $user_id, self::$plugin_prefix . '_sixth_notice_ignore' ) &&
267
+ get_user_meta( $user_id, self::$plugin_prefix . '_seventh_notice_ignore' ) &&
268
+ get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore' ) &&
269
+ ! get_user_meta( $user_id, self::$plugin_prefix . '_ninth_notice_ignore' )
270
  ) {
271
 
272
+ $eigth_ignore_time = get_user_meta( $user_id, self::$plugin_prefix . '_eigth_notice_ignore_time' );
273
+ $ts_seven_days = strtotime( '+7 Days', $eigth_ignore_time[0] );
274
  if ( $current_time > $ts_seven_days ) {
275
+
276
  $add_query_arguments = add_query_arg( self::$plugin_prefix . '_ninth_notice_ignore', '0' );
277
+ $cancel_button = '<a href="' . $add_query_arguments . '" class="dashicons dashicons-dismiss dashicons-dismiss-icon" style="position: absolute; top: 8px; right: 8px; color: #222; opacity: 0.4; text-decoration: none !important;"></a>';
278
+
279
  printf( '<div class="%1$s" style="%2$s"><p>%3$s %4$s</p></div>', $class, $style, self::$ts_pro_notices[9], $cancel_button );
280
  }
281
  }
294
 
295
  }
296
 
297
+ if ( isset( $_GET[ self::$plugin_prefix . '_second_notice_ignore' ] ) && '0' === $_GET[ self::$plugin_prefix . '_second_notice_ignore' ] ) {
298
  add_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore', 'true', true );
299
  add_user_meta( $user_id, self::$plugin_prefix . '_second_notice_ignore_time', current_time( 'timestamp' ), true );
300
+ wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_second_notice_ignore' ) );
301
  }
302
 
303
+ if ( isset( $_GET[ self::$plugin_prefix . '_third_notice_ignore' ] ) && '0' === $_GET[ self::$plugin_prefix . '_third_notice_ignore' ] ) {
304
  add_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore', 'true', true );
305
  add_user_meta( $user_id, self::$plugin_prefix . '_third_notice_ignore_time', current_time( 'timestamp' ), true );
306
  wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_third_notice_ignore' ) );
342
  wp_safe_redirect( remove_query_arg( self::$plugin_prefix . '_ninth_notice_ignore' ) );
343
  }
344
  }
345
+ }
includes/component/tracking-data/class-ts-tracker.php CHANGED
@@ -1,11 +1,11 @@
1
  <?php
2
  /**
3
  * The tracker class adds functionality to track usage of the plugin based on if the customer opted in.
4
- * No personal information is tracked, only general settings, order and user counts and admin email for
5
  * discount code.
6
  *
7
- * @class Wcal_TS_Tracker
8
- * @version 6.8
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) {
@@ -16,22 +16,23 @@ class Wcal_TS_Tracker {
16
 
17
  /**
18
  * URL to the Tracker API endpoint.
 
19
  * @var string
20
  */
21
 
22
  private static $api_url = 'http://tracking.tychesoftwares.com/v1/';
23
 
24
  /**
25
- * @var string Plugin prefix
26
- * @access public
27
- */
28
 
29
  public static $plugin_prefix = '';
30
 
31
  /**
32
- * @var string Plugin name
33
- * @access public
34
- */
35
 
36
  public static $plugin_name = '';
37
 
@@ -43,7 +44,7 @@ class Wcal_TS_Tracker {
43
  self::$plugin_prefix = $ts_plugin_prefix;
44
  self::$plugin_name = $ts_plugin_name;
45
 
46
- add_action( self::$plugin_prefix . '_ts_tracker_send_event', array( __CLASS__, 'ts_send_tracking_data' ) );
47
  }
48
 
49
  /**
@@ -65,27 +66,29 @@ class Wcal_TS_Tracker {
65
  return;
66
  }
67
  }
68
-
69
- $allow_tracking = get_option( self::$plugin_prefix . '_allow_tracking' );
70
  if ( 'yes' == $allow_tracking ) {
71
- $override = true;
72
  }
73
-
74
  // Update time first before sending to ensure it is set
75
  update_option( 'ts_tracker_last_send', time() );
76
 
77
- if( $override == false ) {
78
- $params = array();
79
- $params[ 'tracking_usage' ] = 'no';
80
- $params[ 'url' ] = home_url();
81
- $params[ 'email' ] = '';
82
-
83
- $params = apply_filters( 'ts_tracker_opt_out_data', $params );
84
  } else {
85
- $params = self::ts_get_tracking_data();
86
  }
87
-
88
- wp_safe_remote_post( self::$api_url, array(
 
 
89
  'method' => 'POST',
90
  'timeout' => 45,
91
  'redirection' => 5,
@@ -95,11 +98,12 @@ class Wcal_TS_Tracker {
95
  'body' => json_encode( $params ),
96
  'cookies' => array(),
97
  )
98
- );
99
  }
100
 
101
  /**
102
  * Get the last time tracking data was sent.
 
103
  * @return int|bool
104
  */
105
  private static function ts_get_last_send_time() {
@@ -108,56 +112,58 @@ class Wcal_TS_Tracker {
108
 
109
  /**
110
  * Get all the tracking data.
 
111
  * @return array
112
  */
113
  private static function ts_get_tracking_data() {
114
- $data = array();
115
 
116
  // General site info
117
- $data[ 'url' ] = home_url();
118
- $data[ 'email' ] = apply_filters( 'ts_tracker_admin_email', get_option( 'admin_email' ) );
119
 
120
  // WordPress Info
121
- $data[ 'wp' ] = self::ts_get_wordpress_info();
122
 
123
- $data[ 'theme_info' ] = self::ts_get_theme_info();
124
 
125
  // Server Info
126
- $data[ 'server' ] = self::ts_get_server_info();
127
 
128
  // Plugin info
129
- $all_plugins = self::ts_get_all_plugins();
130
- $data[ 'active_plugins' ] = $all_plugins[ 'active_plugins' ];
131
- $data[ 'inactive_plugins' ] = $all_plugins[ 'inactive_plugins' ];
132
-
133
- //WooCommerce version
134
- $data[ 'wc_plugin_version' ] = self::ts_get_wc_plugin_version();
135
 
 
 
136
 
137
-
138
  return apply_filters( 'ts_tracker_data', $data );
139
  }
140
 
141
  /**
142
  * Get Selected city of the WooCommerce store.
 
143
  * @return string $ts_city Name of the city
144
  */
145
- private static function ts_get_wc_city () {
146
- $ts_city = get_option ( 'woocommerce_store_city' );
147
  return $ts_city;
148
  }
149
 
150
  /**
151
  * Get Selected country of the WooCommerce store.
 
152
  * @return string $ts_country Name of the city
153
  */
154
- private static function ts_get_wc_country () {
155
- $ts_country = get_option ( 'woocommerce_default_country' );
156
  return $ts_country;
157
  }
158
-
159
  /**
160
  * Get WordPress related data.
 
161
  * @return array
162
  */
163
  private static function ts_get_wordpress_info() {
@@ -170,68 +176,73 @@ class Wcal_TS_Tracker {
170
  $memory = max( $memory, $system_memory );
171
  }
172
 
173
- $wp_data[ 'memory_limit' ] = size_format( $memory );
174
- $wp_data[ 'debug_mode' ] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
175
- $wp_data[ 'locale' ] = get_locale();
176
- $wp_data[ 'wp_version' ] = get_bloginfo( 'version' );
177
- $wp_data[ 'multisite' ] = is_multisite() ? 'Yes' : 'No';
178
- $wp_data[ 'blogdescription' ] = get_option ( 'blogdescription' );
179
- $wp_data[ 'blogname' ] = get_option ( 'blogname' );
180
- $wp_data[ 'wc_city' ] = self::ts_get_wc_city();
181
- $wp_data[ 'wc_country' ] = self::ts_get_wc_country();
182
 
183
  return $wp_data;
184
  }
185
 
186
  /**
187
  * Get the current theme info, theme name and version.
 
188
  * @return array
189
  */
190
  public static function ts_get_theme_info() {
191
  $theme_data = wp_get_theme();
192
  $theme_child_theme = is_child_theme() ? 'Yes' : 'No';
193
 
194
- return array( 'theme_name' => $theme_data->Name,
195
- 'theme_version' => $theme_data->Version,
196
- 'child_theme' => $theme_child_theme );
 
 
197
  }
198
 
199
  /**
200
  * Get server related info.
 
201
  * @return array
202
  */
203
  private static function ts_get_server_info() {
204
  global $wpdb;
205
  $server_data = array();
206
 
207
- if ( isset( $_SERVER[ 'SERVER_SOFTWARE' ] ) && ! empty( $_SERVER[ 'SERVER_SOFTWARE' ] ) ) {
208
- $server_data[ 'software' ] = $_SERVER[ 'SERVER_SOFTWARE' ];
209
  }
210
 
211
  if ( function_exists( 'phpversion' ) ) {
212
- $server_data[ 'php_version' ] = phpversion();
213
  }
214
 
215
  if ( function_exists( 'ini_get' ) ) {
216
- $server_data[ 'php_post_max_size' ] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
217
- $server_data[ 'php_time_limt' ] = ini_get( 'max_execution_time' );
218
- $server_data[ 'php_max_input_vars' ] = ini_get( 'max_input_vars' );
219
- $server_data[ 'php_suhosin' ] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
220
  }
221
 
222
- $server_data[ 'mysql_version' ] = $wpdb->db_version();
223
 
224
- $server_data[ 'php_max_upload_size' ] = size_format( wp_max_upload_size() );
225
- $server_data[ 'php_default_timezone' ] = date_default_timezone_get();
226
- $server_data[ 'php_soap' ] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
227
- $server_data[ 'php_fsockopen' ] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
228
- $server_data[ 'php_curl' ] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
229
 
230
  return $server_data;
231
  }
232
 
233
  /**
234
  * Get all plugins grouped into activated or not.
 
235
  * @return array
236
  */
237
  private static function ts_get_all_plugins() {
@@ -240,25 +251,25 @@ class Wcal_TS_Tracker {
240
  include ABSPATH . '/wp-admin/includes/plugin.php';
241
  }
242
 
243
- $plugins = get_plugins();
244
  $active_plugins_keys = get_option( 'active_plugins', array() );
245
- $active_plugins = array();
246
 
247
  foreach ( $plugins as $k => $v ) {
248
  // Take care of formatting the data how we want it.
249
- $formatted = array();
250
- $formatted[ 'name' ] = strip_tags( $v[ 'Name' ] );
251
- if ( isset( $v[ 'Version' ] ) ) {
252
- $formatted[ 'version' ] = strip_tags( $v[ 'Version' ] );
253
  }
254
- if ( isset( $v[ 'Author' ] ) ) {
255
- $formatted[ 'author' ] = strip_tags( $v[ 'Author' ] );
256
  }
257
- if ( isset( $v[ 'Network' ] ) ) {
258
- $formatted[ 'network' ] = strip_tags( $v[ 'Network' ] );
259
  }
260
- if ( isset( $v[ 'PluginURI' ] ) ) {
261
- $formatted[ 'plugin_uri' ] = strip_tags( $v[ 'PluginURI' ] );
262
  }
263
  if ( in_array( $k, $active_plugins_keys ) ) {
264
  // Remove active plugins from list so we can show active and inactive separately
@@ -269,14 +280,18 @@ class Wcal_TS_Tracker {
269
  }
270
  }
271
 
272
- return array( 'active_plugins' => $active_plugins, 'inactive_plugins' => $plugins );
 
 
 
273
  }
274
-
275
  /**
276
  * Sends current WooCommerce version
 
277
  * @return string
278
  */
279
  private static function ts_get_wc_plugin_version() {
280
  return WC()->version;
281
  }
282
- }
1
  <?php
2
  /**
3
  * The tracker class adds functionality to track usage of the plugin based on if the customer opted in.
4
+ * No personal information is tracked, only general settings, order and user counts and admin email for
5
  * discount code.
6
  *
7
+ * @class Wcal_TS_Tracker
8
+ * @version 6.8
9
  */
10
 
11
  if ( ! defined( 'ABSPATH' ) ) {
16
 
17
  /**
18
  * URL to the Tracker API endpoint.
19
+ *
20
  * @var string
21
  */
22
 
23
  private static $api_url = 'http://tracking.tychesoftwares.com/v1/';
24
 
25
  /**
26
+ * @var string Plugin prefix
27
+ * @access public
28
+ */
29
 
30
  public static $plugin_prefix = '';
31
 
32
  /**
33
+ * @var string Plugin name
34
+ * @access public
35
+ */
36
 
37
  public static $plugin_name = '';
38
 
44
  self::$plugin_prefix = $ts_plugin_prefix;
45
  self::$plugin_name = $ts_plugin_name;
46
 
47
+ add_action( self::$plugin_prefix . '_ts_tracker_send_event', array( __CLASS__, 'ts_send_tracking_data' ) );
48
  }
49
 
50
  /**
66
  return;
67
  }
68
  }
69
+
70
+ $allow_tracking = get_option( self::$plugin_prefix . '_allow_tracking' );
71
  if ( 'yes' == $allow_tracking ) {
72
+ $override = true;
73
  }
74
+
75
  // Update time first before sending to ensure it is set
76
  update_option( 'ts_tracker_last_send', time() );
77
 
78
+ if ( $override == false ) {
79
+ $params = array();
80
+ $params['tracking_usage'] = 'no';
81
+ $params['url'] = home_url();
82
+ $params['email'] = '';
83
+
84
+ $params = apply_filters( 'ts_tracker_opt_out_data', $params );
85
  } else {
86
+ $params = self::ts_get_tracking_data();
87
  }
88
+
89
+ wp_safe_remote_post(
90
+ self::$api_url,
91
+ array(
92
  'method' => 'POST',
93
  'timeout' => 45,
94
  'redirection' => 5,
98
  'body' => json_encode( $params ),
99
  'cookies' => array(),
100
  )
101
+ );
102
  }
103
 
104
  /**
105
  * Get the last time tracking data was sent.
106
+ *
107
  * @return int|bool
108
  */
109
  private static function ts_get_last_send_time() {
112
 
113
  /**
114
  * Get all the tracking data.
115
+ *
116
  * @return array
117
  */
118
  private static function ts_get_tracking_data() {
119
+ $data = array();
120
 
121
  // General site info
122
+ $data['url'] = home_url();
123
+ $data['email'] = apply_filters( 'ts_tracker_admin_email', get_option( 'admin_email' ) );
124
 
125
  // WordPress Info
126
+ $data['wp'] = self::ts_get_wordpress_info();
127
 
128
+ $data['theme_info'] = self::ts_get_theme_info();
129
 
130
  // Server Info
131
+ $data['server'] = self::ts_get_server_info();
132
 
133
  // Plugin info
134
+ $all_plugins = self::ts_get_all_plugins();
135
+ $data['active_plugins'] = $all_plugins['active_plugins'];
136
+ $data['inactive_plugins'] = $all_plugins['inactive_plugins'];
 
 
 
137
 
138
+ // WooCommerce version
139
+ $data['wc_plugin_version'] = self::ts_get_wc_plugin_version();
140
 
 
141
  return apply_filters( 'ts_tracker_data', $data );
142
  }
143
 
144
  /**
145
  * Get Selected city of the WooCommerce store.
146
+ *
147
  * @return string $ts_city Name of the city
148
  */
149
+ private static function ts_get_wc_city() {
150
+ $ts_city = get_option( 'woocommerce_store_city' );
151
  return $ts_city;
152
  }
153
 
154
  /**
155
  * Get Selected country of the WooCommerce store.
156
+ *
157
  * @return string $ts_country Name of the city
158
  */
159
+ private static function ts_get_wc_country() {
160
+ $ts_country = get_option( 'woocommerce_default_country' );
161
  return $ts_country;
162
  }
163
+
164
  /**
165
  * Get WordPress related data.
166
+ *
167
  * @return array
168
  */
169
  private static function ts_get_wordpress_info() {
176
  $memory = max( $memory, $system_memory );
177
  }
178
 
179
+ $wp_data['memory_limit'] = size_format( $memory );
180
+ $wp_data['debug_mode'] = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? 'Yes' : 'No';
181
+ $wp_data['locale'] = get_locale();
182
+ $wp_data['wp_version'] = get_bloginfo( 'version' );
183
+ $wp_data['multisite'] = is_multisite() ? 'Yes' : 'No';
184
+ $wp_data['blogdescription'] = get_option( 'blogdescription' );
185
+ $wp_data['blogname'] = get_option( 'blogname' );
186
+ $wp_data['wc_city'] = self::ts_get_wc_city();
187
+ $wp_data['wc_country'] = self::ts_get_wc_country();
188
 
189
  return $wp_data;
190
  }
191
 
192
  /**
193
  * Get the current theme info, theme name and version.
194
+ *
195
  * @return array
196
  */
197
  public static function ts_get_theme_info() {
198
  $theme_data = wp_get_theme();
199
  $theme_child_theme = is_child_theme() ? 'Yes' : 'No';
200
 
201
+ return array(
202
+ 'theme_name' => $theme_data->Name,
203
+ 'theme_version' => $theme_data->Version,
204
+ 'child_theme' => $theme_child_theme,
205
+ );
206
  }
207
 
208
  /**
209
  * Get server related info.
210
+ *
211
  * @return array
212
  */
213
  private static function ts_get_server_info() {
214
  global $wpdb;
215
  $server_data = array();
216
 
217
+ if ( isset( $_SERVER['SERVER_SOFTWARE'] ) && ! empty( $_SERVER['SERVER_SOFTWARE'] ) ) {
218
+ $server_data['software'] = $_SERVER['SERVER_SOFTWARE'];
219
  }
220
 
221
  if ( function_exists( 'phpversion' ) ) {
222
+ $server_data['php_version'] = phpversion();
223
  }
224
 
225
  if ( function_exists( 'ini_get' ) ) {
226
+ $server_data['php_post_max_size'] = size_format( wc_let_to_num( ini_get( 'post_max_size' ) ) );
227
+ $server_data['php_time_limt'] = ini_get( 'max_execution_time' );
228
+ $server_data['php_max_input_vars'] = ini_get( 'max_input_vars' );
229
+ $server_data['php_suhosin'] = extension_loaded( 'suhosin' ) ? 'Yes' : 'No';
230
  }
231
 
232
+ $server_data['mysql_version'] = $wpdb->db_version();
233
 
234
+ $server_data['php_max_upload_size'] = size_format( wp_max_upload_size() );
235
+ $server_data['php_default_timezone'] = date_default_timezone_get();
236
+ $server_data['php_soap'] = class_exists( 'SoapClient' ) ? 'Yes' : 'No';
237
+ $server_data['php_fsockopen'] = function_exists( 'fsockopen' ) ? 'Yes' : 'No';
238
+ $server_data['php_curl'] = function_exists( 'curl_init' ) ? 'Yes' : 'No';
239
 
240
  return $server_data;
241
  }
242
 
243
  /**
244
  * Get all plugins grouped into activated or not.
245
+ *
246
  * @return array
247
  */
248
  private static function ts_get_all_plugins() {
251
  include ABSPATH . '/wp-admin/includes/plugin.php';
252
  }
253
 
254
+ $plugins = get_plugins();
255
  $active_plugins_keys = get_option( 'active_plugins', array() );
256
+ $active_plugins = array();
257
 
258
  foreach ( $plugins as $k => $v ) {
259
  // Take care of formatting the data how we want it.
260
+ $formatted = array();
261
+ $formatted['name'] = strip_tags( $v['Name'] );
262
+ if ( isset( $v['Version'] ) ) {
263
+ $formatted['version'] = strip_tags( $v['Version'] );
264
  }
265
+ if ( isset( $v['Author'] ) ) {
266
+ $formatted['author'] = strip_tags( $v['Author'] );
267
  }
268
+ if ( isset( $v['Network'] ) ) {
269
+ $formatted['network'] = strip_tags( $v['Network'] );
270
  }
271
+ if ( isset( $v['PluginURI'] ) ) {
272
+ $formatted['plugin_uri'] = strip_tags( $v['PluginURI'] );
273
  }
274
  if ( in_array( $k, $active_plugins_keys ) ) {
275
  // Remove active plugins from list so we can show active and inactive separately
280
  }
281
  }
282
 
283
+ return array(
284
+ 'active_plugins' => $active_plugins,
285
+ 'inactive_plugins' => $plugins,
286
+ );
287
  }
288
+
289
  /**
290
  * Sends current WooCommerce version
291
+ *
292
  * @return string
293
  */
294
  private static function ts_get_wc_plugin_version() {
295
  return WC()->version;
296
  }
297
+ }
includes/component/tracking-data/ts-tracking.php CHANGED
@@ -3,7 +3,7 @@ if ( ! defined( 'ABSPATH' ) ) {
3
  exit;
4
  }
5
 
6
- include_once( 'class-ts-tracker.php' );
7
 
8
  /** Adds the Tracking non-senstive data notice
9
  *
@@ -13,12 +13,12 @@ class Wcal_TS_tracking {
13
 
14
  /**
15
  * @var string Plugin prefix
16
- * @access public
17
  */
18
 
19
  public static $plugin_prefix = '';
20
 
21
- /**
22
  * @var string Plugin Name
23
  * @access public
24
  */
@@ -49,7 +49,7 @@ class Wcal_TS_tracking {
49
  * @var string File path
50
  * @access public
51
  */
52
- public static $ts_file_path = '' ;
53
  /**
54
  * @var string plugin locale
55
  * @access public
@@ -77,33 +77,32 @@ class Wcal_TS_tracking {
77
  * @access public
78
  */
79
  public static $ts_register_setting = '';
80
- /**
81
- * Default Constructor
82
- *
83
  */
84
  public function __construct( $ts_plugin_prefix = '', $ts_plugin_name = '', $ts_blog_post_link = '', $ts_plugin_context = '', $ts_plugin_url = '', $setting_page = '', $add_setting = '', $setting_section = '', $setting_register = '' ) {
85
 
86
- self::$plugin_prefix = $ts_plugin_prefix;
87
- self::$plugin_name = $ts_plugin_name;
88
- self::$blog_post_link = $ts_blog_post_link;
89
- self::$plugin_url = $ts_plugin_url;
90
- self::$ts_plugin_locale = $ts_plugin_context;
91
- self::$ts_settings_page = $setting_page;
92
- self::$ts_add_setting_on_page = $add_setting;
93
  self::$ts_add_setting_on_section = $setting_section;
94
- self::$ts_register_setting = $setting_register;
95
 
96
- self::$ts_file_path = untrailingslashit( plugins_url( '/', __FILE__) ) ;
97
- //Tracking Data
98
  add_action( 'admin_notices', array( 'Wcal_TS_tracking', 'ts_track_usage_data' ) );
99
- add_action( 'admin_footer', array( 'Wcal_TS_tracking', 'ts_admin_notices_scripts' ) );
100
- add_action( 'wp_ajax_'.self::$plugin_prefix.'_admin_notices', array( 'Wcal_TS_tracking', 'ts_admin_notices' ) );
101
 
102
  add_filter( 'cron_schedules', array( 'Wcal_TS_tracking', 'ts_add_cron_schedule' ) );
103
 
104
  add_action( self::$plugin_prefix . '_add_new_settings', array( 'Wcal_TS_tracking', 'ts_add_reset_tracking_setting' ) );
105
 
106
- add_action ( 'admin_init', array( 'Wcal_TS_tracking', 'ts_reset_tracking_setting' ) ) ;
107
 
108
  self::ts_schedule_cron_job();
109
  }
@@ -111,9 +110,9 @@ class Wcal_TS_tracking {
111
  /**
112
  * It will delete the tracking option from the database.
113
  */
114
- public static function ts_reset_tracking_setting () {
115
 
116
- if ( isset ( $_GET [ 'ts_action' ] ) && 'wcal_reset_tracking' == $_GET [ 'ts_action' ] ) {
117
  delete_option( self::$plugin_prefix . '_allow_tracking' );
118
  delete_option( 'ts_tracker_last_send' );
119
  $ts_url = remove_query_arg( 'ts_action' );
@@ -123,14 +122,14 @@ class Wcal_TS_tracking {
123
 
124
  /**
125
  * It will add the settinig, which will allow store owner to reset the tracking data. Which will result into stop trakcing the data.
 
126
  * @hook self::$plugin_prefix . '_add_new_settings'
127
- *
128
  */
129
- public static function ts_add_reset_tracking_setting () {
130
-
131
  add_settings_field(
132
  'ts_reset_tracking',
133
- __( 'Reset usage tracking', self::$ts_plugin_locale ),
134
  array( 'Wcal_TS_tracking', 'ts_rereset_tracking_callback' ),
135
  self::$ts_add_setting_on_page,
136
  self::$ts_add_setting_on_section,
@@ -143,47 +142,49 @@ class Wcal_TS_tracking {
143
  );
144
  }
145
 
146
- public static function ts_reset_tracking_setting_section_callback ( ) {
147
 
148
  }
149
 
150
  /**
151
  * It will add the Reset button on the settings page.
 
152
  * @param array $args
153
  */
154
- public static function ts_rereset_tracking_callback ( $args ) {
155
  $wcap_restrict_domain_address = get_option( 'wcap_restrict_domain_address' );
156
  $domain_value = isset( $wcap_restrict_domain_address ) ? esc_attr( $wcap_restrict_domain_address ) : '';
157
  // Next, we update the name attribute to access this element's ID in the context of the display options array
158
  // We also access the show_header element of the options collection in the call to the checked() helper function
159
- $ts_action = self::$ts_settings_page . "&amp;ts_action=" . self::$plugin_prefix . "_reset_tracking";
160
- printf( '<a href="'.$ts_action.'" class="button button-large reset_tracking">Reset</a>' );
161
-
162
  // Here, we'll take the first argument of the array and add it to a label next to the checkbox
163
- $html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
164
  echo $html;
165
  }
166
 
167
  /**
168
  * It will add a cron job for sending the tarcking data.
169
  * By default it will set once in a week interval.
170
- * @hook cron_schedules
 
171
  * @param array $schedules
172
  * @return array $schedules
173
  */
174
  public static function ts_add_cron_schedule( $schedules ) {
175
- $schedules[ 'once_in_week' ] = array(
176
  'interval' => 604800, // one week in seconds
177
- 'display' => __( 'Once in a Week', self::$ts_plugin_locale )
178
  );
179
-
180
  return $schedules;
181
  }
182
 
183
  /**
184
  * To capture the data from the client site.
185
  */
186
- public static function ts_schedule_cron_job () {
187
  if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
188
  wp_schedule_event( time() + 604800, 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
189
  }
@@ -196,65 +197,68 @@ class Wcal_TS_tracking {
196
  * @access public
197
  */
198
  public static function ts_admin_notices_scripts() {
199
-
200
- wp_enqueue_script(
201
  self::$plugin_prefix . 'ts_dismiss_notice',
202
  self::$ts_file_path . '/assets/js/dismiss-notice.js',
203
- '',
204
- '',
205
- false
206
  );
207
 
208
- wp_localize_script( 'ts_dismiss_notice', 'ts_dismiss_notice', array (
209
- 'ts_prefix_of_plugin' => self::$plugin_prefix,
210
- 'ts_admin_url' => admin_url( 'admin-ajax.php' )
211
- ) );
 
 
 
 
212
  }
213
 
214
- /**
215
- * Called when the dismiss icon is clicked on the notice.
216
  *
217
  * @since 6.8
218
  * @access public
219
  */
220
 
221
- public static function ts_admin_notices() {
222
- update_option( self::$plugin_prefix . '_allow_tracking', 'dismissed' );
223
- Wcal_TS_Tracker::ts_send_tracking_data( false );
224
- die();
225
- }
226
 
227
  /**
228
  * Send the data tracking data to the server.
229
- *
230
  * @access public
231
- *
232
  */
233
 
234
  private static function ts_tracking_actions() {
235
  if ( isset( $_GET[ self::$plugin_prefix . '_tracker_optin' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optin' ) ) {
236
  update_option( self::$plugin_prefix . '_allow_tracking', 'yes' );
237
  Wcal_TS_Tracker::ts_send_tracking_data( true );
238
- header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
239
  } elseif ( isset( $_GET[ self::$plugin_prefix . '_tracker_optout' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optout' ) ) {
240
  update_option( self::$plugin_prefix . '_allow_tracking', 'no' );
241
  Wcal_TS_Tracker::ts_send_tracking_data( false );
242
- header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
243
  }
244
  }
245
 
246
  /**
247
  * Adds a data usage tracking notice in the admin
248
- *
249
  * @access public
250
  * @since 6.8
251
  */
252
-
253
  public static function ts_track_usage_data() {
254
  global $current_screen;
255
  $current_screen = get_current_screen();
256
- if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() )
257
- || ( function_exists('is_gutenberg_page') && is_gutenberg_page() ) ) {
258
  return;
259
  }
260
 
@@ -271,6 +275,7 @@ class Wcal_TS_tracking {
271
  <a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( self::$plugin_prefix . '_tracker_optout', 'true' ), self::$plugin_prefix . '_tracker_optout', self::$plugin_prefix . '_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', self::$plugin_context ); ?></a>
272
  </p>
273
  </div>
274
- <?php endif;
 
275
  }
276
- }
3
  exit;
4
  }
5
 
6
+ require_once 'class-ts-tracker.php';
7
 
8
  /** Adds the Tracking non-senstive data notice
9
  *
13
 
14
  /**
15
  * @var string Plugin prefix
16
+ * @access public
17
  */
18
 
19
  public static $plugin_prefix = '';
20
 
21
+ /**
22
  * @var string Plugin Name
23
  * @access public
24
  */
49
  * @var string File path
50
  * @access public
51
  */
52
+ public static $ts_file_path = '';
53
  /**
54
  * @var string plugin locale
55
  * @access public
77
  * @access public
78
  */
79
  public static $ts_register_setting = '';
80
+ /**
81
+ * Default Constructor
 
82
  */
83
  public function __construct( $ts_plugin_prefix = '', $ts_plugin_name = '', $ts_blog_post_link = '', $ts_plugin_context = '', $ts_plugin_url = '', $setting_page = '', $add_setting = '', $setting_section = '', $setting_register = '' ) {
84
 
85
+ self::$plugin_prefix = $ts_plugin_prefix;
86
+ self::$plugin_name = $ts_plugin_name;
87
+ self::$blog_post_link = $ts_blog_post_link;
88
+ self::$plugin_url = $ts_plugin_url;
89
+ self::$ts_plugin_locale = $ts_plugin_context;
90
+ self::$ts_settings_page = $setting_page;
91
+ self::$ts_add_setting_on_page = $add_setting;
92
  self::$ts_add_setting_on_section = $setting_section;
93
+ self::$ts_register_setting = $setting_register;
94
 
95
+ self::$ts_file_path = untrailingslashit( plugins_url( '/', __FILE__ ) );
96
+ // Tracking Data
97
  add_action( 'admin_notices', array( 'Wcal_TS_tracking', 'ts_track_usage_data' ) );
98
+ add_action( 'admin_footer', array( 'Wcal_TS_tracking', 'ts_admin_notices_scripts' ) );
99
+ add_action( 'wp_ajax_' . self::$plugin_prefix . '_admin_notices', array( 'Wcal_TS_tracking', 'ts_admin_notices' ) );
100
 
101
  add_filter( 'cron_schedules', array( 'Wcal_TS_tracking', 'ts_add_cron_schedule' ) );
102
 
103
  add_action( self::$plugin_prefix . '_add_new_settings', array( 'Wcal_TS_tracking', 'ts_add_reset_tracking_setting' ) );
104
 
105
+ add_action( 'admin_init', array( 'Wcal_TS_tracking', 'ts_reset_tracking_setting' ) );
106
 
107
  self::ts_schedule_cron_job();
108
  }
110
  /**
111
  * It will delete the tracking option from the database.
112
  */
113
+ public static function ts_reset_tracking_setting() {
114
 
115
+ if ( isset( $_GET ['ts_action'] ) && 'wcal_reset_tracking' == $_GET ['ts_action'] ) {
116
  delete_option( self::$plugin_prefix . '_allow_tracking' );
117
  delete_option( 'ts_tracker_last_send' );
118
  $ts_url = remove_query_arg( 'ts_action' );
122
 
123
  /**
124
  * It will add the settinig, which will allow store owner to reset the tracking data. Which will result into stop trakcing the data.
125
+ *
126
  * @hook self::$plugin_prefix . '_add_new_settings'
 
127
  */
128
+ public static function ts_add_reset_tracking_setting() {
129
+
130
  add_settings_field(
131
  'ts_reset_tracking',
132
+ __( 'Reset usage tracking', self::$ts_plugin_locale ),
133
  array( 'Wcal_TS_tracking', 'ts_rereset_tracking_callback' ),
134
  self::$ts_add_setting_on_page,
135
  self::$ts_add_setting_on_section,
142
  );
143
  }
144
 
145
+ public static function ts_reset_tracking_setting_section_callback() {
146
 
147
  }
148
 
149
  /**
150
  * It will add the Reset button on the settings page.
151
+ *
152
  * @param array $args
153
  */
154
+ public static function ts_rereset_tracking_callback( $args ) {
155
  $wcap_restrict_domain_address = get_option( 'wcap_restrict_domain_address' );
156
  $domain_value = isset( $wcap_restrict_domain_address ) ? esc_attr( $wcap_restrict_domain_address ) : '';
157
  // Next, we update the name attribute to access this element's ID in the context of the display options array
158
  // We also access the show_header element of the options collection in the call to the checked() helper function
159
+ $ts_action = self::$ts_settings_page . '&amp;ts_action=' . self::$plugin_prefix . '_reset_tracking';
160
+ printf( '<a href="' . $ts_action . '" class="button button-large reset_tracking">Reset</a>' );
161
+
162
  // Here, we'll take the first argument of the array and add it to a label next to the checkbox
163
+ $html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
164
  echo $html;
165
  }
166
 
167
  /**
168
  * It will add a cron job for sending the tarcking data.
169
  * By default it will set once in a week interval.
170
+ *
171
+ * @hook cron_schedules
172
  * @param array $schedules
173
  * @return array $schedules
174
  */
175
  public static function ts_add_cron_schedule( $schedules ) {
176
+ $schedules['once_in_week'] = array(
177
  'interval' => 604800, // one week in seconds
178
+ 'display' => __( 'Once in a Week', self::$ts_plugin_locale ),
179
  );
180
+
181
  return $schedules;
182
  }
183
 
184
  /**
185
  * To capture the data from the client site.
186
  */
187
+ public static function ts_schedule_cron_job() {
188
  if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
189
  wp_schedule_event( time() + 604800, 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
190
  }
197
  * @access public
198
  */
199
  public static function ts_admin_notices_scripts() {
200
+
201
+ wp_enqueue_script(
202
  self::$plugin_prefix . 'ts_dismiss_notice',
203
  self::$ts_file_path . '/assets/js/dismiss-notice.js',
204
+ '',
205
+ '',
206
+ false
207
  );
208
 
209
+ wp_localize_script(
210
+ 'ts_dismiss_notice',
211
+ 'ts_dismiss_notice',
212
+ array(
213
+ 'ts_prefix_of_plugin' => self::$plugin_prefix,
214
+ 'ts_admin_url' => admin_url( 'admin-ajax.php' ),
215
+ )
216
+ );
217
  }
218
 
219
+ /**
220
+ * Called when the dismiss icon is clicked on the notice.
221
  *
222
  * @since 6.8
223
  * @access public
224
  */
225
 
226
+ public static function ts_admin_notices() {
227
+ update_option( self::$plugin_prefix . '_allow_tracking', 'dismissed' );
228
+ Wcal_TS_Tracker::ts_send_tracking_data( false );
229
+ die();
230
+ }
231
 
232
  /**
233
  * Send the data tracking data to the server.
234
+ *
235
  * @access public
 
236
  */
237
 
238
  private static function ts_tracking_actions() {
239
  if ( isset( $_GET[ self::$plugin_prefix . '_tracker_optin' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optin' ) ) {
240
  update_option( self::$plugin_prefix . '_allow_tracking', 'yes' );
241
  Wcal_TS_Tracker::ts_send_tracking_data( true );
242
+ header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
243
  } elseif ( isset( $_GET[ self::$plugin_prefix . '_tracker_optout' ] ) && isset( $_GET[ self::$plugin_prefix . '_tracker_nonce' ] ) && wp_verify_nonce( $_GET[ self::$plugin_prefix . '_tracker_nonce' ], self::$plugin_prefix . '_tracker_optout' ) ) {
244
  update_option( self::$plugin_prefix . '_allow_tracking', 'no' );
245
  Wcal_TS_Tracker::ts_send_tracking_data( false );
246
+ header( 'Location: ' . $_SERVER['HTTP_REFERER'] );
247
  }
248
  }
249
 
250
  /**
251
  * Adds a data usage tracking notice in the admin
252
+ *
253
  * @access public
254
  * @since 6.8
255
  */
256
+
257
  public static function ts_track_usage_data() {
258
  global $current_screen;
259
  $current_screen = get_current_screen();
260
+ if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() )
261
+ || ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) ) {
262
  return;
263
  }
264
 
275
  <a class="button-secondary button button-large skip" href="<?php echo esc_url( wp_nonce_url( add_query_arg( self::$plugin_prefix . '_tracker_optout', 'true' ), self::$plugin_prefix . '_tracker_optout', self::$plugin_prefix . '_tracker_nonce' ) ); ?>"><?php esc_html_e( 'No thanks', self::$plugin_context ); ?></a>
276
  </p>
277
  </div>
278
+ <?php
279
+ endif;
280
  }
281
+ }
includes/component/welcome-page/Instructions DELETED
@@ -1,37 +0,0 @@
1
- Welcome page feature allows you to add an introduction page when a plugin is installed and active for the first time or when it is updated.
2
-
3
- To add this feature to the plugin, you can follow the below steps:
4
-
5
- 1. Copy the ts-welcome.php file into your plugin folder.
6
-
7
- 2. Copy the files in the template folder to template in the plugin.
8
-
9
- 3. Include the file once when on the admin page. This can be done with is_admin() function.
10
-
11
- 4. You need to pass the 6 parameters to the default constructor of the TS_Welcome class. You need to change the value of the variable value as per the respective plugin.
12
-
13
- $wcap_plugin_prefix = 'wcap';
14
- $wcap_plugin_name = 'Abandoned Cart Pro for WooCommerce';
15
- $wcap_blog_post_link = 'https://www.tychesoftwares.com/order-delivery-date-usage-tracking/';
16
- $wcap_locale = 'woocommerce-ac';
17
- define('WCAP_PLUGIN_PATH' , untrailingslashit(plugin_dir_path(__FILE__)) );
18
- $wcap_plugin_folder_name = 'woocommerce-abandon-cart-pro/';
19
- $wcap_plugin_dir_name = WCAP_PLUGIN_PATH . '/woocommerce-ac.php' ;
20
- $wcap_get_previous_version = get_option( 'woocommerce_ac_db_version' );
21
-
22
- new TS_Welcome ( $wcap_plugin_name, $wcap_plugin_prefix, $wcap_locale, $wcap_plugin_folder_name, $wcap_plugin_dir_name, $wcap_get_previous_version );
23
-
24
- 5. Add the below code in the uninstall.php file of the plugin.
25
-
26
- delete_option( '{{plugin-prefix}}_pro_welcome_page_shown' );
27
- delete_option( '{{plugin-prefix}}_pro_welcome_page_shown_time' );
28
-
29
- 6. You need to update the Template as per your update of the plguin. You just need to update the template content.
30
-
31
- Note:
32
-
33
- 1. Please put your all images in the images folder of this folder.
34
- 2. You can use the $ts_dir_image_path for img src. Like <img src="<?php echo $ts_dir_image_path . 'custom-delivery-settings.png'?>"
35
- 3. Please change the Utm parameters
36
-
37
- You just need to append the image name.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/component/welcome-page/assets/images/abandon-cart-cut-off-time.png DELETED
Binary file
includes/component/welcome-page/assets/images/abandoned-cart-lite-email-templates.png DELETED
Binary file
includes/component/welcome-page/assets/images/email-templates-send-time.png DELETED
Binary file
includes/component/welcome-page/assets/images/icon-256x256.png DELETED
Binary file
includes/component/welcome-page/assets/images/site-logo-new.jpg DELETED
Binary file
includes/component/welcome-page/templates/social-media-elements.php DELETED
@@ -1,24 +0,0 @@
1
- <?php
2
- /**
3
- * Welcome page on activate or updation of the plugin
4
- */
5
- ?>
6
- <div class="social-items-wrap">
7
- <iframe src="//www.facebook.com/plugins/like.php?href=https%3A%2F%2Fwww.facebook.com%2Ftychesoftwares&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=false&amp;font&amp;colorscheme=light&amp;action=like&amp;height=21&amp;appId=220596284639969" scrolling="no" frameborder="0" style="border:none;overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe>
8
- <a href="https://twitter.com/tychesoftwares" class="twitter-follow-button" data-show-count="false"><?php
9
- printf(
10
- esc_html_e( 'Follow %s', 'tychesoftwares' ),
11
- '@tychesoftwares'
12
- );
13
- ?></a>
14
- <script>!function (d, s, id) {
15
- var js, fjs = d.getElementsByTagName(s)[0], p = /^http:/.test(d.location) ? 'http' : 'https';
16
- if (!d.getElementById(id)) {
17
- js = d.createElement(s);
18
- js.id = id;
19
- js.src = p + '://platform.twitter.com/widgets.js';
20
- fjs.parentNode.insertBefore(js, fjs);
21
- }
22
- }(document, 'script', 'twitter-wjs');
23
- </script>
24
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/component/welcome-page/templates/welcome/welcome-page.php DELETED
@@ -1,130 +0,0 @@
1
- <?php
2
- /**
3
- * Welcome page on activate or updation of the plugin
4
- */
5
- ?>
6
- <style>
7
- .feature-section .feature-section-item {
8
- float:left;
9
- width:48%;
10
- }
11
- </style>
12
-
13
- <div class="wrap about-wrap">
14
- <?php echo $get_welcome_header; ?>
15
- <div style="float:left;width: 80%;">
16
- <p class="about-text" style="margin-right:20px;"><?php
17
- printf(
18
- __( "Thank you for activating or updating to the latest version of " . $plugin_name . "! If you're a first time user, welcome! You're well to accept deliveries with customer preferred delivery date." )
19
- );
20
- ?>
21
- </p>
22
- </div>
23
-
24
- <div class="wcal-badge"><img src="<?php echo $badge_url; ?>" style="width:150px;"/></div>
25
-
26
- <p>&nbsp;</p>
27
-
28
- <div class="feature-section clearfix introduction">
29
-
30
- <h3><?php esc_html_e( "Get Started with Abandoned Cart Lite", 'woocommerce-abandoned-cart' ); ?></h3>
31
-
32
- <div class="video feature-section-item" style="float:left;padding-right:10px;">
33
- <img src="<?php echo $ts_dir_image_path . 'abandoned-cart-lite-email-templates.png' ?>"
34
- alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-abandoned-cart' ); ?>" style="width:600px;">
35
- </div>
36
-
37
- <div class="content feature-section-item last-feature">
38
- <h3><?php esc_html_e( 'Activate Email Template', 'woocommerce-abandoned-cart' ); ?></h3>
39
-
40
- <p><?php esc_html_e( 'To start sending out abandoned cart notification emails, simply activate the email template from under WooCommerce -> Abandoned Carts -> Email Templates page.', 'woocommerce-abandoned-cart' ); ?></p>
41
- <a href="admin.php?page=woocommerce_ac_page&action=emailtemplates" target="_blank" class="button-secondary">
42
- <?php esc_html_e( 'Click Here to go to Email Templates page', 'woocommerce-abandoned-cart' ); ?>
43
- <span class="dashicons dashicons-external"></span>
44
- </a>
45
- </div>
46
- </div>
47
-
48
- <!-- /.intro-section -->
49
-
50
- <div class="content">
51
-
52
- <h3><?php esc_html_e( "Know more about Abandoned Cart Pro", 'woocommerce-abandoned-cart' ); ?></h3>
53
-
54
- <p><?php _e( 'The Abandoned Cart Pro plugin gives you features where you are able to recover more sales compared to the Lite plugin. Here are some notable features the Pro version provides.' ); ?></p>
55
-
56
- <div class="feature-section clearfix introduction">
57
-
58
- <div class="content feature-section-item last-feature">
59
- <h3><?php esc_html_e( 'Capture Visitor Emails on click of Add to Cart button', 'woocommerce-abandoned-cart' ); ?></h3>
60
-
61
- <p><?php esc_html_e( 'The ability to capture the email address early in the order process is very important to reduce cart abandonment by unknown users as well as to be able to recover their carts if they abandon it. This ultimately leads to increase in your store sales.', 'woocommerce-abandoned-cart' ); ?></p>
62
- <a href="https://www.tychesoftwares.com/capture-guest-user-email-address-before-checkout-page-with-woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
63
- <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
64
- <span class="dashicons dashicons-external"></span>
65
- </a>
66
- </div>
67
- </div>
68
-
69
- <div class="feature-section clearfix">
70
- <div class="content feature-section-item">
71
-
72
- <h3><?php esc_html_e( 'Set different cut-off times for visitors & logged-in users', 'woocommerce-abandoned-cart' ); ?></h3>
73
-
74
- <p><?php esc_html_e( 'The provision for setting two separate cut-off times for different roles is mainly because sometimes if the store admin wants the visitor carts to be captured earlier than the registered user carts, then these different settings can play an important role.', 'woocommerce-abandoned-cart' ); ?></p>
75
- <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/capturing-abandoned-carts/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
76
- <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
77
- <span class="dashicons dashicons-external"></span>
78
- </a>
79
- </div>
80
-
81
- <div class="content feature-section-item last-feature">
82
- <img src="<?php echo $ts_dir_image_path . 'abandon-cart-cut-off-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-abandoned-cart' ); ?>" style="width:450px;">
83
- </div>
84
- </div>
85
-
86
-
87
- <div class="feature-section clearfix introduction">
88
- <div class="video feature-section-item" style="float:left;padding-right:10px;">
89
- <img src="<?php echo $ts_dir_image_path . 'email-templates-send-time.png'; ?>" alt="<?php esc_attr_e( 'WooCommerce Abandoned Cart Lite', 'woocommerce-abandoned-cart' ); ?>" style="width:450px;">
90
- </div>
91
-
92
- <div class="content feature-section-item last-feature">
93
- <h3><?php esc_html_e( 'Send abandoned cart recovery email in minutes of cart being abandoned', 'woocommerce-abandoned-cart' ); ?></h3>
94
-
95
- <p><?php esc_html_e( 'The ability to send the abandoned cart recovery email within first few minutes of cart being abandoned is a big advantage. In the Lite plugin, the earliest an email can be sent is after 1 hour. Whereas in the Pro version, the first recovery email gets sent 15 minutes after the cart is abandoned. This increases the recovery chances manifold.', 'woocommerce-abandoned-cart' ); ?></p>
96
- <a href="https://www.tychesoftwares.com/docs/docs/abandoned-cart-pro-for-woocommerce/default-email-templates/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=AbandonedCartLitePlugin" target="_blank" class="button-secondary">
97
- <?php esc_html_e( 'Learn More', 'woocommerce-abandoned-cart' ); ?>
98
- <span class="dashicons dashicons-external"></span>
99
- </a>
100
- </div>
101
- </div>
102
- </div>
103
-
104
- <div class="feature-section clearfix">
105
- <div class="content feature-section-item">
106
- <h3><?php esc_html_e( 'Getting to Know Tyche Softwares', 'woocommerce-ac' ); ?></h3>
107
- <ul class="ul-disc">
108
- <li><a href="https://tychesoftwares.com/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank"><?php esc_html_e( 'Visit the Tyche Softwares Website', 'woocommerce-ac' ); ?></a></li>
109
- <li><a href="https://tychesoftwares.com/premium-plugins/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank"><?php esc_html_e( 'View all Premium Plugins', 'woocommerce-ac' ); ?></a>
110
- <ul class="ul-disc">
111
- <li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-abandoned-cart-pro/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank">Abandoned Cart Pro Plugin for WooCommerce</a></li>
112
- <li><a href="https://www.tychesoftwares.com/store/premium-plugins/woocommerce-booking-plugin/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank">Booking & Appointment Plugin for WooCommerce</a></li>
113
- <li><a href="https://www.tychesoftwares.com/store/premium-plugins/order-delivery-date-for-woocommerce-pro-21/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank">Order Delivery Date for WooCommerce</a></li>
114
- <li><a href="https://www.tychesoftwares.com/store/premium-plugins/product-delivery-date-pro-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank">Product Delivery Date for WooCommerce</a></li>
115
- <li><a href="https://www.tychesoftwares.com/store/premium-plugins/deposits-for-woocommerce/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank">Deposits for WooCommerce</a></li>
116
- </ul>
117
- </li>
118
- <li><a href="https://tychesoftwares.com/about/?utm_source=wpaboutpage&utm_medium=link&utm_campaign=OrderDeliveryDateProPlugin" target="_blank"><?php esc_html_e( 'Meet the team', $plugin_context ); ?></a></li>
119
- </ul>
120
-
121
- </div>
122
-
123
- <div class="content feature-section-item">
124
- <h3><?php esc_html_e( 'Current Offers', $plugin_context ); ?></h3>
125
- <p>We do not have any offers going on right now</p>
126
- </div>
127
-
128
- </div>
129
- <!-- /.feature-section -->
130
- </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/component/welcome-page/ts-welcome.php DELETED
@@ -1,275 +0,0 @@
1
- <?php
2
-
3
- /**
4
- * Welcome Page Class
5
- *
6
- * Displays on plugin activation or updation
7
- */
8
-
9
- // Exit if accessed directly.
10
- if ( ! defined( 'ABSPATH' ) ) {
11
- exit;
12
- }
13
-
14
- /**
15
- * Wcal_TS_Welcome Class
16
- *
17
- * A general class for About page.
18
- *
19
- * @since 7.7
20
- */
21
-
22
- class Wcal_TS_Welcome {
23
-
24
- /**
25
- * @var string The capability users should have to view the page
26
- */
27
- public $minimum_capability = 'manage_options';
28
-
29
- /**
30
- * @var string The name of the plugin
31
- * @access public
32
- */
33
- public static $plugin_name = "";
34
-
35
- /**
36
- * @var string Unique prefix of the plugin
37
- * @access public
38
- */
39
-
40
- public static $plugin_prefix = '';
41
-
42
- /**
43
- * @var Plugin Context
44
- * @access public
45
- */
46
-
47
- public static $plugin_context = '';
48
-
49
- /**
50
- * @var string Folder of the plugin
51
- * @access public
52
- */
53
- public static $plugin_folder = '';
54
-
55
- /**
56
- * @var string Plugin live version
57
- * @access public
58
- */
59
-
60
- public static $plugin_version = '';
61
-
62
- /**
63
- * @var string Plugin previous version
64
- * @access public
65
- */
66
- public static $previous_plugin_version = '';
67
- /**
68
- * @var string Plugin Url
69
- * @access public
70
- */
71
- public static $plugin_url = '';
72
- /**
73
- * @var string Template base path
74
- * @access public
75
- */
76
- public static $template_base = '';
77
- /**
78
- * @var string Plugin dir name with plugin file name
79
- * @access public
80
- */
81
- public static $plugin_file_path = '';
82
- /**
83
- * Get things started
84
- *
85
- * @since 7.7
86
- */
87
- public function __construct( $ts_plugin_name = '', $ts_plugin_prefix = '', $ts_plugin_context = '', $ts_plugin_folder_name = '', $ts_plugin_dir_name = '' , $ts_previous_version = '' ) {
88
- self::$plugin_name = $ts_plugin_name;
89
- self::$plugin_prefix = $ts_plugin_prefix;
90
- self::$plugin_context = $ts_plugin_context;
91
- self::$plugin_folder = $ts_plugin_folder_name;
92
- self::$plugin_file_path = $ts_plugin_dir_name;
93
-
94
- //Update plugin
95
- add_action( 'admin_init', array( &$this, 'ts_update_db_check' ) );
96
-
97
- add_action( 'admin_menu', array( $this, 'admin_menus' ) );
98
- add_action( 'admin_head', array( $this, 'admin_head' ) );
99
-
100
- if ( !isset( $_GET[ 'page' ] ) ||
101
- ( isset( $_GET[ 'page' ] ) && $_GET[ 'page' ] != self::$plugin_prefix . '-pro-about' ) ) {
102
- add_action( 'admin_init', array( $this, 'ts_pro_welcome' ) );
103
- }
104
-
105
- self::$plugin_version = $this->ts_get_version();
106
-
107
- self::$previous_plugin_version = $ts_previous_version;
108
- self::$plugin_url = $this->ts_get_plugin_url();
109
- self::$template_base = $this->ts_get_template_path();
110
- }
111
-
112
- /**
113
- * This function returns the plugin version number.
114
- *
115
- * @access public
116
- * @since 7.7
117
- * @return $plugin_version
118
- */
119
- public function ts_get_version() {
120
- $plugin_version = '';
121
-
122
- $plugin_data = get_file_data( self::$plugin_file_path, array( 'Version' => 'Version' ) );
123
- if ( ! empty( $plugin_data['Version'] ) ) {
124
- $plugin_version = $plugin_data[ 'Version' ];
125
- }
126
- return $plugin_version;;
127
- }
128
-
129
- /**
130
- * This function returns the plugin url
131
- *
132
- * @access public
133
- * @since 7.7
134
- * @return string
135
- */
136
- public function ts_get_plugin_url() {
137
- return plugins_url() . '/' . self::$plugin_folder . '/';
138
- }
139
-
140
- /**
141
- * This function returns the template directory path
142
- *
143
- * @access public
144
- * @since 7.7
145
- * @return string
146
- */
147
- public function ts_get_template_path() {
148
-
149
- return untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/';
150
- }
151
-
152
- /**
153
- * Register the Dashboard Page which is later hidden but this pages
154
- * is used to render the Welcome page.
155
- *
156
- * @access public
157
- * @since 7.7
158
- * @return void
159
- */
160
- public function admin_menus() {
161
- $display_version = self::$plugin_version;
162
-
163
- // About Page
164
- add_dashboard_page(
165
- sprintf( esc_html__( 'Welcome to %s %s', self::$plugin_context ), self::$plugin_name, $display_version ),
166
- esc_html__( 'Welcome to ' . self::$plugin_name, self::$plugin_context ),
167
- $this->minimum_capability,
168
- self::$plugin_prefix . '-pro-about',
169
- array( $this, 'about_screen' )
170
- );
171
-
172
- }
173
-
174
- /**
175
- * Hide Individual Dashboard Pages
176
- *
177
- * @access public
178
- * @since 7.7
179
- * @return void
180
- */
181
- public function admin_head() {
182
- remove_submenu_page( 'index.php', self::$plugin_prefix . '-pro-about' );
183
- }
184
-
185
- /**
186
- * Render About Screen
187
- *
188
- * @access public
189
- * @since 7.7
190
- * @return void
191
- */
192
- public function about_screen() {
193
- $display_version = self::$plugin_version;
194
- $ts_file_path = plugin_dir_url( __FILE__ ) ;
195
- // Badge for welcome page
196
- $badge_url = $ts_file_path . '/assets/images/icon-256x256.png';
197
- /*
198
- ob_start();
199
- wc_get_template( 'welcome/welcome-page.php', array(
200
- 'plugin_name' => self::$plugin_name,
201
- 'plugin_url' => self::$plugin_url,
202
- 'display_version' => $display_version,
203
- 'badge_url' => $badge_url,
204
- 'ts_dir_image_path' => $ts_file_path . '/assets/images/',
205
- 'plugin_context' => self::$plugin_context,
206
- 'get_welcome_header' => $this->get_welcome_header()
207
- ), self::$plugin_folder, self::$template_base );
208
- echo ob_get_clean();
209
- */
210
- add_option( self::$plugin_prefix . '_pro_welcome_page_shown', 'yes' );
211
- add_option( self::$plugin_prefix . '_pro_welcome_page_shown_time', current_time( 'timestamp' ) );
212
- }
213
-
214
- /**
215
- * The header section for the welcome screen.
216
- *
217
- * @since 7.7
218
- */
219
- public function get_welcome_header() {
220
- // Badge for welcome page
221
- $ts_file_path = plugin_dir_url( __FILE__ ) ;
222
-
223
- // Badge for welcome page
224
- $badge_url = $ts_file_path . '/assets/images/icon-256x256.png';
225
- ?>
226
- <h1 class="welcome-h1"><?php echo get_admin_page_title(); ?></h1>
227
- <?php $this->social_media_elements();
228
- }
229
-
230
- /**
231
- * Social Media Like Buttons
232
- *
233
- * Various social media elements to Tyche Softwares
234
- */
235
- public function social_media_elements() {
236
- ob_start();
237
- wc_get_template( '/social-media-elements.php',
238
- array(),
239
- self::$plugin_folder,
240
- self::$template_base );
241
- echo ob_get_clean();
242
- }
243
- /**
244
- * Sends user to the Welcome page on first activation of the plugin as well as each
245
- * time the plugin is updated is upgraded to a new version
246
- *
247
- * @access public
248
- * @since 7.7
249
- *
250
- * @return void
251
- */
252
- public function ts_pro_welcome() {
253
-
254
- // Bail if activating from network, or bulk
255
- if ( is_network_admin() || isset( $_GET[ 'activate-multi' ] ) ) {
256
- return;
257
- }
258
-
259
- if( !get_option( self::$plugin_prefix . '_pro_welcome_page_shown' ) ) {
260
- wp_safe_redirect( admin_url( 'index.php?page=' . self::$plugin_prefix . '-pro-about' ) );
261
- exit;
262
- }
263
- }
264
-
265
- /**
266
- * Executed when the plugin is updated using the Automatic Updater.
267
- */
268
- public function ts_update_db_check() {
269
-
270
- if ( self::$plugin_version != self::$previous_plugin_version ) {
271
- delete_option( self::$plugin_prefix . '_pro_welcome_page_shown' );
272
- delete_option( self::$plugin_prefix . '_pro_welcome_page_shown_time' );
273
- }
274
- }
275
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
includes/component/woocommerce-check/ts-woo-active.php CHANGED
@@ -5,6 +5,7 @@ if ( ! defined( 'ABSPATH' ) ) {
5
 
6
  /**
7
  * Wcal_TS_Woo_Active Class
 
8
  * @class Wcal_TS_Woo_Active
9
  */
10
 
@@ -18,6 +19,7 @@ class Wcal_TS_Woo_Active {
18
 
19
  /**
20
  * Store the plugin name.
 
21
  * @var string Path of the plugin name.
22
  * @access public
23
  */
@@ -25,18 +27,19 @@ class Wcal_TS_Woo_Active {
25
 
26
  /**
27
  * Store the plguin locale.
 
28
  * @var string Used Plugin locale.
29
  * @access public
30
  */
31
  public $ts_locale = '';
32
 
33
- public function __construct( $ts_plugin_name = '' , $ts_file_name = '', $ts_locale = '' ) {
34
 
35
  $this->plugin_name = $ts_plugin_name;
36
  $this->plugin_file = $ts_file_name;
37
  $this->ts_locale = $ts_locale;
38
-
39
- //Check for WooCommerce plugin
40
  if ( '' != $this->plugin_file ) {
41
  add_action( 'admin_init', array( &$this, 'ts_check_if_woocommerce_active' ) );
42
  }
@@ -47,13 +50,13 @@ class Wcal_TS_Woo_Active {
47
  */
48
  public function ts_check_if_woocommerce_active() {
49
  if ( ! $this->ts_check_woo_installed() ) {
50
- if ( is_plugin_active( $this->plugin_file ) ) {
51
- deactivate_plugins( $this->plugin_file );
52
- add_action( 'admin_notices', array( &$this, 'ts_disabled_notice' ) );
53
- if ( isset( $_GET[ 'activate' ] ) ) {
54
- unset( $_GET[ 'activate' ] );
55
- }
56
- }
57
  }
58
  }
59
 
@@ -61,11 +64,11 @@ class Wcal_TS_Woo_Active {
61
  * Check if WooCommerce is active.
62
  */
63
  public function ts_check_woo_installed() {
64
- if ( class_exists( 'WooCommerce' ) ) {
65
- return true;
66
- } else {
67
- return false;
68
- }
69
  }
70
 
71
  /**
@@ -74,12 +77,12 @@ class Wcal_TS_Woo_Active {
74
  public function ts_disabled_notice() {
75
  global $current_screen;
76
  $current_screen = get_current_screen();
77
- if ( ( method_exists($current_screen, 'is_block_editor') && $current_screen->is_block_editor() )
78
- || ( function_exists('is_gutenberg_page') && is_gutenberg_page() ) ) {
79
  return;
80
  }
81
- $class = 'notice notice-error';
82
  $message = __( $this->plugin_name . ' plugin requires WooCommerce installed and activate.', $this->ts_locale );
83
  printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
84
  }
85
- }
5
 
6
  /**
7
  * Wcal_TS_Woo_Active Class
8
+ *
9
  * @class Wcal_TS_Woo_Active
10
  */
11
 
19
 
20
  /**
21
  * Store the plugin name.
22
+ *
23
  * @var string Path of the plugin name.
24
  * @access public
25
  */
27
 
28
  /**
29
  * Store the plguin locale.
30
+ *
31
  * @var string Used Plugin locale.
32
  * @access public
33
  */
34
  public $ts_locale = '';
35
 
36
+ public function __construct( $ts_plugin_name = '', $ts_file_name = '', $ts_locale = '' ) {
37
 
38
  $this->plugin_name = $ts_plugin_name;
39
  $this->plugin_file = $ts_file_name;
40
  $this->ts_locale = $ts_locale;
41
+
42
+ // Check for WooCommerce plugin
43
  if ( '' != $this->plugin_file ) {
44
  add_action( 'admin_init', array( &$this, 'ts_check_if_woocommerce_active' ) );
45
  }
50
  */
51
  public function ts_check_if_woocommerce_active() {
52
  if ( ! $this->ts_check_woo_installed() ) {
53
+ if ( is_plugin_active( $this->plugin_file ) ) {
54
+ deactivate_plugins( $this->plugin_file );
55
+ add_action( 'admin_notices', array( &$this, 'ts_disabled_notice' ) );
56
+ if ( isset( $_GET['activate'] ) ) {
57
+ unset( $_GET['activate'] );
58
+ }
59
+ }
60
  }
61
  }
62
 
64
  * Check if WooCommerce is active.
65
  */
66
  public function ts_check_woo_installed() {
67
+ if ( class_exists( 'WooCommerce' ) ) {
68
+ return true;
69
+ } else {
70
+ return false;
71
+ }
72
  }
73
 
74
  /**
77
  public function ts_disabled_notice() {
78
  global $current_screen;
79
  $current_screen = get_current_screen();
80
+ if ( ( method_exists( $current_screen, 'is_block_editor' ) && $current_screen->is_block_editor() )
81
+ || ( function_exists( 'is_gutenberg_page' ) && is_gutenberg_page() ) ) {
82
  return;
83
  }
84
+ $class = 'notice notice-error';
85
  $message = __( $this->plugin_name . ' plugin requires WooCommerce installed and activate.', $this->ts_locale );
86
  printf( '<div class="%1$s"><p>%2$s</p></div>', $class, $message );
87
  }
88
+ }
includes/frontend/{wcal_checkout_process.php → class-wcal-checkout-process.php} RENAMED
@@ -3,9 +3,10 @@
3
  * Checkout Process for Abandoned Cart Lite
4
  *
5
  * @since 5.3.0
 
6
  */
7
 
8
- // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit;
11
  }
@@ -13,13 +14,16 @@ if ( ! defined( 'ABSPATH' ) ) {
13
  if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
14
 
15
  /**
16
- * Process recovered orders
17
  */
18
  class Wcal_Checkout_Process {
19
 
20
- function __construct() {
 
 
 
21
 
22
- // delete added temp fields after order is placed
23
  add_filter( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
24
 
25
  add_action( 'woocommerce_order_status_changed', array( &$this, 'wcal_update_cart_details' ), 10, 3 );
@@ -34,12 +38,12 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
34
  * recovered or not.
35
  *
36
  * @hook woocommerce_order_details_after_order_table
37
- * @param array | object $order Order details
38
  * @globals mixed $wpdb
39
  * @globals mixed $woocommerce
40
  * @since 1.0
41
  */
42
- function wcal_action_after_delivery_session( $order ) {
43
 
44
  $order_id = $order->get_id();
45
 
@@ -48,23 +52,17 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
48
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
49
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
50
 
51
- if ( isset( $get_sent_email_id_of_order ) && '' != $get_sent_email_id_of_order ) {
52
- /**
53
- * When Placed order button is clicked,
54
- * we create post meta for that order.
55
- * If that meta is found then update our plugin table for recovered cart
56
- */
57
  $this->wcal_updated_recovered_cart_table( $get_abandoned_id_of_order, $order_id, $get_sent_email_id_of_order, $order );
58
- } elseif ( '' != $get_abandoned_id_of_order && isset( $get_abandoned_id_of_order ) ) {
59
- /**
60
- * if order status is not pending or failed then
61
- * we will delete the abandoned cart record.
62
- * post meta will be created only if the cut off time has been reached.
63
- */
64
  $this->wcal_delete_abanadoned_data_on_order_status( $order_id, $get_abandoned_id_of_order, $wcal_get_order_status );
65
  }
66
 
67
- if ( wcal_common::wcal_get_cart_session( 'email_sent_id' ) != '' ) {
68
  wcal_common::wcal_unset_cart_session( 'email_sent_id' );
69
  }
70
  }
@@ -72,14 +70,14 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
72
  /**
73
  * If customer had placed the order after cut off time and reached the order recived page then it will also delete the abandoned cart if the order status is not pending or failed.
74
  *
75
- * @param int | string $order_id Order id
76
- * @param int | string $get_abandoned_id_of_order Abandoned cart id
77
- * @param string $wcal_get_order_status Order status
78
  * @globals mixed $wpdb
79
  * @globals mixed $woocommerce
80
  * @since 5.0
81
  */
82
- function wcal_delete_abanadoned_data_on_order_status( $order_id, $get_abandoned_id_of_order, $wcal_get_order_status ) {
83
 
84
  global $wpdb, $woocommerce;
85
 
@@ -87,13 +85,12 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
87
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
88
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
89
 
90
- if ( 'pending' != $wcal_get_order_status || 'failed' != $wcal_get_order_status ) {
91
- if ( isset( $get_abandoned_id_of_order ) && '' != $get_abandoned_id_of_order ) {
92
-
93
- $user_id_query = "SELECT user_id FROM `$wcal_history_table_name` WHERE id = %d";
94
  $user_id_results = $wpdb->get_results(
95
  $wpdb->prepare(
96
- $user_id_query,
97
  $get_abandoned_id_of_order
98
  )
99
  );
@@ -102,10 +99,16 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
102
  $wcal_user_id = $user_id_results[0]->user_id;
103
 
104
  if ( $wcal_user_id >= 63000000 ) {
105
- $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id ) );
 
 
 
106
  }
107
 
108
- $wpdb->delete( $wcal_history_table_name, array( 'id' => $get_abandoned_id_of_order ) );
 
 
 
109
  delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
110
  }
111
  }
@@ -117,14 +120,14 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
117
  * Email Sent History table to indicate the order has been
118
  * recovered
119
  *
120
- * @param integer $cart_id - ID of the Abandoned Cart
121
- * @param integer $order_id - Recovered Order ID
122
  * @param integer $wcal_check_email_sent_to_cart - ID of the record in the Email Sent History table.
123
- * @param WC_Order $order - Order Details
124
  *
125
  * @since 7.7
126
  */
127
- function wcal_updated_recovered_cart_table( $cart_id, $order_id, $wcal_check_email_sent_to_cart, $order ) {
128
 
129
  global $wpdb;
130
 
@@ -132,21 +135,20 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
132
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
133
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
134
 
135
- // check & make sure that the recovered cart details are not already updated
136
- $query_status = "SELECT recovered_cart FROM `$wcal_history_table_name` WHERE id = %d";
137
-
138
  $get_status = $wpdb->get_col(
139
  $wpdb->prepare(
140
- $query_status,
141
  $cart_id
142
  )
143
  );
144
 
145
  $recovered_status = isset( $get_status[0] ) ? $get_status[0] : '';
146
 
147
- if ( $recovered_status == 0 ) {
148
 
149
- // Update the cart history table
150
  $update_details = array(
151
  'recovered_cart' => $order_id,
152
  'cart_ignored' => '1',
@@ -154,51 +156,67 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
154
 
155
  $current_user_id = get_current_user_id();
156
 
157
- if ( $current_user_id !== wcal_common::wcal_get_cart_session( 'user_id' ) &&
158
- $current_user_id != 0 ) {
159
  $update_details['user_id'] = $current_user_id;
160
  }
161
 
162
- // check if more than one reminder email has been sent
163
- $check_emails = "SELECT abandoned_order_id FROM `$wcal_sent_email_table_name` WHERE id = %d";
164
- $get_old_cart_id = $wpdb->get_col(
165
  $wpdb->prepare(
166
- $check_emails,
167
  $wcal_check_email_sent_to_cart
168
  )
169
  );
170
 
171
  $get_ids = array();
172
  if ( isset( $get_old_cart_id ) ) {
173
- $query_ids = "SELECT id FROM `$wcal_sent_email_table_name` WHERE abandoned_order_id = %d";
174
- $get_ids = $wpdb->get_col( $wpdb->prepare( $query_ids, $get_old_cart_id ) );
 
 
 
 
 
175
  }
176
 
177
  $update_sent_history = array();
178
 
179
- if ( get_post_meta( $order_id, 'wcal_abandoned_timestamp', true ) != '' ) {
180
  $update_details['abandoned_cart_time'] = get_post_meta( $order_id, 'wcal_abandoned_timestamp', true );
181
 
182
  $update_sent_history['abandoned_order_id'] = $cart_id;
183
 
184
  delete_post_meta( $order_id, 'wcal_abandoned_timestamp', $update_details['abandoned_cart_time'] );
185
  }
 
 
 
 
 
 
 
 
186
 
187
- $wpdb->update( $wcal_history_table_name, $update_details, array( 'id' => $cart_id ) );
188
-
189
- // update the email sent history table
190
  if ( is_array( $get_ids ) && count( $get_ids ) > 1 ) {
191
  $list_ids = implode( ',', $get_ids );
192
- $wpdb->query( "UPDATE `$wcal_sent_email_table_name` SET abandoned_order_id = $cart_id WHERE id IN ($list_ids)" );
 
 
 
 
 
193
  } elseif ( isset( $update_sent_history['abandoned_order_id'] ) ) {
194
- $wpdb->update(
195
  $wcal_sent_email_table_name,
196
  $update_sent_history,
197
- array( 'id' => $wcal_check_email_sent_to_cart )
 
 
198
  );
199
  }
200
 
201
- // Add Order Note
202
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
203
  delete_post_meta( $order_id, 'wcal_abandoned_cart_id' );
204
  delete_post_meta( $order_id, 'wcal_recover_order_placed' );
@@ -211,19 +229,16 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
211
  * Send email to admin when cart is recovered only via PayPal.
212
  *
213
  * @hook woocommerce_order_status_changed
214
- * @param int | string $order_id Order id
215
- * @param string $wc_old_status Old status
216
- * @param string $wc_new_status New status
217
  * @globals mixed $wpdb
218
  * @globals mixed $woocommerce
219
  * @since 2.9
220
  */
221
  public function wcal_update_cart_details( $order_id, $wc_old_status, $wc_new_status ) {
222
 
223
- if ( 'pending' != $wc_new_status &&
224
- 'failed' != $wc_new_status &&
225
- 'cancelled' != $wc_new_status &&
226
- 'trash' != $wc_new_status ) {
227
 
228
  global $wpdb;
229
 
@@ -234,17 +249,16 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
234
  if ( $order_id > 0 ) {
235
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
236
 
237
- if ( $get_abandoned_id_of_order > 0 || wcal_common::wcal_get_cart_session( 'email_sent_id' ) != '' ) {
238
- // recovered order
239
  } else {
240
 
241
  $wcal_abandoned_id = get_post_meta( $order_id, 'wcal_abandoned_cart_id', true );
242
-
243
- // check if it's a guest cart
244
- $query_cart_data = "SELECT user_id, user_type FROM `$wcal_history_table_name` WHERE id = %d";
245
- $get_cart_data = $wpdb->get_results(
246
  $wpdb->prepare(
247
- $query_cart_data,
248
  $wcal_abandoned_id
249
  )
250
  );
@@ -253,20 +267,27 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
253
  $user_type = $get_cart_data[0]->user_type;
254
  $user_id = $get_cart_data[0]->user_id;
255
 
256
- if ( 'GUEST' == $user_type && $user_id >= 63000000 ) {
257
- $wpdb->delete( $wcal_guest_table_name, array( 'id' => $user_id ) );
 
 
 
258
  }
259
  }
260
- $wpdb->delete( $wcal_history_table_name, array( 'id' => $wcal_abandoned_id ) );
261
  }
262
  }
263
- } elseif ( 'pending' == $wc_old_status && 'cancelled' == $wc_new_status ) {
264
  global $wpdb;
265
 
266
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
267
  $wcal_abandoned_id = get_post_meta( $order_id, 'wcal_abandoned_cart_id', true );
268
 
269
- $wpdb->update( $wcal_history_table_name, array( 'cart_ignored' => '1' ), array( 'id' => $wcal_abandoned_id ) );
 
 
 
 
270
  }
271
  }
272
 
@@ -274,20 +295,20 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
274
  * This function will send the email to the store admin when any abandoned cart email recovered.
275
  *
276
  * @hook woocommerce_order_status_changed
277
- * @param int | string $order_id Order id
278
- * @param string $wcap_old_status Old status of the order
279
- * @param string $wcap_new_status New status of the order
280
  * @globals mixed $woocommerce
281
  * @since 1.0
282
  */
283
- function wcal_send_recovery_email( $order_id, $wcap_old_status, $wcap_new_status ) {
284
  global $woocommerce;
285
 
286
- if ( ( 'pending' == $wcap_old_status && 'processing' == $wcap_new_status )
287
- || ( 'pending' == $wcap_old_status && 'completed' == $wcap_new_status )
288
- || ( 'pending' == $wcap_old_status && 'on-hold' == $wcap_new_status )
289
- || ( 'failed' == $wcap_old_status && 'completed' == $wcap_new_status )
290
- || ( 'failed' == $wcap_old_status && 'processing' == $wcap_new_status )
291
  ) {
292
  $user_id = get_current_user_id();
293
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
@@ -297,11 +318,11 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
297
  } else {
298
  $user_id = $order->user_id;
299
  }
300
- if ( $ac_email_admin_recovery == 'on' ) {
301
  $recovered_email_sent = get_post_meta( $order_id, 'wcal_recovered_email_sent', true );
302
  $wcal_check_order_is_recovered = $this->wcal_check_order_is_recovered( $order_id );
303
 
304
- if ( 'yes' != $recovered_email_sent && true === $wcal_check_order_is_recovered ) { // indicates cart is abandoned
305
  $order = wc_get_order( $order_id );
306
  $email_heading = __( 'New Customer Order - Recovered', 'woocommerce' );
307
  $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
@@ -309,9 +330,9 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
309
  $user_email = get_option( 'admin_email' );
310
  $headers[] = 'From: Admin <' . $user_email . '>';
311
  $headers[] = 'Content-Type: text/html';
312
- // Buffer
313
  ob_start();
314
- // Get mail template
315
  wc_get_template(
316
  'emails/admin-new-order.php',
317
  array(
@@ -322,7 +343,7 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
322
  'email' => true,
323
  )
324
  );
325
- // Get contents
326
  $email_body = ob_get_clean();
327
  wc_mail( $user_email, $email_subject, $email_body, $headers );
328
 
@@ -335,15 +356,20 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
335
  /**
336
  * For sending Recovery Email to Admin, we will check that order is recovered or not.
337
  *
338
- * @param int | string $wcal_order_id Order id
339
  * @return boolean true | false
340
  * @globals mixed $wpdb
341
  * @since 2.3
342
  */
343
- function wcal_check_order_is_recovered( $wcal_order_id ) {
344
  global $wpdb;
345
- $wcal_recover_order_query = 'SELECT recovered_cart FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE recovered_cart = %d';
346
- $wcal_recover_order_query_result = $wpdb->get_results( $wpdb->prepare( $wcal_recover_order_query, $wcal_order_id ) );
 
 
 
 
 
347
  if ( count( $wcal_recover_order_query_result ) > 0 ) {
348
  return true;
349
  }
@@ -356,8 +382,8 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
356
  * It will be executed after order placed.
357
  *
358
  * @hook woocommerce_payment_complete_order_status
359
- * @param string $order_status Order Status
360
- * @param int | string $order_id Order Id
361
  * @return string $order_status
362
  * @globals mixed $wpdb
363
  * @since 3.4
@@ -371,25 +397,22 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
371
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
372
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
373
 
374
- // Order Status passed in the function is either
375
- // 'processing' or 'complete' and may or may not reflect the actual order status.
376
  // Hence, always use the status fetched from the order object.
377
-
378
  $order_status = ( $order ) ? $order->get_status() : '';
379
 
380
  $wcal_ac_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
381
  $wcal_email_sent_history_table_name = $wpdb->prefix . 'ac_sent_history_lite';
382
  $wcal_guest_ac_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
383
 
384
- if ( 'pending' != $order_status && 'failed' != $order_status && 'cancelled' != $order_status && 'trash' != $order_status ) {
385
  global $wpdb;
386
 
387
- if ( isset( $get_abandoned_id_of_order ) && '' != $get_abandoned_id_of_order ) {
388
 
389
- $ac_user_id_query = "SELECT user_id, abandoned_cart_time FROM `$wcal_ac_table_name` WHERE id = %d";
390
- $ac_user_id_result = $wpdb->get_results(
391
  $wpdb->prepare(
392
- $ac_user_id_query,
393
  $get_abandoned_id_of_order
394
  )
395
  );
@@ -400,21 +423,24 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
400
  if ( $wcal_user_id >= 63000000 ) {
401
  add_post_meta( $order_id, 'wcal_abandoned_timestamp', $ac_user_id_result[0]->abandoned_cart_time );
402
 
403
- $wpdb->delete( $wcal_guest_ac_table_name, array( 'id' => $wcal_user_id ) );
 
 
 
404
  }
405
 
406
- $wpdb->delete( $wcal_ac_table_name, array( 'id' => $get_abandoned_id_of_order ) );
 
 
 
407
  delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
408
  }
409
  }
410
  }
411
 
412
- if ( 'pending' != $woo_order_status &&
413
- 'failed' != $woo_order_status &&
414
- 'cancelled' != $woo_order_status &&
415
- 'trash' != $woo_order_status ) {
416
 
417
- if ( isset( $get_sent_email_id_of_order ) && '' != $get_sent_email_id_of_order ) {
418
  $this->wcal_updated_recovered_cart( $get_abandoned_id_of_order, $order_id, $get_sent_email_id_of_order, $order );
419
  }
420
  }
@@ -427,14 +453,14 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
427
  * Email Sent History table to indicate the order has been
428
  * recovered
429
  *
430
- * @param integer $cart_id - ID of the Abandoned Cart
431
- * @param integer $order_id - Recovered Order ID
432
  * @param integer $wcal_check_email_sent_to_cart - ID of the record in the Email Sent History table.
433
- * @param WC_Order $order - Order Details
434
  *
435
  * @since 5.3.0
436
  */
437
- function wcal_updated_recovered_cart( $cart_id, $order_id, $wcal_check_email_sent_to_cart, $order ) {
438
 
439
  global $wpdb;
440
 
@@ -442,15 +468,18 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
442
  $wcal_email_sent_table = $wpdb->prefix . 'ac_sent_history_lite';
443
  $wcal_guest_ac_table = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
444
 
445
- // check & make sure that the recovered cart details are not already updated
446
- $query_status = "SELECT recovered_cart FROM `$wcal_ac_table_name` WHERE id = %d";
447
-
448
- $get_status = $wpdb->get_col( $wpdb->prepare( $query_status, $cart_id ) );
 
 
 
449
 
450
  $recovered_status = isset( $get_status[0] ) ? $get_status[0] : '';
451
 
452
- if ( $recovered_status == 0 ) {
453
- // Update the cart history table
454
  $update_details = array(
455
  'recovered_cart' => $order_id,
456
  'cart_ignored' => '1',
@@ -458,24 +487,31 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
458
 
459
  $current_user_id = get_current_user_id();
460
 
461
- if ( $current_user_id !== wcal_common::wcal_get_cart_session( 'user_id' ) &&
462
- $current_user_id != 0 ) {
463
  $update_details['user_id'] = $current_user_id;
464
  }
465
 
466
- // check if more than one reminder email has been sent
467
- $check_emails = "SELECT abandoned_order_id FROM `$wcal_email_sent_table` WHERE id = %d";
468
- $get_old_cart_id = $wpdb->get_col( $wpdb->prepare( $check_emails, $wcal_check_email_sent_to_cart ) );
 
 
 
 
469
 
470
  $get_ids = array();
471
  if ( isset( $get_old_cart_id ) ) {
472
- $query_ids = "SELECT id FROM `$wcal_email_sent_table` WHERE abandoned_order_id = %d";
473
- $get_ids = $wpdb->get_col( $wpdb->prepare( $query_ids, $get_old_cart_id ) );
 
 
 
 
474
  }
475
 
476
  $update_sent_history = array();
477
 
478
- if ( get_post_meta( $order_id, 'wcal_abandoned_timestamp', true ) != '' ) {
479
  $update_details['abandoned_cart_time'] = get_post_meta( $order_id, 'wcal_abandoned_timestamp', true );
480
 
481
  $update_sent_history['abandoned_order_id'] = $cart_id;
@@ -483,21 +519,31 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
483
  delete_post_meta( $order_id, 'wcal_abandoned_timestamp', $update_details['abandoned_cart_time'] );
484
  }
485
 
486
- $wpdb->update( $wcal_ac_table_name, $update_details, array( 'id' => $cart_id ) );
 
 
 
 
487
 
488
- // update the email sent history table
489
  if ( is_array( $get_ids ) && count( $get_ids ) > 1 ) {
490
  $list_ids = implode( ',', $get_ids );
491
- $wpdb->query( "UPDATE `$wcal_email_sent_table` SET abandoned_order_id = $cart_id WHERE id IN ($list_ids)" );
 
 
 
 
 
 
492
  } elseif ( isset( $update_sent_history['abandoned_order_id'] ) ) {
493
- $wpdb->update(
494
  $wcal_email_sent_table,
495
  $update_sent_history,
496
  array( 'id' => $wcal_check_email_sent_to_cart )
497
  );
498
  }
499
 
500
- // Add Order Note
501
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
502
  delete_post_meta( $order_id, 'wcal_abandoned_cart_id' );
503
  delete_post_meta( $order_id, 'wcal_recover_order_placed' );
@@ -511,13 +557,13 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
511
  * delete it.
512
  *
513
  * @hook woocommerce_checkout_order_processed
514
- * @param int | string $order_id Order id
515
  * @globals mixed $wpdb
516
  * @globals mixed $woocommerce
517
  *
518
  * @since 3.4
519
  */
520
- function wcal_order_placed( $order_id ) {
521
 
522
  global $wpdb;
523
  $email_sent_id = wcal_common::wcal_get_cart_session( 'email_sent_id' );
@@ -529,14 +575,13 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
529
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
530
 
531
  $abandoned_order_id_to_save = $abandoned_order_id;
532
- if ( $email_sent_id != '' && $email_sent_id > 0 ) { // recovered cart
533
 
534
- if ( $abandoned_order_id == '' || $abandoned_order_id == false ) {
535
 
536
- $get_ac_id_query = "SELECT abandoned_order_id FROM `$wcal_sent_email_table_name` WHERE id = %d";
537
- $get_ac_id_results = $wpdb->get_results(
538
  $wpdb->prepare(
539
- $get_ac_id_query,
540
  $email_sent_id
541
  )
542
  );
@@ -544,20 +589,19 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
544
  $abandoned_order_id_to_save = $get_ac_id_results[0]->abandoned_order_id;
545
  }
546
 
547
- // if user becomes the registered user
548
- if ( ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) ||
549
- ( isset( $_POST['createaccount'] ) && $_POST['createaccount'] != '' ) ||
550
- ( ! isset( $_POST['createaccount'] ) && 'no' == get_option( 'woocommerce_enable_guest_checkout' ) ) ) {
551
 
552
- if ( $abandoned_order_id != '' && $wcal_user_id_of_guest != '' ) {
553
  $abandoned_cart_id_new_user = $abandoned_order_id;
554
 
555
- // delete the guest record. As it become the logged in user
556
- $get_ac_id_guest_query = "SELECT id, abandoned_cart_time FROM `$wcal_history_table_name` WHERE user_id = %d ORDER BY id DESC";
557
- $get_ac_id_guest_results = $wpdb->get_results(
558
  $wpdb->prepare(
559
- $get_ac_id_guest_query,
560
- $wcal_user_id_of_guest
561
  )
562
  );
563
 
@@ -566,30 +610,36 @@ if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
566
 
567
  add_post_meta( $order_id, 'wcal_abandoned_timestamp', $get_ac_id_guest_results[0]->abandoned_cart_time );
568
 
569
- $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
570
- $wpdb->delete( $wcal_history_table_name, array( 'id' => $get_ac_id_guest_results[0]->id ) );
 
 
 
 
 
 
571
  }
572
- // it is the new registered users cart id
573
  $abandoned_order_id_to_save = $abandoned_cart_id_new_user;
574
  }
575
  }
576
 
577
  add_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', $email_sent_id );
578
  add_post_meta( $order_id, 'wcal_recover_order_placed', $abandoned_order_id );
579
- } elseif ( $abandoned_order_id != '' ) {
580
 
581
- if ( ( isset( $_POST['account_password'] ) && $_POST['account_password'] != '' ) ||
582
- ( isset( $_POST['createaccount'] ) && $_POST['createaccount'] != '' ) ||
583
- ( ! isset( $_POST['createaccount'] ) && 'no' == get_option( 'woocommerce_enable_guest_checkout' ) ) ) {
584
 
585
- if ( $abandoned_order_id != '' && $wcal_user_id_of_guest != '' ) {
586
  $abandoned_cart_id_new_user = $abandoned_order_id;
587
 
588
- // delete the guest record. As it become the logged in user
589
- $wpdb->delete( $wcal_history_table_name, array( 'user_id' => $wcal_user_id_of_guest ) );
590
- $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) );
591
 
592
- // it is the new registered users cart id
593
  $abandoned_order_id_to_save = $abandoned_cart_id_new_user;
594
  }
595
  }
3
  * Checkout Process for Abandoned Cart Lite
4
  *
5
  * @since 5.3.0
6
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Checkout Process
7
  */
8
 
9
+ // Exit if accessed directly.
10
  if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
14
  if ( ! class_exists( 'Wcal_Checkout_Process' ) ) {
15
 
16
  /**
17
+ * Process recovered orders.
18
  */
19
  class Wcal_Checkout_Process {
20
 
21
+ /**
22
+ * Constructor.
23
+ */
24
+ public function __construct() {
25
 
26
+ // Delete added temp fields after order is placed.
27
  add_filter( 'woocommerce_order_details_after_order_table', array( &$this, 'wcal_action_after_delivery_session' ) );
28
 
29
  add_action( 'woocommerce_order_status_changed', array( &$this, 'wcal_update_cart_details' ), 10, 3 );
38
  * recovered or not.
39
  *
40
  * @hook woocommerce_order_details_after_order_table
41
+ * @param array | object $order Order details.
42
  * @globals mixed $wpdb
43
  * @globals mixed $woocommerce
44
  * @since 1.0
45
  */
46
+ public function wcal_action_after_delivery_session( $order ) {
47
 
48
  $order_id = $order->get_id();
49
 
52
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
53
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
54
 
55
+ if ( isset( $get_sent_email_id_of_order ) && '' !== $get_sent_email_id_of_order ) {
56
+
57
+ // When Placed order button is clicked, we create post meta for that order, If that meta is found then update our plugin table for recovered cart.
 
 
 
58
  $this->wcal_updated_recovered_cart_table( $get_abandoned_id_of_order, $order_id, $get_sent_email_id_of_order, $order );
59
+ } elseif ( '' !== $get_abandoned_id_of_order && isset( $get_abandoned_id_of_order ) ) {
60
+
61
+ // If order status is not pending or failed then, we will delete the abandoned cart record. Post meta will be created only if the cut off time has been reached.
 
 
 
62
  $this->wcal_delete_abanadoned_data_on_order_status( $order_id, $get_abandoned_id_of_order, $wcal_get_order_status );
63
  }
64
 
65
+ if ( '' != wcal_common::wcal_get_cart_session( 'email_sent_id' ) ) { // phpcs:ignore
66
  wcal_common::wcal_unset_cart_session( 'email_sent_id' );
67
  }
68
  }
70
  /**
71
  * If customer had placed the order after cut off time and reached the order recived page then it will also delete the abandoned cart if the order status is not pending or failed.
72
  *
73
+ * @param int | string $order_id Order id.
74
+ * @param int | string $get_abandoned_id_of_order Abandoned cart id.
75
+ * @param string $wcal_get_order_status Order status.
76
  * @globals mixed $wpdb
77
  * @globals mixed $woocommerce
78
  * @since 5.0
79
  */
80
+ public function wcal_delete_abanadoned_data_on_order_status( $order_id, $get_abandoned_id_of_order, $wcal_get_order_status ) {
81
 
82
  global $wpdb, $woocommerce;
83
 
85
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
86
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
87
 
88
+ if ( 'pending' !== $wcal_get_order_status || 'failed' !== $wcal_get_order_status ) {
89
+ if ( isset( $get_abandoned_id_of_order ) && '' !== $get_abandoned_id_of_order ) {
90
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
 
91
  $user_id_results = $wpdb->get_results(
92
  $wpdb->prepare(
93
+ 'SELECT user_id FROM `' . $wcal_history_table_name . '` WHERE id = %d', // phpcs:ignore
94
  $get_abandoned_id_of_order
95
  )
96
  );
99
  $wcal_user_id = $user_id_results[0]->user_id;
100
 
101
  if ( $wcal_user_id >= 63000000 ) {
102
+ $wpdb->delete( // phpcs:ignore
103
+ $wcal_guest_table_name,
104
+ array( 'id' => $wcal_user_id )
105
+ );
106
  }
107
 
108
+ $wpdb->delete( // phpcs:ignore
109
+ $wcal_history_table_name,
110
+ array( 'id' => $get_abandoned_id_of_order )
111
+ );
112
  delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
113
  }
114
  }
120
  * Email Sent History table to indicate the order has been
121
  * recovered
122
  *
123
+ * @param integer $cart_id - ID of the Abandoned Cart.
124
+ * @param integer $order_id - Recovered Order ID.
125
  * @param integer $wcal_check_email_sent_to_cart - ID of the record in the Email Sent History table.
126
+ * @param WC_Order $order - Order Details.
127
  *
128
  * @since 7.7
129
  */
130
+ public function wcal_updated_recovered_cart_table( $cart_id, $order_id, $wcal_check_email_sent_to_cart, $order ) {
131
 
132
  global $wpdb;
133
 
135
  $wcal_guest_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
136
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
137
 
138
+ // Check & make sure that the recovered cart details are not already updated.
139
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
 
140
  $get_status = $wpdb->get_col(
141
  $wpdb->prepare(
142
+ 'SELECT recovered_cart FROM `' . $wcal_history_table_name . '` WHERE id = %d', // phpcs:ignore
143
  $cart_id
144
  )
145
  );
146
 
147
  $recovered_status = isset( $get_status[0] ) ? $get_status[0] : '';
148
 
149
+ if ( 0 == $recovered_status ) { // phpcs:ignore
150
 
151
+ // Update the cart history table.
152
  $update_details = array(
153
  'recovered_cart' => $order_id,
154
  'cart_ignored' => '1',
156
 
157
  $current_user_id = get_current_user_id();
158
 
159
+ if ( wcal_common::wcal_get_cart_session( 'user_id' ) != $current_user_id && 0 != $current_user_id ) { // phpcs:ignore
 
160
  $update_details['user_id'] = $current_user_id;
161
  }
162
 
163
+ // check if more than one reminder email has been sent.
164
+ $get_old_cart_id = $wpdb->get_col( // phpcs:ignore
 
165
  $wpdb->prepare(
166
+ 'SELECT abandoned_order_id FROM `$wcal_sent_email_table_name` WHERE id = %d',
167
  $wcal_check_email_sent_to_cart
168
  )
169
  );
170
 
171
  $get_ids = array();
172
  if ( isset( $get_old_cart_id ) ) {
173
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
174
+ $get_ids = $wpdb->get_col(
175
+ $wpdb->prepare(
176
+ 'SELECT id FROM `' . $wcal_sent_email_table_name . '` WHERE abandoned_order_id = %d', // phpcs:ignore
177
+ $get_old_cart_id
178
+ )
179
+ );
180
  }
181
 
182
  $update_sent_history = array();
183
 
184
+ if ( '' !== get_post_meta( $order_id, 'wcal_abandoned_timestamp', true ) ) {
185
  $update_details['abandoned_cart_time'] = get_post_meta( $order_id, 'wcal_abandoned_timestamp', true );
186
 
187
  $update_sent_history['abandoned_order_id'] = $cart_id;
188
 
189
  delete_post_meta( $order_id, 'wcal_abandoned_timestamp', $update_details['abandoned_cart_time'] );
190
  }
191
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
192
+ $wpdb->update(
193
+ $wcal_history_table_name,
194
+ $update_details,
195
+ array(
196
+ 'id' => $cart_id,
197
+ )
198
+ );
199
 
200
+ // update the email sent history table.
 
 
201
  if ( is_array( $get_ids ) && count( $get_ids ) > 1 ) {
202
  $list_ids = implode( ',', $get_ids );
203
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
204
+ $wpdb->query(
205
+ 'UPDATE `' . $wcal_sent_email_table_name . '` SET abandoned_order_id = %d WHERE id IN (%s)', // phpcs:ignore
206
+ (int) $cart_id,
207
+ $list_ids
208
+ );
209
  } elseif ( isset( $update_sent_history['abandoned_order_id'] ) ) {
210
+ $wpdb->update( // phpcs:ignore
211
  $wcal_sent_email_table_name,
212
  $update_sent_history,
213
+ array(
214
+ 'id' => $wcal_check_email_sent_to_cart,
215
+ )
216
  );
217
  }
218
 
219
+ // Add Order Note.
220
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
221
  delete_post_meta( $order_id, 'wcal_abandoned_cart_id' );
222
  delete_post_meta( $order_id, 'wcal_recover_order_placed' );
229
  * Send email to admin when cart is recovered only via PayPal.
230
  *
231
  * @hook woocommerce_order_status_changed
232
+ * @param int | string $order_id Order id.
233
+ * @param string $wc_old_status Old status.
234
+ * @param string $wc_new_status New status.
235
  * @globals mixed $wpdb
236
  * @globals mixed $woocommerce
237
  * @since 2.9
238
  */
239
  public function wcal_update_cart_details( $order_id, $wc_old_status, $wc_new_status ) {
240
 
241
+ if ( 'pending' !== $wc_new_status && 'failed' !== $wc_new_status && 'cancelled' !== $wc_new_status && 'trash' !== $wc_new_status ) {
 
 
 
242
 
243
  global $wpdb;
244
 
249
  if ( $order_id > 0 ) {
250
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
251
 
252
+ if ( $get_abandoned_id_of_order > 0 || '' != wcal_common::wcal_get_cart_session( 'email_sent_id' ) ) { // phpcs:ignore
253
+ // recovered order.
254
  } else {
255
 
256
  $wcal_abandoned_id = get_post_meta( $order_id, 'wcal_abandoned_cart_id', true );
257
+ // check if it's a guest cart.
258
+ // phpcs:ignore WordPress.DB.DirectDatabaseQuery
259
+ $get_cart_data = $wpdb->get_results(
 
260
  $wpdb->prepare(
261
+ 'SELECT user_id, user_type FROM `' . $wcal_history_table_name . '` WHERE id = %d', // phpcs:ignore
262
  $wcal_abandoned_id
263
  )
264
  );
267
  $user_type = $get_cart_data[0]->user_type;
268
  $user_id = $get_cart_data[0]->user_id;
269
 
270
+ if ( 'GUEST' === $user_type && $user_id >= 63000000 ) {
271
+ $wpdb->delete( // phpcs:ignore
272
+ $wcal_guest_table_name,
273
+ array( 'id' => $user_id )
274
+ );
275
  }
276
  }
277
+ $wpdb->delete( $wcal_history_table_name, array( 'id' => $wcal_abandoned_id ) ); // phpcs:ignore
278
  }
279
  }
280
+ } elseif ( 'pending' === $wc_old_status && 'cancelled' === $wc_new_status ) {
281
  global $wpdb;
282
 
283
  $wcal_history_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
284
  $wcal_abandoned_id = get_post_meta( $order_id, 'wcal_abandoned_cart_id', true );
285
 
286
+ $wpdb->update( // phpcs:ignore
287
+ $wcal_history_table_name,
288
+ array( 'cart_ignored' => '1' ),
289
+ array( 'id' => $wcal_abandoned_id )
290
+ );
291
  }
292
  }
293
 
295
  * This function will send the email to the store admin when any abandoned cart email recovered.
296
  *
297
  * @hook woocommerce_order_status_changed
298
+ * @param int | string $order_id Order id.
299
+ * @param string $wcap_old_status Old status of the order.
300
+ * @param string $wcap_new_status New status of the order.
301
  * @globals mixed $woocommerce
302
  * @since 1.0
303
  */
304
+ public function wcal_send_recovery_email( $order_id, $wcap_old_status, $wcap_new_status ) {
305
  global $woocommerce;
306
 
307
+ if ( ( 'pending' === $wcap_old_status && 'processing' === $wcap_new_status )
308
+ || ( 'pending' === $wcap_old_status && 'completed' === $wcap_new_status )
309
+ || ( 'pending' === $wcap_old_status && 'on-hold' === $wcap_new_status )
310
+ || ( 'failed' === $wcap_old_status && 'completed' === $wcap_new_status )
311
+ || ( 'failed' === $wcap_old_status && 'processing' === $wcap_new_status )
312
  ) {
313
  $user_id = get_current_user_id();
314
  $ac_email_admin_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
318
  } else {
319
  $user_id = $order->user_id;
320
  }
321
+ if ( 'on' === $ac_email_admin_recovery ) {
322
  $recovered_email_sent = get_post_meta( $order_id, 'wcal_recovered_email_sent', true );
323
  $wcal_check_order_is_recovered = $this->wcal_check_order_is_recovered( $order_id );
324
 
325
+ if ( 'yes' !== $recovered_email_sent && true === $wcal_check_order_is_recovered ) { // indicates cart is abandoned.
326
  $order = wc_get_order( $order_id );
327
  $email_heading = __( 'New Customer Order - Recovered', 'woocommerce' );
328
  $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
330
  $user_email = get_option( 'admin_email' );
331
  $headers[] = 'From: Admin <' . $user_email . '>';
332
  $headers[] = 'Content-Type: text/html';
333
+ // Buffer.
334
  ob_start();
335
+ // Get mail template.
336
  wc_get_template(
337
  'emails/admin-new-order.php',
338
  array(
343
  'email' => true,
344
  )
345
  );
346
+ // Get contents.
347
  $email_body = ob_get_clean();
348
  wc_mail( $user_email, $email_subject, $email_body, $headers );
349
 
356
  /**
357
  * For sending Recovery Email to Admin, we will check that order is recovered or not.
358
  *
359
+ * @param int | string $wcal_order_id Order id.
360
  * @return boolean true | false
361
  * @globals mixed $wpdb
362
  * @since 2.3
363
  */
364
+ public function wcal_check_order_is_recovered( $wcal_order_id ) {
365
  global $wpdb;
366
+
367
+ $wcal_recover_order_query_result = $wpdb->get_results( // phpcs:ignore
368
+ $wpdb->prepare(
369
+ 'SELECT recovered_cart FROM `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` WHERE recovered_cart = %d', // phpcs:ignore
370
+ $wcal_order_id
371
+ )
372
+ );
373
  if ( count( $wcal_recover_order_query_result ) > 0 ) {
374
  return true;
375
  }
382
  * It will be executed after order placed.
383
  *
384
  * @hook woocommerce_payment_complete_order_status
385
+ * @param string $woo_order_status Order Status.
386
+ * @param int | string $order_id Order Id.
387
  * @return string $order_status
388
  * @globals mixed $wpdb
389
  * @since 3.4
397
  $get_abandoned_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed', true );
398
  $get_sent_email_id_of_order = get_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', true );
399
 
400
+ // Order Status passed in the function is either 'processing' or 'complete' and may or may not reflect the actual order status.
 
401
  // Hence, always use the status fetched from the order object.
 
402
  $order_status = ( $order ) ? $order->get_status() : '';
403
 
404
  $wcal_ac_table_name = $wpdb->prefix . 'ac_abandoned_cart_history_lite';
405
  $wcal_email_sent_history_table_name = $wpdb->prefix . 'ac_sent_history_lite';
406
  $wcal_guest_ac_table_name = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
407
 
408
+ if ( 'pending' !== $order_status && 'failed' !== $order_status && 'cancelled' !== $order_status && 'trash' !== $order_status ) {
409
  global $wpdb;
410
 
411
+ if ( isset( $get_abandoned_id_of_order ) && '' !== $get_abandoned_id_of_order ) {
412
 
413
+ $ac_user_id_result = $wpdb->get_results( // phpcs:ignore
 
414
  $wpdb->prepare(
415
+ 'SELECT user_id, abandoned_cart_time FROM `' . $wcal_ac_table_name . '` WHERE id = %d', // phpcs:ignore
416
  $get_abandoned_id_of_order
417
  )
418
  );
423
  if ( $wcal_user_id >= 63000000 ) {
424
  add_post_meta( $order_id, 'wcal_abandoned_timestamp', $ac_user_id_result[0]->abandoned_cart_time );
425
 
426
+ $wpdb->delete( // phpcs:ignore
427
+ $wcal_guest_ac_table_name,
428
+ array( 'id' => $wcal_user_id )
429
+ );
430
  }
431
 
432
+ $wpdb->delete( // phpcs:ignore
433
+ $wcal_ac_table_name,
434
+ array( 'id' => $get_abandoned_id_of_order )
435
+ );
436
  delete_post_meta( $order_id, 'wcal_recover_order_placed', $get_abandoned_id_of_order );
437
  }
438
  }
439
  }
440
 
441
+ if ( 'pending' !== $woo_order_status && 'failed' !== $woo_order_status && 'cancelled' !== $woo_order_status && 'trash' !== $woo_order_status ) {
 
 
 
442
 
443
+ if ( isset( $get_sent_email_id_of_order ) && '' !== $get_sent_email_id_of_order ) {
444
  $this->wcal_updated_recovered_cart( $get_abandoned_id_of_order, $order_id, $get_sent_email_id_of_order, $order );
445
  }
446
  }
453
  * Email Sent History table to indicate the order has been
454
  * recovered
455
  *
456
+ * @param integer $cart_id - ID of the Abandoned Cart.
457
+ * @param integer $order_id - Recovered Order ID.
458
  * @param integer $wcal_check_email_sent_to_cart - ID of the record in the Email Sent History table.
459
+ * @param WC_Order $order - Order Details.
460
  *
461
  * @since 5.3.0
462
  */
463
+ public function wcal_updated_recovered_cart( $cart_id, $order_id, $wcal_check_email_sent_to_cart, $order ) {
464
 
465
  global $wpdb;
466
 
468
  $wcal_email_sent_table = $wpdb->prefix . 'ac_sent_history_lite';
469
  $wcal_guest_ac_table = $wpdb->prefix . 'ac_guest_abandoned_cart_history_lite';
470
 
471
+ // check & make sure that the recovered cart details are not already updated.
472
+ $get_status = $wpdb->get_col( // phpcs:ignore
473
+ $wpdb->prepare(
474
+ 'SELECT recovered_cart FROM `' . $wcal_ac_table_name . '` WHERE id = %d', // phpcs:ignore
475
+ $cart_id
476
+ )
477
+ );
478
 
479
  $recovered_status = isset( $get_status[0] ) ? $get_status[0] : '';
480
 
481
+ if ( 0 == $recovered_status ) { // phpcs:ignore
482
+ // Update the cart history table.
483
  $update_details = array(
484
  'recovered_cart' => $order_id,
485
  'cart_ignored' => '1',
487
 
488
  $current_user_id = get_current_user_id();
489
 
490
+ if ( wcal_common::wcal_get_cart_session( 'user_id' ) != $current_user_id && 0 != $current_user_id ) { // phpcs:ignore
 
491
  $update_details['user_id'] = $current_user_id;
492
  }
493
 
494
+ // check if more than one reminder email has been sent.
495
+ $get_old_cart_id = $wpdb->get_col( // phpcs:ignore
496
+ $wpdb->prepare(
497
+ 'SELECT abandoned_order_id FROM `' . $wcal_email_sent_table . '` WHERE id = %d', // phpcs:ignore
498
+ $wcal_check_email_sent_to_cart
499
+ )
500
+ );
501
 
502
  $get_ids = array();
503
  if ( isset( $get_old_cart_id ) ) {
504
+ $get_ids = $wpdb->get_col( // phpcs:ignore
505
+ $wpdb->prepare(
506
+ 'SELECT id FROM `' . $wcal_email_sent_table . '` WHERE abandoned_order_id = %d', // phpcs:ignore
507
+ $get_old_cart_id
508
+ )
509
+ );
510
  }
511
 
512
  $update_sent_history = array();
513
 
514
+ if ( '' !== get_post_meta( $order_id, 'wcal_abandoned_timestamp', true ) ) {
515
  $update_details['abandoned_cart_time'] = get_post_meta( $order_id, 'wcal_abandoned_timestamp', true );
516
 
517
  $update_sent_history['abandoned_order_id'] = $cart_id;
519
  delete_post_meta( $order_id, 'wcal_abandoned_timestamp', $update_details['abandoned_cart_time'] );
520
  }
521
 
522
+ $wpdb->update( // phpcs:ignore
523
+ $wcal_ac_table_name,
524
+ $update_details,
525
+ array( 'id' => $cart_id )
526
+ );
527
 
528
+ // update the email sent history table.
529
  if ( is_array( $get_ids ) && count( $get_ids ) > 1 ) {
530
  $list_ids = implode( ',', $get_ids );
531
+ $wpdb->query( // phpcs:ignore
532
+ $wpdb->prepare(
533
+ 'UPDATE `' . $wcal_email_sent_table . '` SET abandoned_order_id = %d WHERE id IN (%s)', // phpcs:ignore
534
+ $cart_id,
535
+ $list_ids
536
+ )
537
+ );
538
  } elseif ( isset( $update_sent_history['abandoned_order_id'] ) ) {
539
+ $wpdb->update( // phpcs:ignore
540
  $wcal_email_sent_table,
541
  $update_sent_history,
542
  array( 'id' => $wcal_check_email_sent_to_cart )
543
  );
544
  }
545
 
546
+ // Add Order Note.
547
  $order->add_order_note( __( 'This order was abandoned & subsequently recovered.', 'woocommerce-abandoned-cart' ) );
548
  delete_post_meta( $order_id, 'wcal_abandoned_cart_id' );
549
  delete_post_meta( $order_id, 'wcal_recover_order_placed' );
557
  * delete it.
558
  *
559
  * @hook woocommerce_checkout_order_processed
560
+ * @param int | string $order_id Order id.
561
  * @globals mixed $wpdb
562
  * @globals mixed $woocommerce
563
  *
564
  * @since 3.4
565
  */
566
+ public function wcal_order_placed( $order_id ) {
567
 
568
  global $wpdb;
569
  $email_sent_id = wcal_common::wcal_get_cart_session( 'email_sent_id' );
575
  $wcal_sent_email_table_name = $wpdb->prefix . 'ac_sent_history_lite';
576
 
577
  $abandoned_order_id_to_save = $abandoned_order_id;
578
+ if ( (int) $email_sent_id > 0 ) { // recovered cart.
579
 
580
+ if ( '' == $abandoned_order_id || $abandoned_order_id == false ) { // phpcs:ignore
581
 
582
+ $get_ac_id_results = $wpdb->get_results( // phpcs:ignore
 
583
  $wpdb->prepare(
584
+ 'SELECT abandoned_order_id FROM `' . $wcal_sent_email_table_name . '` WHERE id = %d', // phpcs:ignore
585
  $email_sent_id
586
  )
587
  );
589
  $abandoned_order_id_to_save = $get_ac_id_results[0]->abandoned_order_id;
590
  }
591
 
592
+ // if user becomes the registered user.
593
+ if ( ( isset( $_POST['account_password'] ) && '' !== $_POST['account_password'] ) || // phpcs:ignore WordPress.Security.NonceVerification
594
+ ( isset( $_POST['createaccount'] ) && '' !== $_POST['createaccount'] ) || // phpcs:ignore WordPress.Security.NonceVerification
595
+ ( ! isset( $_POST['createaccount'] ) && 'no' === get_option( 'woocommerce_enable_guest_checkout', '' ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
596
 
597
+ if ( '' != $abandoned_order_id && '' != $wcal_user_id_of_guest ) { // phpcs:ignore
598
  $abandoned_cart_id_new_user = $abandoned_order_id;
599
 
600
+ // delete the guest record. As it become the logged in user.
601
+ $get_ac_id_guest_results = $wpdb->get_results( // phpcs:ignore
 
602
  $wpdb->prepare(
603
+ 'SELECT id, abandoned_cart_time FROM `' . $wcal_history_table_name . '` WHERE user_id = %d ORDER BY id DESC', // phpcs:ignore
604
+ (int) $wcal_user_id_of_guest
605
  )
606
  );
607
 
610
 
611
  add_post_meta( $order_id, 'wcal_abandoned_timestamp', $get_ac_id_guest_results[0]->abandoned_cart_time );
612
 
613
+ $wpdb->delete( // phpcs:ignore
614
+ $wcal_guest_table_name,
615
+ array( 'id' => $wcal_user_id_of_guest )
616
+ );
617
+ $wpdb->delete( // phpcs:ignore
618
+ $wcal_history_table_name,
619
+ array( 'id' => $get_ac_id_guest_results[0]->id )
620
+ );
621
  }
622
+ // it is the new registered users cart id.
623
  $abandoned_order_id_to_save = $abandoned_cart_id_new_user;
624
  }
625
  }
626
 
627
  add_post_meta( $order_id, 'wcal_recover_order_placed_sent_id', $email_sent_id );
628
  add_post_meta( $order_id, 'wcal_recover_order_placed', $abandoned_order_id );
629
+ } elseif ( '' !== $abandoned_order_id ) {
630
 
631
+ if ( ( isset( $_POST['account_password'] ) && '' !== $_POST['account_password'] ) || // phpcs:ignore WordPress.Security.NonceVerification
632
+ ( isset( $_POST['createaccount'] ) && '' !== $_POST['createaccount'] ) || // phpcs:ignore WordPress.Security.NonceVerification
633
+ ( ! isset( $_POST['createaccount'] ) && 'no' === get_option( 'woocommerce_enable_guest_checkout', '' ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
634
 
635
+ if ( '' !== $abandoned_order_id && '' !== $wcal_user_id_of_guest ) {
636
  $abandoned_cart_id_new_user = $abandoned_order_id;
637
 
638
+ // delete the guest record. As it become the logged in user.
639
+ $wpdb->delete( $wcal_history_table_name, array( 'user_id' => $wcal_user_id_of_guest ) ); // phpcs:ignore
640
+ $wpdb->delete( $wcal_guest_table_name, array( 'id' => $wcal_user_id_of_guest ) ); // phpcs:ignore
641
 
642
+ // it is the new registered users cart id.
643
  $abandoned_order_id_to_save = $abandoned_cart_id_new_user;
644
  }
645
  }
includes/frontend/{wcal_frontend.php → class-wcal-frontend.php} RENAMED
@@ -3,9 +3,10 @@
3
  * Frontend loader for Abandoned Cart Lite
4
  *
5
  * @since 5.3.0
 
6
  */
7
 
8
- // Exit if accessed directly
9
  if ( ! defined( 'ABSPATH' ) ) {
10
  exit;
11
  }
@@ -17,14 +18,18 @@ if ( ! class_exists( 'Wcal_Frontend' ) ) {
17
  */
18
  class Wcal_Frontend {
19
 
20
- function __construct() {
21
-
 
 
22
  $this->include_files();
23
  }
24
 
25
- function include_files() {
26
-
27
- include_once 'wcal_checkout_process.php';
 
 
28
  }
29
  }
30
  }
3
  * Frontend loader for Abandoned Cart Lite
4
  *
5
  * @since 5.3.0
6
+ * @package Abandoned-Cart-Lite-for-WooCommerce/Frontend
7
  */
8
 
9
+ // Exit if accessed directly.
10
  if ( ! defined( 'ABSPATH' ) ) {
11
  exit;
12
  }
18
  */
19
  class Wcal_Frontend {
20
 
21
+ /**
22
+ * Constructor.
23
+ */
24
+ public function __construct() {
25
  $this->include_files();
26
  }
27
 
28
+ /**
29
+ * Include the file.
30
+ */
31
+ public function include_files() {
32
+ include_once 'class-wcal-checkout-process.php';
33
  }
34
  }
35
  }
readme.txt CHANGED
@@ -4,7 +4,7 @@ Contributors: ashokrane, pinal.shah, bhavik.kiri, chetnapatel, tychesoftwares, d
4
  Tags: cart abandonment, abandon cart, cart recovery, recover woocommerce cart, increase woocommerce conversion rate, increase sales with woocommerce
5
  Author URI: https://www.tychesoftwares.com/
6
  Requires at least: 1.3
7
- Tested up to: 5.5.1
8
  Stable tag: trunk
9
  Requires PHP: 5.6
10
  License: GPLv2 or late
@@ -223,6 +223,11 @@ The admin can use the merge code `{{cart.unsubscribe}}' in the email templates.
223
 
224
  == Changelog ==
225
 
 
 
 
 
 
226
  = 5.8.2 (30.10.2020) =
227
  * Fix - Improved the code run in the action scheduler to include performance fixes.
228
  * Fix - Multiple instances of the woocommerce_ac_send_email action were observed in the Tools->Pending Actions.
4
  Tags: cart abandonment, abandon cart, cart recovery, recover woocommerce cart, increase woocommerce conversion rate, increase sales with woocommerce
5
  Author URI: https://www.tychesoftwares.com/
6
  Requires at least: 1.3
7
+ Tested up to: 5.6
8
  Stable tag: trunk
9
  Requires PHP: 5.6
10
  License: GPLv2 or late
223
 
224
  == Changelog ==
225
 
226
+ = 5.8.3 (06.11.2020) =
227
+ * Fix - Added more changes related to sanitization of data & SQL queries to make the plugin WPCS compliant.
228
+ * Tweak - The plugin will no longer support running a cron job manually via cPanel. This has been done to ensure the security standards for WordPress are met.
229
+ * The plugin uses the Action Scheduler library from WooCommerce to send automated reminder emails since version 5.7.
230
+
231
  = 5.8.2 (30.10.2020) =
232
  * Fix - Improved the code run in the action scheduler to include performance fixes.
233
  * Fix - Multiple instances of the woocommerce_ac_send_email action were observed in the Tools->Pending Actions.
woocommerce-ac.php CHANGED
@@ -3,35 +3,35 @@
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: 5.8.2
7
  * Author: Tyche Softwares
8
  * Author URI: http://www.tychesoftwares.com/
9
  * Text Domain: woocommerce-abandoned-cart
10
  * Domain Path: /i18n/languages/
11
  * Requires PHP: 5.6
12
  * WC requires at least: 3.0.0
13
- * WC tested up to: 4.6.1
14
  *
15
  * @package Abandoned-Cart-Lite-for-WooCommerce
16
  */
17
 
18
  require_once 'class-wcal-update.php';
19
- require_once 'includes/wcal_class-guest.php';
20
  require_once 'includes/class-wcal-default-template-settings.php';
21
  require_once 'includes/class-wcal-delete-handler.php';
22
  require_once 'includes/classes/class-wcal-aes.php';
23
  require_once 'includes/classes/class-wcal-aes-counter.php';
24
- require_once 'includes/wcal-common.php';
25
 
26
  require_once 'includes/class-wcal-admin-notice.php';
27
- require_once 'includes/wcal_data_tracking_message.php';
28
  require_once 'includes/admin/class-wcal-personal-data-eraser.php';
29
- require_once 'includes/admin/class-wcal-privacy-export.php';
30
  require_once 'includes/admin/class-wcal-abandoned-cart-details.php';
31
 
32
- require_once 'includes/admin/wcap_pro_settings.php';
33
- require_once 'includes/admin/wcap_pro_settings_callbacks.php';
34
- require_once 'includes/admin/wcap_add_cart_popup_modal.php';
35
 
36
  load_plugin_textdomain( 'woocommerce-abandoned-cart', false, basename( dirname( __FILE__ ) ) . '/i18n/languages' );
37
 
@@ -118,7 +118,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
118
  }
119
 
120
  if ( ! defined( 'WCAL_PLUGIN_VERSION' ) ) {
121
- define( 'WCAL_PLUGIN_VERSION', '5.8.2' );
122
  }
123
  $this->one_hour = 60 * 60;
124
  $this->three_hours = 3 * $this->one_hour;
@@ -174,8 +174,8 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
174
  // Action Scheduler for Cron.
175
  require_once 'includes/libraries/action-scheduler/action-scheduler.php';
176
  add_action( 'init', array( &$this, 'wcal_add_scheduled_action' ) );
177
- require_once 'cron/wcal_send_email.php';
178
- require_once 'includes/wcal_process_base.php';
179
 
180
  // WordPress Administration Menu.
181
  add_action( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
@@ -240,7 +240,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
240
 
241
  add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
242
 
243
- include_once 'includes/frontend/wcal_frontend.php';
244
  }
245
 
246
  /**
@@ -274,7 +274,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
274
  */
275
  public static function wcal_add_component_file() {
276
  if ( is_admin() ) {
277
- require_once 'includes/wcal_all_component.php';
278
 
279
  }
280
  }
@@ -653,7 +653,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
653
  }
654
  } else {
655
  if ( ! get_blog_option( $blog_id, 'wcal_new_default_templates' ) ) {
656
- if ( 0 == $check_table_empty ) {
657
  $default_template = new Wcal_Default_Template_Settings();
658
  $default_template->wcal_create_default_templates( $db_prefix, $blog_id );
659
  }
@@ -936,7 +936,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
936
  */
937
  public function ac_lite_cart_time_validation( $input ) {
938
  $output = '';
939
- if ( '' != $input && ( is_numeric( $input ) && $input > 0 ) ) {
940
  $output = stripslashes( $input );
941
  } else {
942
  add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
@@ -953,7 +953,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
953
  */
954
  public static function wcal_delete_days_validation( $input ) {
955
  $output = '';
956
- if ( '' == $input || ( is_numeric( $input ) && $input > 0 ) ) {
957
  $output = stripslashes( $input );
958
  } else {
959
  add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
@@ -989,10 +989,10 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
989
  */
990
  public function ac_lite_email_admin_on_recovery( $args ) {
991
  // First, we read the option.
992
- $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery' );
993
 
994
  // This condition added to avoid the notie displyed while Check box is unchecked.
995
- if ( isset( $email_admin_on_recovery ) && '' == $email_admin_on_recovery ) {
996
  $email_admin_on_recovery = 'off';
997
  }
998
  // Next, we update the name attribute to access this element's ID in the context of the display options array.
@@ -1212,7 +1212,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1212
  }
1213
 
1214
  global $wpdb,$woocommerce;
1215
- $current_time = current_time( 'timestamp' );
1216
  $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
1217
  $track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1218
  $cart_ignored = 0;
@@ -1257,9 +1257,9 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1257
  $cart_info_meta['cart'] = WC()->session->cart;
1258
  $cart_info_meta = wp_json_encode( $cart_info_meta );
1259
 
1260
- if ( '' !== $cart_info_meta && '{"cart":[]}' != $cart_info_meta && '""' !== $cart_info_meta ) {
1261
- $cart_info = $cart_info_meta;
1262
- $user_type = 'REGISTERED';
1263
  $wpdb->query( //phpcs:ignore
1264
  $wpdb->prepare(
1265
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type ) VALUES ( %d, %s, %d, %s, %s )',
@@ -1341,7 +1341,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1341
  // GDPR consent.
1342
  $gdpr_consent = true;
1343
  $show_gdpr_msg = wcal_common::wcal_get_cart_session( 'wcal_cart_tracking_refused' );
1344
- if ( isset( $show_gdpr_msg ) && 'yes' === $show_gdpr_msg ) {
1345
  $gdpr_consent = false;
1346
  }
1347
 
@@ -1367,7 +1367,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1367
 
1368
  $updated_cart_info = wp_json_encode( $cart );
1369
 
1370
- if ( count( $results ) > 0 && '{"cart":[]}' != $updated_cart_info ) {
1371
  if ( $compare_time > $results[0]->abandoned_cart_time ) {
1372
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1373
 
@@ -1415,10 +1415,10 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1415
  0
1416
  )
1417
  );
1418
- if ( 0 == count( $results ) ) {
1419
  $cart_info = $updated_cart_info;
1420
  $blank_cart_info = '[]';
1421
- if ( $blank_cart_info != $cart_info && '{"cart":[]}' != $cart_info ) {
1422
  $wpdb->query( //phpcs:ignore
1423
  $wpdb->prepare(
1424
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` ( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id ) VALUES ( %s, %s, %s, %s, %s, %s )',
@@ -1434,7 +1434,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1434
  }
1435
  } elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
1436
  $blank_cart_info = '[]';
1437
- if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
1438
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1439
  $wpdb->query( // phpcs:ignore
1440
  $wpdb->prepare(
@@ -1459,7 +1459,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1459
  }
1460
  } else {
1461
  $blank_cart_info = '[]';
1462
- if ( $blank_cart_info != $updated_cart_info && '{"cart":[]}' != $updated_cart_info ) {
1463
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1464
  $wpdb->query( //phpcs:ignore
1465
  $wpdb->prepare(
@@ -1591,9 +1591,9 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1591
  sleep( 2 );
1592
  $url = get_option( 'siteurl' );
1593
  ?>
1594
- <script>
1595
  location.href = "<?php echo esc_url( $url ); ?>";
1596
- </script>
1597
  <?php
1598
  }
1599
  } else {
@@ -1622,10 +1622,10 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1622
  session_start();
1623
  }
1624
  global $wpdb;
1625
- $validate_server_string = isset( $_GET ['validate'] ) ? rawurldecode( wp_unslash( $_GET ['validate'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
1626
  $validate_server_string = str_replace( ' ', '+', $validate_server_string );
1627
  $validate_encoded_string = $validate_server_string;
1628
- $crypt_key = get_option( 'wcal_security_key' );
1629
  $link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $crypt_key, 256 );
1630
  $sent_email_id_pos = strpos( $link_decode, '&' );
1631
  $email_sent_id = substr( $link_decode, 0, $sent_email_id_pos );
@@ -1633,7 +1633,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1633
  wcal_common::wcal_set_cart_session( 'email_sent_id', $email_sent_id );
1634
  set_transient( 'wcal_email_sent_id', $email_sent_id, 5 );
1635
 
1636
- $url_pos = strpos( $link_decode, '=' );
1637
  ++$url_pos;
1638
  $url = substr( $link_decode, $url_pos );
1639
  $get_ac_id_results = $wpdb->get_results( //phpcs:ignore
@@ -1722,10 +1722,10 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1722
  * @since 1.0
1723
  */
1724
  public function wcal_load_guest_persistent_cart() {
1725
- if ( wcal_common::wcal_get_cart_session( 'user_id' ) != '' ) {
1726
  global $woocommerce;
1727
- $saved_cart = json_decode( get_user_meta( wcal_common::wcal_get_cart_session( 'user_id' ), '_woocommerce_persistent_cart', true ), true );
1728
- $c = array();
1729
 
1730
  $cart_contents_total = 0;
1731
  $cart_contents_weight = 0;
@@ -1761,7 +1761,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1761
  }
1762
 
1763
  if ( $saved_cart ) {
1764
- if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || count( $woocommerce->session->cart ) == 0 ) {
1765
  $woocommerce->session->cart = $saved_cart['cart'];
1766
  $woocommerce->session->cart_contents_total = $cart_contents_total;
1767
  $woocommerce->session->cart_contents_weight = $cart_contents_weight;
@@ -1832,9 +1832,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1832
  } else {
1833
  $abandoned_cart_quantity = '';
1834
  }
1835
- if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
1836
- ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
1837
- ( $current_cart_quantity != $abandoned_cart_quantity ) ) {
1838
  return false;
1839
  }
1840
  }
@@ -1882,18 +1880,16 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1882
  $abandoned_cart_product_id = '';
1883
  }
1884
  if ( isset( $abandoned_cart_arr[ $key ][ $item_key ]['variation_id'] ) ) {
1885
- $abandoned_cart_variation_id = $abandoned_cart_arr[ $key ][ $item_key ]['variation_id'];
1886
  } else {
1887
  $abandoned_cart_variation_id = '';
1888
  }
1889
  if ( isset( $abandoned_cart_arr[ $key ][ $item_key ]['quantity'] ) ) {
1890
- $abandoned_cart_quantity = $abandoned_cart_arr[ $key ][ $item_key ]['quantity'];
1891
  } else {
1892
- $abandoned_cart_quantity = '';
1893
  }
1894
- if ( ( $current_cart_product_id != $abandoned_cart_product_id ) ||
1895
- ( $current_cart_variation_id != $abandoned_cart_variation_id ) ||
1896
- ( $current_cart_quantity != $abandoned_cart_quantity ) ) {
1897
  return false;
1898
  }
1899
  }
@@ -1919,7 +1915,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
1919
  if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
1920
  return;
1921
  }
1922
- if ( 'true' == get_user_option( 'rich_editing' ) ) {
1923
  remove_filter( 'the_excerpt', 'wpautop' );
1924
  add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_mce' ) );
1925
  add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
@@ -2077,33 +2073,33 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2077
  WCAL_PLUGIN_VERSION,
2078
  false
2079
  );
2080
- $mode = isset( $_GET['mode'] ) ? sanitize_text_field( wp_unslash( $_GET['mode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
2081
  if ( 'emailtemplates' === $action && ( 'addnewtemplate' === $mode || 'edittemplate' === $mode ) ) {
2082
  wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin.min.js', array( 'jquery', 'jquery-tiptip' ), WCAL_PLUGIN_VERSION, false );
2083
- wp_enqueue_script( 'woocommerce_admin');
2084
  $locale = localeconv();
2085
  $decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
2086
  $params = array(
2087
  // translators: %s: decimal.
2088
- 'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
2089
  // translators: %s: price decimal separator.
2090
- 'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
2091
- 'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
2092
- 'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
2093
- 'decimal_point' => $decimal,
2094
- 'mon_decimal_point' => wc_get_price_decimal_separator(),
2095
- 'strings' => array(
2096
  'import_products' => __( 'Import', 'woocommerce' ),
2097
  'export_products' => __( 'Export', 'woocommerce' ),
2098
  ),
2099
- 'urls' => array(
2100
  'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
2101
  'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
2102
  ),
2103
  );
2104
-
2105
  // If we dont localize this script then from the WooCommerce check it will not run the javascript further and tooltip wont show any data.
2106
- // Also, we need above all parameters for the WooCoomerce js file. So we have taken it from the WooCommerce. @since: 5.1.2
2107
  wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
2108
  }
2109
  ?>
@@ -2296,7 +2292,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2296
  }
2297
  }
2298
 
2299
- if ( isset( $_GET['action'] ) ) {
2300
  $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
2301
  } else {
2302
  $action = '';
@@ -2397,7 +2393,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2397
  $wcal_general_settings_class = 'current';
2398
  break;
2399
  case 'wcal_email_settings':
2400
- $wcal_email_setting = 'current';
2401
  break;
2402
  case 'wcap_sms_settings':
2403
  $wcap_sms_settings = 'current';
@@ -2431,7 +2427,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2431
  </li>
2432
  </ul>
2433
  <br class="clear">
2434
- <?php
2435
  if ( 'wcal_general_settings' === $section || '' === $section ) {
2436
  ?>
2437
  <form method="post" action="options.php">
@@ -2461,9 +2457,8 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2461
  </div>
2462
  <?php
2463
  } elseif ( 'dashboard' === $action || '' === $action || '-1' === $action || '1' === $action_two ) {
2464
- include_once 'includes/classes/class-wcal-dashboard-report.php';
2465
- Wcal_Dashboard_Report::wcal_dashboard_display();
2466
-
2467
  } elseif ( 'listcart' === $action ) {
2468
 
2469
  ?>
@@ -2550,8 +2545,8 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2550
  <p> <?php esc_html_e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-abandoned-cart' ); ?> </p>
2551
  <?php
2552
  // Save the field values.
2553
- $insert_template_successfuly = '';
2554
- $update_template_successfuly = '';
2555
  $woocommerce_ac_email_subject = isset( $_POST['woocommerce_ac_email_subject'] ) ? trim( htmlspecialchars( sanitize_text_field( wp_unslash( $_POST['woocommerce_ac_email_subject'] ) ) ), ENT_QUOTES ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
2556
  $woocommerce_ac_email_body = isset( $_POST['woocommerce_ac_email_body'] ) ? trim( wp_unslash( $_POST['woocommerce_ac_email_body'] ) ) : ''; // phpcs:ignore
2557
  $woocommerce_ac_template_name = isset( $_POST['woocommerce_ac_template_name'] ) ? trim( sanitize_text_field( wp_unslash( $_POST['woocommerce_ac_template_name'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
@@ -2562,7 +2557,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2562
  $is_wc_template = empty( $_POST['is_wc_template'] ) ? '0' : '1'; // phpcs:ignore WordPress.Security.NonceVerification
2563
 
2564
  if ( isset( $_POST['ac_settings_frm'] ) && 'save' === sanitize_text_field( wp_unslash( $_POST['ac_settings_frm'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
2565
- $default_value = 0;
2566
 
2567
  $insert_template_successfuly = $wpdb->query( //phpcs:ignore
2568
  $wpdb->prepare(
@@ -2631,7 +2626,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2631
  if ( '1' === $current_template_status ) {
2632
  $active = '0';
2633
  } else {
2634
- $active = '1';
2635
  $get_selected_template_result = $wpdb->get_results( // phpcs:ignore
2636
  $wpdb->prepare(
2637
  'SELECT * FROM `' . $wpdb->prefix . 'ac_email_templates_lite` WHERE id = %d',
@@ -2816,7 +2811,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2816
  </script>
2817
  <?php
2818
  include_once 'includes/classes/class-wcal-recover-orders-table.php';
2819
- $wcal_recover_orders_list = new WCAL_Recover_Orders_Table();
2820
  $wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
2821
 
2822
  $start_date_range = isset( $_POST['start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification
@@ -2852,6 +2847,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
2852
  printf(
2853
  // translators: All counts of items & amounts.
2854
  wp_kses_post(
 
2855
  __( 'During the selected range <strong>%1$d</strong> carts totaling <strong>%2$s</strong> were abandoned. We were able to recover <strong>%3$d</strong> of them, which led to an extra <strong>%4$s</strong>', 'woocommerce-abandoned-cart' )
2856
  ),
2857
  esc_attr( $count ),
@@ -3652,7 +3648,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3652
  $subject_email_preview = isset( $_POST['subject_email_preview'] ) ? stripslashes( sanitize_text_field( wp_unslash( $_POST['subject_email_preview'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3653
  $subject_email_preview = convert_smilies( $subject_email_preview );
3654
  $subject_email_preview = str_ireplace( '{{customer.firstname}}', 'John', $subject_email_preview );
3655
- $body_email_preview = isset( $_POST['body_email_preview'] ) ? convert_smilies( wp_unslash( $_POST['body_email_preview'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3656
  $is_wc_template = isset( $_POST['is_wc_template'] ) ? sanitize_text_field( wp_unslash( $_POST['is_wc_template'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3657
  $wc_template_header = isset( $_POST['wc_template_header'] ) ? stripslashes( sanitize_text_field( wp_unslash( $_POST['wc_template_header'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3658
 
@@ -3675,7 +3671,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3675
  $headers .= 'Content-Type: text/plain' . "\r\n";
3676
  $headers .= 'Reply-To: ' . $reply_name_preview . ' ' . "\r\n";
3677
  $var = '<table width = 100%>
3678
- <tr> <td colspan="5"> <h3>' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
3679
  <tr align="center">
3680
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
3681
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
@@ -3709,7 +3705,7 @@ if ( ! class_exists( 'woocommerce_abandon_cart_lite' ) ) {
3709
  $headers = 'From: ' . $from_email_name . ' <' . $from_email_preview . '>' . "\r\n";
3710
  $headers .= 'Content-Type: text/html' . "\r\n";
3711
  $headers .= 'Reply-To: ' . $reply_name_preview . ' ' . "\r\n";
3712
- $var = '<h3>' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3>
3713
  <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
3714
  <tr align="center">
3715
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
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: 5.8.3
7
  * Author: Tyche Softwares
8
  * Author URI: http://www.tychesoftwares.com/
9
  * Text Domain: woocommerce-abandoned-cart
10
  * Domain Path: /i18n/languages/
11
  * Requires PHP: 5.6
12
  * WC requires at least: 3.0.0
13
+ * WC tested up to: 4.6.2
14
  *
15
  * @package Abandoned-Cart-Lite-for-WooCommerce
16
  */
17
 
18
  require_once 'class-wcal-update.php';
19
+ require_once 'includes/class-wcal-guest-ac.php';
20
  require_once 'includes/class-wcal-default-template-settings.php';
21
  require_once 'includes/class-wcal-delete-handler.php';
22
  require_once 'includes/classes/class-wcal-aes.php';
23
  require_once 'includes/classes/class-wcal-aes-counter.php';
24
+ require_once 'includes/class-wcal-common.php';
25
 
26
  require_once 'includes/class-wcal-admin-notice.php';
27
+ require_once 'includes/class-wcal-tracking-msg.php';
28
  require_once 'includes/admin/class-wcal-personal-data-eraser.php';
29
+ require_once 'includes/admin/class-wcal-personal-data-export.php';
30
  require_once 'includes/admin/class-wcal-abandoned-cart-details.php';
31
 
32
+ require_once 'includes/admin/class-wcap-pro-settings.php';
33
+ require_once 'includes/admin/class-wcap-pro-settings-callbacks.php';
34
+ require_once 'includes/admin/class-wcap-add-cart-popup-modal.php';
35
 
36
  load_plugin_textdomain( 'woocommerce-abandoned-cart', false, basename( dirname( __FILE__ ) ) . '/i18n/languages' );
37
 
118
  }
119
 
120
  if ( ! defined( 'WCAL_PLUGIN_VERSION' ) ) {
121
+ define( 'WCAL_PLUGIN_VERSION', '5.8.3' );
122
  }
123
  $this->one_hour = 60 * 60;
124
  $this->three_hours = 3 * $this->one_hour;
174
  // Action Scheduler for Cron.
175
  require_once 'includes/libraries/action-scheduler/action-scheduler.php';
176
  add_action( 'init', array( &$this, 'wcal_add_scheduled_action' ) );
177
+ require_once 'cron/class-wcal-cron.php';
178
+ require_once 'includes/class-wcal-process-base.php';
179
 
180
  // WordPress Administration Menu.
181
  add_action( 'admin_menu', array( &$this, 'wcal_admin_menu' ) );
240
 
241
  add_action( 'admin_notices', array( 'Wcal_Admin_Notice', 'wcal_show_db_update_notice' ) );
242
 
243
+ include_once 'includes/frontend/class-wcal-frontend.php';
244
  }
245
 
246
  /**
274
  */
275
  public static function wcal_add_component_file() {
276
  if ( is_admin() ) {
277
+ require_once 'includes/class-wcal-all-component.php';
278
 
279
  }
280
  }
653
  }
654
  } else {
655
  if ( ! get_blog_option( $blog_id, 'wcal_new_default_templates' ) ) {
656
+ if ( 0 === $check_table_empty ) {
657
  $default_template = new Wcal_Default_Template_Settings();
658
  $default_template->wcal_create_default_templates( $db_prefix, $blog_id );
659
  }
936
  */
937
  public function ac_lite_cart_time_validation( $input ) {
938
  $output = '';
939
+ if ( '' != $input && ( is_numeric( $input ) && $input > 0 ) ) { // phpcs:ignore
940
  $output = stripslashes( $input );
941
  } else {
942
  add_settings_error( 'ac_lite_cart_abandoned_time', 'error found', __( 'Abandoned cart cut off time should be numeric and has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
953
  */
954
  public static function wcal_delete_days_validation( $input ) {
955
  $output = '';
956
+ if ( '' == $input || ( is_numeric( $input ) && $input > 0 ) ) { // phpcS:ignore
957
  $output = stripslashes( $input );
958
  } else {
959
  add_settings_error( 'ac_lite_delete_abandoned_order_days', 'error found', __( 'Automatically Delete Abandoned Orders after X days has to be greater than 0.', 'woocommerce-abandoned-cart' ) );
989
  */
990
  public function ac_lite_email_admin_on_recovery( $args ) {
991
  // First, we read the option.
992
+ $email_admin_on_recovery = get_option( 'ac_lite_email_admin_on_recovery', '' );
993
 
994
  // This condition added to avoid the notie displyed while Check box is unchecked.
995
+ if ( isset( $email_admin_on_recovery ) && '' === $email_admin_on_recovery ) {
996
  $email_admin_on_recovery = 'off';
997
  }
998
  // Next, we update the name attribute to access this element's ID in the context of the display options array.
1212
  }
1213
 
1214
  global $wpdb,$woocommerce;
1215
+ $current_time = current_time( 'timestamp' ); // phpcs:ignore
1216
  $cut_off_time = get_option( 'ac_lite_cart_abandoned_time' );
1217
  $track_guest_cart_from_cart_page = get_option( 'ac_lite_track_guest_cart_from_cart_page' );
1218
  $cart_ignored = 0;
1257
  $cart_info_meta['cart'] = WC()->session->cart;
1258
  $cart_info_meta = wp_json_encode( $cart_info_meta );
1259
 
1260
+ if ( '' !== $cart_info_meta && '{"cart":[]}' !== $cart_info_meta && '""' !== $cart_info_meta ) {
1261
+ $cart_info = $cart_info_meta;
1262
+ $user_type = 'REGISTERED';
1263
  $wpdb->query( //phpcs:ignore
1264
  $wpdb->prepare(
1265
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` ( user_id, abandoned_cart_info, abandoned_cart_time, cart_ignored, user_type ) VALUES ( %d, %s, %d, %s, %s )',
1341
  // GDPR consent.
1342
  $gdpr_consent = true;
1343
  $show_gdpr_msg = wcal_common::wcal_get_cart_session( 'wcal_cart_tracking_refused' );
1344
+ if ( isset( $show_gdpr_msg ) && 'yes' == $show_gdpr_msg ) { // phpcs:ignore
1345
  $gdpr_consent = false;
1346
  }
1347
 
1367
 
1368
  $updated_cart_info = wp_json_encode( $cart );
1369
 
1370
+ if ( count( $results ) > 0 && '{"cart":[]}' !== $updated_cart_info ) {
1371
  if ( $compare_time > $results[0]->abandoned_cart_time ) {
1372
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1373
 
1415
  0
1416
  )
1417
  );
1418
+ if ( 0 === count( $results ) ) {
1419
  $cart_info = $updated_cart_info;
1420
  $blank_cart_info = '[]';
1421
+ if ( $blank_cart_info !== $cart_info && '{"cart":[]}' !== $cart_info ) {
1422
  $wpdb->query( //phpcs:ignore
1423
  $wpdb->prepare(
1424
  'INSERT INTO `' . $wpdb->prefix . 'ac_abandoned_cart_history_lite` ( abandoned_cart_info , abandoned_cart_time , cart_ignored , recovered_cart, user_type, session_id ) VALUES ( %s, %s, %s, %s, %s, %s )',
1434
  }
1435
  } elseif ( $compare_time > $results[0]->abandoned_cart_time ) {
1436
  $blank_cart_info = '[]';
1437
+ if ( $blank_cart_info !== $updated_cart_info && '{"cart":[]}' !== $updated_cart_info ) {
1438
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1439
  $wpdb->query( // phpcs:ignore
1440
  $wpdb->prepare(
1459
  }
1460
  } else {
1461
  $blank_cart_info = '[]';
1462
+ if ( $blank_cart_info !== $updated_cart_info && '{"cart":[]}' !== $updated_cart_info ) {
1463
  if ( ! $this->wcal_compare_only_guest_carts( $updated_cart_info, $results[0]->abandoned_cart_info ) ) {
1464
  $wpdb->query( //phpcs:ignore
1465
  $wpdb->prepare(
1591
  sleep( 2 );
1592
  $url = get_option( 'siteurl' );
1593
  ?>
1594
+ <script>
1595
  location.href = "<?php echo esc_url( $url ); ?>";
1596
+ </script>
1597
  <?php
1598
  }
1599
  } else {
1622
  session_start();
1623
  }
1624
  global $wpdb;
1625
+ $validate_server_string = isset( $_GET ['validate'] ) ? rawurldecode( wp_unslash( $_GET ['validate'] ) ) : ''; // phpcs:ignore
1626
  $validate_server_string = str_replace( ' ', '+', $validate_server_string );
1627
  $validate_encoded_string = $validate_server_string;
1628
+ $crypt_key = get_option( 'wcal_security_key' );
1629
  $link_decode = Wcal_Aes_Ctr::decrypt( $validate_encoded_string, $crypt_key, 256 );
1630
  $sent_email_id_pos = strpos( $link_decode, '&' );
1631
  $email_sent_id = substr( $link_decode, 0, $sent_email_id_pos );
1633
  wcal_common::wcal_set_cart_session( 'email_sent_id', $email_sent_id );
1634
  set_transient( 'wcal_email_sent_id', $email_sent_id, 5 );
1635
 
1636
+ $url_pos = strpos( $link_decode, '=' );
1637
  ++$url_pos;
1638
  $url = substr( $link_decode, $url_pos );
1639
  $get_ac_id_results = $wpdb->get_results( //phpcs:ignore
1722
  * @since 1.0
1723
  */
1724
  public function wcal_load_guest_persistent_cart() {
1725
+ if ( wcal_common::wcal_get_cart_session( 'user_id' ) != '' ) { // phpcs:ignore
1726
  global $woocommerce;
1727
+ $saved_cart = json_decode( get_user_meta( wcal_common::wcal_get_cart_session( 'user_id' ), '_woocommerce_persistent_cart', true ), true );
1728
+ $c = array();
1729
 
1730
  $cart_contents_total = 0;
1731
  $cart_contents_weight = 0;
1761
  }
1762
 
1763
  if ( $saved_cart ) {
1764
+ if ( empty( $woocommerce->session->cart ) || ! is_array( $woocommerce->session->cart ) || 0 === count( $woocommerce->session->cart ) ) {
1765
  $woocommerce->session->cart = $saved_cart['cart'];
1766
  $woocommerce->session->cart_contents_total = $cart_contents_total;
1767
  $woocommerce->session->cart_contents_weight = $cart_contents_weight;
1832
  } else {
1833
  $abandoned_cart_quantity = '';
1834
  }
1835
+ if ( ( $current_cart_product_id != $abandoned_cart_product_id ) || ( $current_cart_variation_id != $abandoned_cart_variation_id ) || ( $current_cart_quantity != $abandoned_cart_quantity ) ) { // phpcs:ignore
 
 
1836
  return false;
1837
  }
1838
  }
1880
  $abandoned_cart_product_id = '';
1881
  }
1882
  if ( isset( $abandoned_cart_arr[ $key ][ $item_key ]['variation_id'] ) ) {
1883
+ $abandoned_cart_variation_id = $abandoned_cart_arr[ $key ][ $item_key ]['variation_id'];
1884
  } else {
1885
  $abandoned_cart_variation_id = '';
1886
  }
1887
  if ( isset( $abandoned_cart_arr[ $key ][ $item_key ]['quantity'] ) ) {
1888
+ $abandoned_cart_quantity = $abandoned_cart_arr[ $key ][ $item_key ]['quantity'];
1889
  } else {
1890
+ $abandoned_cart_quantity = '';
1891
  }
1892
+ if ( ( $current_cart_product_id != $abandoned_cart_product_id ) || ( $current_cart_variation_id != $abandoned_cart_variation_id ) || ( $current_cart_quantity != $abandoned_cart_quantity ) ) { // phpcs:ignore
 
 
1893
  return false;
1894
  }
1895
  }
1915
  if ( ! current_user_can( 'edit_posts' ) && ! current_user_can( 'edit_pages' ) ) {
1916
  return;
1917
  }
1918
+ if ( 'true' === get_user_option( 'rich_editing' ) ) {
1919
  remove_filter( 'the_excerpt', 'wpautop' );
1920
  add_filter( 'tiny_mce_before_init', array( &$this, 'wcal_format_tiny_mce' ) );
1921
  add_filter( 'mce_buttons', array( &$this, 'wcal_filter_mce_button' ) );
2073
  WCAL_PLUGIN_VERSION,
2074
  false
2075
  );
2076
+ $mode = isset( $_GET['mode'] ) ? sanitize_text_field( wp_unslash( $_GET['mode'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
2077
  if ( 'emailtemplates' === $action && ( 'addnewtemplate' === $mode || 'edittemplate' === $mode ) ) {
2078
  wp_register_script( 'woocommerce_admin', WC()->plugin_url() . '/assets/js/admin/woocommerce_admin.min.js', array( 'jquery', 'jquery-tiptip' ), WCAL_PLUGIN_VERSION, false );
2079
+ wp_enqueue_script( 'woocommerce_admin' );
2080
  $locale = localeconv();
2081
  $decimal = isset( $locale['decimal_point'] ) ? $locale['decimal_point'] : '.';
2082
  $params = array(
2083
  // translators: %s: decimal.
2084
+ 'i18n_decimal_error' => sprintf( __( 'Please enter in decimal (%s) format without thousand separators.', 'woocommerce' ), $decimal ),
2085
  // translators: %s: price decimal separator.
2086
+ 'i18n_mon_decimal_error' => sprintf( __( 'Please enter in monetary decimal (%s) format without thousand separators and currency symbols.', 'woocommerce' ), wc_get_price_decimal_separator() ),
2087
+ 'i18n_country_iso_error' => __( 'Please enter in country code with two capital letters.', 'woocommerce' ),
2088
+ 'i18_sale_less_than_regular_error' => __( 'Please enter in a value less than the regular price.', 'woocommerce' ),
2089
+ 'decimal_point' => $decimal,
2090
+ 'mon_decimal_point' => wc_get_price_decimal_separator(),
2091
+ 'strings' => array(
2092
  'import_products' => __( 'Import', 'woocommerce' ),
2093
  'export_products' => __( 'Export', 'woocommerce' ),
2094
  ),
2095
+ 'urls' => array(
2096
  'import_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_importer' ) ),
2097
  'export_products' => esc_url_raw( admin_url( 'edit.php?post_type=product&page=product_exporter' ) ),
2098
  ),
2099
  );
2100
+
2101
  // If we dont localize this script then from the WooCommerce check it will not run the javascript further and tooltip wont show any data.
2102
+ // Also, we need above all parameters for the WooCoomerce js file. So we have taken it from the WooCommerce. @since: 5.1.2.
2103
  wp_localize_script( 'woocommerce_admin', 'woocommerce_admin', $params );
2104
  }
2105
  ?>
2292
  }
2293
  }
2294
 
2295
+ if ( isset( $_GET['action'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification
2296
  $action = sanitize_text_field( wp_unslash( $_GET['action'] ) ); // phpcs:ignore WordPress.Security.NonceVerification
2297
  } else {
2298
  $action = '';
2393
  $wcal_general_settings_class = 'current';
2394
  break;
2395
  case 'wcal_email_settings':
2396
+ $wcal_email_setting = 'current';
2397
  break;
2398
  case 'wcap_sms_settings':
2399
  $wcap_sms_settings = 'current';
2427
  </li>
2428
  </ul>
2429
  <br class="clear">
2430
+ <?php
2431
  if ( 'wcal_general_settings' === $section || '' === $section ) {
2432
  ?>
2433
  <form method="post" action="options.php">
2457
  </div>
2458
  <?php
2459
  } elseif ( 'dashboard' === $action || '' === $action || '-1' === $action || '1' === $action_two ) {
2460
+ include_once 'includes/classes/class-wcal-dashboard-report.php';
2461
+ Wcal_Dashboard_Report::wcal_dashboard_display();
 
2462
  } elseif ( 'listcart' === $action ) {
2463
 
2464
  ?>
2545
  <p> <?php esc_html_e( 'Add email templates at different intervals to maximize the possibility of recovering your abandoned carts.', 'woocommerce-abandoned-cart' ); ?> </p>
2546
  <?php
2547
  // Save the field values.
2548
+ $insert_template_successfuly = '';
2549
+ $update_template_successfuly = '';
2550
  $woocommerce_ac_email_subject = isset( $_POST['woocommerce_ac_email_subject'] ) ? trim( htmlspecialchars( sanitize_text_field( wp_unslash( $_POST['woocommerce_ac_email_subject'] ) ) ), ENT_QUOTES ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
2551
  $woocommerce_ac_email_body = isset( $_POST['woocommerce_ac_email_body'] ) ? trim( wp_unslash( $_POST['woocommerce_ac_email_body'] ) ) : ''; // phpcs:ignore
2552
  $woocommerce_ac_template_name = isset( $_POST['woocommerce_ac_template_name'] ) ? trim( sanitize_text_field( wp_unslash( $_POST['woocommerce_ac_template_name'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
2557
  $is_wc_template = empty( $_POST['is_wc_template'] ) ? '0' : '1'; // phpcs:ignore WordPress.Security.NonceVerification
2558
 
2559
  if ( isset( $_POST['ac_settings_frm'] ) && 'save' === sanitize_text_field( wp_unslash( $_POST['ac_settings_frm'] ) ) ) { // phpcs:ignore WordPress.Security.NonceVerification
2560
+ $default_value = 0;
2561
 
2562
  $insert_template_successfuly = $wpdb->query( //phpcs:ignore
2563
  $wpdb->prepare(
2626
  if ( '1' === $current_template_status ) {
2627
  $active = '0';
2628
  } else {
2629
+ $active = '1';
2630
  $get_selected_template_result = $wpdb->get_results( // phpcs:ignore
2631
  $wpdb->prepare(
2632
  'SELECT * FROM `' . $wpdb->prefix . 'ac_email_templates_lite` WHERE id = %d',
2811
  </script>
2812
  <?php
2813
  include_once 'includes/classes/class-wcal-recover-orders-table.php';
2814
+ $wcal_recover_orders_list = new Wcal_Recover_Orders_Table();
2815
  $wcal_recover_orders_list->wcal_recovered_orders_prepare_items();
2816
 
2817
  $start_date_range = isset( $_POST['start_date'] ) ? sanitize_text_field( wp_unslash( $_POST['start_date'] ) ) : '';// phpcs:ignore WordPress.Security.NonceVerification
2847
  printf(
2848
  // translators: All counts of items & amounts.
2849
  wp_kses_post(
2850
+ // translators: Abandoned & recovered numbers and order totals.
2851
  __( 'During the selected range <strong>%1$d</strong> carts totaling <strong>%2$s</strong> were abandoned. We were able to recover <strong>%3$d</strong> of them, which led to an extra <strong>%4$s</strong>', 'woocommerce-abandoned-cart' )
2852
  ),
2853
  esc_attr( $count ),
3648
  $subject_email_preview = isset( $_POST['subject_email_preview'] ) ? stripslashes( sanitize_text_field( wp_unslash( $_POST['subject_email_preview'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3649
  $subject_email_preview = convert_smilies( $subject_email_preview );
3650
  $subject_email_preview = str_ireplace( '{{customer.firstname}}', 'John', $subject_email_preview );
3651
+ $body_email_preview = isset( $_POST['body_email_preview'] ) ? convert_smilies( wp_unslash( $_POST['body_email_preview'] ) ) : ''; // phpcs:ignore
3652
  $is_wc_template = isset( $_POST['is_wc_template'] ) ? sanitize_text_field( wp_unslash( $_POST['is_wc_template'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3653
  $wc_template_header = isset( $_POST['wc_template_header'] ) ? stripslashes( sanitize_text_field( wp_unslash( $_POST['wc_template_header'] ) ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification
3654
 
3671
  $headers .= 'Content-Type: text/plain' . "\r\n";
3672
  $headers .= 'Reply-To: ' . $reply_name_preview . ' ' . "\r\n";
3673
  $var = '<table width = 100%>
3674
+ <tr> <td colspan="5"> <h3 style="text-align:center">' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3> </td></tr>
3675
  <tr align="center">
3676
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>
3677
  <th>' . __( 'Name', 'woocommerce-abandoned-cart' ) . '</th>
3705
  $headers = 'From: ' . $from_email_name . ' <' . $from_email_preview . '>' . "\r\n";
3706
  $headers .= 'Content-Type: text/html' . "\r\n";
3707
  $headers .= 'Reply-To: ' . $reply_name_preview . ' ' . "\r\n";
3708
+ $var = '<h3 style="text-align:center">' . __( 'Your Shopping Cart', 'woocommerce-abandoned-cart' ) . '</h3>
3709
  <table border="0" cellpadding="10" cellspacing="0" class="templateDataTable">
3710
  <tr align="center">
3711
  <th>' . __( 'Item', 'woocommerce-abandoned-cart' ) . '</th>