wc_nav_menu_items( array $items )
Hide menu items conditionally.
Description Description
Parameters Parameters
- $items
-
(Required) Navigation items.
Return Return
(array)
Source Source
File: includes/wc-page-functions.php
function wc_nav_menu_items( $items ) {
if ( ! is_user_logged_in() ) {
$customer_logout = get_option( 'woocommerce_logout_endpoint', 'customer-logout' );
if ( ! empty( $customer_logout ) && ! empty( $items ) && is_array( $items ) ) {
foreach ( $items as $key => $item ) {
if ( empty( $item->url ) ) {
continue;
}
$path = wp_parse_url( $item->url, PHP_URL_PATH );
$query = wp_parse_url( $item->url, PHP_URL_QUERY );
if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) {
unset( $items[ $key ] );
}
}
}
}
return $items;
}