diff --git a/includes/admin/settings/class-wc-settings-accounts.php b/includes/admin/settings/class-wc-settings-accounts.php index de882e608c7..6ad96f13473 100644 --- a/includes/admin/settings/class-wc-settings-accounts.php +++ b/includes/admin/settings/class-wc-settings-accounts.php @@ -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' ), diff --git a/includes/class-wc-install.php b/includes/class-wc-install.php index 09327a3bb7f..ed63d28b026 100644 --- a/includes/class-wc-install.php +++ b/includes/class-wc-install.php @@ -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' ) ) ); diff --git a/includes/class-wc-query.php b/includes/class-wc-query.php index 8b434a8f346..a841d6de583 100644 --- a/includes/class-wc-query.php +++ b/includes/class-wc-query.php @@ -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) */ diff --git a/includes/wc-page-functions.php b/includes/wc-page-functions.php index 06d84a2558d..3bb01991c3d 100644 --- a/includes/wc-page-functions.php +++ b/includes/wc-page-functions.php @@ -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; diff --git a/includes/wc-template-functions.php b/includes/wc-template-functions.php index 5299782a2f9..6c69eb2ccf5 100644 --- a/includes/wc-template-functions.php +++ b/includes/wc-template-functions.php @@ -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; } diff --git a/templates/myaccount/my-account.php b/templates/myaccount/my-account.php index 9270e056d3e..05b0584c700 100644 --- a/templates/myaccount/my-account.php +++ b/templates/myaccount/my-account.php @@ -16,8 +16,13 @@ wc_print_messages(); ?>

%s. From your account dashboard you can view your recent orders, manage your shipping and billing addresses and edit your password and account details.', 'woocommerce' ), + __( 'Hello %s (not %s? Sign out).', '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 edit your password and account details.', 'woocommerce' ), woocommerce_customer_edit_account_url() ); ?> diff --git a/uninstall.php b/uninstall.php index 3d91604b9e6..2b89fa1d703 100644 --- a/uninstall.php +++ b/uninstall.php @@ -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' ) )