diff --git a/includes/shortcodes/class-wc-shortcode-my-account.php b/includes/shortcodes/class-wc-shortcode-my-account.php index d224c3be9ff..2032b97a3dd 100644 --- a/includes/shortcodes/class-wc-shortcode-my-account.php +++ b/includes/shortcodes/class-wc-shortcode-my-account.php @@ -56,10 +56,14 @@ class WC_Shortcode_My_Account { } else { wc_get_template( 'myaccount/form-login.php' ); } - } else { + } else { // Start output buffer since the html may need discarding for BW compatibility ob_start(); + if ( isset( $wp->query_vars['customer-logout'] ) ) { + wc_add_notice( sprintf( __( 'Are you sure you want to log out? Confirm and log out', 'woocommerce' ), wc_logout_url() ) ); + } + // Collect notices before output $notices = wc_get_notices(); diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 705652b5604..7e13e02bd0e 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -33,7 +33,7 @@ function wc_template_redirect() { wp_redirect( wc_get_page_permalink( 'cart' ) ); exit; - } elseif ( isset( $wp->query_vars['customer-logout'] ) ) { + } elseif ( isset( $wp->query_vars['customer-logout'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( $_REQUEST['_wpnonce'], 'customer-logout' ) ) { // Logout wp_redirect( str_replace( '&', '&', wp_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) ); @@ -2646,7 +2646,7 @@ function wc_logout_url( $redirect = '' ) { $redirect = $redirect ? $redirect : wc_get_page_permalink( 'myaccount' ); if ( $logout_endpoint ) { - return wc_get_endpoint_url( 'customer-logout', '', $redirect ); + return wp_nonce_url( wc_get_endpoint_url( 'customer-logout', '', $redirect ), 'customer-logout' ); } else { return wp_logout_url( $redirect ); } diff --git a/templates/myaccount/dashboard.php b/templates/myaccount/dashboard.php index 7762cd83d06..a9079be843d 100644 --- a/templates/myaccount/dashboard.php +++ b/templates/myaccount/dashboard.php @@ -26,7 +26,7 @@ if ( ! defined( 'ABSPATH' ) ) {
Sign out)', 'woocommerce' ), + __( 'Hello %1$s (not %1$s? Log out)', 'woocommerce' ), '' . esc_html( $current_user->display_name ) . '', esc_url( wc_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) );