[wp-trac] [WordPress Trac] #37026: PHP Notice: Trying to get property of non-object in wp-admin\nav-menus.php on line 836

WordPress Trac noreply at wordpress.org
Sat Jun 4 07:56:38 UTC 2016


#37026: PHP Notice:  Trying to get property of non-object in wp-admin\nav-menus.php
on line 836
--------------------------+-----------------------------
 Reporter:  skylarkcob    |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Menus         |    Version:  4.5.2
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 I'm using WordPress 4.5.2 and get this PHP Notice:

 {{{
 PHP Notice:  Trying to get property of non-object in wp-admin\nav-
 menus.php on line 836
 }}}

 When I export and import database for using on localhost (one database
 content for two sites), two sites using different theme and have different
 menu location.

 My first site has menu location Mobile, when I use this database on new
 site with Twenty Sixteen theme, it doesn't have this location, so the
 notice message appeared.

 The menu location on Menu Settings section looks like this:

 {{{

 Mobile (Currently set to: )
 }}}


 Plese add a conditional function to check if is a nav menu object before
 get its name.

 {{{
 wp_get_nav_menu_object( $menu_locations[ $location ] )->name
 }}}

 It's not an error, but I don't want to see this notice message when coding
 theme. Thank you.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/37026>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list