Merge pull request #17015 from woocommerce/fix/17014

Check `$item->url` is set.
This commit is contained in:
Claudiu Lodromanean 2017-10-02 09:10:16 -07:00 committed by GitHub
commit 590838eb82
1 changed files with 6 additions and 2 deletions

View File

@ -111,7 +111,7 @@ function wc_get_endpoint_url( $endpoint, $value = '', $permalink = '' ) {
/**
* Hide menu items conditionally.
*
* @param array $items
* @param array $items Navigation items.
* @return array
*/
function wc_nav_menu_items( $items ) {
@ -120,8 +120,12 @@ function wc_nav_menu_items( $items ) {
if ( ! empty( $customer_logout ) ) {
foreach ( $items as $key => $item ) {
$path = parse_url( $item->url, PHP_URL_PATH );
if ( empty( $item->url ) ) {
continue;
}
$path = parse_url( $item->url, PHP_URL_PATH );
$query = parse_url( $item->url, PHP_URL_QUERY );
if ( strstr( $path, $customer_logout ) || strstr( $query, $customer_logout ) ) {
unset( $items[ $key ] );
}