Skip to content

Commit

Permalink
URL encode to preserve text attributes in permalinks
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Jul 28, 2015
1 parent 808c01c commit 1b45bcd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion includes/class-wc-product-variation.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ public function exists() {
* @return string
*/
public function get_permalink( $cart_item = null ) {
return add_query_arg( array_filter( isset( $cart_item['variation'] ) ? $cart_item['variation'] : $this->variation_data ), get_permalink( $this->id ) );
return add_query_arg( array_map( 'urlencode', array_filter( isset( $cart_item['variation'] ) ? $cart_item['variation'] : $this->variation_data ) ), get_permalink( $this->id ) );
}

/**
Expand Down
2 changes: 1 addition & 1 deletion templates/single-product/add-to-cart/variable.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<td class="label"><label for="<?php echo sanitize_title( $attribute_name ); ?>"><?php echo wc_attribute_label( $attribute_name ); ?></label></td>
<td class="value">
<?php
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] : $product->get_variation_default_attribute( $attribute_name );
$selected = isset( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) ? wc_clean( $_REQUEST[ 'attribute_' . sanitize_title( $attribute_name ) ] ) : $product->get_variation_default_attribute( $attribute_name );
wc_dropdown_variation_attribute_options( array( 'options' => $options, 'attribute' => $attribute_name, 'product' => $product, 'selected' => $selected ) );
echo end( $attribute_keys ) === $attribute_name ? '<a class="reset_variations" href="#">' . __( 'Clear selection', 'woocommerce' ) . '</a>' : '';
?>
Expand Down

0 comments on commit 1b45bcd

Please sign in to comment.