WooCommerce Germanized - Version 2.0.4

Version Description

  • Fix: Legal checkboxes Woo 2.4 support
Download this release

Release Info

Developer vendidero
Plugin Icon 128x128 WooCommerce Germanized
Version 2.0.4
Comparing to
See all releases

Code changes from version 2.0.3 to 2.0.4

includes/admin/views/html-admin-page-checkboxes.php CHANGED
@@ -12,7 +12,7 @@ if ( ! defined( 'ABSPATH' ) ) {
12
  <table class="wc-gzd-legal-checkboxes widefat">
13
  <thead>
14
  <tr>
15
- <th class="wc-gzd-legal-checkbox-sort"><?php echo wc_help_tip( __( 'Drag and drop to re-order checkboxes. This is the order being used for printing the fields.', 'woocommerce-germanized' ) ); ?></th>
16
  <th class="wc-gzd-legal-checkbox-name"><?php esc_html_e( 'Name', 'woocommerce-germanized' ); ?></th>
17
  <th class="wc-gzd-legal-checkbox-desc"><?php esc_html_e( 'Description', 'woocommerce-germanized' ); ?></th>
18
  <th class="wc-gzd-legal-checkbox-enabled"><?php esc_html_e( 'Enabled', 'woocommerce-germanized' ); ?></th>
12
  <table class="wc-gzd-legal-checkboxes widefat">
13
  <thead>
14
  <tr>
15
+ <th class="wc-gzd-legal-checkbox-sort"><?php echo wc_gzd_help_tip( __( 'Drag and drop to re-order checkboxes. This is the order being used for printing the fields.', 'woocommerce-germanized' ) ); ?></th>
16
  <th class="wc-gzd-legal-checkbox-name"><?php esc_html_e( 'Name', 'woocommerce-germanized' ); ?></th>
17
  <th class="wc-gzd-legal-checkbox-desc"><?php esc_html_e( 'Description', 'woocommerce-germanized' ); ?></th>
18
  <th class="wc-gzd-legal-checkbox-enabled"><?php esc_html_e( 'Enabled', 'woocommerce-germanized' ); ?></th>
includes/class-wc-gzd-dependencies.php CHANGED
@@ -74,9 +74,9 @@ class WC_GZD_Dependencies {
74
  // Set whether current WooCommerce Version supports CRUD
75
  $this->set_wc_supports_crud();
76
 
77
- //if ( $plugin->version != get_option( 'woocommerce_' . $this->prefix . '_version' ) ) {
78
  $this->delete_cached_plugin_header_data();
79
- //}
80
 
81
  add_action( 'woocommerce_updated', array( $this, 'delete_cached_plugin_header_data' ) );
82
 
74
  // Set whether current WooCommerce Version supports CRUD
75
  $this->set_wc_supports_crud();
76
 
77
+ if ( $plugin->version != get_option( 'woocommerce_' . $this->prefix . '_version' ) ) {
78
  $this->delete_cached_plugin_header_data();
79
+ }
80
 
81
  add_action( 'woocommerce_updated', array( $this, 'delete_cached_plugin_header_data' ) );
82
 
includes/class-wc-gzd-legal-checkbox-manager.php CHANGED
@@ -290,6 +290,10 @@ class WC_GZD_Legal_Checkbox_Manager {
290
 
291
  // Make sure we are not registering core checkboxes again
292
  foreach( $this->get_options() as $id => $checkbox_args ) {
 
 
 
 
293
  if ( $checkbox = $this->get_checkbox( $id ) ) {
294
  $checkbox->update( $checkbox_args );
295
  } elseif ( ! in_array( $id, $this->get_core_checkbox_ids() ) ) {
@@ -412,7 +416,7 @@ class WC_GZD_Legal_Checkbox_Manager {
412
 
413
  // Make sure we do understand yes and no as bools
414
  foreach( $bools as $bool ) {
415
- $args[ $bool ] = wc_string_to_bool( $args[ $bool ] );
416
  }
417
 
418
  if ( empty( $args['html_name'] ) ) {
290
 
291
  // Make sure we are not registering core checkboxes again
292
  foreach( $this->get_options() as $id => $checkbox_args ) {
293
+ if ( isset( $checkbox_args['id'] ) ) {
294
+ unset( $checkbox_args['id'] );
295
+ }
296
+
297
  if ( $checkbox = $this->get_checkbox( $id ) ) {
298
  $checkbox->update( $checkbox_args );
299
  } elseif ( ! in_array( $id, $this->get_core_checkbox_ids() ) ) {
416
 
417
  // Make sure we do understand yes and no as bools
418
  foreach( $bools as $bool ) {
419
+ $args[ $bool ] = wc_gzd_string_to_bool( $args[ $bool ] );
420
  }
421
 
422
  if ( empty( $args['html_name'] ) ) {
includes/class-wc-gzd-legal-checkbox.php CHANGED
@@ -104,6 +104,12 @@ class WC_GZD_Legal_Checkbox {
104
 
105
  public function update_option( $key, $value ) {
106
  $options = WC_GZD_Legal_Checkbox_Manager::instance()->get_options();
 
 
 
 
 
 
107
  $options[ $this->get_id() ][ $key ] = $value;
108
  $this->settings[ $key ] = $value;
109
 
@@ -155,7 +161,7 @@ class WC_GZD_Legal_Checkbox {
155
  * @param bool $show_label_only
156
  */
157
  public function set_hide_input( $hide_input ) {
158
- $this->settings['hide_input'] = wc_bool_to_string( $hide_input );
159
  }
160
 
161
  /**
@@ -422,7 +428,7 @@ class WC_GZD_Legal_Checkbox {
422
  * @param bool $enabled
423
  */
424
  public function set_is_enabled( $enabled ) {
425
- $this->settings['is_enabled'] = wc_bool_to_string( $enabled );
426
  }
427
 
428
  /**
@@ -447,7 +453,7 @@ class WC_GZD_Legal_Checkbox {
447
  * @param bool $show
448
  */
449
  public function set_is_shown( $show ) {
450
- $this->settings['is_shown'] = wc_bool_to_string( $show );
451
  }
452
 
453
  /**
@@ -472,7 +478,7 @@ class WC_GZD_Legal_Checkbox {
472
  * @param bool $mandatory
473
  */
474
  public function set_is_mandatory( $mandatory ) {
475
- $this->settings['is_mandatory'] = wc_bool_to_string( $mandatory );
476
  }
477
 
478
  /**
@@ -497,7 +503,7 @@ class WC_GZD_Legal_Checkbox {
497
  * @param bool $refresh_fragments
498
  */
499
  public function set_refresh_fragments( $refresh_fragments ) {
500
- $this->settings['refresh_fragments'] = wc_bool_to_string( $refresh_fragments );
501
  }
502
 
503
  /**
@@ -522,7 +528,7 @@ class WC_GZD_Legal_Checkbox {
522
  * @param bool $is_core
523
  */
524
  public function set_is_core( $is_core ) {
525
- $this->settings['is_core'] = wc_bool_to_string( $is_core );
526
  }
527
 
528
  /**
@@ -820,7 +826,7 @@ class WC_GZD_Legal_Checkbox {
820
  */
821
  public function admin_options() {
822
  foreach( $this->get_form_fields() as $field ) {
823
- if ( ! isset( $field['id'] ) ) {
824
  continue;
825
  }
826
 
@@ -830,7 +836,7 @@ class WC_GZD_Legal_Checkbox {
830
  WC_Admin_Settings::output_fields( $this->get_form_fields() );
831
 
832
  foreach( $this->get_form_fields() as $field ) {
833
- if ( ! isset( $field['id'] ) ) {
834
  continue;
835
  }
836
 
104
 
105
  public function update_option( $key, $value ) {
106
  $options = WC_GZD_Legal_Checkbox_Manager::instance()->get_options();
107
+
108
+ // Do not allow overriding id
109
+ if ( 'id' === $key ) {
110
+ return false;
111
+ }
112
+
113
  $options[ $this->get_id() ][ $key ] = $value;
114
  $this->settings[ $key ] = $value;
115
 
161
  * @param bool $show_label_only
162
  */
163
  public function set_hide_input( $hide_input ) {
164
+ $this->settings['hide_input'] = wc_gzd_bool_to_string( $hide_input );
165
  }
166
 
167
  /**
428
  * @param bool $enabled
429
  */
430
  public function set_is_enabled( $enabled ) {
431
+ $this->settings['is_enabled'] = wc_gzd_bool_to_string( $enabled );
432
  }
433
 
434
  /**
453
  * @param bool $show
454
  */
455
  public function set_is_shown( $show ) {
456
+ $this->settings['is_shown'] = wc_gzd_bool_to_string( $show );
457
  }
458
 
459
  /**
478
  * @param bool $mandatory
479
  */
480
  public function set_is_mandatory( $mandatory ) {
481
+ $this->settings['is_mandatory'] = wc_gzd_bool_to_string( $mandatory );
482
  }
483
 
484
  /**
503
  * @param bool $refresh_fragments
504
  */
505
  public function set_refresh_fragments( $refresh_fragments ) {
506
+ $this->settings['refresh_fragments'] = wc_gzd_bool_to_string( $refresh_fragments );
507
  }
508
 
509
  /**
528
  * @param bool $is_core
529
  */
530
  public function set_is_core( $is_core ) {
531
+ $this->settings['is_core'] = wc_gzd_bool_to_string( $is_core );
532
  }
533
 
534
  /**
826
  */
827
  public function admin_options() {
828
  foreach( $this->get_form_fields() as $field ) {
829
+ if ( ! isset( $field['id'] ) || 'title' === $field['type'] ) {
830
  continue;
831
  }
832
 
836
  WC_Admin_Settings::output_fields( $this->get_form_fields() );
837
 
838
  foreach( $this->get_form_fields() as $field ) {
839
+ if ( ! isset( $field['id'] ) || 'title' === $field['type'] ) {
840
  continue;
841
  }
842
 
includes/import/class-wc-gzd-product-import.php CHANGED
@@ -110,7 +110,7 @@ class WC_GZD_Product_Import {
110
  }
111
 
112
  public function parse_bool_str( $value ) {
113
- $value = wc_string_to_bool( $value );
114
  return ( $value ? 'yes' : '' );
115
  }
116
 
110
  }
111
 
112
  public function parse_bool_str( $value ) {
113
+ $value = wc_gzd_string_to_bool( $value );
114
  return ( $value ? 'yes' : '' );
115
  }
116
 
includes/wc-gzd-legacy-functions.php CHANGED
@@ -246,4 +246,15 @@ function wc_gzd_deprecated_function( $function, $version, $replacement = null )
246
  _deprecated_function( $function, $version, $replacement );
247
  }
248
  // @codingStandardsIgnoreEnd
 
 
 
 
 
 
 
 
 
 
 
249
  }
246
  _deprecated_function( $function, $version, $replacement );
247
  }
248
  // @codingStandardsIgnoreEnd
249
+ }
250
+
251
+ function wc_gzd_string_to_bool( $string ) {
252
+ return is_bool( $string ) ? $string : ( 'yes' === $string || 1 === $string || 'true' === $string || '1' === $string );
253
+ }
254
+
255
+ function wc_gzd_bool_to_string( $bool ) {
256
+ if ( ! is_bool( $bool ) ) {
257
+ $bool = wc_gzd_string_to_bool( $bool );
258
+ }
259
+ return true === $bool ? 'yes' : 'no';
260
  }
readme.txt CHANGED
@@ -5,7 +5,7 @@ Requires at least: 3.8
5
  Tested up to: 4.9
6
  WC requires at least: 2.4
7
  WC tested up to: 3.4
8
- Stable tag: 2.0.3
9
  Requires PHP: 5.3
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
@@ -161,6 +161,9 @@ Bug reports may be filed via our [GitHub repository](https://github.com/vendider
161
 
162
  == Changelog ==
163
 
 
 
 
164
  = 2.0.3 =
165
  * Improvement: Added reviews (review form) as new legal checkbox location
166
  * Improvement: Merge html classes for legal checkboxes instead of replacing them
5
  Tested up to: 4.9
6
  WC requires at least: 2.4
7
  WC tested up to: 3.4
8
+ Stable tag: 2.0.4
9
  Requires PHP: 5.3
10
  License: GPLv3
11
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
161
 
162
  == Changelog ==
163
 
164
+ = 2.0.4 =
165
+ * Fix: Legal checkboxes Woo 2.4 support
166
+
167
  = 2.0.3 =
168
  * Improvement: Added reviews (review form) as new legal checkbox location
169
  * Improvement: Merge html classes for legal checkboxes instead of replacing them
woocommerce-germanized.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: WooCommerce Germanized extends WooCommerce to become a legally compliant store in the german market.
6
- * Version: 2.0.3
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
@@ -31,7 +31,7 @@ final class WooCommerce_Germanized {
31
  *
32
  * @var string
33
  */
34
- public $version = '2.0.3';
35
 
36
  /**
37
  * Single instance of WooCommerce Germanized Main Class
3
  * Plugin Name: WooCommerce Germanized
4
  * Plugin URI: https://www.vendidero.de/woocommerce-germanized
5
  * Description: WooCommerce Germanized extends WooCommerce to become a legally compliant store in the german market.
6
+ * Version: 2.0.4
7
  * Author: Vendidero
8
  * Author URI: https://vendidero.de
9
  * Requires at least: 3.8
31
  *
32
  * @var string
33
  */
34
+ public $version = '2.0.4';
35
 
36
  /**
37
  * Single instance of WooCommerce Germanized Main Class