Merge pull request #21403 from woocommerce/fix/21294

Fix attributes bugs
This commit is contained in:
Claudiu Lodromanean 2018-09-28 08:24:03 -07:00 committed by GitHub
commit f1a7792454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -1104,7 +1104,7 @@ class WC_Product extends WC_Abstract_Legacy_Product {
$attributes = array_fill_keys( array_keys( $this->get_attributes( 'edit' ) ), null );
foreach ( $raw_attributes as $attribute ) {
if ( is_a( $attribute, 'WC_Product_Attribute' ) ) {
$attributes[ sanitize_text_field( $attribute->get_name() ) ] = $attribute;
$attributes[ sanitize_title( $attribute->get_name() ) ] = $attribute;
}
}

View File

@ -631,7 +631,7 @@ class WC_AJAX {
$i = -1;
foreach ( $data['attribute_names'] as $attribute_name ) {
$attribute = isset( $attributes[ $attribute_name ] ) ? $attributes[ $attribute_name ] : false;
$attribute = isset( $attributes[ sanitize_title( $attribute_name ) ] ) ? $attributes[ sanitize_title( $attribute_name ) ] : false;
if ( ! $attribute ) {
continue;
}

View File

@ -373,7 +373,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
// Maybe store a transient of the count values.
$cache = apply_filters( 'woocommerce_layered_nav_count_maybe_cache', true );
if ( true === $cache ) {
$cached_counts = (array) get_transient( 'wc_layered_nav_counts_' . $taxonomy );
$cached_counts = (array) get_transient( 'wc_layered_nav_counts_' . sanitize_title( $taxonomy ) );
} else {
$cached_counts = array();
}
@ -383,7 +383,7 @@ class WC_Widget_Layered_Nav extends WC_Widget {
$counts = array_map( 'absint', wp_list_pluck( $results, 'term_count', 'term_count_id' ) );
$cached_counts[ $query_hash ] = $counts;
if ( true === $cache ) {
set_transient( 'wc_layered_nav_counts_' . $taxonomy, $cached_counts, DAY_IN_SECONDS );
set_transient( 'wc_layered_nav_counts_' . sanitize_title( $taxonomy ), $cached_counts, DAY_IN_SECONDS );
}
}