Make logout an endpoint. Still hide it from menus. Fixes #3589

@coenjacobs do we need to do something about this for .14? Will leave
for you next week :)
This commit is contained in:
Mike Jolley 2013-08-23 16:41:02 +01:00
parent 5289193021
commit 64d87cbef7
7 changed files with 21 additions and 23 deletions

View File

@ -51,17 +51,6 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'desc_tip' => true,
),
array(
'title' => __( 'Logout Page', 'woocommerce' ),
'desc' => __( 'Parent: "My Account"', 'woocommerce' ),
'id' => 'woocommerce_logout_page_id',
'type' => 'single_select_page',
'default' => '',
'class' => 'chosen_select_nostd',
'css' => 'min-width:300px;',
'desc_tip' => true,
),
array( 'type' => 'sectionend', 'id' => 'account_page_options' ),
array( 'title' => __( 'My Account Endpoints', 'woocommerce' ), 'type' => 'title', 'desc' => __( 'Endpoints are appended to your page URLs to handle specific actions on the accounts pages. They should be unique.', 'woocommerce' ), 'id' => 'account_endpoint_options' ),
@ -102,6 +91,15 @@ class WC_Settings_Accounts extends WC_Settings_Page {
'desc_tip' => true,
),
array(
'title' => __( 'Logout', 'woocommerce' ),
'desc' => __( 'Endpoint for the triggering logout. You can add this to your menus via a custom link: yoursite.com/?customer-logout=true', 'woocommerce' ),
'id' => 'woocommerce_logout_endpoint',
'type' => 'text',
'default' => 'customer-logout',
'desc_tip' => true,
),
array( 'type' => 'sectionend', 'id' => 'account_endpoint_options' ),
array( 'title' => __( 'Registration Options', 'woocommerce' ), 'type' => 'title', 'id' => 'account_registration_options' ),

View File

@ -223,12 +223,6 @@ class WC_Install {
'name' => _x( 'my-account', 'page_slug', 'woocommerce' ),
'title' => __( 'My Account', 'woocommerce' ),
'content' => '[woocommerce_my_account]'
),
'logout' => array(
'name' => _x( 'logout', 'page_slug', 'woocommerce' ),
'title' => __( 'Logout', 'woocommerce' ),
'content' => '',
'parent' => 'myaccount'
)
) );

View File

@ -28,7 +28,8 @@ class WC_Query {
'view-order',
'edit-account',
'edit-address',
'lost-password'
'lost-password',
'customer-logout'
);
/** @public array Unfiltered product ids (before layered nav etc) */

View File

@ -79,7 +79,7 @@ function woocommerce_customer_edit_account_url() {
}
/**
* woocommerce_nav_menu_items function.
* Hide menu items conditionally
*
* @param array $items
* @param mixed $args
@ -93,9 +93,8 @@ function woocommerce_nav_menu_items( $items, $args ) {
$hide_pages = apply_filters( 'woocommerce_logged_out_hidden_page_ids', $hide_pages );
foreach ( $items as $key => $item ) {
if ( ! empty( $item->object_id ) && ! empty( $item->object ) && in_array( $item->object_id, $hide_pages ) && $item->object == 'page' ) {
if ( strstr( $item->url, 'customer-logout' ) )
unset( $items[ $key ] );
}
}
}
return $items;

View File

@ -124,7 +124,7 @@ function woocommerce_template_redirect() {
}
// Logout
elseif ( is_page( woocommerce_get_page_id( 'logout' ) ) ) {
elseif ( isset( $wp->query_vars['customer-logout'] ) ) {
wp_redirect( str_replace( '&', '&', wp_logout_url( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) ) ) );
exit;
}

View File

@ -16,8 +16,13 @@ wc_print_messages(); ?>
<p class="myaccount_user">
<?php
printf(
__( 'Hello, <strong>%s</strong>. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
__( 'Hello <strong>%s</strong> (not %s? <a href="%s">Sign out</a>).', 'woocommerce' ) . ' ',
$current_user->display_name,
$current_user->display_name,
wp_logout_url()
);
printf( __( 'From your account dashboard you can view your recent orders, manage your shipping and billing addresses and <a href="%s">edit your password and account details</a>.', 'woocommerce' ),
woocommerce_customer_edit_account_url()
);
?>

View File

@ -25,6 +25,7 @@ wp_delete_post( get_option('woocommerce_myaccount_page_id'), true );
wp_delete_post( get_option('woocommerce_edit_address_page_id'), true );
wp_delete_post( get_option('woocommerce_view_order_page_id'), true );
wp_delete_post( get_option('woocommerce_change_password_page_id'), true );
wp_delete_post( get_option('woocommerce_logout_page_id'), true );
// mijireh checkout page
if ( $mijireh_page = get_page_by_path( 'mijireh-secure-checkout' ) )