From fe9e89f3b76249077f86b2f922ea1e52ea54b8e6 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 7 Dec 2016 12:04:44 +0000 Subject: [PATCH 1/2] wc_logout_url function --- includes/wc-template-functions.php | 17 +++++++++++++++++ templates/myaccount/dashboard.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index eb5094b22be..e95e2e5d01b 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -2545,3 +2545,20 @@ function wc_get_rating_html( $rating ) { function wc_get_price_html_from_text() { return apply_filters( 'woocommerce_get_price_html_from_text', '' . _x( 'From:', 'min_price', 'woocommerce' ) . ' ' ); } + +/** + * Get logout endpoint. + * + * @since 2.6.9 + * @return string + */ +function wc_logout_url( $redirect = '' ) { + $logout_endpoint = get_option( 'woocommerce_logout_endpoint' ); + $redirect = $redirect ? $redirect : wc_get_page_permalink( 'myaccount' ); + + if ( $logout_endpoint ) { + return wc_get_endpoint_url( 'customer-logout', '', $redirect ); + } else { + return wp_logout_url( $redirect ); + } +} diff --git a/templates/myaccount/dashboard.php b/templates/myaccount/dashboard.php index 215f9eaf3f5..7762cd83d06 100644 --- a/templates/myaccount/dashboard.php +++ b/templates/myaccount/dashboard.php @@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) { printf( __( 'Hello %1$s (not %1$s? Sign out)', 'woocommerce' ), '' . esc_html( $current_user->display_name ) . '', - esc_url( wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) ) ) + esc_url( wc_logout_url( wc_get_page_permalink( 'myaccount' ) ) ) ); ?>

From 9a9d133fc305a2c2acd137c1e127f362160e0b50 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Wed, 7 Dec 2016 12:07:10 +0000 Subject: [PATCH 2/2] Use correct endpoint for lost password link --- includes/wc-account-functions.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/includes/wc-account-functions.php b/includes/wc-account-functions.php index 4a396979226..c4b46364596 100644 --- a/includes/wc-account-functions.php +++ b/includes/wc-account-functions.php @@ -22,10 +22,11 @@ if ( ! defined( 'ABSPATH' ) ) { * @return string */ function wc_lostpassword_url( $default_url = '' ) { - $wc_password_reset_url = wc_get_page_permalink( 'myaccount' ); + $wc_password_reset_url = wc_get_page_permalink( 'myaccount' ); + $lost_password_endpoint = get_option( 'woocommerce_myaccount_lost_password_endpoint' ); - if ( false !== $wc_password_reset_url ) { - return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url ); + if ( false !== $wc_password_reset_url && ! empty( $lost_password_endpoint ) ) { + return wc_get_endpoint_url( $lost_password_endpoint, '', $wc_password_reset_url ); } else { return $default_url; }