Last active
August 29, 2015 13:59
-
-
Save grok/10508187 to your computer and use it in GitHub Desktop.
Encountering what appears to be a core bug with the core WordPress Walker_Nav_Menu being extended within PHP 5.4.24 WordPress V3.8.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class My_Walker extends Walker_Nav_Menu { | |
} | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
echo '##### COMMENSE MY WALKER #####' . "\n"; | |
wp_nav_menu( | |
array( | |
'walker' => new My_Walker() | |
) | |
); | |
echo '##### COMPLETE MY WALKER #####'; | |
echo "\n\n"; | |
echo '##### COMMENSE CORE WALKER #####' . "\n"; | |
wp_nav_menu(); | |
echo '##### COMPLETE CORE WALKER #####'; | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php get_header(); ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##### COMMENSE MY WALKER ##### | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>148</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>151</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>151</b><br /> | |
<br /> | |
<b>Notice</b>: Trying to get property of non-object in <b>/wp-includes/nav-menu-template.php</b> on line <b>153</b><br /> | |
<div class="menu"><ul><li id="menu-item-2" class="menu-item-2"><a></a></li></ul></div> | |
##### COMPLETE MY WALKER ##### | |
##### COMMENSE CORE WALKER ##### | |
<div class="menu"><ul><li class="page_item page-item-2"><a href="/?page_id=2">Sample Page</a></li></ul></div> | |
##### COMPLETE CORE WALKER ##### |
"This is actually only a problem up until you create a menu in the back end, give it an item, and assign it to the menu location."
What happens if you...
wp_nav_menu(array('walker' => new My_Walker(), 'fallback_cb' => false));
@JoshKoberstein are you speaking towards AFTER you have created a menu entry and have >= 1 menu item in it?
This problem only manifests if you write the code and no menu exists in the system as far as I can tell.
P.S. I'm including @ notation with your name so that when they get that working it should display properly :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Current Solutions
Until ticket #24587 is resolved, this can be fixed by
redeclaring the functions from core in my extended class and just changing to arrays or typecasting.If you go to nav-menu-template.php and just copy out the code for Walker_Nav_Menu into your walker and change $args->whatever to $args['whatever'] -- this should fix it.I know this is C&P and a shit way to go about it - but it's a known bug and all we can do at the moment.This is actually only a problem up until you create a menu in the back end, give it an item, and assign it to the menu location.