Prevent changing slug to name via pointer

Fixes #10727
This commit is contained in:
Mike Jolley 2016-04-19 11:42:44 +01:00
parent 3ff10a4ce2
commit 1dccf92953
1 changed files with 6 additions and 4 deletions

View File

@ -116,24 +116,26 @@ class WC_Order_Item_Meta {
if ( ! empty( $this->item['item_meta_array'] ) ) { if ( ! empty( $this->item['item_meta_array'] ) ) {
foreach ( $this->item['item_meta_array'] as $meta_id => $meta ) { foreach ( $this->item['item_meta_array'] as $meta_id => $meta ) {
if ( "" === $meta->value || is_serialized( $meta->value ) || ( ! empty( $hideprefix ) && substr( $meta->key, 0, 1 ) == $hideprefix ) ) { if ( "" === $meta->value || is_serialized( $meta->value ) || ( ! empty( $hideprefix ) && substr( $meta->key, 0, 1 ) === $hideprefix ) ) {
continue; continue;
} }
$attribute_key = urldecode( str_replace( 'attribute_', '', $meta->key ) ); $attribute_key = urldecode( str_replace( 'attribute_', '', $meta->key ) );
$meta_value = $meta->value;
// If this is a term slug, get the term's nice name // If this is a term slug, get the term's nice name
if ( taxonomy_exists( $attribute_key ) ) { if ( taxonomy_exists( $attribute_key ) ) {
$term = get_term_by( 'slug', $meta->value, $attribute_key ); $term = get_term_by( 'slug', $meta_value, $attribute_key );
if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) { if ( ! is_wp_error( $term ) && is_object( $term ) && $term->name ) {
$meta->value = $term->name; $meta_value = $term->name;
} }
} }
$formatted_meta[ $meta_id ] = array( $formatted_meta[ $meta_id ] = array(
'key' => $meta->key, 'key' => $meta->key,
'label' => wc_attribute_label( $attribute_key, $this->product ), 'label' => wc_attribute_label( $attribute_key, $this->product ),
'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta->value ), 'value' => apply_filters( 'woocommerce_order_item_display_meta_value', $meta_value ),
); );
} }
} }