WooCommerce Print Invoice & Delivery Note - Version 4.4.8

Version Description

(02.04.2019) =

  • Fix - When a noticed was dismissed from the plugin, then it will dismiss all other notices from other plugins also. This is fixed now.
  • Fix - Some errors in debug.log file are fixed.
Download this release

Release Info

Developer ashokrane
Plugin Icon 128x128 WooCommerce Print Invoice & Delivery Note
Version 4.4.8
Comparing to
See all releases

Code changes from version 4.4.2 to 4.4.8

Files changed (55) hide show
  1. includes/class-wcdn-settings.php +21 -4
  2. includes/class-wcdn-theme.php +1 -1
  3. includes/class-wcdn-writepanel.php +1 -1
  4. includes/component/README.md +1 -0
  5. includes/component/deactivate-survey-popup/Instructions +73 -0
  6. includes/component/deactivate-survey-popup/class-ts-deactivation.php +231 -0
  7. includes/component/deactivate-survey-popup/template/ts-deactivate-modal.php +387 -0
  8. includes/component/faq-support/Instructions +47 -0
  9. includes/component/faq-support/templates/faq-page/faq-page.php +134 -0
  10. includes/component/faq-support/ts-faq-support.php +232 -0
  11. includes/component/tracking-data/Instructions +54 -0
  12. includes/component/tracking-data/assets/images/site-logo-new.jpg +0 -0
  13. includes/component/tracking-data/assets/js/dismiss-notice.js +23 -0
  14. includes/component/tracking-data/class-ts-tracker.php +282 -0
  15. includes/component/tracking-data/ts-tracking.php +317 -0
  16. includes/component/woocommerce-check/Instructions +11 -0
  17. includes/component/woocommerce-check/ts-woo-active.php +80 -0
  18. includes/wcdn-all-component.php +280 -0
  19. includes/wcdn-template-functions.php +2 -3
  20. includes/wcdn-welcome.php +0 -277
  21. languages/woocommerce-delivery-notes-cs_CZ.mo +0 -0
  22. languages/woocommerce-delivery-notes-cs_CZ.po +675 -272
  23. languages/woocommerce-delivery-notes-da_DK.mo +0 -0
  24. languages/woocommerce-delivery-notes-da_DK.po +779 -291
  25. languages/woocommerce-delivery-notes-de_DE.mo +0 -0
  26. languages/woocommerce-delivery-notes-de_DE.po +691 -289
  27. languages/woocommerce-delivery-notes-es_ES.mo +0 -0
  28. languages/woocommerce-delivery-notes-es_ES.po +713 -242
  29. languages/woocommerce-delivery-notes-et.mo +0 -0
  30. languages/woocommerce-delivery-notes-et.po +766 -284
  31. languages/woocommerce-delivery-notes-fa_IR.mo +0 -0
  32. languages/woocommerce-delivery-notes-fa_IR.po +827 -260
  33. languages/woocommerce-delivery-notes-fi_FI.mo +0 -0
  34. languages/woocommerce-delivery-notes-fi_FI.po +750 -307
  35. languages/woocommerce-delivery-notes-fr_FR.mo +0 -0
  36. languages/woocommerce-delivery-notes-fr_FR.po +662 -288
  37. languages/woocommerce-delivery-notes-it_IT.mo +0 -0
  38. languages/woocommerce-delivery-notes-it_IT.po +730 -257
  39. languages/woocommerce-delivery-notes-ja.mo +0 -0
  40. languages/woocommerce-delivery-notes-ja.po +432 -236
  41. languages/woocommerce-delivery-notes-nb_NO.mo +0 -0
  42. languages/woocommerce-delivery-notes-nb_NO.po +690 -322
  43. languages/woocommerce-delivery-notes-nl_NL.mo +0 -0
  44. languages/woocommerce-delivery-notes-nl_NL.po +717 -271
  45. languages/woocommerce-delivery-notes-pt_BR.mo +0 -0
  46. languages/woocommerce-delivery-notes-pt_BR.po +750 -306
  47. languages/woocommerce-delivery-notes-sv_SE.mo +0 -0
  48. languages/woocommerce-delivery-notes-sv_SE.po +675 -276
  49. languages/woocommerce-delivery-notes-vi_VN.mo +0 -0
  50. languages/woocommerce-delivery-notes-vi_VN.po +672 -272
  51. languages/woocommerce-delivery-notes.pot +436 -264
  52. readme.txt +28 -2
  53. templates/print-order/print-content.php +75 -59
  54. uninstall.php +9 -12
  55. woocommerce-delivery-notes.php +107 -8
includes/class-wcdn-settings.php CHANGED
@@ -12,6 +12,12 @@ if ( !defined( 'ABSPATH' ) ) {
12
*/
13
if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
14
15
class WooCommerce_Delivery_Notes_Settings {
16
17
public $id;
@@ -32,6 +38,17 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
32
add_action( 'woocommerce_admin_field_wcdn_image_select', array( $this, 'output_image_select' ) );
33
add_action( 'wp_ajax_wcdn_settings_load_image', array( $this, 'load_image_ajax' ) );
34
add_filter( 'wcdn_get_settings', array( $this, 'generate_template_type_fields' ), 10, 2 );
35
}
36
37
/**
@@ -82,6 +99,7 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
82
* Get the settings fields
83
*/
84
public function get_settings( $section = '' ) {
85
$settings = apply_filters( 'wcdn_get_settings_no_section',
86
array(
87
array(
@@ -93,7 +111,7 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
93
94
array(
95
'title' => __( 'Style', 'woocommerce-delivery-notes' ),
96
- 'desc' => sprintf( __( 'The default print style. Read the <a href="%1$s">FAQ</a> to learn how to customize it.', 'woocommerce-delivery-notes' ), 'https://wordpress.org/plugins/woocommerce-delivery-notes/faq/', '#' ),
97
'id' => 'wcdn_template_style',
98
'class' => 'wc-enhanced-select',
99
'default' => '',
@@ -263,7 +281,7 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
263
'type' => 'text',
264
'desc_tip' => __( 'This text will be appended to the invoice number.', 'woocommerce-delivery-notes' )
265
),
266
-
267
array(
268
'type' => 'sectionend',
269
'id' => 'invoice_options'
@@ -488,5 +506,4 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
488
}
489
490
}
491
-
492
- ?>
12
*/
13
if ( !class_exists( 'WooCommerce_Delivery_Notes_Settings' ) ) {
14
15
+ /**
16
+ * WooCommerce Print Delivery Notes
17
+ *
18
+ * @author Tyche Softwares
19
+ * @package WooCommerce-Delivery-Notes/Settings
20
+ */
21
class WooCommerce_Delivery_Notes_Settings {
22
23
public $id;
38
add_action( 'woocommerce_admin_field_wcdn_image_select', array( $this, 'output_image_select' ) );
39
add_action( 'wp_ajax_wcdn_settings_load_image', array( $this, 'load_image_ajax' ) );
40
add_filter( 'wcdn_get_settings', array( $this, 'generate_template_type_fields' ), 10, 2 );
41
+ add_action( 'woocommerce_admin_field_link' , array( &$this, 'wcdn_add_admin_field_reset_button' ) );
42
+ }
43
+
44
+ /**
45
+ * It will add a reset tracking data button on the settting page.
46
+ * @hook woocommerce_admin_field_link
47
+ */
48
+ public static function wcdn_add_admin_field_reset_button ( $value ) {
49
+ if ( $value [ 'id' ] == 'ts_reset_tracking' ){
50
+ do_action ( 'wcdn_add_new_settings', $value );
51
+ }
52
}
53
54
/**
99
* Get the settings fields
100
*/
101
public function get_settings( $section = '' ) {
102
+ $wcdn_faq_url = admin_url( 'index.php?page=wcdn_faq_page' ) ;
103
$settings = apply_filters( 'wcdn_get_settings_no_section',
104
array(
105
array(
111
112
array(
113
'title' => __( 'Style', 'woocommerce-delivery-notes' ),
114
+ 'desc' => sprintf( __( 'The default print style. Read the <a href="%1$s">FAQ</a> to learn how to customize it.', 'woocommerce-delivery-notes' ), $wcdn_faq_url, '#' ),
115
'id' => 'wcdn_template_style',
116
'class' => 'wc-enhanced-select',
117
'default' => '',
281
'type' => 'text',
282
'desc_tip' => __( 'This text will be appended to the invoice number.', 'woocommerce-delivery-notes' )
283
),
284
+ apply_filters ( 'wcdn_add_settings_field', '' ),
285
array(
286
'type' => 'sectionend',
287
'id' => 'invoice_options'
506
}
507
508
}
509
+ ?>
includes/class-wcdn-theme.php CHANGED
@@ -148,4 +148,4 @@ echo "\n****************************************************\n\n";
148
149
}
150
151
- ?>
148
149
}
150
151
+ ?>
includes/class-wcdn-writepanel.php CHANGED
@@ -268,4 +268,4 @@ if ( !class_exists( 'WooCommerce_Delivery_Notes_Writepanel' ) ) {
268
269
}
270
271
- ?>
268
269
}
270
271
+ ?>
includes/component/README.md ADDED
@@ -0,0 +1 @@
1
+ # ts-plugin-features-boilerplate
includes/component/deactivate-survey-popup/Instructions ADDED
@@ -0,0 +1,73 @@
1
+ Add a popup with some questions when the plugin is deactivated.
2
+
3
+ To add this feature to the plugin, you can follow the below steps:
4
+
5
+ 1. Copy the class-ts-deactivation.php file.
6
+
7
+ 2. Include the file class-ts-deactivation.php once when on the admin page. This can be done with is_admin() function.
8
+
9
+ 3. You need to pass the 2 parameters to the init function of the TS_deactivate class. You need to change the value of the variable as per the respective plugin.
10
+
11
+ $wcap_file_name = 'woocommerce-abandon-cart-pro/woocommerce-ac.php';
12
+ $wcap_plugin_name = 'Abandoned Cart Pro for WooCommerce';
13
+
14
+ $wcap_deativate = new TS_deactivate;
15
+ $wcap_deativate->init( $wcap_file_name, $wcap_plugin_name );
16
+
17
+ 4. In respective plugin you have to add the filter as below:
18
+ The filter name: ts_deativate_plugin_questions
19
+
20
+ Please follow the below Standard method to add your plugin specific deactivate questions.
21
+
22
+ Note: Dont chnage the below things in the function:
23
+
24
+ 1. Main index: 0,1,2,3
25
+ 2. The "id" paramter value in sub array.
26
+
27
+ add_filter ( 'ts_deativate_plugin_questions', array( 'Wcap_Common', 'wcap_deactivate_add_questions' ), 10, 1 );
28
+
29
+ /**
30
+ * It will add the Questions while admin deactivate the plugin.
31
+ * @hook ts_deativate_plugin_questions
32
+ * @param array $wcap_add_questions Blank array
33
+ * @return array $wcap_add_questions List of all questions.
34
+ */
35
+ public static function wcap_deactivate_add_questions ( $wcap_add_questions ) {
36
+
37
+ $wcap_add_questions = array(
38
+ 0 => array(
39
+ 'id' => 4,
40
+ 'text' => __( "Custom Delivery Settings are not working", "woocommerce-ac" ),
41
+ 'input_type' => '',
42
+ 'input_placeholder' => ''
43
+ ),
44
+ 1 => array(
45
+ 'id' => 5,
46
+ 'text' => __( "Minimum Delivery Time (in hours) is not working as expected", "woocommerce-ac" ),
47
+ 'input_type' => '',
48
+ 'input_placeholder' => ''
49
+ ),
50
+ 2 => array(
51
+ 'id' => 6,
52
+ 'text' => __( "Shipping Days feature is not working", "woocommerce-ac" ),
53
+ 'input_type' => '',
54
+ 'input_placeholder' => ''
55
+ ),
56
+ 3 => array(
57
+ 'id' => 7,
58
+ 'text' => __( "The plugin is not compatible with another plugin", "woocommerce-ac" ),
59
+ 'input_type' => 'textfield',
60
+ 'input_placeholder' => __( "Which Plugin?", "ts-deactivation-survey" )
61
+ )
62
+
63
+ );
64
+ return $wcap_add_questions;
65
+ }
66
+
67
+ Once the above changes are done. Data will be stored in the tychesod_tracking database in the staging cpanel.
68
+
69
+ - The ts_tracking_data table will store the unique tracking id, site URL and admin email address.
70
+
71
+ - The ts_deactivation_survery table will store the meta for the reason for deactivating the plugin. Here tracking_id will be same as tracking id in ts_tracking_data.
72
+
73
+ - The ts_tracking_plugins table will store the plugin name from which the action is performed. Here tracking_id will be same as tracking id in ts_tracking_data.
includes/component/deactivate-survey-popup/class-ts-deactivation.php ADDED
@@ -0,0 +1,231 @@
1
+ <?php
2
+
3
+ /**
4
+ * Contains the logic for deactivation popups
5
+ * @since 1.0.0
6
+ */
7
+ class WCDN_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
+ */
38
+ public static $ts_plugin_url = '';
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' ) );
53
+ }
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="wcdn-ts-slug" data-slug="' . self::$ts_plugin_file_name . '"></i>';
66
+ }
67
+ return $links;
68
+ }
69
+
70
+ /**
71
+ * Localizes all the string used
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 );
176
+
177
+ return $uninstall_reasons;
178
+ }
179
+
180
+ /**
181
+ * get exact str against the slug
182
+ *
183
+ * @param type $slug
184
+ *
185
+ * @return type
186
+ */
187
+ public static function load_str( $slug ) {
188
+ return self::$ts_deactivation_str[ $slug ];
189
+ }
190
+
191
+ /**
192
+ * Called after the user has submitted his reason for deactivating the plugin.
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
+ );
226
+ // Print '1' for successful operation.
227
+ echo 1;
228
+ exit;
229
+ }
230
+
231
+ }
includes/component/deactivate-survey-popup/template/ts-deactivate-modal.php ADDED
@@ -0,0 +1,387 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ $slug = $VARS[ 'slug' ];
7
+ $confirmation_message = '';
8
+ $reasons = $VARS['reasons']['default'];
9
+ $reasons_list_items_html = '';
10
+ $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 > .wcdn-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( WCDN_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( WCDN_TS_deactivate::load_str( 'deactivation-modal-button-cancel' ) ); ?></a>'
192
+ + ' </div>'
193
+ + ' </div>'
194
+ + '</div>',
195
+ $modal = $(modalHtml),
196
+
197
+ $deactivateLink = $('#the-list .deactivate > .wcdn-ts-slug').prev();
198
+
199
+ for( var i = 0; i < $deactivateLink.length; i++ ) {
200
+ $deactivateLinks[ $( $deactivateLink[i] ).siblings( ".wcdn-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( ".wcdn-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( WCDN_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( WCDN_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( WCDN_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( WCDN_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/faq-support/Instructions ADDED
@@ -0,0 +1,47 @@
1
+ Add FAQ's submenu or tab in the plugin.
2
+
3
+ To add this feature to the plugin, you can follow the below steps:
4
+
5
+ 1. Copy the ts-faq-support.php file into your plugin folder. And faq-page folder into templates folder.
6
+
7
+ 2. Include the ts-faq-support.php file once when on the admin page. This can be done with is_admin() function.
8
+
9
+ 3. You need to pass the 7 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.
10
+
11
+ $wcap_plugin_prefix = 'wcap';
12
+ $wcap_plugin_name = 'Abandoned Cart Pro for WooCommerce';
13
+ $wcap_blog_post_link = 'https://www.tychesoftwares.com/order-delivery-date-usage-tracking/';
14
+ $wcap_locale = 'woocommerce-ac';
15
+ $wcap_plugin_folder_name = 'woocommerce-abandon-cart-pro/';
16
+ $wcap_plugins_page = 'admin.php?page=woocommerce_ac_page';
17
+ $wcap_plugin_slug = 'woocommerce_ac_page';
18
+
19
+ $ts_pro_faq = self::wcap_get_faq ();
20
+ new TS_Faq_Support( $wcap_plugin_name, $wcap_plugin_prefix, $wcap_plugins_page, $wcap_locale, $wcap_plugin_folder_name, $wcap_plugin_slug, $ts_pro_faq );
21
+
22
+ Here , $ts_pro_faq is an array.
23
+
24
+ The structure of the array is like below:
25
+
26
+ $ts_faq = array(
27
+ 1 => array (
28
+ 'question' => '',
29
+ 'answer' => ''
30
+ )
31
+ );
32
+
33
+ Here Index start from 1. Do not change it. We need to display 10 Questions and answers, so you can add 10 questions and answers in the above format.
34
+
35
+ 4. You need to create 3 do_action in your respective plugin. And it should follow below standard.
36
+
37
+ 1. {{plugin-prefix}}_add_settings_tab
38
+ 2. {{plugin-prefix}}_add_tab_content
39
+ 3. {{plugin-prefix}}_add_submenu
40
+
41
+ 5. {{plugin-prefix}}_add_settings_tab : This do_action will be placed after your plguins tab. It will allow to add new tab.
42
+
43
+ 6. {{plugin-prefix}}_add_tab_content : This do_action will be placed where you display the content of the tab.
44
+
45
+ 7. {{plugin-prefix}}_add_submenu : This do_action will be placed where you have screated sub menu of your plguin.
46
+
47
+ 8. You need to update all faq of the plugins.
includes/component/faq-support/templates/faq-page/faq-page.php ADDED
@@ -0,0 +1,134 @@
1
+ <?php
2
+ /**
3
+ * FAQ & Support page
4
+ */
5
+ ?>
6
+ <style>
7
+ .faq-ts-accordion {
8
+ background-color: #ccc;
9
+ color: #444;
10
+ cursor: pointer;
11
+ padding: 18px;
12
+ width: 100%;
13
+ border: none;
14
+ text-align: left;
15
+ outline: none;
16
+ font-size: 15px;
17
+ transition: 0.4s;
18
+ margin-bottom: 5px;
19
+ }
20
+ .active, .faq-ts-accordion:hover {
21
+ background-color: #ccc;
22
+ }
23
+ .faq-ts-accordion:after {
24
+ content: '\002B';
25
+ color: #777;
26
+ font-weight: bold;
27
+ float: right;
28
+ margin-left: 5px;
29
+ }
30
+ .active:after {
31
+ content: "\2212";
32
+ }
33
+ .panel {
34
+ padding: 0 18px;
35
+ display: none;
36
+ background-color: light-grey;
37
+ overflow: hidden;
38
+ }
39
+ .main-panel {
40
+ width: 650px !important;
41
+ }
42
+ .support-panel {
43
+ padding: 5px;
44
+ }
45
+ .dashicons-external {
46
+ content: "\f504";
47
+ }
48
+ .dashicons-editor-help {
49
+ content: "\f223";
50
+ }
51
+ div.panel.show {
52
+ display: block !important;
53
+ }
54
+
55
+ </style>
56
+
57
+ <div class="main-panel">
58
+ <h3>Frequently Asked Questions for <?php echo $ts_plugin_name; ?> Plugin</h3>
59
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[1]['question'] ?></strong></button>
60
+ <div class="panel">
61
+ <p><?php echo $ts_faq[1]['answer'] ?></p>
62
+ </div>
63
+
64
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[2]['question'] ?></strong></button>
65
+ <div class="panel">
66
+ <p><?php echo $ts_faq[2]['answer'] ?></p>
67
+ </div>
68
+
69
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[3]['question'] ?></strong></button>
70
+ <div class="panel">
71
+ <p><?php echo $ts_faq[3]['answer'] ?></p>
72
+ </div>
73
+
74
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[4]['question'] ?></strong></button>
75
+ <div class="panel">
76
+ <p><?php echo $ts_faq[4]['answer'] ?></p>
77
+ </div>
78
+
79
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[5]['question'] ?></strong></button>
80
+ <div class="panel">
81
+ <p><?php echo $ts_faq[5]['answer'] ?></p>
82
+ </div>
83
+
84
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[6]['question'] ?></strong></button>
85
+ <div class="panel">
86
+ <p><?php echo $ts_faq[6]['answer'] ?></p>
87
+ </div>
88
+
89
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[7]['question'] ?></strong></button>
90
+ <div class="panel">
91
+ <p><?php echo $ts_faq[7]['answer'] ?></p>
92
+ </div>
93
+
94
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[8]['question'] ?></strong></button>
95
+ <div class="panel">
96
+ <p><?php echo $ts_faq[8]['answer'] ?></p>
97
+ </div>
98
+
99
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[9]['question'] ?></strong></button>
100
+ <div class="panel">
101
+ <p><?php echo $ts_faq[9]['answer'] ?></p>
102
+ </div>
103
+ <button class="faq-ts-accordion"><span class="dashicons dashicons-editor-help"></span><strong><?php echo $ts_faq[10]['question'] ?></strong></button>
104
+ <div class="panel">
105
+ <p><?php echo $ts_faq[10]['answer'] ?></p>
106
+ </div>
107
+ </div>
108
+
109
+ <div class="support-panel">
110
+ <p style="font-size: 19px">
111
+ If your queries are not answered here, you can send an email directly to <strong>support@tychesoftwares.freshdesk.com</strong> for some additional requirements.
112
+ </p>
113
+ </div>
114
+ <script>
115
+ var acc = document.getElementsByClassName("faq-ts-accordion");
116
+ var i;
117
+
118
+ for (i = 0; i < acc.length; i++) {
119
+ acc[i].onclick = function() {
120
+ hideAll();
121
+
122
+ this.classList.toggle("active");
123
+ this.nextElementSibling.classList.toggle("show");
124
+ }
125
+ }
126
+
127
+ function hideAll() {
128
+ for (i = 0; i < acc.length; i++) {
129
+ acc[i].classList.toggle( "active", false);
130
+ acc[i].nextElementSibling.classList.toggle( "show", false );
131
+ }
132
+ }
133
+
134
+ </script>
includes/component/faq-support/ts-faq-support.php ADDED
@@ -0,0 +1,232 @@
1
+ <?php
2
+
3
+ /**
4
+ *
5
+ * @since 1.0.0
6
+ */
7
+ class WCDN_TS_Faq_Support {
8
+
9
+ /**
10
+ * @var string The capability users should have to view the page
11
+ */
12
+ public static $minimum_capability = 'manage_options';
13
+
14
+ /**
15
+ * @var string Plugin name
16
+ * @access public
17
+ */
18
+
19
+ public static $plugin_name = '';
20
+
21
+ /**
22
+ * @var string Plugin prefix
23
+ * @access public
24
+ */
25
+ public static $plugin_prefix = '';
26
+
27
+ /**
28
+ * @var string Plugins page path
29
+ * @access public
30
+ */
31
+ public static $plugin_page = '';
32
+
33
+ /**
34
+ * @var string Plugins plugin local
35
+ * @access public
36
+ */
37
+ public static $plugin_locale = '';
38
+
39
+ /**
40
+ * @var string Plugin folder name
41
+ * @access public
42
+ */
43
+ public static $plugin_folder = '';
44
+ /**
45
+ * @var string Plugin url
46
+ * @access public
47
+ */
48
+ public static $plugin_url = '';
49
+ /**
50
+ * @var string Template path
51
+ * @access public
52
+ */
53
+ public static $template_base = '';
54
+ /**
55
+ * @var string Slug on Main menu
56
+ * @access public
57
+ */
58
+ public static $plugin_slug = '';
59
+
60
+ /**
61
+ * @var array List of all questions and answers.
62
+ * @access public
63
+ */
64
+ public static $ts_faq = array ();
65
+ /**
66
+ * @var string Slug for FAQ submenu
67
+ * @access public
68
+ */
69
+ public static $ts_faq_submenu_slug = '';
70
+ /**
71
+ * Initialization of hooks where we prepare the functionality to ask use for survey
72
+ */
73
+ public function __construct( $ts_plugin_mame = '', $ts_plugin_prefix = '', $ts_plugin_page = '', $ts_plugin_locale = '', $ts_plugin_folder_name = '', $ts_plugin_slug = '', $ts_faq_array = array(), $faq_submenu_slug = '' ) {
74
+
75
+ self::$plugin_name = $ts_plugin_mame;
76
+ self::$plugin_prefix = $ts_plugin_prefix;
77
+ self::$plugin_page = $ts_plugin_page;
78
+ self::$plugin_locale = $ts_plugin_locale;
79
+ self::$plugin_slug = $ts_plugin_slug;
80
+ self::$ts_faq = $ts_faq_array;
81
+ self::$ts_faq_submenu_slug = ( '' == $faq_submenu_slug ) ? self::$plugin_slug : $faq_submenu_slug ;
82
+
83
+
84
+ //Add a sub menu in the main menu of the plugin if added.
85
+ add_action( self::$plugin_prefix . '_add_submenu', array( &$this, 'ts_add_submenu' ) );
86
+
87
+ //Add a tab for FAQ & Support along with other plugin settings tab.
88
+ add_action( self::$plugin_prefix . '_add_settings_tab', array( &$this, 'ts_add_new_settings_tab' ) );
89
+ add_action( self::$plugin_prefix . '_add_tab_content', array( &$this, 'ts_add_tab_content' ) );
90
+
91
+ add_action ( self::$plugin_prefix . '_add_meta_footer', array( &$this, 'ts_add_meta_footer_text' ), 10, 1 );
92
+
93
+ add_action( 'admin_menu', array( &$this, 'ts_admin_menus' ) );
94
+ add_action( 'admin_head', array( &$this, 'admin_head' ) );
95
+
96
+ self::$plugin_folder = $ts_plugin_folder_name;
97
+ self::$plugin_url = $this->ts_get_plugin_url();
98
+ self::$template_base = $this->ts_get_template_path();
99
+
100
+ }
101
+
102
+
103
+ public static function ts_add_meta_footer_text () {
104
+ ?>
105
+ <tr> <td> <br></td> </tr>
106
+
107
+ <tr>
108
+ <td colspan="2">
109
+ You have any queries? Please check our <a href=<?php echo admin_url( 'index.php?page='.self::$plugin_prefix .'_faq_page' ) ; ?> >FAQ</a> page.
110
+ </td>
111
+ <tr>
112
+ <?php
113
+ }
114
+
115
+ /**
116
+ * Register the Dashboard Page which is later hidden but this pages
117
+ * is used to render the Welcome page.
118
+ *
119
+ * @access public
120
+ * @since 7.7
121
+ * @return void
122
+ */
123
+ public function ts_admin_menus() {
124
+
125
+ // About Page
126
+ add_dashboard_page(
127
+ sprintf( esc_html__( 'Frequently Asked Questions for %s', self::$plugin_locale ), self::$plugin_name ),
128
+ esc_html__( 'Frequently Asked Questions for ' . self::$plugin_name, self::$plugin_locale ),
129
+ self::$minimum_capability,
130
+ self::$plugin_prefix . '_faq_page',
131
+ array( $this, 'ts_faq_support_page' )
132
+ );
133
+
134
+ }
135
+
136
+ /**
137
+ * Hide Individual Dashboard Pages
138
+ *
139
+ * @access public
140
+ * @since 7.7
141
+ * @return void
142
+ */
143
+ public function admin_head() {
144
+ remove_submenu_page( 'index.php', self::$plugin_prefix . '_faq_page' );
145
+ }
146
+ /**
147
+ * Adds a subment to the main menu of the plugin
148
+ *
149
+ * @since 7.7
150
+ */
151
+
152
+ public function ts_add_submenu() {
153
+ $page = add_submenu_page( self::$plugin_slug,
154
+ 'FAQ & Support',
155
+ 'FAQ & Support',
156
+ 'manage_woocommerce',
157
+ self::$ts_faq_submenu_slug .
158
+ '&action=faq_support_page',
159
+ array( &$this, 'ts_add_tab_content' )
160
+ );
161
+
162
+ }
163
+
164
+ /**
165
+ * Add a new tab on the settings page.
166
+ *
167
+ * @since 7.7
168
+ */
169
+ public function ts_add_new_settings_tab() {
170
+ $faq_support_page = '';
171
+ if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'faq_support_page' ) {
172
+ $faq_support_page = "nav-tab-active";
173
+ }
174
+ $ts_plugins_page_url = self::$plugin_page . "&action=faq_support_page" ;
175
+ ?>
176
+ <a href="<?php echo $ts_plugins_page_url; ?>" class="nav-tab <?php echo $faq_support_page; ?>"> <?php _e( 'FAQ & Support', self::$plugin_locale ); ?> </a>
177
+ <?php
178
+
179
+
180
+ }
181
+
182
+ /**
183
+ * Add content to the new tab added.
184
+ *
185
+ * @since 7.7
186
+ */
187
+
188
+ public function ts_add_tab_content() {
189
+ if( isset( $_GET[ 'action' ] ) && $_GET[ 'action' ] == 'faq_support_page' ) {
190
+ $this->ts_faq_support_page();
191
+ }
192
+ }
193
+
194
+ /**
195
+ * Adds a page to display the FAQ's and support information
196
+ *
197
+ * @since 7.7
198
+ */
199
+ public function ts_faq_support_page() {
200
+ ob_start();
201
+ wc_get_template( 'faq-page/faq-page.php',
202
+ array(
203
+ 'ts_plugin_name' => self::$plugin_name,
204
+ 'ts_faq' => self::$ts_faq
205
+ ),
206
+ self::$plugin_folder,
207
+ self::$template_base );
208
+ echo ob_get_clean();
209
+ }
210
+
211
+ /**
212
+ * This function returns the plugin url
213
+ *
214
+ * @access public
215
+ * @since 7.7
216
+ * @return string
217
+ */
218
+ public function ts_get_plugin_url() {
219
+ return plugins_url() . '/' . self::$plugin_folder;
220
+ }
221
+
222
+ /**
223
+ * This function returns the template directory path
224
+ *
225
+ * @access public
226
+ * @since 7.7
227
+ * @return string
228
+ */
229
+ public function ts_get_template_path() {
230
+ return untrailingslashit( plugin_dir_path( __FILE__ ) ) . '/templates/';
231
+ }
232
+ }
includes/component/tracking-data/Instructions ADDED
@@ -0,0 +1,54 @@
1
+ Add a notice to ask customers to collect non-sensitive data for the plugin and provide them with 20% coupon code if they allow us to collect data.
2
+
3
+ To add this feature to the plugin, you can follow the below steps:
4
+
5
+ 1. Copy the ts-tracking.php file and class-ts-tracker.php file into your plugin folder.
6
+
7
+ 2. Include the file ts-tracking.php once when on the admin page. This can be done with is_admin() function.
8
+
9
+ 3. You need to pass the 5 parameters to the default constructor of the TS_tracking class. You need to change the value of the variable as per the respective plugin.
10
+
11
+ $wcap_plugin_prefix = 'wcap';
12
+ $wcap_plugin_name = 'Abandoned Cart Pro for WooCommerce';
13
+ $wcap_blog_post_link = 'https://www.tychesoftwares.com/order-delivery-date-usage-tracking/';
14
+ $wcap_locale = 'woocommerce-ac';
15
+ WCAP_PLUGIN_URL = untrailingslashit(plugins_url('/', __FILE__)) ;
16
+
17
+ new TS_tracking( $wcap_plugin_prefix, $wcap_plugin_name, $wcap_blog_post_link, $wcap_locale, WCAP_PLUGIN_URL );
18
+
19
+ 4. Then you need to pass 2 parameters to the TS_Tracker class. You need to change the value of the variable as per the respective plugin.
20
+
21
+ $wcap_plugin_prefix = 'wcap';
22
+ $wcap_plugin_name = 'Abandoned Cart Pro for WooCommerce';
23
+ new TS_Tracker( $wcap_plugin_prefix, $wcap_plugin_name );
24
+
25
+ 5. We are using these class for tracking the data from the websites, so to track the data from the site we need to add the plugin data.
26
+
27
+ To get the data from the website you need to use 2 filters.
28
+
29
+ 1. ts_tracker_data : It will be called when admin allows tracking the data.
30
+
31
+ 2. ts_tracker_opt_out_data : It will be called when an admin does not allow to track the data
32
+
33
+ Both filters have 1 argument, you need to add all the data as per the plugin.
34
+
35
+ 6. We need to give the table name in the tracking data. You need to pass that in above both filter.
36
+
37
+ IMP: ts_meta_data_table_name - this should contain the table name which will store the plugin specific data. This should not be skipped.
38
+
39
+ Like: $plugin_data[ 'ts_meta_data_table_name' ] = 'ts_tracking_wcap_meta_data';
40
+
41
+ Here, key 'ts_meta_data_table_name' should remain same, you just need to change the table name.
42
+
43
+ Here, in the AC pro case, I have given table name as 'ts_tracking_{{prefix-of-plugin}}_meta_data
44
+
45
+ 7. Here we need 1 js file and 1 image for the tracking of the data. So I have added in the same folder, so the code structure is kept as per the current location.
46
+
47
+ If you move the js file and the image to another place then you need to change that in the 'ts-tracking.php' file.
48
+
49
+ You need to change the line number #75 for js file.
50
+ You need to change the line number #127 for the image.
51
+
52
+ 8. It is also have the ajax function which will be named as
53
+
54
+ 'wp_ajax_{{plugin-prefix}}_admin_notices'
includes/component/tracking-data/assets/images/site-logo-new.jpg ADDED
Binary file
includes/component/tracking-data/assets/js/dismiss-notice.js ADDED
@@ -0,0 +1,23 @@
1
+ /**
2
+ * This function allows to dismiss the notices which are shown from the plugin.
3
+ *
4
+ * @namespace orddd_notice_dismissible
5
+ * @since 6.8
6
+ */
7
+ // Make notices dismissible
8
+ jQuery(document).ready( function() {
9
+
10
+ jQuery('.wcdn-tracker').on( 'click', 'button.notice-dismiss', function(){
11
+
12
+ // since 2.8 ajaxurl is always defined in the admin header and points to admin-ajax.php
13
+ var admin_url = jQuery( "#admin_url" ).val();
14
+ ajaxurl = admin_url + "admin-ajax.php";
15
+
16
+ var data = {
17
+ action: "wcdn_admin_notices"
18
+ };
19
+
20
+ jQuery.post( ajaxurl, data, function( response ) {
21
+ });
22
+ });
23
+ });
includes/component/tracking-data/class-ts-tracker.php ADDED
@@ -0,0 +1,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 WCDN_TS_Tracker
8
+ * @version 6.8
9
+ */
10
+
11
+ if ( ! defined( 'ABSPATH' ) ) {
12
+ exit;
13
+ }
14
+
15
+ class WCDN_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
+
38
+ /**
39
+ * Hook into cron event.
40
+ */
41
+ public function __construct( $ts_plugin_prefix = '', $ts_plugin_name = '' ) {
42
+
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
+ /**
50
+ * Decide whether to send tracking data or not.
51
+ *
52
+ * @param boolean $override
53
+ */
54
+ public static function ts_send_tracking_data( $override = false ) {
55
+ if ( ! apply_filters( 'ts_tracker_send_override', $override ) ) {
56
+ // Send a maximum of once per week by default.
57
+ $last_send = self::ts_get_last_send_time();
58
+ if ( $last_send && $last_send > apply_filters( 'ts_tracker_last_send_interval', strtotime( '-1 week' ) ) ) {
59
+ return;
60
+ }
61
+ } else {
62
+ // Make sure there is at least a 1 hour delay between override sends, we don't want duplicate calls due to double clicking links.
63
+ $last_send = self::ts_get_last_send_time();
64
+ if ( $last_send && $last_send > strtotime( '-1 hours' ) ) {
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( 'wcdn_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,
92
+ 'httpversion' => '1.0',
93
+ 'blocking' => false,
94
+ 'headers' => array( 'user-agent' => 'TSTracker/' . md5( esc_url( home_url( '/' ) ) ) . ';' ),
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() {
106
+ return apply_filters( 'ts_tracker_last_send_time', get_option( 'wcdn_ts_tracker_last_send', false ) );
107
+ }
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() {
164
+ $wp_data = array();
165
+
166
+ $memory = wc_let_to_num( WP_MEMORY_LIMIT );
167
+
168
+ if ( function_exists( 'memory_get_usage' ) ) {
169
+ $system_memory = wc_let_to_num( @ini_get( 'memory_limit' ) );
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() {
238
+ // Ensure get_plugins function is loaded
239
+ if ( ! function_exists( 'get_plugins' ) ) {
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
265
+ unset( $plugins[ $k ] );
266
+ $active_plugins[ $k ] = $formatted;
267
+ } else {
268
+ $plugins[ $k ] = $formatted;
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
+ }
includes/component/tracking-data/ts-tracking.php ADDED
@@ -0,0 +1,317 @@
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ) {
3
+ exit;
4
+ }
5
+
6
+ include_once( 'class-ts-tracker.php' );
7
+
8
+ /** Adds the Tracking non-senstive data notice
9
+ *
10
+ * @since 6.8
11
+ */
12
+ class WCDN_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
+ */
25
+
26
+ public static $plugin_name = '';
27
+
28
+ /**
29
+ * @var string Tracking data blog post link
30
+ * @access public
31
+ */
32
+
33
+ public static $blog_post_link = '';
34
+
35
+ /**
36
+ * @var string Plugin context
37
+ * @access public
38
+ */
39
+
40
+ public static $plugin_context = '';
41
+
42
+ /**
43
+ * @var string Plugin url
44
+ * @access public
45
+ */
46
+ public static $plugin_url = '';
47
+
48
+ /**
49
+ * @var string File path
50
+ * @access public
51
+ */
52
+ public static $ts_file_path = '' ;
53
+ /**
54
+ * @var string plugin locale
55
+ * @access public
56
+ */
57
+ public static $ts_plugin_locale = '';
58
+
59
+ /**
60
+ * @var string Settings page
61
+ * @access public
62
+ */
63
+ public static $ts_settings_page = '';
64
+
65
+ /**
66
+ * @var string On which setting page need to add setting
67
+ * @access public
68
+ */
69
+ public static $ts_add_setting_on_page = '';
70
+ /**
71
+ * @var string On which section setting need to add
72
+ * @access public
73
+ */
74
+ public static $ts_add_setting_on_section = '';
75
+ /**
76
+ * @var string Register setting
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( 'WCDN_TS_tracking', 'ts_track_usage_data' ) );
99
+ add_action( 'admin_footer', array( 'WCDN_TS_tracking', 'ts_admin_notices_scripts' ) );
100
+ add_action( 'wp_ajax_'.self::$plugin_prefix.'_admin_notices', array( 'WCDN_TS_tracking', 'ts_admin_notices' ) );
101
+
102
+ add_filter( 'cron_schedules', array( 'WCDN_TS_tracking', 'ts_add_cron_schedule' ) );
103
+
104
+ add_action( self::$plugin_prefix . '_add_new_settings', array( 'WCDN_TS_tracking', 'ts_add_reset_tracking_setting' ) );
105
+
106
+ add_action ( 'admin_init', array( 'WCDN_TS_tracking', 'ts_reset_tracking_setting' ) ) ;
107
+
108
+ self::ts_schedule_cron_job();
109
+
110
+ add_filter( self::$plugin_prefix . '_add_settings_field', array( 'WCDN_TS_tracking', 'ts_add_new_settings_field') );
111
+ }
112
+
113
+ /**
114
+ * It will add the New setting for the WooCommerce settings.
115
+ * @hook self::$plugin_prefix . '_add_settings_field'
116
+ */
117
+ public static function ts_add_new_settings_field ( $ts_settings ) {
118
+
119
+ $ts_settings = array (
120
+ 'name' => __( 'Reset usage tracking', 'deposits-for-woocommerce'),
121
+ 'type' => 'link',
122
+ 'desc' => __( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data','ts-tracking'),
123
+ 'button_text' => 'Reset',
124
+ 'desc_tip' => true,
125
+ 'class' => 'button-secondary reset_tracking',
126
+ 'id' => 'ts_reset_tracking',
127
+ );
128
+
129
+ return $ts_settings;
130
+ }
131
+
132
+
133
+
134
+ /**
135
+ * It will delete the tracking option from the database.
136
+ */
137
+ public static function ts_reset_tracking_setting () {
138
+
139
+ if ( isset ( $_GET [ 'ts_action' ] ) && 'wcdn_reset_tracking' == $_GET [ 'ts_action' ] ) {
140
+ delete_option( self::$plugin_prefix . '_allow_tracking' );
141
+ delete_option( 'wcdn_ts_tracker_last_send' );
142
+ $ts_url = remove_query_arg( 'ts_action' );
143
+ wp_safe_redirect( $ts_url );
144
+ }
145
+ }
146
+
147
+ /**
148
+ * It will add the settinig, which will allow store owner to reset the tracking data. Which will result into stop trakcing the data.
149
+ * @hook self::$plugin_prefix . '_add_new_settings'
150
+ *
151
+ */
152
+ public static function ts_add_reset_tracking_setting ( $value ) {
153
+
154
+ if ( '' == self::$ts_add_setting_on_page && '' == self::$ts_add_setting_on_section && '' == self::$ts_register_setting ) {
155
+ if ( $value['id'] == 'ts_reset_tracking' ) {
156
+ $description = WC_Admin_Settings::get_field_description( $value );
157
+ $ts_action = self::$ts_settings_page . "&amp;ts_action=" . self::$plugin_prefix . "_reset_tracking";
158
+ ?>
159
+
160
+ <tr valign="top">
161
+ <th scope="row" class="titledesc">
162
+ <label for="<?php echo esc_attr( $value['id'] ); ?>"><?php echo esc_html( $value['title'] ); ?></label>
163
+ <?php echo $description['tooltip_html'];?>
164
+ </th>
165
+
166
+ <td class="forminp forminp-<?php echo sanitize_title( $value['type'] ) ?>">
167
+
168
+ <a href = "<?php echo $ts_action; ?>"
169
+ name ="ts_reset_tracking"
170
+ id ="ts_reset_tracking"
171
+ style="<?php echo esc_attr( $value['css'] ); ?>"
172
+ class="<?php echo esc_attr( $value['class'] ); ?>"
173
+ > <?php echo $value['button_text']; ?> </a> <?php echo $description['description']; ?>
174
+ </td>
175
+ </tr><?php
176
+ }
177
+ } else {
178
+ add_settings_field(
179
+ 'ts_reset_tracking',
180
+ __( 'Reset usage tracking', self::$ts_plugin_locale ),
181
+ array( 'WCDN_TS_tracking', 'ts_rereset_tracking_callback' ),
182
+ self::$ts_add_setting_on_page,
183
+ self::$ts_add_setting_on_section,
184
+ array( 'This will reset your usage tracking settings, causing it to show the opt-in banner again and not sending any data.', self::$ts_plugin_locale )
185
+ );
186
+
187
+ register_setting(
188
+ self::$ts_register_setting,
189
+ 'ts_reset_tracking'
190
+ );
191
+ }
192
+ }
193
+
194
+ public static function ts_reset_tracking_setting_section_callback ( ) {
195
+
196
+ }
197
+
198
+ /**
199
+ * It will add the Reset button on the settings page.
200
+ * @param array $args
201
+ */
202
+ public static function ts_rereset_tracking_callback ( $args ) {
203
+ $wcap_restrict_domain_address = get_option( 'wcap_restrict_domain_address' );
204
+ $domain_value = isset( $wcap_restrict_domain_address ) ? esc_attr( $wcap_restrict_domain_address ) : '';
205
+ // Next, we update the name attribute to access this element's ID in the context of the display options array
206
+ // We also access the show_header element of the options collection in the call to the checked() helper function
207
+ $ts_action = self::$ts_settings_page . "&amp;ts_action=" . self::$plugin_prefix . "_reset_tracking";
208
+ printf( '<a href="'.$ts_action.'" class="button button-large reset_tracking">Reset</a>' );
209
+
210
+ // Here, we'll take the first argument of the array and add it to a label next to the checkbox
211
+ $html = '<label for="wcap_restrict_domain_address_label"> ' . $args[0] . '</label>';
212
+ echo $html;
213
+ }
214
+
215
+ /**
216
+ * It will add a cron job for sending the tarcking data.
217
+ * By default it will set once in a week interval.
218
+ * @hook cron_schedules
219
+ * @param array $schedules
220
+ * @return array $schedules
221
+ */
222
+ public static function ts_add_cron_schedule( $schedules ) {
223
+ $schedules[ 'once_in_week' ] = array(
224
+ 'interval' => 604800, // one week in seconds
225
+ 'display' => __( 'Once in a Week', self::$ts_plugin_locale )
226
+ );
227
+
228
+ return $schedules;
229
+ }
230
+
231
+ /**
232
+ * To capture the data from the client site.
233
+ */
234
+ public static function ts_schedule_cron_job () {
235
+ if ( ! wp_next_scheduled( self::$plugin_prefix . '_ts_tracker_send_event' ) ) {
236
+ wp_schedule_event( time(), 'once_in_week', self::$plugin_prefix . '_ts_tracker_send_event' );
237
+ }
238
+ }
239
+
240
+ /**
241
+ * Load the js file in the admin
242
+ *
243
+ * @since 6.8
244
+ * @access public
245
+ */
246
+ public static function ts_admin_notices_scripts() {
247
+
248
+ wp_enqueue_script(
249
+ self::$plugin_prefix . 'ts_dismiss_notice',
250
+ self::$ts_file_path . '/assets/js/dismiss-notice.js',
251
+ '',
252
+ '',
253
+ false
254
+ );
255
+
256
+ wp_localize_script( 'ts_dismiss_notice', 'ts_dismiss_notice', array (
257
+ 'ts_prefix_of_plugin' => self::$plugin_prefix,
258
+ 'ts_admin_url' => admin_url( 'admin-ajax.php' )
259
+ ) );
260
+ }
261
+
262
+ /**
263
+ * Called when the dismiss icon is clicked on the notice.
264
+ *
265
+ * @since 6.8
266
+ * @access public
267
+ */
268
+
269
+ public static function ts_admin_notices() {
270
+ update_option( self::$plugin_prefix . '_allow_tracking', 'dismissed' );
271
+ WCDN_TS_Tracker::ts_send_tracking_data( false );
272
+ die();
273
+ }
274
+
275
+ /**
276
+ * Send the data tracking data to the server.
277
+ *
278
+ * @access public
279
+ *
280
+ */
281
+
282
+ private static function ts_tracking_actions() {
283
+ 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' ) ) {
284
+ update_option( self::$plugin_prefix . '_allow_tracking', 'yes' );
285
+ WCDN_TS_Tracker::ts_send_tracking_data( true );
286
+ header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
287
+ } 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' ) ) {
288
+ update_option( self::$plugin_prefix . '_allow_tracking', 'no' );
289
+ WCDN_TS_Tracker::ts_send_tracking_data( false );
290
+ header( 'Location: ' . $_SERVER[ 'HTTP_REFERER' ] );
291
+ }
292
+ }
293
+
294
+ /**
295
+ * Adds a data usage tracking notice in the admin
296
+ *
297
+ * @access public
298
+ * @since 6.8
299
+ */
300
+
301
+ public static function ts_track_usage_data() {
302
+ $admin_url = get_admin_url();
303
+ echo '<input type="hidden" id="admin_url" value="' . $admin_url . '"/>';
304
+ self::ts_tracking_actions();
305
+ if ( 'unknown' === get_option( self::$plugin_prefix . '_allow_tracking', 'unknown' ) ) : ?>
306
+ <div class="<?php echo self::$plugin_prefix; ?>-message <?php echo self::$plugin_prefix; ?>-tracker notice notice-info is-dismissible" style="position: relative;">
307
+ <div style="position: absolute;"><img class="site-logo" src= " <?php echo self::$ts_file_path . '/assets/images/site-logo-new.jpg '; ?> "></div>
308
+ <p style="margin: 10px 0 10px 130px; font-size: medium;">
309
+ <?php print( __( 'Want to help make ' . self::$plugin_name . ' even more awesome? Allow ' . self::$plugin_name . ' to collect non-sensitive diagnostic data and usage information and get 20% off on your next purchase. <a href="' . self::$blog_post_link . '" target="_blank">Find out more</a>.', self::$plugin_context ) ); ?></p>
310
+ <p class="submit">
311
+ <a class="button-primary button button-large" href="<?php echo esc_url( wp_nonce_url( add_query_arg( self::$plugin_prefix . '_tracker_optin', 'true' ), self::$plugin_prefix . '_tracker_optin', self::$plugin_prefix . '_tracker_nonce' ) ); ?>"><?php esc_html_e( 'Allow', self::$plugin_context ); ?></a>
312
+ <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>
313
+ </p>
314
+ </div>
315
+ <?php endif;
316
+ }
317
+ }
includes/component/woocommerce-check/Instructions ADDED
@@ -0,0 +1,11 @@
1
+ Add a notice if the WooCommerce is not active.
2
+
3
+ To add this feature to the plugin, you can follow the below steps:
4
+
5
+ 1. Copy the ts-woo-active.php file into your plugin file.
6
+
7
+ 2. Include the file ts-woo-active.php once when on the admin page. This can be done with is_admin() function.
8
+
9
+ 3. Change the value of the $plugin_name and $plugin_file variable of the TS_Woo_Active class with the name of your plugin.
10
+
11
+ 4. Now if the WooCommerce plugin is inactive, then our plugin will be inactive automatically with a notice displayed.
includes/component/woocommerce-check/ts-woo-active.php ADDED
@@ -0,0 +1,80 @@