/**
* Hide menu items conditionally.
*
* @param array $items
* @return array
*/
function wc_nav_menu_items( $items ) {
if ( ! is_user_logged_in() ) {
$customer_logout = get_option( 'woocommerce_logout_endpoint', 'customer-logout' );
if ( ! empty( $customer_logout ) ) {
foreach ( $items as $key => $item ) {
if ( strstr( $item->url, $customer_logout ) ) {
unset( $items[ $key ] );
}
}
}
}
return $items;
}
add_filter( 'wp_nav_menu_objects', 'wc_nav_menu_items', 10 );