plugin updates
This commit is contained in:
@@ -31,18 +31,18 @@ function wc_template_redirect() {
|
||||
if ( is_page( wc_get_page_id( 'checkout' ) ) && wc_get_page_id( 'checkout' ) !== wc_get_page_id( 'cart' ) && WC()->cart->is_empty() && empty( $wp->query_vars['order-pay'] ) && ! isset( $wp->query_vars['order-received'] ) && ! is_customize_preview() && apply_filters( 'woocommerce_checkout_redirect_empty_cart', true ) ) {
|
||||
wp_safe_redirect( wc_get_cart_url() );
|
||||
exit;
|
||||
|
||||
}
|
||||
|
||||
// Logout.
|
||||
if ( isset( $wp->query_vars['customer-logout'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' ) ) {
|
||||
wp_safe_redirect( str_replace( '&', '&', wp_logout_url( apply_filters( 'woocommerce_logout_default_redirect_url', wc_get_page_permalink( 'myaccount' ) ) ) ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// Redirect to the correct logout endpoint.
|
||||
if ( isset( $wp->query_vars['customer-logout'] ) && 'true' === $wp->query_vars['customer-logout'] ) {
|
||||
wp_safe_redirect( esc_url_raw( wc_get_account_endpoint_url( 'customer-logout' ) ) );
|
||||
// Logout endpoint under My Account page. Logging out requires a valid nonce.
|
||||
if ( isset( $wp->query_vars['customer-logout'] ) ) {
|
||||
if ( ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' ) ) {
|
||||
wp_logout();
|
||||
wp_safe_redirect( wc_get_logout_redirect_url() );
|
||||
exit;
|
||||
}
|
||||
/* translators: %s: logout url */
|
||||
wc_add_notice( sprintf( __( 'Are you sure you want to log out? <a href="%s">Confirm and log out</a>', 'woocommerce' ), wc_logout_url() ) );
|
||||
wp_safe_redirect( wc_get_page_permalink( 'myaccount' ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
@@ -240,8 +240,8 @@ function wc_set_loop_prop( $prop, $value = '' ) {
|
||||
* Set the current visbility for a product in the woocommerce_loop global.
|
||||
*
|
||||
* @since 4.4.0
|
||||
* @param int $product_id Product it to cache visbiility for.
|
||||
* @param bool $value The poduct visibility value to cache.
|
||||
* @param int $product_id Product it to cache visibility for.
|
||||
* @param bool $value The product visibility value to cache.
|
||||
*/
|
||||
function wc_set_loop_product_visibility( $product_id, $value ) {
|
||||
wc_set_loop_prop( "product_visibility_$product_id", $value );
|
||||
@@ -1387,6 +1387,10 @@ if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) {
|
||||
),
|
||||
);
|
||||
|
||||
if ( is_a( $product, 'WC_Product_Simple' ) ) {
|
||||
$defaults['attributes']['data-success_message'] = $product->add_to_cart_success_message();
|
||||
}
|
||||
|
||||
$args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product );
|
||||
|
||||
if ( ! empty( $args['attributes']['aria-describedby'] ) ) {
|
||||
@@ -2854,6 +2858,12 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
||||
}
|
||||
|
||||
if ( $args['required'] ) {
|
||||
// hidden inputs are the only kind of inputs that don't need an `aria-required` attribute.
|
||||
// checkboxes apply the `custom_attributes` to the label - we need to apply the attribute on the input itself, instead.
|
||||
if ( ! in_array( $args['type'], array( 'hidden', 'checkbox' ), true ) ) {
|
||||
$args['custom_attributes']['aria-required'] = 'true';
|
||||
}
|
||||
|
||||
$args['class'][] = 'validate-required';
|
||||
$required = ' <abbr class="required" title="' . esc_attr__( 'required', 'woocommerce' ) . '">*</abbr>';
|
||||
} else {
|
||||
@@ -2978,12 +2988,13 @@ if ( ! function_exists( 'woocommerce_form_field' ) ) {
|
||||
}
|
||||
|
||||
$field .= sprintf(
|
||||
'<input type="checkbox" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %5$s /> %6$s',
|
||||
'<input type="checkbox" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %5$s%6$s /> %7$s',
|
||||
esc_attr( $key ),
|
||||
esc_attr( $args['id'] ),
|
||||
esc_attr( $args['checked_value'] ),
|
||||
esc_attr( 'input-checkbox ' . implode( ' ', $args['input_class'] ) ),
|
||||
checked( $value, $args['checked_value'], false ),
|
||||
$args['required'] ? ' aria-required="true"' : '',
|
||||
wp_kses_post( $args['label'] )
|
||||
);
|
||||
|
||||
@@ -3728,22 +3739,31 @@ function wc_get_price_html_from_text() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logout endpoint.
|
||||
* Get the redirect URL after logging out. Defaults to the my account page.
|
||||
*
|
||||
* @since 9.3.0
|
||||
* @return string
|
||||
*/
|
||||
function wc_get_logout_redirect_url() {
|
||||
/**
|
||||
* Filters the logout redirect URL.
|
||||
*
|
||||
* @since 2.6.9
|
||||
* @param string $logout_url Logout URL.
|
||||
* @return string
|
||||
*/
|
||||
return apply_filters( 'woocommerce_logout_default_redirect_url', wc_get_page_permalink( 'myaccount' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get logout link.
|
||||
*
|
||||
* @since 2.6.9
|
||||
*
|
||||
* @param string $redirect Redirect URL.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function wc_logout_url( $redirect = '' ) {
|
||||
$redirect = $redirect ? $redirect : apply_filters( 'woocommerce_logout_default_redirect_url', wc_get_page_permalink( 'myaccount' ) );
|
||||
|
||||
if ( get_option( 'woocommerce_logout_endpoint' ) ) {
|
||||
return wp_nonce_url( wc_get_endpoint_url( 'customer-logout', '', $redirect ), 'customer-logout' );
|
||||
}
|
||||
|
||||
return wp_logout_url( $redirect );
|
||||
return wp_logout_url( $redirect ? $redirect : wc_get_logout_redirect_url() );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user