selected logic, with added sanitize_title
This commit is contained in:
parent
301e9339a9
commit
45d6c55f2a
|
@ -2767,6 +2767,12 @@ if ( ! function_exists( 'wc_dropdown_variation_attribute_options' ) ) {
|
|||
'show_option_none' => __( 'Choose an option', 'woocommerce' ),
|
||||
) );
|
||||
|
||||
// Get selected value.
|
||||
if ( false === $args['selected'] && $args['attribute'] && $args['product'] instanceof WC_Product ) {
|
||||
$selected_key = 'attribute_' . sanitize_title( $args['attribute'] );
|
||||
$args['selected'] = isset( $_REQUEST[ $selected_key ] ) ? wc_clean( urldecode( wp_unslash( $_REQUEST[ $selected_key ] ) ) ) : $args['product']->get_variation_default_attribute( $args['attribute'] ); // WPCS: input var ok, CSRF ok, sanitization ok.
|
||||
}
|
||||
|
||||
$options = $args['options'];
|
||||
$product = $args['product'];
|
||||
$attribute = $args['attribute'];
|
||||
|
|
Loading…
Reference in New Issue