Version Description
- 2018-04-19 =
- Fixed hooks priority for Display On settings tab
- Fixed required field message - removed HTML tags from field label
- Fixed add field function with HTML in label
- Fixed display NIP field added by the iFirma plugin
Download this release
Release Info
Developer | jablonowski |
Plugin | Flexible Checkout Fields for WooCommerce – WooCommerce Checkout Manager |
Version | 1.6.3 |
Comparing to | |
See all releases |
Code changes from version 1.6.2 to 1.6.3
- classes/activation-tracker.php +66 -0
- classes/display-options.php +39 -51
- classes/filed-validation.php +25 -4
- classes/settings.php +10 -1
- classes/views/settings-fields.php +33 -16
- composer.json +11 -9
- flexible-checkout-fields.php +10 -5
- readme.txt +8 -2
- vendor/autoload.php +1 -1
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/autoload_static.php +1 -1
classes/activation-tracker.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
if ( ! defined( 'ABSPATH' ) ) {
|
3 |
+
exit;
|
4 |
+
} // Exit if accessed directly
|
5 |
+
|
6 |
+
class Flexible_Checkout_Fields_Activation_Tracker {
|
7 |
+
|
8 |
+
/** @var string */
|
9 |
+
private $namespace;
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Flexible_Checkout_Fields_Activation_Tracker constructor.
|
13 |
+
*
|
14 |
+
* @param $namespace string for settings
|
15 |
+
*/
|
16 |
+
public function __construct( $namespace ) {
|
17 |
+
$this->namespace = $namespace;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Option name for date storage
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
private function get_option_name_activation_date() {
|
26 |
+
return $this->namespace . '_activation';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns activation date and sets it if were not set before
|
31 |
+
*
|
32 |
+
* @return int unix timestamp for activation datetime
|
33 |
+
*/
|
34 |
+
public function get_activation_date() {
|
35 |
+
$activation_date
|
36 |
+
= get_option( $this->get_option_name_activation_date() );
|
37 |
+
if ( empty( $activation_date ) ) {
|
38 |
+
return $this->touch_activation_date();
|
39 |
+
}
|
40 |
+
|
41 |
+
return intval( $activation_date );
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Was activation more than two weeks before today
|
46 |
+
*
|
47 |
+
* @return bool
|
48 |
+
*/
|
49 |
+
public function is_activated_more_than_two_weeks() {
|
50 |
+
$two_weeks = 60 * 60 * 24 * 7 * 2;
|
51 |
+
|
52 |
+
return $this->get_activation_date() + $two_weeks < time();
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Sets activatiion date for today
|
57 |
+
*
|
58 |
+
* @return int unit timestamp for now
|
59 |
+
*/
|
60 |
+
public function touch_activation_date() {
|
61 |
+
$now = time();
|
62 |
+
update_option( $this->get_option_name_activation_date(), $now );
|
63 |
+
|
64 |
+
return $now;
|
65 |
+
}
|
66 |
+
}
|
classes/display-options.php
CHANGED
@@ -3,22 +3,37 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
3 |
|
4 |
class Flexible_Checkout_Fields_Disaplay_Options {
|
5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
6 |
protected $plugin;
|
7 |
|
8 |
protected $current_address_type = 'shipping';
|
9 |
|
10 |
protected $in_email_address = false;
|
11 |
|
|
|
|
|
|
|
|
|
|
|
12 |
public function __construct( $plugin ) {
|
13 |
$this->plugin = $plugin;
|
14 |
$this->hooks();
|
15 |
}
|
16 |
|
|
|
|
|
|
|
17 |
protected function hooks() {
|
18 |
-
add_filter( 'woocommerce_localisation_address_formats', array( $this, 'woocommerce_localisation_address_formats' ) );
|
19 |
-
add_filter( 'woocommerce_formatted_address_replacements', array( $this, 'woocommerce_formatted_address_replacements' ),
|
20 |
-
add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'woocommerce_order_formatted_billing_address' ),
|
21 |
-
add_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'woocommerce_order_formatted_shipping_address' ),
|
22 |
|
23 |
// addresses in my account
|
24 |
add_filter( 'woocommerce_my_account_my_address_formatted_address', array( $this, 'woocommerce_my_account_my_address_formatted_address' ), 10, 3 );
|
@@ -62,27 +77,8 @@ class Flexible_Checkout_Fields_Disaplay_Options {
|
|
62 |
if ( isset( $type ) && is_array( $type ) ) {
|
63 |
foreach ( $type as $field ) {
|
64 |
if ( isset( $field['visible'] ) && $field['visible'] == 0 && isset( $field['custom_field'] ) && $field['custom_field'] == 1 ) {
|
65 |
-
$add_field = true;
|
66 |
-
if ( $this->is_thankyou_page() ) {
|
67 |
-
$add_field = false;
|
68 |
-
if ( !isset( $field['display_on_thank_you'] ) || $field['display_on_thank_you'] == '1' ) {
|
69 |
-
$add_field = true;
|
70 |
-
}
|
71 |
-
}
|
72 |
-
if ( $this->is_order_page() ) {
|
73 |
-
$add_field = false;
|
74 |
-
if ( !isset( $field['display_on_order'] ) || $field['display_on_order'] == '1' ) {
|
75 |
-
$add_field = true;
|
76 |
-
}
|
77 |
-
}
|
78 |
-
if ( $this->is_in_email() ) {
|
79 |
-
$add_field = false;
|
80 |
-
if ( !isset( $field['display_on_emails'] ) || $field['display_on_emails'] == '1' ) {
|
81 |
-
$add_field = true;
|
82 |
-
}
|
83 |
-
}
|
84 |
$value = wpdesk_get_order_meta( $order_id, '_'.$field['name'] , true );
|
85 |
-
if ( $
|
86 |
if ( !empty( $checkout_field_type[$field['type']]['has_options'] ) ) {
|
87 |
$array_options = explode("\n", $field['option']);
|
88 |
if( !empty( $array_options ) ) {
|
@@ -188,32 +184,7 @@ class Flexible_Checkout_Fields_Disaplay_Options {
|
|
188 |
if ( isset( $field['type'] ) && in_array( $field['type'], array( 'heading', 'info' ) ) ) {
|
189 |
continue;
|
190 |
}
|
191 |
-
$
|
192 |
-
if ( $this->is_edit_address_page() ) {
|
193 |
-
$add_field = false;
|
194 |
-
if ( !isset( $field['display_on_address'] ) || $field['display_on_address'] == '1' ) {
|
195 |
-
$add_field = true;
|
196 |
-
}
|
197 |
-
}
|
198 |
-
if ( $this->is_order_page() ) {
|
199 |
-
$add_field = false;
|
200 |
-
if ( !isset( $field['display_on_order'] ) || $field['display_on_order'] == '1' ) {
|
201 |
-
$add_field = true;
|
202 |
-
}
|
203 |
-
}
|
204 |
-
if ( $this->is_in_email() ) {
|
205 |
-
$add_field = false;
|
206 |
-
if ( !isset( $field['display_on_email'] ) || $field['display_on_email'] == '1' ) {
|
207 |
-
$add_field = true;
|
208 |
-
}
|
209 |
-
}
|
210 |
-
if ( $this->is_thankyou_page() ) {
|
211 |
-
$add_field = false;
|
212 |
-
if ( !isset( $field['display_on_thank_you'] ) || $field['display_on_thank_you'] == '1' ) {
|
213 |
-
$add_field = true;
|
214 |
-
}
|
215 |
-
}
|
216 |
-
if ( $add_field ) {
|
217 |
if ( $default_format != '' ) {
|
218 |
$default_format .= "\n";
|
219 |
}
|
@@ -225,6 +196,23 @@ class Flexible_Checkout_Fields_Disaplay_Options {
|
|
225 |
return $new_formats;
|
226 |
}
|
227 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
public function is_admin_edit_order() {
|
229 |
$admin_edit_order = false;
|
230 |
if ( is_admin() ) {
|
@@ -363,7 +351,7 @@ class Flexible_Checkout_Fields_Disaplay_Options {
|
|
363 |
$remove_field = false;
|
364 |
if ( $edit_address_page ) {
|
365 |
$remove_field = true;
|
366 |
-
if ( !isset( $cf_field[
|
367 |
$remove_field = false;
|
368 |
}
|
369 |
}
|
3 |
|
4 |
class Flexible_Checkout_Fields_Disaplay_Options {
|
5 |
|
6 |
+
const HOOK_PRIORITY_LAST = 999999;
|
7 |
+
|
8 |
+
const DISPLAY_ON_ADDRESS = 'display_on_address';
|
9 |
+
const DISPLAY_ON_THANK_YOU = 'display_on_thank_you';
|
10 |
+
const DISPLAY_ON_ORDER = 'display_on_order';
|
11 |
+
const DISPLAY_ON_EMAILS = 'display_on_emails';
|
12 |
+
|
13 |
protected $plugin;
|
14 |
|
15 |
protected $current_address_type = 'shipping';
|
16 |
|
17 |
protected $in_email_address = false;
|
18 |
|
19 |
+
/**
|
20 |
+
* Flexible_Checkout_Fields_Disaplay_Options constructor.
|
21 |
+
*
|
22 |
+
* @param Flexible_Checkout_Fields_Plugin $plugin
|
23 |
+
*/
|
24 |
public function __construct( $plugin ) {
|
25 |
$this->plugin = $plugin;
|
26 |
$this->hooks();
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
*
|
31 |
+
*/
|
32 |
protected function hooks() {
|
33 |
+
add_filter( 'woocommerce_localisation_address_formats', array( $this, 'woocommerce_localisation_address_formats' ), self::HOOK_PRIORITY_LAST );
|
34 |
+
add_filter( 'woocommerce_formatted_address_replacements', array( $this, 'woocommerce_formatted_address_replacements' ), self::HOOK_PRIORITY_LAST, 2 );
|
35 |
+
add_filter( 'woocommerce_order_formatted_billing_address', array( $this, 'woocommerce_order_formatted_billing_address' ), self::HOOK_PRIORITY_LAST, 2 );
|
36 |
+
add_filter( 'woocommerce_order_formatted_shipping_address', array( $this, 'woocommerce_order_formatted_shipping_address' ), self::HOOK_PRIORITY_LAST, 2 );
|
37 |
|
38 |
// addresses in my account
|
39 |
add_filter( 'woocommerce_my_account_my_address_formatted_address', array( $this, 'woocommerce_my_account_my_address_formatted_address' ), 10, 3 );
|
77 |
if ( isset( $type ) && is_array( $type ) ) {
|
78 |
foreach ( $type as $field ) {
|
79 |
if ( isset( $field['visible'] ) && $field['visible'] == 0 && isset( $field['custom_field'] ) && $field['custom_field'] == 1 ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
80 |
$value = wpdesk_get_order_meta( $order_id, '_'.$field['name'] , true );
|
81 |
+
if ( $this->is_field_displayable( $field ) && $value ) {
|
82 |
if ( !empty( $checkout_field_type[$field['type']]['has_options'] ) ) {
|
83 |
$array_options = explode("\n", $field['option']);
|
84 |
if( !empty( $array_options ) ) {
|
184 |
if ( isset( $field['type'] ) && in_array( $field['type'], array( 'heading', 'info' ) ) ) {
|
185 |
continue;
|
186 |
}
|
187 |
+
if ( $this->is_field_displayable( $field ) ) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
188 |
if ( $default_format != '' ) {
|
189 |
$default_format .= "\n";
|
190 |
}
|
196 |
return $new_formats;
|
197 |
}
|
198 |
|
199 |
+
private function is_field_displayable( $field ) {
|
200 |
+
$displayable = true;
|
201 |
+
if ( $this->is_edit_address_page() ) {
|
202 |
+
$displayable = !isset( $field[self::DISPLAY_ON_ADDRESS] ) || $field[self::DISPLAY_ON_ADDRESS] == '1';
|
203 |
+
}
|
204 |
+
if ( $this->is_order_page() ) {
|
205 |
+
$displayable = !isset( $field[self::DISPLAY_ON_ORDER] ) || $field[self::DISPLAY_ON_ORDER] == '1';
|
206 |
+
}
|
207 |
+
if ( $this->is_in_email() ) {
|
208 |
+
$displayable = !isset( $field[self::DISPLAY_ON_EMAILS] ) || $field[self::DISPLAY_ON_EMAILS] == '1';
|
209 |
+
}
|
210 |
+
if ( $this->is_thankyou_page() ) {
|
211 |
+
$displayable = !isset( $field[self::DISPLAY_ON_THANK_YOU] ) || $field[self::DISPLAY_ON_THANK_YOU] == '1';
|
212 |
+
}
|
213 |
+
return $displayable;
|
214 |
+
}
|
215 |
+
|
216 |
public function is_admin_edit_order() {
|
217 |
$admin_edit_order = false;
|
218 |
if ( is_admin() ) {
|
351 |
$remove_field = false;
|
352 |
if ( $edit_address_page ) {
|
353 |
$remove_field = true;
|
354 |
+
if ( !isset( $cf_field[self::DISPLAY_ON_ADDRESS] ) || $cf_field[self::DISPLAY_ON_ADDRESS] == '1' ) {
|
355 |
$remove_field = false;
|
356 |
}
|
357 |
}
|
classes/filed-validation.php
CHANGED
@@ -3,6 +3,9 @@ if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
|
3 |
|
4 |
class Flexible_Checkout_Fields_Field_Validation {
|
5 |
|
|
|
|
|
|
|
6 |
protected $plugin;
|
7 |
|
8 |
/**
|
@@ -12,14 +15,26 @@ class Flexible_Checkout_Fields_Field_Validation {
|
|
12 |
*/
|
13 |
public function __construct( $plugin ) {
|
14 |
$this->plugin = $plugin;
|
15 |
-
$this->hooks();
|
16 |
}
|
17 |
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
}
|
21 |
|
22 |
-
|
|
|
|
|
|
|
23 |
foreach ( $data as $field => $value ) {
|
24 |
do_action( 'flexible_checkout_fields_validate_' . $field, $value );
|
25 |
}
|
@@ -34,10 +49,16 @@ class Flexible_Checkout_Fields_Field_Validation {
|
|
34 |
}
|
35 |
}
|
36 |
|
|
|
|
|
|
|
37 |
public function get_custom_validations() {
|
38 |
return apply_filters( 'flexible_checkout_fields_custom_validation', array() );
|
39 |
}
|
40 |
|
|
|
|
|
|
|
41 |
public function get_validation_options() {
|
42 |
$validation_options = array(
|
43 |
'' => __( 'Default', 'flexible-checkout-fields' ),
|
3 |
|
4 |
class Flexible_Checkout_Fields_Field_Validation {
|
5 |
|
6 |
+
/**
|
7 |
+
* @var Flexible_Checkout_Fields_Plugin
|
8 |
+
*/
|
9 |
protected $plugin;
|
10 |
|
11 |
/**
|
15 |
*/
|
16 |
public function __construct( $plugin ) {
|
17 |
$this->plugin = $plugin;
|
|
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
+
*
|
22 |
+
*/
|
23 |
+
public function hooks() {
|
24 |
+
add_action( 'woocommerce_after_checkout_validation', array( $this, 'woocommerce_after_checkout_validation_action' ) );
|
25 |
+
add_filter( 'woocommerce_checkout_required_field_notice', array( $this, 'woocommerce_checkout_required_field_notice_filter' ), 10, 2 );
|
26 |
+
}
|
27 |
+
|
28 |
+
public function woocommerce_checkout_required_field_notice_filter( $notice, $field_label ) {
|
29 |
+
$field_label = strip_tags( $field_label );
|
30 |
+
$notice = sprintf( __( '%s is a required field.', 'woocommerce' ), '<strong>' . $field_label . '</strong>' );
|
31 |
+
return $notice;
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* @param $data
|
36 |
+
*/
|
37 |
+
public function woocommerce_after_checkout_validation_action( $data ) {
|
38 |
foreach ( $data as $field => $value ) {
|
39 |
do_action( 'flexible_checkout_fields_validate_' . $field, $value );
|
40 |
}
|
49 |
}
|
50 |
}
|
51 |
|
52 |
+
/**
|
53 |
+
* @return array
|
54 |
+
*/
|
55 |
public function get_custom_validations() {
|
56 |
return apply_filters( 'flexible_checkout_fields_custom_validation', array() );
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* @return array
|
61 |
+
*/
|
62 |
public function get_validation_options() {
|
63 |
$validation_options = array(
|
64 |
'' => __( 'Default', 'flexible-checkout-fields' ),
|
classes/settings.php
CHANGED
@@ -164,6 +164,9 @@
|
|
164 |
|
165 |
include( 'views/settings-tabs.php' );
|
166 |
|
|
|
|
|
|
|
167 |
switch ($current_tab) {
|
168 |
case 'settings':
|
169 |
|
@@ -192,9 +195,11 @@
|
|
192 |
|
193 |
$args = array(
|
194 |
'plugin' => $this->plugin,
|
195 |
-
'checkout_fields' => $checkout_fields
|
|
|
196 |
);
|
197 |
|
|
|
198 |
include( 'views/settings-fields.php' );
|
199 |
|
200 |
break;
|
@@ -202,6 +207,10 @@
|
|
202 |
|
203 |
}
|
204 |
|
|
|
|
|
|
|
|
|
205 |
|
206 |
public function validate_field_name( $name, $section ) {
|
207 |
if ( in_array( $section, array( 'billing' ) ) ) {
|
164 |
|
165 |
include( 'views/settings-tabs.php' );
|
166 |
|
167 |
+
require_once('activation-tracker.php');
|
168 |
+
$activation_tracker = new Flexible_Checkout_Fields_Activation_Tracker( $this->plugin->plugin_namespace );
|
169 |
+
|
170 |
switch ($current_tab) {
|
171 |
case 'settings':
|
172 |
|
195 |
|
196 |
$args = array(
|
197 |
'plugin' => $this->plugin,
|
198 |
+
'checkout_fields' => $checkout_fields,
|
199 |
+
'show_ads' => $activation_tracker->is_activated_more_than_two_weeks()
|
200 |
);
|
201 |
|
202 |
+
|
203 |
include( 'views/settings-fields.php' );
|
204 |
|
205 |
break;
|
207 |
|
208 |
}
|
209 |
|
210 |
+
private function is_active_more_than_week() {
|
211 |
+
|
212 |
+
}
|
213 |
+
|
214 |
|
215 |
public function validate_field_name( $name, $section ) {
|
216 |
if ( in_array( $section, array( 'billing' ) ) ) {
|
classes/views/settings-fields.php
CHANGED
@@ -1,6 +1,9 @@
|
|
1 |
<?php
|
2 |
global $woocommerce;
|
3 |
|
|
|
|
|
|
|
4 |
$validation_options = $this->plugin->field_validation->get_validation_options();
|
5 |
|
6 |
$checkout_fields = $args['checkout_fields'];
|
@@ -111,7 +114,9 @@ foreach ( $plugin->sections as $section ) {
|
|
111 |
</div>
|
112 |
</form>
|
113 |
</div>
|
114 |
-
|
|
|
|
|
115 |
<?php do_action( 'flexible_checkout_fields_after_add_new_field' ); ?>
|
116 |
</div>
|
117 |
|
@@ -201,7 +206,7 @@ foreach ( $plugin->sections as $section ) {
|
|
201 |
<?php endif; ?>
|
202 |
</span>
|
203 |
<?php if ( ! empty( $field['label'] ) ): ?>
|
204 |
-
<?php echo esc_html( $field['label'] ); ?>
|
205 |
<?php else: ?>
|
206 |
<?php echo $name ?>
|
207 |
<?php endif; ?>
|
@@ -261,6 +266,7 @@ foreach ( $plugin->sections as $section ) {
|
|
261 |
</div>
|
262 |
|
263 |
<?php
|
|
|
264 |
$checked = '';
|
265 |
$style = '';
|
266 |
if ( isset( $settings[ $key ][ $name ]['type'] )
|
@@ -273,17 +279,22 @@ foreach ( $plugin->sections as $section ) {
|
|
273 |
$checked = ' checked';
|
274 |
}
|
275 |
}
|
|
|
|
|
|
|
|
|
|
|
276 |
?>
|
277 |
<div style="<?php echo $style; ?>">
|
278 |
<input type="hidden"
|
279 |
name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]"
|
280 |
-
value="0"
|
281 |
-
|
282 |
<label>
|
283 |
<input class="field_required"
|
284 |
type="checkbox"
|
285 |
name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]"
|
286 |
-
value="1" <?php echo $checked; ?>
|
287 |
data-qa-id="field-required"
|
288 |
/>
|
289 |
<?php _e( 'Required Field', 'flexible-checkout-fields' ) ?>
|
@@ -566,15 +577,6 @@ foreach ( $plugin->sections as $section ) {
|
|
566 |
return tmp_short_name;
|
567 |
}
|
568 |
|
569 |
-
/* to delete
|
570 |
-
jQuery(document).on('keydown','.short_name',function(){
|
571 |
-
if ( jQuery(this).attr('data-alert') != '1' ) {
|
572 |
-
if ( !confirm( '<?php _e( 'Changing this field...', 'flexible-checkout-fields' ); ?>' ) ) return false;
|
573 |
-
jQuery(this).attr('data-alert','1');
|
574 |
-
}
|
575 |
-
})
|
576 |
-
*/
|
577 |
-
|
578 |
jQuery('.sortable').sortable({
|
579 |
handle: '.field-item-handle',
|
580 |
placeholder: 'sortable-placeholder',
|
@@ -584,6 +586,20 @@ foreach ( $plugin->sections as $section ) {
|
|
584 |
}
|
585 |
});
|
586 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
587 |
// Add New Field
|
588 |
jQuery("#button_add_field").click(function (e) {
|
589 |
e.preventDefault();
|
@@ -603,7 +619,7 @@ foreach ( $plugin->sections as $section ) {
|
|
603 |
return false;
|
604 |
}
|
605 |
var html = '';
|
606 |
-
html += '<li class="field-item menu-item element_' + field_slug + ' just-added" data-qa-id="field-item" data-qa-id2="' + field_label + '">';
|
607 |
//html += '<li class="field-item menu-item">';
|
608 |
html += '<div class="menu-item-bar">';
|
609 |
html += '<div class="menu-item-handle field-item-handle">';
|
@@ -612,7 +628,7 @@ foreach ( $plugin->sections as $section ) {
|
|
612 |
html += '<span class="item-type">';
|
613 |
html += fcf_field_type[field_type]['name'];
|
614 |
html += '</span>';
|
615 |
-
html += field_label;
|
616 |
html += '</span>';
|
617 |
html += '<span class="item-controls">';
|
618 |
html += '<a href="#" class="item-edit more"><span class="screen-reader-text"><?php _e( 'Edit', 'flexible-checkout-fields' ) ?></span></a>';
|
@@ -852,6 +868,7 @@ foreach ( $plugin->sections as $section ) {
|
|
852 |
return false;
|
853 |
}
|
854 |
jQuery(this).find('select').prop('disabled', false);
|
|
|
855 |
jQuery(this).find('.major-publishing-actions').find('.spinner').css('visibility', 'visible');
|
856 |
jQuery('.flexible_checkout_fields_add_rule select').each(function () {
|
857 |
jQuery(this).attr('disabled', 'disabled');
|
1 |
<?php
|
2 |
global $woocommerce;
|
3 |
|
4 |
+
/** @see validate_checkout method https://github.com/woocommerce/woocommerce/blob/master/includes/class-wc-checkout.php#L719 */
|
5 |
+
$fields_always_required_by_woocommerce = array( 'shipping_country', 'billing_country' );
|
6 |
+
|
7 |
$validation_options = $this->plugin->field_validation->get_validation_options();
|
8 |
|
9 |
$checkout_fields = $args['checkout_fields'];
|
114 |
</div>
|
115 |
</form>
|
116 |
</div>
|
117 |
+
<?php if ($args['show_ads']): ?>
|
118 |
+
<?php include( 'settings-ads.php' ); ?>
|
119 |
+
<?php endif; ?>
|
120 |
<?php do_action( 'flexible_checkout_fields_after_add_new_field' ); ?>
|
121 |
</div>
|
122 |
|
206 |
<?php endif; ?>
|
207 |
</span>
|
208 |
<?php if ( ! empty( $field['label'] ) ): ?>
|
209 |
+
<?php echo esc_html( strip_tags( $field['label'] ) ); ?>
|
210 |
<?php else: ?>
|
211 |
<?php echo $name ?>
|
212 |
<?php endif; ?>
|
266 |
</div>
|
267 |
|
268 |
<?php
|
269 |
+
$disabled = '';
|
270 |
$checked = '';
|
271 |
$style = '';
|
272 |
if ( isset( $settings[ $key ][ $name ]['type'] )
|
279 |
$checked = ' checked';
|
280 |
}
|
281 |
}
|
282 |
+
if ( in_array( $name, $fields_always_required_by_woocommerce ) ) {
|
283 |
+
if ( $field_required ) {
|
284 |
+
$disabled = ' disabled';
|
285 |
+
}
|
286 |
+
}
|
287 |
?>
|
288 |
<div style="<?php echo $style; ?>">
|
289 |
<input type="hidden"
|
290 |
name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]"
|
291 |
+
value="0"
|
292 |
+
/>
|
293 |
<label>
|
294 |
<input class="field_required"
|
295 |
type="checkbox"
|
296 |
name="inspire_checkout_fields[settings][<?php echo $key ?>][<?php echo $name ?>][required]"
|
297 |
+
value="1" <?php echo $checked; ?> <?php echo $disabled; ?>
|
298 |
data-qa-id="field-required"
|
299 |
/>
|
300 |
<?php _e( 'Required Field', 'flexible-checkout-fields' ) ?>
|
577 |
return tmp_short_name;
|
578 |
}
|
579 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
jQuery('.sortable').sortable({
|
581 |
handle: '.field-item-handle',
|
582 |
placeholder: 'sortable-placeholder',
|
586 |
}
|
587 |
});
|
588 |
|
589 |
+
function strip_tags( html ) {
|
590 |
+
return jQuery('<p>' + html + '</p>').text();
|
591 |
+
}
|
592 |
+
|
593 |
+
function htmlEncode(value){
|
594 |
+
//create a in-memory div, set it's inner text(which jQuery automatically encodes)
|
595 |
+
//then grab the encoded contents back out. The div never exists on the page.
|
596 |
+
return jQuery('<div/>').text(value).html();
|
597 |
+
}
|
598 |
+
|
599 |
+
function htmlDecode(value){
|
600 |
+
return jQuery('<div/>').html(value).text();
|
601 |
+
}
|
602 |
+
|
603 |
// Add New Field
|
604 |
jQuery("#button_add_field").click(function (e) {
|
605 |
e.preventDefault();
|
619 |
return false;
|
620 |
}
|
621 |
var html = '';
|
622 |
+
html += '<li class="field-item menu-item element_' + field_slug + ' just-added" data-qa-id="field-item" data-qa-id2="' + htmlEncode( field_label ) + '">';
|
623 |
//html += '<li class="field-item menu-item">';
|
624 |
html += '<div class="menu-item-bar">';
|
625 |
html += '<div class="menu-item-handle field-item-handle">';
|
628 |
html += '<span class="item-type">';
|
629 |
html += fcf_field_type[field_type]['name'];
|
630 |
html += '</span>';
|
631 |
+
html += htmlEncode( strip_tags(field_label) );
|
632 |
html += '</span>';
|
633 |
html += '<span class="item-controls">';
|
634 |
html += '<a href="#" class="item-edit more"><span class="screen-reader-text"><?php _e( 'Edit', 'flexible-checkout-fields' ) ?></span></a>';
|
868 |
return false;
|
869 |
}
|
870 |
jQuery(this).find('select').prop('disabled', false);
|
871 |
+
jQuery(this).find('.field_required').prop('disabled', false);
|
872 |
jQuery(this).find('.major-publishing-actions').find('.spinner').css('visibility', 'visible');
|
873 |
jQuery('.flexible_checkout_fields_add_rule select').each(function () {
|
874 |
jQuery(this).attr('disabled', 'disabled');
|
composer.json
CHANGED
@@ -1,29 +1,31 @@
|
|
1 |
{
|
2 |
-
"
|
3 |
-
"minimum-stability": "stable",
|
4 |
-
"license": "proprietary",
|
5 |
"authors": [
|
6 |
{
|
7 |
-
"name": "
|
8 |
-
"email": "
|
9 |
}
|
10 |
],
|
11 |
"require": {
|
12 |
-
|
13 |
},
|
14 |
"require-dev": {
|
15 |
-
"phpunit/phpunit": "
|
16 |
"wp-coding-standards/wpcs": "^0.14.1",
|
17 |
"squizlabs/php_codesniffer": "^3.0.2",
|
18 |
-
"mockery/mockery": "
|
19 |
-
"10up/wp_mock": "
|
20 |
"wimg/php-compatibility": "^8"
|
21 |
},
|
|
|
|
|
22 |
"scripts": {
|
23 |
"test": "echo composer is alive",
|
24 |
"phpcs": "phpcs",
|
25 |
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
|
|
|
26 |
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
|
|
|
27 |
"docs": "apigen generate"
|
28 |
}
|
29 |
}
|
1 |
{
|
2 |
+
"name": "wpdesk/flexible-checkout-fields",
|
|
|
|
|
3 |
"authors": [
|
4 |
{
|
5 |
+
"name": "Krzysiek",
|
6 |
+
"email": "krzysiek@wpdesk.pl"
|
7 |
}
|
8 |
],
|
9 |
"require": {
|
10 |
+
"php": ">=5.5"
|
11 |
},
|
12 |
"require-dev": {
|
13 |
+
"phpunit/phpunit": "<7",
|
14 |
"wp-coding-standards/wpcs": "^0.14.1",
|
15 |
"squizlabs/php_codesniffer": "^3.0.2",
|
16 |
+
"mockery/mockery": "*",
|
17 |
+
"10up/wp_mock": "*",
|
18 |
"wimg/php-compatibility": "^8"
|
19 |
},
|
20 |
+
"autoload-dev": {
|
21 |
+
},
|
22 |
"scripts": {
|
23 |
"test": "echo composer is alive",
|
24 |
"phpcs": "phpcs",
|
25 |
"phpunit-unit": "phpunit --configuration phpunit-unit.xml --coverage-text --colors=never",
|
26 |
+
"phpunit-unit-fast": "phpunit --configuration phpunit-unit.xml --no-coverage",
|
27 |
"phpunit-integration": "phpunit --configuration phpunit-integration.xml --coverage-text --colors=never",
|
28 |
+
"phpunit-integration-fast": "phpunit --configuration phpunit-integration.xml --no-coverage",
|
29 |
"docs": "apigen generate"
|
30 |
}
|
31 |
}
|
flexible-checkout-fields.php
CHANGED
@@ -3,15 +3,15 @@
|
|
3 |
Plugin Name: Flexible Checkout Fields
|
4 |
Plugin URI: https://www.wpdesk.net/products/flexible-checkout-fields-pro-woocommerce/
|
5 |
Description: Manage your WooCommerce checkout fields. Change order, labels, placeholders and add new fields.
|
6 |
-
Version: 1.6.
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-checkout-fields
|
10 |
Domain Path: /lang/
|
11 |
Requires at least: 4.5
|
12 |
-
Tested up to: 4.9.
|
13 |
WC requires at least: 2.6.14
|
14 |
-
WC tested up to: 3.3.
|
15 |
|
16 |
Copyright 2017 WP Desk Ltd.
|
17 |
|
@@ -33,8 +33,12 @@
|
|
33 |
|
34 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
35 |
|
|
|
|
|
|
|
|
|
36 |
if ( ! defined( 'FCF_VERSION' ) ) {
|
37 |
-
define( 'FCF_VERSION',
|
38 |
}
|
39 |
|
40 |
|
@@ -62,7 +66,7 @@
|
|
62 |
|
63 |
class Flexible_Checkout_Fields_Plugin extends WPDesk_Plugin_1_8 {
|
64 |
|
65 |
-
protected $script_version = '
|
66 |
|
67 |
protected $fields = array();
|
68 |
|
@@ -134,6 +138,7 @@
|
|
134 |
|
135 |
include( 'classes/filed-validation.php' );
|
136 |
$this->field_validation = new Flexible_Checkout_Fields_Field_Validation( $this );
|
|
|
137 |
|
138 |
}
|
139 |
|
3 |
Plugin Name: Flexible Checkout Fields
|
4 |
Plugin URI: https://www.wpdesk.net/products/flexible-checkout-fields-pro-woocommerce/
|
5 |
Description: Manage your WooCommerce checkout fields. Change order, labels, placeholders and add new fields.
|
6 |
+
Version: 1.6.3
|
7 |
Author: WP Desk
|
8 |
Author URI: https://www.wpdesk.net/
|
9 |
Text Domain: flexible-checkout-fields
|
10 |
Domain Path: /lang/
|
11 |
Requires at least: 4.5
|
12 |
+
Tested up to: 4.9.5
|
13 |
WC requires at least: 2.6.14
|
14 |
+
WC tested up to: 3.3.5
|
15 |
|
16 |
Copyright 2017 WP Desk Ltd.
|
17 |
|
33 |
|
34 |
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
|
35 |
|
36 |
+
$plugin_version = '1.6.3';
|
37 |
+
define( 'FLEXIBLE_CHECKOUT_FIELDS_VERSION', $plugin_version );
|
38 |
+
|
39 |
+
|
40 |
if ( ! defined( 'FCF_VERSION' ) ) {
|
41 |
+
define( 'FCF_VERSION', FLEXIBLE_CHECKOUT_FIELDS_VERSION );
|
42 |
}
|
43 |
|
44 |
|
66 |
|
67 |
class Flexible_Checkout_Fields_Plugin extends WPDesk_Plugin_1_8 {
|
68 |
|
69 |
+
protected $script_version = '1.6.3';
|
70 |
|
71 |
protected $fields = array();
|
72 |
|
138 |
|
139 |
include( 'classes/filed-validation.php' );
|
140 |
$this->field_validation = new Flexible_Checkout_Fields_Field_Validation( $this );
|
141 |
+
$this->field_validation->hooks();
|
142 |
|
143 |
}
|
144 |
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: wpdesk
|
|
3 |
Donate link: https://www.wpdesk.net/flexible-checkout-fields-woocommerce/
|
4 |
Tags: woocommerce checkout fields, woocommerce custom fields, woocommerce checkout manager, woocommerce checkout editor, woocommerce fields manager, woocommerce fields editor, woocommerce custom checkout fields, woocommerce checkout options, woocommerce checkout pro, woocommerce custom sections, woocommerce file upload
|
5 |
Requires at least: 4.5
|
6 |
-
Tested up to: 4.9.
|
7 |
-
Stable tag: 1.6.
|
8 |
Requires PHP: 5.5
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
@@ -187,6 +187,12 @@ If you are upgrading from the old WooCommerce Checkout Fields version (1.1, wooc
|
|
187 |
|
188 |
== Changelog ==
|
189 |
|
|
|
|
|
|
|
|
|
|
|
|
|
190 |
= 1.6.2 - 2018-03-29 =
|
191 |
* Fixed problems with display email and phone fields on order edit page in admin area
|
192 |
* Fixed display the checkbox 'I would like to receive a VAT invoice in checkout' after turn on the Flexible Checkout Fields plugin when Flexible Invoices is available
|
3 |
Donate link: https://www.wpdesk.net/flexible-checkout-fields-woocommerce/
|
4 |
Tags: woocommerce checkout fields, woocommerce custom fields, woocommerce checkout manager, woocommerce checkout editor, woocommerce fields manager, woocommerce fields editor, woocommerce custom checkout fields, woocommerce checkout options, woocommerce checkout pro, woocommerce custom sections, woocommerce file upload
|
5 |
Requires at least: 4.5
|
6 |
+
Tested up to: 4.9.5
|
7 |
+
Stable tag: 1.6.3
|
8 |
Requires PHP: 5.5
|
9 |
License: GPLv3 or later
|
10 |
License URI: http://www.gnu.org/licenses/gpl-3.0.html
|
187 |
|
188 |
== Changelog ==
|
189 |
|
190 |
+
= 1.6.3 - 2018-04-19 =
|
191 |
+
* Fixed hooks priority for Display On settings tab
|
192 |
+
* Fixed required field message - removed HTML tags from field label
|
193 |
+
* Fixed add field function with HTML in label
|
194 |
+
* Fixed display NIP field added by the iFirma plugin
|
195 |
+
|
196 |
= 1.6.2 - 2018-03-29 =
|
197 |
* Fixed problems with display email and phone fields on order edit page in admin area
|
198 |
* Fixed display the checkbox 'I would like to receive a VAT invoice in checkout' after turn on the Flexible Checkout Fields plugin when Flexible Invoices is available
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitf82fb6584623f915d46f9c224929c604::getLoader();
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,15 +19,15 @@ class ComposerAutoloaderInit02006317293084c449522f778c3210c9
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
-
call_user_func(\Composer\Autoload\
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitf82fb6584623f915d46f9c224929c604
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitf82fb6584623f915d46f9c224929c604', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitf82fb6584623f915d46f9c224929c604', 'loadClassLoader'));
|
25 |
|
26 |
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
|
27 |
if ($useStaticLoader) {
|
28 |
require_once __DIR__ . '/autoload_static.php';
|
29 |
|
30 |
+
call_user_func(\Composer\Autoload\ComposerStaticInitf82fb6584623f915d46f9c224929c604::getInitializer($loader));
|
31 |
} else {
|
32 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
33 |
foreach ($map as $namespace => $path) {
|
vendor/composer/autoload_static.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
-
class
|
8 |
{
|
9 |
public static function getInitializer(ClassLoader $loader)
|
10 |
{
|
4 |
|
5 |
namespace Composer\Autoload;
|
6 |
|
7 |
+
class ComposerStaticInitf82fb6584623f915d46f9c224929c604
|
8 |
{
|
9 |
public static function getInitializer(ClassLoader $loader)
|
10 |
{
|