Merge pull request #12535 from woocommerce/fallbacks-for-endpoints

Fix lost password and account links
This commit is contained in:
Mike Jolley 2016-12-07 18:18:40 +00:00 committed by GitHub
commit 07932b4432
3 changed files with 22 additions and 4 deletions

View File

@ -22,10 +22,11 @@ if ( ! defined( 'ABSPATH' ) ) {
* @return string * @return string
*/ */
function wc_lostpassword_url( $default_url = '' ) { 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 ) { if ( false !== $wc_password_reset_url && ! empty( $lost_password_endpoint ) ) {
return wc_get_endpoint_url( 'lost-password', '', $wc_password_reset_url ); return wc_get_endpoint_url( $lost_password_endpoint, '', $wc_password_reset_url );
} else { } else {
return $default_url; return $default_url;
} }

View File

@ -2545,3 +2545,20 @@ function wc_get_rating_html( $rating ) {
function wc_get_price_html_from_text() { function wc_get_price_html_from_text() {
return apply_filters( 'woocommerce_get_price_html_from_text', '<span class="from">' . _x( 'From:', 'min_price', 'woocommerce' ) . ' </span>' ); return apply_filters( 'woocommerce_get_price_html_from_text', '<span class="from">' . _x( 'From:', 'min_price', 'woocommerce' ) . ' </span>' );
} }
/**
* 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 );
}
}

View File

@ -28,7 +28,7 @@ if ( ! defined( 'ABSPATH' ) ) {
printf( printf(
__( 'Hello %1$s (not %1$s? <a href="%2$s">Sign out</a>)', 'woocommerce' ), __( 'Hello %1$s (not %1$s? <a href="%2$s">Sign out</a>)', 'woocommerce' ),
'<strong>' . esc_html( $current_user->display_name ) . '</strong>', '<strong>' . esc_html( $current_user->display_name ) . '</strong>',
esc_url( wc_get_endpoint_url( 'customer-logout', '', wc_get_page_permalink( 'myaccount' ) ) ) esc_url( wc_logout_url( wc_get_page_permalink( 'myaccount' ) ) )
); );
?></p> ?></p>