diff --git a/woocommerce-functions.php b/woocommerce-functions.php index 7b22da16957..4452dd2f6b5 100644 --- a/woocommerce-functions.php +++ b/woocommerce-functions.php @@ -171,9 +171,15 @@ function woocommerce_list_pages( $pages ){ * @return string */ function woocommerce_nav_menu_items( $items, $args ) { - if ( get_option('woocommerce_menu_logout_link')=='yes' && strstr($items, get_permalink(woocommerce_get_page_id('myaccount'))) && is_user_logged_in() ) - $items .= '
  • '.__( 'Logout', 'woocommerce' ).'
  • '; + if ( is_user_logged_in() && get_option('woocommerce_menu_logout_link') == 'yes' ) { + $my_account_page_id = woocommerce_get_page_id( 'myaccount' ); + $permalink = get_permalink( $my_account_page_id ); + + if ( $my_account_page_id && $permalink && $items && strstr( $items, $permalink ) ) { + $items .= '
  • ' . __( 'Logout', 'woocommerce' ) . '
  • '; + } + } return $items; }