PluginProbe ʕ •ᴥ•ʔ
Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager / 3.5.2
Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager v3.5.2
4.1.38 trunk 1.2 1.2.1 1.2.2 1.2.3 1.3 1.3.1 1.3.2 1.3.3 1.4 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.10 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.2 1.8.3 1.9.0 1.9.1 1.9.2 1.9.3 2.0.0 2.0.1 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.4 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.7.0 2.7.1 2.8.0 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.10 3.0.11 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 3.1.2 3.1.3 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.3.0 3.4.0 3.4.1 3.4.2 3.4.3 3.5.0 3.5.1 3.5.10 3.5.11 3.5.12 3.5.13 3.5.14 3.5.15 3.5.16 3.5.17 3.5.18 3.5.19 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.5.7 3.5.8 3.5.9 3.6.0 4.0.0 4.1.0 4.1.1 4.1.10 4.1.11 4.1.12 4.1.13 4.1.14 4.1.15 4.1.16 4.1.17 4.1.18 4.1.19 4.1.2 4.1.20 4.1.21 4.1.22 4.1.23 4.1.24 4.1.25 4.1.26 4.1.27 4.1.28 4.1.29 4.1.3 4.1.30 4.1.31 4.1.32 4.1.34 4.1.35 4.1.36 4.1.37 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9
flexible-checkout-fields / classes / tracker.php
flexible-checkout-fields / classes Last commit date
activation-tracker.php 3 years ago display-options.php 3 years ago field-type-settings.php 3 years ago field.php 3 years ago filed-validation.php 3 years ago myaccount-edit-address.php 3 years ago myaccount-field-processor.php 3 years ago plugin.php 3 years ago settings.php 3 years ago tracker.php 3 years ago user-meta-checkout.php 3 years ago user-meta.php 3 years ago user-profile.php 3 years ago
tracker.php
369 lines
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
4
5 if ( ! class_exists( 'WPDesk_Flexible_Checkout_Fields_Tracker' ) ) {
6 class WPDesk_Flexible_Checkout_Fields_Tracker {
7
8 public static $script_version = '11';
9
10 public function __construct() {
11 $this->hooks();
12 }
13
14 public function hooks() {
15 add_filter( 'wpdesk_tracker_data', array( $this, 'wpdesk_tracker_data' ), 11 );
16 add_filter( 'wpdesk_tracker_notice_screens', array( $this, 'wpdesk_tracker_notice_screens' ) );
17
18 add_filter( 'plugin_action_links_flexible-checkout-fields/flexible-checkout-fields.php', array( $this, 'plugin_action_links' ) );
19 add_action( 'activated_plugin', array( $this, 'activated_plugin' ), 10, 2 );
20 }
21
22 public function wpdesk_tracker_data( $data ) {
23 $sections = array(
24 'billing',
25 'shipping',
26 'order',
27 'before_customer_details',
28 'after_customer_details',
29 'before_checkout_billing_form',
30 'after_checkout_billing_form',
31 'before_checkout_shipping_form',
32 'after_checkout_shipping_form',
33 'before_checkout_registration_form',
34 'after_checkout_registration_form',
35 'before_order_notes',
36 'after_order_notes',
37 'review_order_before_submit',
38 'review_order_after_submit',
39 );
40 $settings_fields = get_option('inspire_checkout_fields_settings', array() );
41 if ( ! is_array( $settings_fields ) ) {
42 $settings_fields = array();
43 }
44
45 $plugin_data = [
46 'sections' => $this->get_sections_data( $sections, $settings_fields ),
47 'fields_names' => $this->get_fields_names( $settings_fields ),
48 'options' => array(
49 'css_disable' => get_option( 'inspire_checkout_fields_css_disable', '0' )
50 ),
51 'pro_version' => array(
52 'is_active' => is_flexible_checkout_fields_pro_active() ? '1' : '0',
53 'is_activated' => ( get_option( 'api_flexible-checkout-fields-pro_activated', '' ) === 'Activated' ) ? '1' : '0',
54 ),
55 ];
56
57 $data['flexible_checkout_fields'] = $plugin_data;
58
59 return $data;
60 }
61
62 private function get_fields_names( $settings_fields ) {
63 $items = array();
64 foreach ( $settings_fields as $section_key => $fields ) {
65 foreach ( $fields as $field_name => $field ) {
66 $name = str_replace( $section_key . '_', '', $field_name );
67 if ( !isset( $items[ $name ] ) ) {
68 $items[ $name ] = 0;
69 }
70 $items[ $name ]++;
71 }
72 }
73 return $items;
74 }
75
76 private function get_sections_data( $sections, $settings_fields ) {
77 $settings_sections = get_option('inspire_checkout_fields_section_settings', array() );
78 if ( ! is_array( $settings_sections ) ) {
79 $settings_sections = array();
80 }
81 $default_data = array(
82 'enabled' => 0,
83 'has_title' => 0,
84 'has_css' => 0,
85 'fields' => array(),
86 'fields_count' => 0,
87 );
88
89 $data = array();
90 foreach ( $sections as $section ) {
91 $data[$section] = $default_data;
92 if ( in_array( $section, array( 'billing', 'shipping', 'order' ) )
93 || get_option( 'inspire_checkout_fields_' . $section, '0' ) ) {
94 $data[$section]['enabled'] = '1';
95 }
96 if ( isset( $settings_sections[ $section ] ) && ! empty( $settings_sections[ $section ]['section_title'] ) ) {
97 $data[$section]['has_title'] = '1';
98 }
99 if ( isset( $settings_sections[ $section ] ) && ! empty( $settings_sections[ $section ]['section_css'] ) ) {
100 $data[$section]['has_css'] = '1';
101 }
102 $data[$section]['fields'] = $this->get_fields_data( $section, $settings_fields );
103 if ( isset( $settings_fields[ $section ] ) ) {
104 $data[$section]['fields_count'] = count( $settings_fields[ $section ] );
105 }
106 }
107
108 return $data;
109 }
110
111 private function get_fields_data( $section, $settings ) {
112 if ( ! isset( $settings[ $section ] ) ) {
113 return array();
114 }
115 $default_data = array(
116 'count' => 0,
117 'enabled' => 0,
118 'required' => 0,
119 'validation' => array(),
120 'default_value' => 0,
121 'placeholder' => 0,
122 'display_on' => array(
123 'thank_you' => 0,
124 'on_address' => 0,
125 'on_order' => 0,
126 'on_emails' => 0,
127 'option_new_line_before' => 0,
128 'option_show_label' => 0,
129 ),
130 'conditional_logic' => array(),
131 'pricing' => array(
132 'enabled' => 0,
133 'types' => array(),
134 'values' => array(),
135 'tax_classes' => array(),
136 ),
137 );
138
139 $data = array();
140 foreach ( $settings[ $section ] as $field ) {
141 $field_type = ( isset( $field['type'] ) ) ? $field['type'] : '_null_';
142
143 if ( ! isset( $data[ $field_type ] ) ) {
144 $data[ $field_type ] = $default_data;
145 }
146 $data[ $field_type ]['count']++;
147 if ( isset( $field['visible'] ) && ! $field['visible'] ) {
148 $data[ $field_type ]['enabled']++;
149 }
150 if ( isset( $field['required'] ) && $field['required'] ) {
151 $data[ $field_type ]['required']++;
152 }
153 if ( isset( $field['validation'] ) && $field['validation'] ) {
154 if ( ! isset( $data[ $field_type ]['validation'][ $field['validation'] ] ) ) {
155 $data[ $field_type ]['validation'][ $field['validation'] ] = 0;
156 }
157 $data[ $field_type ]['validation'][ $field['validation'] ]++;
158 }
159 if ( isset( $field['default'] ) && $field['default'] ) {
160 $data[ $field_type ]['default_value']++;
161 }
162 if ( isset( $field['placeholder'] ) && $field['placeholder'] ) {
163 $data[ $field_type ]['placeholder']++;
164 }
165 if ( isset( $field['display_on_thank_you'] ) && $field['display_on_thank_you'] ) {
166 $data[ $field_type ]['display_on']['thank_you']++;
167 }
168 if ( isset( $field['display_on_address'] ) && $field['display_on_address'] ) {
169 $data[ $field_type ]['display_on']['on_address']++;
170 }
171 if ( isset( $field['display_on_order'] ) && $field['display_on_order'] ) {
172 $data[ $field_type ]['display_on']['on_order']++;
173 }
174 if ( isset( $field['display_on_emails'] ) && $field['display_on_emails'] ) {
175 $data[ $field_type ]['display_on']['on_emails']++;
176 }
177 if ( isset( $field['display_on_option_new_line_before'] ) && $field['display_on_option_new_line_before'] ) {
178 $data[ $field_type ]['display_on']['option_new_line_before']++;
179 }
180 if ( isset( $field['display_on_option_show_label'] ) && $field['display_on_option_show_label'] ) {
181 $data[ $field_type ]['display_on']['option_show_label']++;
182 }
183 if ( isset( $field['pricing_enabled'] ) && $field['pricing_enabled'] ) {
184 $data[ $field_type ]['pricing']['enabled']++;
185 }
186 if ( isset( $field['pricing_values'] ) && $field['pricing_values'] ) {
187 foreach ( $field['pricing_values'] as $pricing_value ) {
188 if ( ! isset( $data[ $field_type ]['pricing']['types'][ $pricing_value['type'] ] ) ) {
189 $data[ $field_type ]['pricing']['types'][ $pricing_value['type'] ] = 0;
190 }
191 $data[ $field_type ]['pricing']['types'][ $pricing_value['type'] ]++;
192 }
193 foreach ( $field['pricing_values'] as $pricing_value ) {
194 if ( ! isset( $data[ $field_type ]['pricing']['values'][ $pricing_value['value'] ] ) ) {
195 $data[ $field_type ]['pricing']['values'][ $pricing_value['value'] ] = 0;
196 }
197 $data[ $field_type ]['pricing']['values'][ $pricing_value['value'] ]++;
198 }
199 foreach ( $field['pricing_values'] as $pricing_value ) {
200 if ( ! isset( $data[ $field_type ]['pricing']['tax_classes'][ $pricing_value['tax_class'] ] ) ) {
201 $data[ $field_type ]['pricing']['tax_classes'][ $pricing_value['tax_class'] ] = 0;
202 }
203 $data[ $field_type ]['pricing']['tax_classes'][ $pricing_value['tax_class'] ]++;
204 }
205 }
206 $data[ $field_type ]['conditional_logic'] = $this->get_conditional_logic_data(
207 $field,
208 $data[ $field_type ]['conditional_logic']
209 );
210 }
211
212 return $data;
213 }
214
215 private function get_conditional_logic_data( $field, $current_data ) {
216 $default_data = array(
217 'enabled' => 0,
218 'action' => array(),
219 'operator' => array(),
220 'rule_options' => array(),
221 'rule_operators' => array(),
222 );
223
224 $data = ( $current_data )
225 ? $current_data
226 : array(
227 'products' => $default_data,
228 'fields' => $default_data,
229 'shipping' => $default_data,
230 )
231 ;
232
233 if ( isset( $field['conditional_logic'] ) && $field['conditional_logic'] ) {
234 $data['products']['enabled']++;
235 }
236 if ( isset( $field['conditional_logic_action'] ) && $field['conditional_logic_action'] ) {
237 if ( ! isset( $data['products']['action'][ $field['conditional_logic_action'] ] ) ) {
238 $data['products']['action'][ $field['conditional_logic_action'] ] = 0;
239 }
240 $data['products']['action'][ $field['conditional_logic_action'] ]++;
241 }
242 if ( isset( $field['conditional_logic_operator'] ) && $field['conditional_logic_operator'] ) {
243 if ( ! isset( $data['products']['operator'][ $field['conditional_logic_operator'] ] ) ) {
244 $data['products']['operator'][ $field['conditional_logic_operator'] ] = 0;
245 }
246 $data['products']['operator'][ $field['conditional_logic_operator'] ]++;
247 }
248 if ( isset( $field['conditional_logic_rules'] ) && $field['conditional_logic_rules'] ) {
249 foreach ( $field['conditional_logic_rules'] as $rule ) {
250 if ( ! isset( $data['products']['rule_options'][ $rule['condition'] ] ) ) {
251 $data['products']['rule_options'][ $rule['condition'] ] = 0;
252 }
253 $data['products']['rule_options'][ $rule['condition'] ]++;
254 if ( ! isset( $data['products']['rule_operators'][ $rule['what'] ] ) ) {
255 $data['products']['rule_operators'][ $rule['what'] ] = 0;
256 }
257 $data['products']['rule_operators'][ $rule['what'] ]++;
258 }
259 }
260
261 if ( isset( $field['conditional_logic_fields'] ) && $field['conditional_logic_fields'] ) {
262 $data['fields']['enabled']++;
263 }
264 if ( isset( $field['conditional_logic_fields_action'] ) && $field['conditional_logic_fields_action'] ) {
265 if ( ! isset( $data['fields']['action'][ $field['conditional_logic_fields_action'] ] ) ) {
266 $data['fields']['action'][ $field['conditional_logic_fields_action'] ] = 0;
267 }
268 $data['fields']['action'][ $field['conditional_logic_fields_action'] ]++;
269 }
270 if ( isset( $field['conditional_logic_fields_operator'] ) && $field['conditional_logic_fields_operator'] ) {
271 if ( ! isset( $data['fields']['operator'][ $field['conditional_logic_fields_operator'] ] ) ) {
272 $data['fields']['operator'][ $field['conditional_logic_fields_operator'] ] = 0;
273 }
274 $data['fields']['operator'][ $field['conditional_logic_fields_operator'] ]++;
275 }
276 if ( isset( $field['conditional_logic_fields_rules'] ) && $field['conditional_logic_fields_rules'] ) {
277 foreach ( $field['conditional_logic_fields_rules'] as $rule ) {
278 if ( ! isset( $data['fields']['rule_operators'][ $rule['condition'] ] ) ) {
279 $data['fields']['rule_operators'][ $rule['condition'] ] = 0;
280 }
281 $data['fields']['rule_operators'][ $rule['condition'] ]++;
282 }
283 }
284
285 if ( isset( $field['conditional_logic_shipping_fields'] ) && $field['conditional_logic_shipping_fields'] ) {
286 $data['shipping']['enabled']++;
287 }
288 if ( isset( $field['conditional_logic_shipping_fields_action'] ) && $field['conditional_logic_shipping_fields_action'] ) {
289 if ( ! isset( $data['shipping']['action'][ $field['conditional_logic_shipping_fields_action'] ] ) ) {
290 $data['shipping']['action'][ $field['conditional_logic_shipping_fields_action'] ] = 0;
291 }
292 $data['shipping']['action'][ $field['conditional_logic_shipping_fields_action'] ]++;
293 }
294 if ( isset( $field['conditional_logic_shipping_fields_operator'] ) && $field['conditional_logic_shipping_fields_operator'] ) {
295 if ( ! isset( $data['shipping']['operator'][ $field['conditional_logic_shipping_fields_operator'] ] ) ) {
296 $data['shipping']['operator'][ $field['conditional_logic_shipping_fields_operator'] ] = 0;
297 }
298 $data['shipping']['operator'][ $field['conditional_logic_shipping_fields_operator'] ]++;
299 }
300
301 return $data;
302 }
303
304 public function wpdesk_tracker_notice_screens( $screens ) {
305 $current_screen = get_current_screen();
306 if ( $current_screen->id == 'woocommerce_page_inspire_checkout_fields_settings' ) {
307 $screens[] = $current_screen->id;
308 }
309 return $screens;
310 }
311
312 public function plugin_action_links( $links ) {
313 if ( !wpdesk_tracker_enabled() || apply_filters( 'wpdesk_tracker_do_not_ask', false ) ) {
314 return $links;
315 }
316 $options = get_option('wpdesk_helper_options', array() );
317 if ( !is_array( $options )) {
318 $options = array();
319 }
320 if ( empty( $options['wpdesk_tracker_agree'] ) ) {
321 $options['wpdesk_tracker_agree'] = '0';
322 }
323 $plugin_links = array();
324 if ( $options['wpdesk_tracker_agree'] == '0' ) {
325 $opt_in_link = admin_url( 'admin.php?page=wpdesk_tracker&plugin=flexible-checkout-fields/flexible-checkout-fields.php' );
326 $plugin_links[] = '<a href="' . $opt_in_link . '">' . __( 'Opt-in', 'flexible-checkout-fields' ) . '</a>';
327 }
328 else {
329 $opt_in_link = admin_url( 'plugins.php?wpdesk_tracker_opt_out=1&plugin=flexible-checkout-fields/flexible-checkout-fields.php' );
330 $plugin_links[] = '<a href="' . $opt_in_link . '">' . __( 'Opt-out', 'flexible-checkout-fields' ) . '</a>';
331 }
332 return array_merge( $plugin_links, $links );
333 }
334
335 public function activated_plugin( $plugin, $network_wide ) {
336 if ( $network_wide ) {
337 return;
338 }
339 if ( defined( 'WP_CLI' ) && WP_CLI ) {
340 return;
341 }
342 if ( !wpdesk_tracker_enabled() ) {
343 return;
344 }
345 if ( $plugin == 'flexible-checkout-fields/flexible-checkout-fields.php' ) {
346 $options = get_option('wpdesk_helper_options', array() );
347
348 if ( empty( $options ) ) {
349 $options = array();
350 }
351 if ( empty( $options['wpdesk_tracker_agree'] ) ) {
352 $options['wpdesk_tracker_agree'] = '0';
353 }
354 $wpdesk_tracker_skip_plugin = get_option( 'wpdesk_tracker_skip_flexible_checkout_fields', '0' );
355 if ( $options['wpdesk_tracker_agree'] == '0' && $wpdesk_tracker_skip_plugin == '0' ) {
356 update_option( 'wpdesk_tracker_notice', '1' );
357 update_option( 'wpdesk_tracker_skip_flexible_checkout_fields', '1' );
358 if ( !apply_filters( 'wpdesk_tracker_do_not_ask', false ) ) {
359 wp_redirect( admin_url( 'admin.php?page=wpdesk_tracker&plugin=flexible-checkout-fields/flexible-checkout-fields.php' ) );
360 exit;
361 }
362 }
363 }
364 }
365
366 }
367
368 }
369