PluginProbe ʕ •ᴥ•ʔ
PiWeb Delivery & Pickup Date Time for WooCommerce / 3.0.49.67
PiWeb Delivery & Pickup Date Time for WooCommerce v3.0.49.67
3.0.63 3.0.62 3.0.61 3.0.60 3.0.49.49 3.0.49.6 3.0.49.60 3.0.49.61 3.0.49.62 3.0.49.63 3.0.49.64 3.0.49.66 3.0.49.67 3.0.49.69 3.0.49.7 3.0.49.70 3.0.49.72 3.0.49.73 3.0.49.74 3.0.49.76 3.0.49.77 3.0.49.79 3.0.49.9 3.0.49.90 3.0.49.91 3.0.49.92 3.0.49.93 3.0.49.94 3.0.49.96 3.0.49.97 3.0.49.99 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 2.9.17 3.0.47 3.0.49 3.0.49.1 3.0.49.10 3.0.49.11 3.0.49.12 3.0.49.13 3.0.49.16 3.0.49.17 3.0.49.19 3.0.49.2 3.0.49.20 3.0.49.21 3.0.49.22 3.0.49.23 3.0.49.24 3.0.49.26 3.0.49.27 3.0.49.29 3.0.49.3 3.0.49.30 3.0.49.31 3.0.49.32 3.0.49.33 3.0.49.34 3.0.49.36 3.0.49.37 3.0.49.39 3.0.49.4 3.0.49.40 3.0.49.41 3.0.49.42 3.0.49.43 3.0.49.44 3.0.49.46 3.0.49.47
pi-woocommerce-order-date-time-and-type / admin / class-analytics.php
pi-woocommerce-order-date-time-and-type / admin Last commit date
css 9 months ago img 9 months ago js 9 months ago partials 9 months ago class-adv-order-filter.php 9 months ago class-analytics.php 9 months ago class-order-tip-promotion.php 9 months ago class-pi-dtt-labels.php 9 months ago class-pi-dtt-order-table.php 9 months ago conflict-fixer.php 9 months ago menu.php 9 months ago options-addons.php 9 months ago options-date.php 9 months ago options-limit.php 9 months ago options-pickup.php 9 months ago options-time-slot.php 9 months ago options-time.php 9 months ago options.php 9 months ago
class-analytics.php
258 lines
1 <?php
2 /**
3 * v1.0.2
4 */
5
6
7 if ( ! defined( 'ABSPATH' ) ) exit;
8
9 class Pi_Dtt_Analytics{
10
11 private $plugin_slug;
12 private $plugin_path;
13 private $version;
14 private $url;
15 private $plugin_name;
16 private $enable_tracking;
17 private $enable_tracking_action;
18 public function __construct($plugin_name, $plugin_path, $version) {
19 $this->plugin_name = $plugin_name;
20 $this->plugin_path = $plugin_path;
21
22 $parts = explode('/', $this->plugin_path);
23
24 $this->plugin_slug = $parts[0];
25
26 $this->enable_tracking = 'pisol_'.$this->plugin_slug;
27 $this->enable_tracking_action = 'pisol_'.$this->plugin_slug.'_action';
28
29
30 $this->version = $version;
31
32 $this->url = 'https://www.piwebsolution.com/plugin-tracker/';
33
34 add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'));
35 add_action( 'admin_footer-plugins.php', [ $this, 'print_deactivation_modal' ] );
36 add_action('admin_post_pi_handle_deactivation_' . $this->plugin_slug, array($this, 'handle_deactivation_form'));
37
38 add_action('admin_notices', array($this, 'show_tracker_notice'));
39
40 add_action('admin_post_' . $this->enable_tracking_action, array($this, 'handle_tracker_action'));
41
42 }
43
44 public function show_tracker_notice() {
45 //delete_option($this->enable_tracking);
46 if (!empty(get_option($this->enable_tracking, ''))) {
47 return;
48 }
49
50 $notice = '<div class="notice notice-error is-dismissible">';
51 $notice .= '<h4>Help to Improve ' . esc_html($this->plugin_name) . ' plugin</h4>';
52 $notice .= '<p>'.__("Hi, your support can make a big difference!", 'conditional-discount-rule-woocommerce').'</p>';
53 $notice .= '<p>'.__("We collect only technical data — including the plugin version, WordPress version, WooCommerce version, and site url — solely to improve compatibility and enhance plugin features.", 'conditional-discount-rule-woocommerce').'</p>';
54
55 $notice .= '<p style="display: flex; justify-content: space-between; margin-top: 10px;">';
56
57 $notice .= sprintf(
58 '<a href="%s" class="button">%s</a>',
59 esc_url(admin_url('admin-post.php?enable=0&action=' . $this->enable_tracking_action)),
60 __('I Don\'t Help', 'conditional-discount-rule-woocommerce')
61 );
62 $notice .= sprintf(
63 '<a href="%s" class="button button-primary" style="margin-right:20px; padding-left:30px; padding-right:30px;">%s</a>',
64 esc_url(admin_url('admin-post.php?enable=1&action=' . $this->enable_tracking_action)),
65 __('I Will Help', 'conditional-discount-rule-woocommerce')
66 );
67
68 $notice .= '</p>';
69 $notice .= '</div>';
70 echo $notice;
71
72 }
73
74 public function handle_tracker_action() {
75 if (isset($_GET['enable']) && in_array($_GET['enable'], array('1', '0'))) {
76 $enable = $_GET['enable'] === '1' ? 'enable' : 'disable';
77 update_option($this->enable_tracking, $enable);
78 $redirect_url = isset($_SERVER['HTTP_REFERER']) ? esc_url_raw($_SERVER['HTTP_REFERER']) : admin_url();
79
80 if ($enable === 'enable') {
81 $this->send_activation_data('enable');
82 }
83
84 wp_safe_redirect($redirect_url);
85 exit;
86 }
87 }
88
89 public function send_activation_data($action, $message = '') {
90
91 $data = array(
92 'plugin_slug' => $this->plugin_slug,
93 'version' => $this->version,
94 'site_url' => get_site_url(),
95 'wp_version' => get_bloginfo('version'),
96 'wc_version' => function_exists('WC') ? WC()->version : '',
97 'action' => $action,
98 'message' => $message,
99 );
100
101 // Make the request non-blocking by setting 'blocking' => false
102 wp_remote_post($this->url, array(
103 'body' => wp_json_encode($data),
104 'headers' => array('Content-Type' => 'application/json'),
105 'blocking' => false,
106 ));
107 }
108
109 function enqueue_scripts($hook) {
110 if ($hook !== 'plugins.php') return;
111
112 $js = '
113 jQuery(document).ready(function($) {
114 var id = "deactivate-'.$this->plugin_slug.'";
115
116 jQuery(document).on("click", "#"+id, function(e) {
117
118 var href = $(this).attr("href");
119 var popup = "#pi-deactivation-reason-'.$this->plugin_slug.'";
120 if ($(popup).length) {
121 e.preventDefault();
122 $(popup).show();
123 }
124 });
125
126 jQuery(document).on("click", "#pi-deactivator-close-'.$this->plugin_slug.'", function(e) {
127
128 var popup = "#pi-deactivation-reason-'.$this->plugin_slug.'";
129 if ($(popup).length) {
130 e.preventDefault();
131 $(popup).hide();
132 }
133 });
134
135 jQuery(document).on("change", "#pi-deact-form-'.esc_attr($this->plugin_slug).' input[name=\'reason_radio\']", function () {
136 if (jQuery(this).val() === "Other") {
137 jQuery("#pi-deact-form-'.esc_attr($this->plugin_slug).' textarea").show();
138 } else {
139 jQuery("#pi-deact-form-'.esc_attr($this->plugin_slug).' textarea").hide();
140 }
141 });
142 });
143 ';
144
145 wp_add_inline_script('jquery', $js);
146
147 // Add the deactivation modal CSS as inline style
148 $css = '.pi-deactivation-overlay-' . esc_attr($this->plugin_slug) . ' {
149 display: none;
150 position: fixed;
151 top: 0; left: 0; right: 0; bottom: 0;
152 width: 100%;
153 height: 100%;
154 background: rgba(0,0,0,0.5);
155 z-index: 9999;
156 }
157
158 .pi-deact-close-' . esc_attr($this->plugin_slug) . ' {
159 color: #000;
160 text-decoration: none;
161 font-size: 20px;
162 font-weight: bold;
163 }
164
165 .pi-deactivation-modal-' . esc_attr($this->plugin_slug) . ' {
166 position: fixed;
167 top: 50%;
168 left: 50%;
169 transform: translate(-50%, -50%);
170 background: #fff;
171 padding: 20px;
172 width: 400px;
173 max-width: 90%;
174 max-height: 90%;
175 overflow: auto;
176 box-shadow: 0 2px 10px rgba(0,0,0,0.3);
177 z-index: 10000;
178 }';
179 wp_add_inline_style('wp-admin', $css);
180 }
181
182 public function print_deactivation_modal() {
183 $nonce = wp_create_nonce('pi_deactivate_nonce_' . $this->plugin_slug);
184 ?>
185 <div id="pi-deactivation-reason-<?php echo esc_attr($this->plugin_slug); ?>" style="display:none;" class="pi-deactivation-overlay-<?php echo esc_attr($this->plugin_slug); ?>">
186 <div class="pi-deactivation-modal-<?php echo esc_attr($this->plugin_slug); ?>">
187 <a href="javascript:void(0);" id="pi-deactivator-close-<?php echo esc_attr($this->plugin_slug); ?>" class="pi-deact-close-<?php echo esc_attr($this->plugin_slug); ?>" style="position: absolute; top: 10px; right: 10px; z-index: 10001;">&times;</a>
188 <form id="pi-deact-form-<?php echo esc_attr($this->plugin_slug); ?>" method="post" action="<?php echo esc_url(admin_url('admin-post.php')); ?>">
189 <h3>Help us to improve by giving reason for deactivation:</h3>
190 <div style="margin-bottom:10px;">
191 <label style="margin-bottom:10px; display:block;"><input type="radio" name="reason_radio" value="Was looking for something else"> Was looking for something else</label>
192 <label style="margin-bottom:10px; display:block;"><input type="radio" name="reason_radio" value="I found a better plugin"> I found a better plugin</label>
193 <label style="margin-bottom:10px; display:block;"><input type="radio" name="reason_radio" value="The plugin broke my site"> The plugin broke my site</label>
194 <label style="margin-bottom:10px; display:block;"><input type="radio" name="reason_radio" value="The plugin is not working as expected"> The plugin is not working as expected</label>
195 <label style="margin-bottom:10px; display:block;"><input type="radio" name="reason_radio" value="Other"> Other (please specify below)</label>
196 </div>
197 <textarea id="pi-deact-reason-<?php echo esc_attr($this->plugin_slug); ?>" name="message" style="width:100%; display:none;" rows="4" placeholder="Let us know the reason for deactivation"></textarea>
198 <?php
199 // Hidden fields
200 echo '<input type="hidden" name="action" value="pi_handle_deactivation_' . esc_attr($this->plugin_slug) . '">';
201 echo '<input type="hidden" name="plugin_slug" value="' . esc_attr($this->plugin_slug) . '">';
202 echo '<input type="hidden" name="nonce" value="' . esc_attr($nonce) . '">';
203 ?>
204 <p style="display: flex; justify-content: space-between; margin-top: 10px;">
205 <button type="submit" name="action_type" class="pi-deact-skip button" value="skip">Skip</button>
206 <button type="submit" class="pi-deact-submit button button-primary" name="action_type" value="submit">Deactivate & Submit</button>
207 </p>
208 </form>
209 </div>
210 </div>
211 <?php
212 }
213
214 public function handle_deactivation_form() {
215 if (!isset($_POST['nonce']) || !wp_verify_nonce($_POST['nonce'], 'pi_deactivate_nonce_' . $this->plugin_slug)) {
216 wp_die(__('Security check failed', 'conditional-discount-rule-woocommerce'));
217 }
218
219 $plugin_slug = sanitize_text_field($_POST['plugin_slug'] ?? '');
220 $message = sanitize_textarea_field($_POST['message'] ?? '');
221 $reason = sanitize_text_field($_POST['reason_radio'] ?? '');
222 // Combine reason and message, prioritizing reason if message is empty
223 if (!empty($reason) && !empty($message)) {
224 $message = $reason . ': ' . $message;
225 } elseif (!empty($reason)) {
226 $message = $reason;
227 }
228
229 $action_type = sanitize_text_field($_POST['action_type'] ?? '');
230
231 if (is_multisite() && is_plugin_active_for_network($this->plugin_path)) {
232 if (is_super_admin()) {
233 deactivate_plugins($this->plugin_path, false, true); // network-wide
234 } else {
235 wp_die(__('You do not have permission to deactivate a network plugin.', 'conditional-discount-rule-woocommerce'));
236 }
237 } else {
238 deactivate_plugins($this->plugin_path); // normal
239 }
240
241 if($action_type === 'submit'){
242 $this->send_activation_data('disable', wp_strip_all_tags($message));
243 }
244
245
246 // Redirect back to plugins page
247 wp_safe_redirect(admin_url('plugins.php'));
248 exit;
249 }
250
251
252 }
253
254 new Pi_Dtt_Analytics(
255 'WooCommerce Delivery Date & Time Plugin',
256 'pi-woocommerce-order-date-time-and-type/pi-woocommerce-order-date-time-and-type.php',
257 PISOL_DTT_PLUGIN_VERSION
258 );