[wp-trac] [WordPress Trac] #20275: wp_update_nav_menu hook is not fired when nav menu item is auto-added
WordPress Trac
wp-trac at lists.automattic.com
Wed Mar 21 19:30:59 UTC 2012
#20275: wp_update_nav_menu hook is not fired when nav menu item is auto-added
--------------------------+-----------------------------
Reporter: inderpreet99 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Menus | Version: 3.3.1
Severity: normal | Keywords: has-patch
--------------------------+-----------------------------
WP calls the action hook 'wp_update_nav_menu' when a navigation menu is
updated. For example, go to Site Design -> Custom Menus -> Click the "Save
Menu" button on a menu.
Next to the Menu title, the Custom Menus provide the user to
"Automatically add new top-level pages". When this option is checked, and
a new top-level page is created, the 'wp_update_nav_menu' hook is not
fired. So the attached nav-menu-hooks.diff patch fixes that.
I would also suggest that we do not use the same hook 'wp_update_nav_menu'
twice (as it is currently being done) with different amount of arguments,
because this causes a PHP Warning
{{{
PHP Warning: Missing argument 2 for x_save_footer() in
/var/www/branches/x.trunk/wp-content/themes/x/functions.php on line 815,
referer: http://x.com/x/wp-admin/nav-menus.php
}}}
for code:
{{{
add_action('wp_update_nav_menu', 'x_save_footer', 10, 2);
}}}
So, the hook call at nav-menu.php:255 has 2 parameters and the call at
nav-menus.php:383 has 1 parameter.
As a fix, the action hook in nav-menu.php should be named something else,
like 'wp_update_nav_menu_object' (because it is updating the object), as
done in the attached nav-menu-hooks.diff patch. This will also prevent the
same hook from being fired twice when updating the nav menus.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/20275>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list