Version Description
- Added: Compatibility with WooCommerce 2.4
- Updated: Core plugin
Download this release
Release Info
Developer | yithemes |
Plugin | YITH WooCommerce Compare |
Version | 2.0.2 |
Comparing to | |
See all releases |
Code changes from version 2.0.1 to 2.0.2
- README.txt +9 -5
- includes/class.yith-woocompare-admin.php +12 -6
- init.php +3 -3
- plugin-fw/assets/css/yit-plugin-panel.css +5 -0
- plugin-fw/lib/yit-plugin-panel-wc.php +72 -1
- plugin-fw/yit-functions.php +62 -0
- templates/compare.php +2 -2
README.txt
CHANGED
@@ -4,12 +4,12 @@ Contributors: yithemes
|
|
4 |
Tags: wc, shop, woocommerce, compare, compare products, product compare, widget, comparison, product comparison, compare table
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 4.2.4
|
7 |
-
Stable tag: 2.0.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
|
12 |
-
WooCommerce Compatible up to 2.
|
13 |
|
14 |
|
15 |
== Description ==
|
@@ -64,6 +64,11 @@ Yes, you can sort the fields in the compare table. You can do it in YIT Plugins
|
|
64 |
|
65 |
== Changelog ==
|
66 |
|
|
|
|
|
|
|
|
|
|
|
67 |
= 2.0.1 =
|
68 |
|
69 |
* Fixed: Compare table layout
|
@@ -176,8 +181,7 @@ Full documentation is available [here](http://yithemes.com/docs-plugins/yith-woo
|
|
176 |
|
177 |
== Upgrade notice ==
|
178 |
|
179 |
-
= 2.0.
|
180 |
|
181 |
-
*
|
182 |
-
* Fixed: undefined function unblock() in main js
|
183 |
* Updated: Core plugin
|
4 |
Tags: wc, shop, woocommerce, compare, compare products, product compare, widget, comparison, product comparison, compare table
|
5 |
Requires at least: 3.5.1
|
6 |
Tested up to: 4.2.4
|
7 |
+
Stable tag: 2.0.2
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
11 |
YITH WooCommerce Compare allows you to compare more products of your shop in one complete table.
|
12 |
+
WooCommerce Compatible up to 2.4.x
|
13 |
|
14 |
|
15 |
== Description ==
|
64 |
|
65 |
== Changelog ==
|
66 |
|
67 |
+
= 2.0.2 =
|
68 |
+
|
69 |
+
* Added: Compatibility with WooCommerce 2.4
|
70 |
+
* Updated: Core plugin
|
71 |
+
|
72 |
= 2.0.1 =
|
73 |
|
74 |
* Fixed: Compare table layout
|
181 |
|
182 |
== Upgrade notice ==
|
183 |
|
184 |
+
= 2.0.2 =
|
185 |
|
186 |
+
* Added: Compatibility with WooCommerce 2.4
|
|
|
187 |
* Updated: Core plugin
|
includes/class.yith-woocompare-admin.php
CHANGED
@@ -93,7 +93,7 @@ if ( ! class_exists( 'YITH_Woocompare_Admin' ) ) {
|
|
93 |
|
94 |
add_action( 'woocommerce_admin_field_woocompare_image_width', array( $this, 'admin_fields_woocompare_image_width' ) );
|
95 |
add_action( 'woocommerce_admin_field_woocompare_attributes', array( $this, 'admin_fields_attributes' ), 10, 1 );
|
96 |
-
|
97 |
|
98 |
// YITH WCWL Loaded
|
99 |
do_action( 'yith_woocompare_loaded' );
|
@@ -401,20 +401,24 @@ if ( ! class_exists( 'YITH_Woocompare_Admin' ) ) {
|
|
401 |
*
|
402 |
* @access public
|
403 |
* @param mixed $value
|
404 |
-
* @
|
|
|
|
|
405 |
* @since 1.0.0
|
406 |
*/
|
407 |
-
public function admin_update_custom_option( $value ) {
|
408 |
|
409 |
$val = array();
|
410 |
-
$checked_fields = isset( $_POST[ $
|
411 |
-
$fields = array_map( 'trim', explode( ',', $_POST[ $
|
412 |
|
413 |
foreach ( $fields as $field ) {
|
414 |
$val[ $field ] = in_array( $field, $checked_fields );
|
415 |
}
|
416 |
|
417 |
-
update_option( str_replace( '_attrs', '', $
|
|
|
|
|
418 |
}
|
419 |
|
420 |
/**
|
@@ -435,6 +439,8 @@ if ( ! class_exists( 'YITH_Woocompare_Admin' ) ) {
|
|
435 |
wp_enqueue_style( 'yith_woocompare_admin', YITH_WOOCOMPARE_URL . 'assets/css/admin.css' );
|
436 |
wp_enqueue_script( 'yith_woocompare', YITH_WOOCOMPARE_URL . 'assets/js/woocompare-admin.js', array( 'jquery', 'jquery-ui-sortable' ) );
|
437 |
}
|
|
|
|
|
438 |
}
|
439 |
}
|
440 |
}
|
93 |
|
94 |
add_action( 'woocommerce_admin_field_woocompare_image_width', array( $this, 'admin_fields_woocompare_image_width' ) );
|
95 |
add_action( 'woocommerce_admin_field_woocompare_attributes', array( $this, 'admin_fields_attributes' ), 10, 1 );
|
96 |
+
add_filter( 'woocommerce_admin_settings_sanitize_option_yith_woocompare_fields_attrs', array( $this, 'admin_update_custom_option' ), 10, 3 );
|
97 |
|
98 |
// YITH WCWL Loaded
|
99 |
do_action( 'yith_woocompare_loaded' );
|
401 |
*
|
402 |
* @access public
|
403 |
* @param mixed $value
|
404 |
+
* @param mixed $option
|
405 |
+
* @param mixed $raw_value
|
406 |
+
* @return mixed
|
407 |
* @since 1.0.0
|
408 |
*/
|
409 |
+
public function admin_update_custom_option( $value, $option, $raw_value ) {
|
410 |
|
411 |
$val = array();
|
412 |
+
$checked_fields = isset( $_POST[ $option['id'] ] ) ? maybe_unserialize( $_POST[ $option['id'] ] ) : array();
|
413 |
+
$fields = array_map( 'trim', explode( ',', $_POST[ $option['id'] . '_positions' ] ) );
|
414 |
|
415 |
foreach ( $fields as $field ) {
|
416 |
$val[ $field ] = in_array( $field, $checked_fields );
|
417 |
}
|
418 |
|
419 |
+
update_option( str_replace( '_attrs', '', $option['id'] ), $val );
|
420 |
+
|
421 |
+
return $value;
|
422 |
}
|
423 |
|
424 |
/**
|
439 |
wp_enqueue_style( 'yith_woocompare_admin', YITH_WOOCOMPARE_URL . 'assets/css/admin.css' );
|
440 |
wp_enqueue_script( 'yith_woocompare', YITH_WOOCOMPARE_URL . 'assets/js/woocompare-admin.js', array( 'jquery', 'jquery-ui-sortable' ) );
|
441 |
}
|
442 |
+
|
443 |
+
do_action( 'yith_woocompare_enqueue_styles_scripts' );
|
444 |
}
|
445 |
}
|
446 |
}
|
init.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: YITH WooCommerce Compare
|
4 |
* Plugin URI: https://yithemes.com/
|
5 |
* Description: YITH WooCommerce Compare allows you to compare more products with WooCommerce plugin, through product attributes.
|
6 |
-
* Version: 2.0.
|
7 |
* Author: Yithemes
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-wcmp
|
@@ -11,7 +11,7 @@
|
|
11 |
*
|
12 |
* @author Yithemes
|
13 |
* @package YITH WooCommerce Compare
|
14 |
-
* @version 2.0.
|
15 |
*/
|
16 |
/* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
|
17 |
|
@@ -56,7 +56,7 @@ if ( ! function_exists( 'yith_plugin_registration_hook' ) ) {
|
|
56 |
register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
|
57 |
|
58 |
if ( ! defined( 'YITH_WOOCOMPARE_VERSION' ) ){
|
59 |
-
define( 'YITH_WOOCOMPARE_VERSION', '2.0.
|
60 |
}
|
61 |
if ( ! defined( 'YITH_WOOCOMPARE_FREE_INIT' ) ) {
|
62 |
define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) );
|
3 |
* Plugin Name: YITH WooCommerce Compare
|
4 |
* Plugin URI: https://yithemes.com/
|
5 |
* Description: YITH WooCommerce Compare allows you to compare more products with WooCommerce plugin, through product attributes.
|
6 |
+
* Version: 2.0.2
|
7 |
* Author: Yithemes
|
8 |
* Author URI: http://yithemes.com/
|
9 |
* Text Domain: yith-wcmp
|
11 |
*
|
12 |
* @author Yithemes
|
13 |
* @package YITH WooCommerce Compare
|
14 |
+
* @version 2.0.2
|
15 |
*/
|
16 |
/* Copyright 2013 Your Inspiration Themes (email : plugins@yithemes.com)
|
17 |
|
56 |
register_activation_hook( __FILE__, 'yith_plugin_registration_hook' );
|
57 |
|
58 |
if ( ! defined( 'YITH_WOOCOMPARE_VERSION' ) ){
|
59 |
+
define( 'YITH_WOOCOMPARE_VERSION', '2.0.2' );
|
60 |
}
|
61 |
if ( ! defined( 'YITH_WOOCOMPARE_FREE_INIT' ) ) {
|
62 |
define( 'YITH_WOOCOMPARE_FREE_INIT', plugin_basename( __FILE__ ) );
|
plugin-fw/assets/css/yit-plugin-panel.css
CHANGED
@@ -626,6 +626,11 @@
|
|
626 |
color: #45bbe6;
|
627 |
}
|
628 |
|
|
|
|
|
|
|
|
|
|
|
629 |
/* === Responsive === */
|
630 |
|
631 |
@media (max-width: 767px) {}
|
626 |
color: #45bbe6;
|
627 |
}
|
628 |
|
629 |
+
/* WooCommerce 2.4 Support */
|
630 |
+
.woocommerce table.form-table .colorpick{
|
631 |
+
width: 6em;
|
632 |
+
}
|
633 |
+
|
634 |
/* === Responsive === */
|
635 |
|
636 |
@media (max-width: 767px) {}
|
plugin-fw/lib/yit-plugin-panel-wc.php
CHANGED
@@ -37,6 +37,11 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
37 |
*/
|
38 |
public $settings = array();
|
39 |
|
|
|
|
|
|
|
|
|
|
|
40 |
/**
|
41 |
* @var array
|
42 |
*/
|
@@ -51,6 +56,14 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
51 |
*/
|
52 |
public function __construct( $args = array() ) {
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
if ( ! empty( $args ) ) {
|
55 |
$this->settings = $args;
|
56 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
@@ -64,10 +77,14 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
64 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
65 |
add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
|
66 |
add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
|
|
|
67 |
|
68 |
/* Add VideoBox and InfoBox */
|
69 |
add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
|
70 |
add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
|
|
|
|
|
|
|
71 |
}
|
72 |
}
|
73 |
|
@@ -251,6 +268,16 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
251 |
$yit_options = $this->get_main_array_options();
|
252 |
$current_tab = $this->get_current_tab();
|
253 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
254 |
woocommerce_update_options( $yit_options[ $current_tab ] );
|
255 |
|
256 |
do_action( 'yit_panel_wc_after_update' );
|
@@ -320,7 +347,6 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
320 |
} else {
|
321 |
add_option($value['id'], $default_value);
|
322 |
}
|
323 |
-
|
324 |
}
|
325 |
|
326 |
}
|
@@ -328,6 +354,51 @@ if ( ! class_exists( 'YIT_Plugin_Panel_WooCommerce' ) ) {
|
|
328 |
|
329 |
}
|
330 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
331 |
|
332 |
}
|
333 |
}
|
37 |
*/
|
38 |
public $settings = array();
|
39 |
|
40 |
+
/**
|
41 |
+
* @var array a setting list of parameters
|
42 |
+
*/
|
43 |
+
public $wc_type = array();
|
44 |
+
|
45 |
/**
|
46 |
* @var array
|
47 |
*/
|
56 |
*/
|
57 |
public function __construct( $args = array() ) {
|
58 |
|
59 |
+
$this->wc_type = array(
|
60 |
+
'checkbox',
|
61 |
+
'textarea',
|
62 |
+
'multiselect',
|
63 |
+
'multi_select_countries',
|
64 |
+
'image_width'
|
65 |
+
);
|
66 |
+
|
67 |
if ( ! empty( $args ) ) {
|
68 |
$this->settings = $args;
|
69 |
$this->_tabs_path_files = $this->get_tabs_path_files();
|
77 |
add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
|
78 |
add_action( 'admin_init', array( $this, 'woocommerce_update_options' ) );
|
79 |
add_filter( 'woocommerce_screen_ids', array( $this, 'add_allowed_screen_id' ) );
|
80 |
+
add_filter( 'woocommerce_admin_settings_sanitize_option', array( $this, 'maybe_unserialize_panel_data' ), 10, 3 );
|
81 |
|
82 |
/* Add VideoBox and InfoBox */
|
83 |
add_action( 'woocommerce_admin_field_boxinfo', array( $this, 'add_infobox' ), 10, 1 );
|
84 |
add_action( 'woocommerce_admin_field_videobox', array( $this, 'add_videobox' ), 10, 1 );
|
85 |
+
|
86 |
+
/* WooCommerce 2.4 Support */
|
87 |
+
add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
|
88 |
}
|
89 |
}
|
90 |
|
268 |
$yit_options = $this->get_main_array_options();
|
269 |
$current_tab = $this->get_current_tab();
|
270 |
|
271 |
+
if( version_compare( WC()->version, '2.4.0', '>=' ) ) {
|
272 |
+
if ( ! empty( $yit_options[ $current_tab ] ) ) {
|
273 |
+
foreach ( $yit_options[ $current_tab ] as $option ) {
|
274 |
+
if ( isset( $option['id'] ) && isset( $_POST[ $option['id'] ] ) && isset( $option['type' ] ) && ! in_array( $option['type'], $this->wc_type ) ) {
|
275 |
+
$_POST[ $option['id'] ] = maybe_serialize( $_POST[ $option['id'] ] );
|
276 |
+
}
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
woocommerce_update_options( $yit_options[ $current_tab ] );
|
282 |
|
283 |
do_action( 'yit_panel_wc_after_update' );
|
347 |
} else {
|
348 |
add_option($value['id'], $default_value);
|
349 |
}
|
|
|
350 |
}
|
351 |
|
352 |
}
|
354 |
|
355 |
}
|
356 |
|
357 |
+
/**
|
358 |
+
* Add the woocommerce body class in plugin panel page
|
359 |
+
*
|
360 |
+
* @author Andrea Grillo <andrea.grillo@yithemes.com>
|
361 |
+
* @since 2.0
|
362 |
+
* @param $classes The body classes
|
363 |
+
*
|
364 |
+
* @return array Filtered body classes
|
365 |
+
*/
|
366 |
+
public function admin_body_class( $admin_body_classes ){
|
367 |
+
$admin_body_classes .= ' woocommerce ';
|
368 |
+
return $admin_body_classes;
|
369 |
+
}
|
370 |
+
|
371 |
+
/**
|
372 |
+
* Maybe unserialize panel data
|
373 |
+
*
|
374 |
+
* @param $value mixed Option value
|
375 |
+
* @param $option mixed Option settings array
|
376 |
+
* @param $raw_value string Raw option value
|
377 |
+
*
|
378 |
+
* @return mixed Filtered return value
|
379 |
+
* @author Antonio La Rocca <antonio.larocca@yithemes.com>
|
380 |
+
* @since 2.0
|
381 |
+
*/
|
382 |
+
public function maybe_unserialize_panel_data( $value, $option, $raw_value ) {
|
383 |
+
|
384 |
+
|
385 |
+
if( ! version_compare( WC()->version, '2.4.0', '>=' ) || ! isset( $option['type' ] ) || in_array( $option['type'], $this->wc_type ) ) {
|
386 |
+
return $value;
|
387 |
+
}
|
388 |
+
|
389 |
+
$yit_options = $this->get_main_array_options();
|
390 |
+
$current_tab = $this->get_current_tab();
|
391 |
+
|
392 |
+
if( ! empty( $yit_options[ $current_tab ] ) ){
|
393 |
+
foreach( $yit_options[ $current_tab ] as $option_array ){
|
394 |
+
if( isset( $option_array['id'] ) && isset( $option['id'] ) && $option_array['id'] == $option['id'] ){
|
395 |
+
return maybe_unserialize( $value );
|
396 |
+
}
|
397 |
+
}
|
398 |
+
}
|
399 |
+
|
400 |
+
return $value;
|
401 |
+
}
|
402 |
|
403 |
}
|
404 |
}
|
plugin-fw/yit-functions.php
CHANGED
@@ -818,4 +818,66 @@ if ( ! function_exists( 'yit_load_js_file' ) ) {
|
|
818 |
|
819 |
return $filename;
|
820 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
821 |
}
|
818 |
|
819 |
return $filename;
|
820 |
}
|
821 |
+
}
|
822 |
+
|
823 |
+
if ( ! function_exists( 'yit_wpml_register_string' ) ) {
|
824 |
+
/**
|
825 |
+
* Register a string in wpml trnslation
|
826 |
+
*
|
827 |
+
* @param $contenxt context name
|
828 |
+
* @param $name string name
|
829 |
+
* @param $value value to translate
|
830 |
+
*
|
831 |
+
* @since 2.0.0
|
832 |
+
* @author Andrea Frascaspata <andrea.frascaspata@yithemes.com>
|
833 |
+
*/
|
834 |
+
function yit_wpml_register_string( $contenxt , $name , $value ) {
|
835 |
+
// wpml string translation
|
836 |
+
do_action( 'wpml_register_single_string', $contenxt, $name, $value );
|
837 |
+
}
|
838 |
+
}
|
839 |
+
|
840 |
+
if ( ! function_exists( 'yit_wpml_string_translate' ) ) {
|
841 |
+
/**
|
842 |
+
* Get a string translation
|
843 |
+
*
|
844 |
+
* @param $contenxt context name
|
845 |
+
* @param $name string name
|
846 |
+
* @param $default_value value to translate
|
847 |
+
*
|
848 |
+
* @return string the string translated
|
849 |
+
* @since 2.0.0
|
850 |
+
* @author Andrea Frascaspata <andrea.frascaspata@yithemes.com>
|
851 |
+
*/
|
852 |
+
function yit_wpml_string_translate( $contenxt, $name, $default_value ) {
|
853 |
+
return apply_filters( 'wpml_translate_single_string', $default_value, $contenxt, $name );
|
854 |
+
}
|
855 |
+
|
856 |
+
}
|
857 |
+
|
858 |
+
if ( ! function_exists( 'yit_wpml_object_id' ) ) {
|
859 |
+
/**
|
860 |
+
* Get id of post translation in current language
|
861 |
+
*
|
862 |
+
* @param int $element_id
|
863 |
+
* @param string $element_type
|
864 |
+
* @param bool $return_original_if_missing
|
865 |
+
* @param null|string $ulanguage_code
|
866 |
+
*
|
867 |
+
* @return int the translation id
|
868 |
+
* @since 2.0.0
|
869 |
+
* @author Antonio La Rocca <antonio.larocca@yithemes.com>
|
870 |
+
*/
|
871 |
+
function yit_wpml_object_id( $element_id, $element_type = 'post', $return_original_if_missing = false, $ulanguage_code = null ) {
|
872 |
+
if( function_exists( 'wpml_object_id' ) ){
|
873 |
+
return wpml_object_id( $element_id, $element_type, $return_original_if_missing, $ulanguage_code );
|
874 |
+
}
|
875 |
+
elseif( function_exists( 'icl_object_id' ) ){
|
876 |
+
return icl_object_id( $element_id, $element_type, $return_original_if_missing, $ulanguage_code );
|
877 |
+
}
|
878 |
+
else{
|
879 |
+
return $element_id;
|
880 |
+
}
|
881 |
+
}
|
882 |
+
|
883 |
}
|
templates/compare.php
CHANGED
@@ -211,7 +211,7 @@ $localized_table_text = function_exists( 'icl_translate' ) ? icl_translate( 'Plu
|
|
211 |
});
|
212 |
|
213 |
// remove add to cart button after added
|
214 |
-
$('body').on('added_to_cart', function(){
|
215 |
button_clicked.hide();
|
216 |
|
217 |
<?php if ( $is_iframe ) : ?>
|
@@ -219,7 +219,7 @@ $localized_table_text = function_exists( 'icl_translate' ) ? icl_translate( 'Plu
|
|
219 |
|
220 |
// Replace fragments
|
221 |
if ( fragments ) {
|
222 |
-
$.each(fragments, function(key, value) {
|
223 |
$(key, window.parent.document).replaceWith(value);
|
224 |
});
|
225 |
}
|
211 |
});
|
212 |
|
213 |
// remove add to cart button after added
|
214 |
+
$('body').on('added_to_cart', function( ev, fragments, cart_hash, button ){
|
215 |
button_clicked.hide();
|
216 |
|
217 |
<?php if ( $is_iframe ) : ?>
|
219 |
|
220 |
// Replace fragments
|
221 |
if ( fragments ) {
|
222 |
+
$.each(fragments, function(key, value) {
|
223 |
$(key, window.parent.document).replaceWith(value);
|
224 |
});
|
225 |
}
|