#33891 closed defect (bug) (invalid)
apply_filters bug
Reported by: | rgout | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 4.4 |
Component: | General | Keywords: | |
Focuses: | Cc: |
Description
Hello,
While I was trying to change some menu items with a filter I encountered a strange bug.
When I try to use the filter: wp_nav_menu_items it is supposed to send $items and $args as denoted by the documentation here: https://developer.wordpress.org/reference/hooks/wp_nav_menu_items/
I also checked the code just to be sure that $args should indeed be sent.
Upon trying to debug the issue I found out that $args is alive and well before applying the filter and also seems to be fine after the filter.
However, when you hook into the filter and use the params like this:
function modify_nav_menu_items($items, $args) { // Do something here return $items; } add_filter('wp_nav_menu_items', 'modify_nav_menu_items');
At this point, $args is NULL
It seems to get lost somewhere in the process of the apply_filter() function.
I am running 4.3.1 since this morning but I have never tested this bug on an older installation.
Hi @rgout, welcome to Trac!
You have to specify the number of arguments in your
add_filter()
call: