Below is a differential between the unpatched vulnerable code and the patched update, for reference.
--- a/woo-product-filter/classes/class-woobewoo-pf-frame.php
+++ b/woo-product-filter/classes/class-woobewoo-pf-frame.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Frame Class
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -738,12 +738,13 @@
/**
* proVersionCompare.
*
- * @version 3.3.0
+ * @version 3.4.6
*/
public function proVersionCompare( $requires, $compare = '>', $notPro = true ) {
if ( is_null( $this->_proVersion ) ) {
- if ( $this->isPro() && function_exists( 'getProPlugFullPathWpf' ) ) {
- $plugin_data = get_file_data( getProPlugFullPathWpf(), array( 'Version' => 'Version' ) );
+ $pro_path = $this->isPro() ? woobewoo_pf_get_pro_full_path() : false;
+ if ( $pro_path ) {
+ $plugin_data = get_file_data( $pro_path, array( 'Version' => 'Version' ) );
$this->_proVersion = $plugin_data['Version'];
} else {
$this->_proVersion = false;
--- a/woo-product-filter/classes/class-woobewoo-pf-html.php
+++ b/woo-product-filter/classes/class-woobewoo-pf-html.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Html Class
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -21,7 +21,7 @@
* output. Extends the 'post' context with form elements and data-* / aria-*
* attributes that the filter widget emits.
*
- * @version 3.3.0
+ * @version 3.4.6
* @since 3.3.0
*
* @return array
@@ -170,6 +170,17 @@
'viewbox' => true,
'width' => true,
'height' => true,
+ 'fill' => true,
+ 'stroke' => true,
+ )
+ );
+ $allowed['symbol'] = array_merge(
+ $common,
+ array(
+ 'id' => true,
+ 'viewbox' => true,
+ 'width' => true,
+ 'height' => true,
'fill' => true,
'stroke' => true,
)
--- a/woo-product-filter/classes/class-woobewoo-pf-mod-installer.php
+++ b/woo-product-filter/classes/class-woobewoo-pf-mod-installer.php
@@ -4,7 +4,7 @@
*
* Handles the installation, activation, deactivation, and management of modules for the plugin.
*
- * @version 3.4.1
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -147,7 +147,7 @@
/**
* _getPluginLocations.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
private static function _getPluginLocations() {
$locations = array();
@@ -167,7 +167,8 @@
}
}
- $locations['plugPath'] = empty( $plug ) && function_exists( 'getProPlugFullPathWpf' ) ? plugin_basename( getProPlugFullPathWpf() ) : plugin_basename( trim( $plug ) );
+ $pro_path = empty( $plug ) ? woobewoo_pf_get_pro_full_path() : false;
+ $locations['plugPath'] = $pro_path ? plugin_basename( $pro_path ) : plugin_basename( trim( $plug ) );
$locations['plugDir'] = dirname( WP_PLUGIN_DIR . WPF_DS . $locations['plugPath'] );
$locations['plugMainFile'] = WP_PLUGIN_DIR . WPF_DS . $locations['plugPath'];
$locations['xmlPath'] = $locations['plugDir'] . WPF_DS . 'install.xml';
--- a/woo-product-filter/config.php
+++ b/woo-product-filter/config.php
@@ -59,8 +59,8 @@
define( 'WPF_EOL', "n" );
define( 'WPF_PLUGIN_INSTALLED', true );
-define( 'WPF_VERSION', '3.4.5' );
-define( 'WPF_PRO_REQUIRES', '3.4.5' );
+define( 'WPF_VERSION', '3.4.6' );
+define( 'WPF_PRO_REQUIRES', '3.4.0' ); // Oldest compatible PRO (class/file naming introduced in 3.4.0).
define( 'WPF_USER', 'user' );
define( 'WPF_CLASS_PREFIX', 'WooBeWoo_PF_' );
--- a/woo-product-filter/functions.php
+++ b/woo-product-filter/functions.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - Functions
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -249,7 +249,7 @@
/**
* Recursive implode of array.
*
- * @verson 3.4.0
+ * @version 3.4.0
*
* @param string $glue imploder
* @param array $array array to implode
@@ -340,44 +340,122 @@
/**
* woobewoo_pf_deactivate.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
add_action( 'admin_init', 'woobewoo_pf_deactivate' );
if ( ! function_exists( 'woobewoo_pf_deactivate' ) ) {
function woobewoo_pf_deactivate() {
- if ( class_exists( 'WooBeWoo_PF_Frame' ) && function_exists( 'getProPlugFullPathWpf' ) ) {
- $pathPro = getProPlugFullPathWpf();
- $proPlugin = plugin_basename( $pathPro );
- if ( is_plugin_active( $proPlugin ) ) {
- $pluginData = get_file_data( $pathPro, array( 'Version' => 'Version' ) );
- $isProActive = WooBeWoo_PF_Frame::_()->moduleActive( 'access' );
- if ( ! version_compare( $pluginData['Version'], WPF_PRO_REQUIRES, '>=' ) ) {
- if ( $isProActive ) {
- call_user_func_array( array( 'WooBeWoo_PF_Mod_Installer', 'deactivate' ), array( array( 'license' ) ) );
- }
- } elseif ( ! $isProActive ) {
- call_user_func_array( array( 'WooBeWoo_PF_Mod_Installer', 'activate' ), array( true ) );
- }
- }
+ if ( ! class_exists( 'WooBeWoo_PF_Frame' ) ) {
+ return;
+ }
+ $path_pro = woobewoo_pf_get_pro_full_path();
+ if ( ! $path_pro || ! is_plugin_active( plugin_basename( $path_pro ) ) ) {
+ return;
+ }
+ $plugin_data = get_file_data( $path_pro, array( 'Version' => 'Version' ) );
+ if ( ! version_compare( $plugin_data['Version'], WPF_PRO_REQUIRES, '>=' ) ) {
+ // Too old PRO: its modules can't be loaded by this version (see woobewoo_pf_pro_incompatible_notice()).
+ return;
+ }
+ // PRO modules left inactive (e.g., by an older Free version) while PRO is active, compatible and licensed.
+ if ( ! WooBeWoo_PF_Frame::_()->moduleActive( 'access' ) && woobewoo_pf_is_pro_license_active() ) {
+ call_user_func_array( array( 'WooBeWoo_PF_Mod_Installer', 'activate' ), array( true ) );
}
}
}
/**
+ * woobewoo_pf_get_pro_full_path.
+ *
+ * PRO main file path, for PRO >= 3.4.0 and for older PRO versions.
+ *
+ * @version 3.4.6
+ * @since 3.4.6
+ */
+if ( ! function_exists( 'woobewoo_pf_get_pro_full_path' ) ) {
+ function woobewoo_pf_get_pro_full_path() {
+ if ( function_exists( 'woobeboo_pf_get_pro_plugin_full_path' ) ) {
+ return woobeboo_pf_get_pro_plugin_full_path();
+ }
+ if ( function_exists( 'getProPlugFullPathWpf' ) ) {
+ return getProPlugFullPathWpf();
+ }
+ return false;
+ }
+}
+
+/**
+ * woobewoo_pf_is_pro_license_active.
+ *
+ * @version 3.4.6
+ * @since 3.4.6
+ */
+if ( ! function_exists( 'woobewoo_pf_is_pro_license_active' ) ) {
+ function woobewoo_pf_is_pro_license_active() {
+ $license = WooBeWoo_PF_Frame::_()->getModule( 'license' );
+ $model = $license ? $license->getModel() : null;
+ return $model && method_exists( $model, 'isActive' ) && $model->isActive();
+ }
+}
+
+/**
+ * woobewoo_pf_pro_incompatible_notice.
+ *
+ * @version 3.4.6
+ * @since 3.4.6
+ */
+add_action( 'admin_notices', 'woobewoo_pf_pro_incompatible_notice' );
+if ( ! function_exists( 'woobewoo_pf_pro_incompatible_notice' ) ) {
+ function woobewoo_pf_pro_incompatible_notice() {
+ if ( ! current_user_can( 'activate_plugins' ) || ! class_exists( 'WooBeWoo_PF_Frame' ) ) {
+ return;
+ }
+ $path_pro = woobewoo_pf_get_pro_full_path();
+ if ( ! $path_pro || ! is_plugin_active( plugin_basename( $path_pro ) ) ) {
+ return;
+ }
+ $plugin_data = get_file_data( $path_pro, array( 'Version' => 'Version' ) );
+ if ( version_compare( $plugin_data['Version'], WPF_PRO_REQUIRES, '>=' ) ) {
+ return;
+ }
+ echo '<div class="notice notice-error"><p><strong>';
+ printf(
+ /* translators: 1: PRO version, 2: Free version, 3: required PRO version */
+ esc_html__( 'Product Filter by WBW: PRO version %1$s is not compatible with the Free (Base) version %2$s, so PRO features are disabled. Please update the PRO plugin to version %3$s or later.', 'woo-product-filter' ),
+ esc_html( $plugin_data['Version'] ),
+ esc_html( WPF_VERSION ),
+ esc_html( WPF_PRO_REQUIRES )
+ );
+ echo '</strong></p></div>';
+ }
+}
+
+/**
* woobewoo_pf_translate_string.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
if ( ! function_exists( 'woobewoo_pf_translate_string' ) ) {
- function woobewoo_pf_translate_string( $value, $name = '', $context = 'woo-product-filter' ) {
+ function woobewoo_pf_translate_string( $value, $name = '', $context = 'woo-product-filter', $register = null ) {
if ( has_action( 'wpml_register_single_string' ) ) {
- // Register the string.
- do_action(
- 'wpml_register_single_string', // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
- $context,
- $name,
- $value
- );
+ // Each string needs its own name: with an empty name WPML/Polylang keep only the last string
+ // registered and Polylang copies translations between them. The lookup below uses the value as name.
+ if ( '' === (string) $name ) {
+ $name = $value;
+ }
+ // Register the string only when a filter is saved or in wp-admin screens, never on
+ // front-end page views or AJAX filtering (Polylang/WPML write to the DB on each call).
+ if ( null === $register ) {
+ $register = is_admin() && ! wp_doing_ajax();
+ }
+ if ( $register ) {
+ do_action(
+ 'wpml_register_single_string', // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound
+ $context,
+ $name,
+ $value
+ );
+ }
// Get the translated value.
return apply_filters(
--- a/woo-product-filter/modules/meta/models/class-woobewoo-pf-meta-model.php
+++ b/woo-product-filter/modules/meta/models/class-woobewoo-pf-meta-model.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Meta_Model Class
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -19,6 +19,14 @@
public $metaVarSuf = '#wpfvar#';
public $startLockLimit = 20;
+ /**
+ * Whether the current run has set the full-indexing lock (`start_indexing` = 2).
+ *
+ * @version 3.4.6
+ * @since 3.4.6
+ */
+ private $indexingLockAcquired = false;
+
public function __construct() {
$this->existMB = function_exists( 'mb_substr' );
$this->_setTbl( 'meta_data' );
@@ -44,10 +52,19 @@
/**
* recalcMetaValues.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
public function recalcMetaValues( $productId = 0, $params = array() ) {
- $result = $this->doRecalcMetaValues( $productId, $params );
+ $this->indexingLockAcquired = false;
+ $result = $this->doRecalcMetaValues( $productId, $params );
+ // Release the full-indexing lock taken by this run if it did not finish (errors, nothing to index...).
+ if ( $this->indexingLockAcquired ) {
+ $optModel = WooBeWoo_PF_Frame::_()->getModule( 'options' )->getModel();
+ if ( 2 == $optModel->get( 'start_indexing' ) ) {
+ $optModel->save( 'start_indexing', 1 );
+ }
+ $this->indexingLockAcquired = false;
+ }
if ( ! $result && WooBeWoo_PF_Frame::_()->getModule( 'options' )->getModel()->get( 'logging' ) == 1 ) {
$logger = wc_get_logger();
if ( $logger ) {
@@ -60,15 +77,15 @@
/**
* doRecalcMetaValues.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
public function doRecalcMetaValues( $productId, $params ) {
if ( ! empty( $productId ) && ! is_numeric( $productId ) ) {
return false;
}
$isAllProducts = empty( $productId );
- $isAllKeys = empty( $params );
- $fullRecalc = $isAllProducts && $isAllKeys;
+ $is_all_keys = empty( $params );
+ $fullRecalc = $isAllProducts && $is_all_keys;
$keysModel = WooBeWoo_PF_Frame::_()->getModule( 'meta' )->getModel( 'meta_keys' );
$optModel = WooBeWoo_PF_Frame::_()->getModule( 'options' )->getModel();
@@ -88,9 +105,10 @@
}
if ( $fullRecalc ) {
$optModel->save( 'start_indexing', 2 );
+ $this->indexingLockAcquired = true;
}
- if ( $isAllKeys ) {
+ if ( $is_all_keys ) {
$params['parent'] = 0;
}
@@ -115,7 +133,7 @@
$isKnownKeyList = true;
$whereKeys = $whereProduct;
- if ( ! $isAllKeys ) {
+ if ( ! $is_all_keys ) {
$list = '';
foreach ( $keys as $key ) {
$list .= $key['id'] . ',';
@@ -536,7 +554,13 @@
}
set_time_limit( 300 ); // phpcs:ignore Squiz.PHP.DiscouragedFunctions.Discouraged
- if ( ! $valsModel->recalcValuesCount( $isAllKeys ? array() : $keyRecalc ) ) {
+ // All keys: full recalculation on a full re-index, only this product's values on a product update.
+ if ( $is_all_keys ) {
+ $counts_ok = $isAllProducts ? $valsModel->recalcValuesCount( array(), true ) : $valsModel->recalcProductValuesCount( $productId );
+ } else {
+ $counts_ok = $valsModel->recalcValuesCount( $keyRecalc );
+ }
+ if ( ! $counts_ok ) {
$this->pushError( $valsModel->getErrors() );
return false;
}
--- a/woo-product-filter/modules/meta/models/class-woobewoo-pf-meta-values-model.php
+++ b/woo-product-filter/modules/meta/models/class-woobewoo-pf-meta-values-model.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Meta_Values_Model Class
*
- * @version 3.4.0
+ * @version 3.4.6
*/
defined( 'ABSPATH' ) || exit;
@@ -248,22 +248,48 @@
/**
* recalcValuesCount.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
- public function recalcValuesCount( $keyIds = array() ) {
+ public function recalcValuesCount( $key_ids = array(), $all_keys = false ) {
- $keyIds = array_map( 'intval', (array) $keyIds );
- $keyIds = array_filter( $keyIds );
- if ( empty( $keyIds ) ) {
+ $key_ids = array_map( 'intval', (array) $key_ids );
+ $key_ids = array_filter( $key_ids );
+ if ( empty( $key_ids ) && ! $all_keys ) {
return true;
}
$query = 'UPDATE `@__meta_values` as v SET ' .
' product_cnt=IF(exists(SELECT 1 FROM `@__meta_data` m WHERE m.key_id=v.key_id AND m.val_id=v.id AND m.is_var!=1 LIMIT 1),1,0),
variation_cnt=IF(exists(SELECT 1 FROM `@__meta_data` m WHERE m.key_id=v.key_id AND m.val_id=v.id AND m.is_var=1 LIMIT 1),1,0) ';
- if ( ! empty( $keyIds ) ) {
- $query .= ' WHERE v.key_id IN (' . implode( ',', $keyIds ) . ')';
+ if ( ! empty( $key_ids ) ) {
+ $query .= ' WHERE v.key_id IN (' . implode( ',', $key_ids ) . ')';
+ }
+ if ( ! WooBeWoo_PF_Db::query( $query ) ) {
+ $this->pushError( WooBeWoo_PF_Db::getError() );
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * recalcProductValuesCount.
+ *
+ * Recalculates counts only for the values used by one product (and its variations).
+ *
+ * @version 3.4.6
+ * @since 3.4.6
+ */
+ public function recalcProductValuesCount( $product_id ) {
+ $product_id = (int) $product_id;
+ if ( empty( $product_id ) ) {
+ return true;
}
+ $query = 'UPDATE `@__meta_values` as v SET ' .
+ ' product_cnt=IF(exists(SELECT 1 FROM `@__meta_data` m WHERE m.key_id=v.key_id AND m.val_id=v.id AND m.is_var!=1 LIMIT 1),1,0),
+ variation_cnt=IF(exists(SELECT 1 FROM `@__meta_data` m WHERE m.key_id=v.key_id AND m.val_id=v.id AND m.is_var=1 LIMIT 1),1,0) ' .
+ ' WHERE v.id IN (SELECT pm.val_id FROM `@__meta_data` pm WHERE pm.product_id=' . $product_id .
+ " OR pm.product_id IN (SELECT pv.ID FROM `#__posts` pv WHERE pv.post_parent=" . $product_id . " AND pv.post_type='product_variation'))";
if ( ! WooBeWoo_PF_Db::query( $query ) ) {
$this->pushError( WooBeWoo_PF_Db::getError() );
return false;
--- a/woo-product-filter/modules/woofilters/class-woobewoo-pf-woofilters-controller.php
+++ b/woo-product-filter/modules/woofilters/class-woobewoo-pf-woofilters-controller.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Woofilters_Controller Class
*
- * @version 3.4.3
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -223,14 +223,14 @@
/**
* woobewoo_pf_draw_filter_ajax.
*
- * @since 3.4.0
+ * @since 3.4.6
*/
public function woobewoo_pf_draw_filter_ajax() {
$res = new WooBeWoo_PF_Response();
$data = WooBeWoo_PF_Req::get( 'post' );
if ( isset( $data ) && $data ) {
if ( ! empty( $data['settings']['filters']['order'] ) ) {
- $metaKeys = $this->getDataFilterMetaKeys( stripcslashes( $data['settings']['filters']['order'] ) );
+ $metaKeys = $this->getDataFilterMetaKeys( $data['settings']['filters']['order'] );
if ( count( $metaKeys ) > 0 ) {
WooBeWoo_PF_Frame::_()->getModule( 'meta' )->calcNeededMetaValues();
}
@@ -351,19 +351,19 @@
/**
* woobewoo_pf_filters_frontend.
*
- * @version 3.4.3
+ * @version 3.4.6
*/
public function woobewoo_pf_filters_frontend() {
$res = new WooBeWoo_PF_Response();
$params = WooBeWoo_PF_Req::get( 'post' );
- $filtersDataBackend = WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['filtersDataBackend'] ) );
- $queryvars = WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['queryvars'] ) );
- $filterSettings = WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['filterSettings'] ) );
- $generalSettings = WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['generalSettings'] ) );
- $woocommerceSettings = WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['woocommerceSettings'] ) );
- $shortcodeAttr = isset( $params['shortcodeAttr'] ) ? WooBeWoo_PF_Utils::jsonDecode( stripslashes( $params['shortcodeAttr'] ) ) : array();
+ $filtersDataBackend = WooBeWoo_PF_Utils::jsonDecode( $params['filtersDataBackend'] );
+ $queryvars = WooBeWoo_PF_Utils::jsonDecode( $params['queryvars'] );
+ $filterSettings = WooBeWoo_PF_Utils::jsonDecode( $params['filterSettings'] );
+ $generalSettings = WooBeWoo_PF_Utils::jsonDecode( $params['generalSettings'] );
+ $woocommerceSettings = WooBeWoo_PF_Utils::jsonDecode( $params['woocommerceSettings'] );
+ $shortcodeAttr = isset( $params['shortcodeAttr'] ) ? WooBeWoo_PF_Utils::jsonDecode( $params['shortcodeAttr'] ) : array();
$curUrl = esc_url_raw( wp_unslash( $_POST['currenturl'] ) ); // phpcs:ignore WordPress.Security.NonceVerification.Missing, WordPress.Security.ValidatedSanitizedInput.InputNotValidated
$queryvars['posts_per_page'] = isset( $filterSettings['count_product_shop'] ) && ! empty( $filterSettings['count_product_shop'] ) ? $filterSettings['count_product_shop'] : $queryvars['posts_per_page'];
$use_category_filtration = isset( $filterSettings['use_category_filtration'] ) ? $filterSettings['use_category_filtration'] : 1;
@@ -595,10 +595,10 @@
endwhile;
$productsHtml = ob_get_clean();
if ( empty( $productsHtml ) ) {
- $productsHtml = ' <div class="no-products-found">' . $filterSettings['text_no_products'] . '</div>';
+ $productsHtml = ' <div class="no-products-found">' . wp_kses_post( $filterSettings['text_no_products'] ?? '' ) . '</div>';
}
} else {
- $productsHtml = ' <div class="no-products-found">' . $filterSettings['text_no_products'] . '</div>';
+ $productsHtml = ' <div class="no-products-found">' . wp_kses_post( $filterSettings['text_no_products'] ?? '' ) . '</div>';
}
}
@@ -850,7 +850,7 @@
/**
* Create args for WP_Query.
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @param array $filtersDataBackend Filters arranged with filtering order with some specific filtering data in it
* @param array $queryvars Query filtering variables
@@ -893,8 +893,26 @@
'wpf_query' => 1,
'tax_query' => array( 'wpf_tax' => 1 ), // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
);
- if ( ! empty( $filterSettings['default_query'] ) ) {
- $args = array_merge( $args, $filterSettings['default_query'] );
+ if (
+ ! empty( $filterSettings['default_query'] ) &&
+ is_array( $filterSettings['default_query'] )
+ ) {
+ // The default query comes from the browser: it must not widen the queried post types or statuses.
+ $defaultQuery = $filterSettings['default_query'];
+ if (
+ isset( $defaultQuery['post_status'] ) &&
+ ! in_array( $defaultQuery['post_status'], array( '', 'publish' ), true )
+ ) {
+ unset( $defaultQuery['post_status'] );
+ }
+ if (
+ isset( $defaultQuery['post_type'] ) &&
+ array_diff( array_filter( (array) $defaultQuery['post_type'] ), array( 'product', 'product_variation' ) )
+ ) {
+ unset( $defaultQuery['post_type'] );
+ }
+ unset( $defaultQuery['perm'], $defaultQuery['post_password'], $defaultQuery['has_password'] );
+ $args = array_merge( $args, $defaultQuery );
}
$args['tax_query'] = $module->addHiddenFilterQuery( $args['tax_query'] ); // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_tax_query
--- a/woo-product-filter/modules/woofilters/class-woobewoo-pf-woofilters.php
+++ b/woo-product-filter/modules/woofilters/class-woobewoo-pf-woofilters.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Woofilters Class
*
- * @version 3.4.4
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -1901,7 +1901,7 @@
/**
* maybeShowProductSubcategories.
*
- * @version 3.3.0
+ * @version 3.4.6
*/
public function maybeShowProductSubcategories( $loop_html, $categoryPageId ) {
// Use term meta directly instead of woocommerce_get_loop_display_mode(), which
@@ -1909,6 +1909,13 @@
// on full page reload after filters are applied.
$display_type = get_term_meta( $categoryPageId, 'display_type', true );
$display_type = '' === $display_type ? get_option( 'woocommerce_category_archive_display', '' ) : $display_type;
+ // Same as woocommerce_get_loop_display_mode(): show products when there are no subcategories to show.
+ if (
+ 'subcategories' === $display_type &&
+ ! $this->needSubcategoriesDisplay( $categoryPageId )
+ ) {
+ return $loop_html;
+ }
if ( 'subcategories' === $display_type || 'both' === $display_type ) {
add_filter( 'term_link', array( $this, 'setSubcategoriesLink' ), 99 );
$taxonomies = $this->getFilterTaxonomies( array(), true );
@@ -3290,14 +3297,20 @@
/**
* renderSelectedFilters.
*
- * @version 3.3.1
+ * @version 3.4.6
*/
public function renderSelectedFilters( $params ) {
$p = array(
'id' => ( isset( $params['id'] ) ? (int) $params['id'] : 0 ),
);
- return apply_filters( 'woobewoo_pf_render_selected_filters', '', $p );
+ // Rendered by the Free view, as in 3.3.0. The Pro listener on the Dispatcher hook
+ // (`wpf_woobewoo_pf_render_selected_filters`) is never reached by the plain hook below.
+ $html = WooBeWoo_PF_Frame::_()->isPro() ?
+ WooBeWoo_PF_Html::escapedHtml( $this->getView()->renderSelectedFiltersHtml( $p ) ) :
+ '';
+
+ return apply_filters( 'woobewoo_pf_render_selected_filters', $html, $p );
}
/**
--- a/woo-product-filter/modules/woofilters/models/class-woobewoo-pf-woofilters-model.php
+++ b/woo-product-filter/modules/woofilters/models/class-woobewoo-pf-woofilters-model.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Woofilters_Model Class
*
- * @version 3.4.5
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -392,17 +392,17 @@
/**
* _dataSave.
*
- * @version 3.4.5
+ * @version 3.4.6
*/
protected function _dataSave( $data, $update = false ) {
- $esettings = isset( $data['esettings'] ) ? WooBeWoo_PF_Utils::jsonDecode( stripslashes( $data['esettings'] ) ) : array();
+ $esettings = isset( $data['esettings'] ) ? WooBeWoo_PF_Utils::jsonDecode( $data['esettings'] ) : array();
if ( ! empty( $esettings ) ) {
$data['settings'] = array_merge( $esettings, ( isset( $data['settings'] ) && is_array( $data['settings'] ) ? $data['settings'] : array() ) );
}
$settings = isset( $data['settings'] ) ? $data['settings'] : array();
- $data['settings']['filters']['order'] = isset( $settings['filters'] ) && isset( $settings['filters']['order'] ) ? stripslashes( $settings['filters']['order'] ) : '';
+ $data['settings']['filters']['order'] = isset( $settings['filters'] ) && isset( $settings['filters']['order'] ) ? $settings['filters']['order'] : '';
$notEdit = array( 'filters' );
foreach ( $data['settings'] as $key => $value ) {
if ( ! in_array( $key, $notEdit ) && is_string( $value ) ) {
@@ -426,7 +426,7 @@
/**
* WPML string translation.
*
- * @version 3.4.0
+ * @version 3.4.6
*/
private function translateStrings( $data_settings ) {
$filters_arr = json_decode( $data_settings['filters']['order'], true );
@@ -436,61 +436,61 @@
if ( is_array( $filters_arr ) ) {
foreach ( $filters_arr as $key => $filter ) {
if ( isset( $filter['settings']['f_dropdown_first_option_text'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_dropdown_first_option_text'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_dropdown_first_option_text'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_title'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_title'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_title'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_description'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_description'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_description'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_custom_title'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_custom_title'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_custom_title'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_search_label'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_search_label'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_search_label'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_stock_statuses[in]'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[in]'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[in]'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_stock_statuses[out]'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[out]'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[out]'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_stock_statuses[on]'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[on]'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_stock_statuses[on]'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_add_text'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_add_text'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_add_text'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_add_text5'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_add_text5'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_add_text5'], '', 'woo-product-filter', true );
}
if ( isset( $filter['settings']['f_checkbox_label'] ) ) {
- woobewoo_pf_translate_string( $filter['settings']['f_checkbox_label'] );
+ woobewoo_pf_translate_string( $filter['settings']['f_checkbox_label'], '', 'woo-product-filter', true );
}
}
}
// here goes other plugin settings strings
if ( ! empty( $data_settings['filtering_button_word'] ) ) {
- woobewoo_pf_translate_string( $data_settings['filtering_button_word'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['filtering_button_word'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['show_clean_button_word'] ) ) {
- woobewoo_pf_translate_string( $data_settings['show_clean_button_word'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['show_clean_button_word'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['hide_button_hide_text'] ) ) {
- woobewoo_pf_translate_string( $data_settings['hide_button_hide_text'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['hide_button_hide_text'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['hide_button_show_text'] ) ) {
- woobewoo_pf_translate_string( $data_settings['hide_button_show_text'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['hide_button_show_text'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['text_no_products'] ) ) {
- woobewoo_pf_translate_string( $data_settings['text_no_products'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['text_no_products'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['enable_overlay_word'] ) && '1' == $data_settings['enable_overlay_word'] && ! empty( $data_settings['overlay_word'] ) ) {
- woobewoo_pf_translate_string( $data_settings['overlay_word'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['overlay_word'], '', 'woo-product-filter', true );
}
if ( ! empty( $data_settings['selected_params_clear'] ) && '1' == $data_settings['selected_params_clear'] && ! empty( $data_settings['selected_clean_word'] ) ) {
- woobewoo_pf_translate_string( $data_settings['selected_clean_word'] ); // ?
+ woobewoo_pf_translate_string( $data_settings['selected_clean_word'], '', 'woo-product-filter', true );
}
}
--- a/woo-product-filter/modules/woofilters/views/class-woobewoo-pf-woofilters-view.php
+++ b/woo-product-filter/modules/woofilters/views/class-woobewoo-pf-woofilters-view.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - WooBeWoo_PF_Woofilters_View Class
*
- * @version 3.4.5
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -197,7 +197,7 @@
/**
* renderHtml.
*
- * @version 3.4.3
+ * @version 3.4.6
*/
public function renderHtml( $params ) {
$isWooCommercePluginActivated = $this->getModule()->isWooCommercePluginActivated();
@@ -218,9 +218,7 @@
// preview case
if ( isset( $params['settings'] ) ) {
- $params['settings']['filters']['order'] = stripcslashes( $params['settings']['filters']['order'] );
- $settings = $params;
- // other
+ $settings = $params;
} else {
$settings = $this->getCurrentSettings( $id );
}
@@ -531,7 +529,7 @@
/**
* generateFiltersHtml.
*
- * @version 3.4.5
+ * @version 3.4.6
*/
public function generateFiltersHtml( $filterSettings, $viewId, $prodCatId = false, $noWooPage = false, $taxonomies = array() ) {
$this->setCurrentSettings( $filterSettings );
@@ -833,9 +831,17 @@
$settings,
$filterId
);
+ // Backward compatibility: hook name used up to 3.4.4 (Pro <= 3.4.4 and custom code on `wpf_addCustomCss`).
+ $custom_css = WooBeWoo_PF_Dispatcher::applyFilters(
+ 'addCustomCss',
+ $custom_css,
+ $settings,
+ $filterId
+ );
+ // Keep the code intact (tags inside strings, `a < b`...), only prevent it from closing its own element.
wp_add_inline_style(
'woobewoo-pf-frontend-filters',
- wp_strip_all_tags( $custom_css )
+ preg_replace( '#</(style)#i', '</$1', (string) $custom_css )
);
$custom_js = WooBeWoo_PF_Dispatcher::applyFilters(
@@ -846,7 +852,7 @@
);
wp_add_inline_script(
'woobewoo-pf-frontend-filters',
- wp_strip_all_tags( $custom_js )
+ preg_replace( '#</(script)#i', '</$1', (string) $custom_js )
);
$this->resetFilterExistsTerms();
--- a/woo-product-filter/modules/woofilters/views/tpl/woofiltersEditTabOptions.php
+++ b/woo-product-filter/modules/woofilters/views/tpl/woofiltersEditTabOptions.php
@@ -2,7 +2,7 @@
/**
* Product Filter by WBW - Woofilters Edit Tab Options
*
- * @version 3.4.0
+ * @version 3.4.6
*
* @author woobewoo
*/
@@ -1052,7 +1052,7 @@
</div>
</div>
<?php }
- WooBeWoo_PF_Dispatcher::doAction( 'addEditTabDesign', 'partEditTabOptionsContent', $this->filter['id'], $this->filter['id'] );
+ WooBeWoo_PF_Dispatcher::doAction( 'addEditTabDesign', 'partEditTabOptionsContent', $this->settings, $this->filter['id'] );
?>
<div class="woobewoo_row row-settings-block">
--- a/woo-product-filter/woo-product-filter.php
+++ b/woo-product-filter/woo-product-filter.php
@@ -3,7 +3,7 @@
* Plugin Name: Product Filter for WooCommerce by WBW
* Plugin URI: https://woobewoo.com/product/woocommerce-filter/
* Description: Filter products in your store in most efficient way
- * Version: 3.4.5
+ * Version: 3.4.6
* Author: woobewoo
* Author URI: https://woobewoo.com/
* Requires at least: 5.0