Support » Plugin: Admin Toolbar Menus » Trying to get property of non-object

  • Resolved Jon Brown

    (@jb510)


    It would be nice to cleanup the PHP notices for “Trying to get property of non-object”.

    2017 01 11 at 5 33 PM

    Mostly harmless, just log spam…

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Benbodhi

    (@benbodhi)

    Hi @jb510

    Firstly, thanks for using my plugin!
    I am looking at fixing that up for a future version 🙂

    Ben – see https://gist.github.com/jb510/0f31cdf0c667e983c94cfc290a6fc23b

    wp_get_nav_menu_object() will return “false” ( a non-object ) when it’s empty… you just need to check that before continuing, more performant that way too 😀

    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
    if (false != $menu) {
    	$menu_items = wp_get_nav_menu_items( $menu->term_id );
    
    	foreach( (array) $menu_items as $key => $menu_item ) {
    [snip]
    		} // end foreach
    	} // end if
    } // end menu1 - site-name menu
    Plugin Author Benbodhi

    (@benbodhi)

    Thanks for your effort!
    I’ll test and update the plugin 🙂

    Plugin Author Benbodhi

    (@benbodhi)

    Hi @jb510,

    I have included the conditionals you provided in an update I just released (1.0.4).

    Thanks for your help and patience!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Trying to get property of non-object’ is closed to new replies.