[wp-trac] [WordPress Trac] #33891: apply_filters bug

WordPress Trac noreply at wordpress.org
Wed Sep 16 09:47:23 UTC 2015


#33891: apply_filters bug
--------------------------+-----------------------------
 Reporter:  rgout         |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  trunk
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 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.

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


More information about the wp-trac mailing list