What does (10, 2) mean when used with add_filter

Please tell my what is 10, 2 in below mention code:

add_filter('nav_menu_css_class', 'add_active_class', 10, 2 );

function add_active_class($classes, $item) {

if($item->menu_item_parent == 0 && in_array('current-menu-item', $classes)) {

    $classes[] = "active";

}

return $classes;

}

Related posts

1 comment

  1. Have a look at the codex page for add_filter.

    The 10 is the $priority parameter (10 is default) which defines when your function will run in regards to the other functions which are attached to the nav_menu_css_class filter. 2 is the $accepted_args parameter which tells wordpress how many parameters the function you want to add will take. In this case your add_active_class function can take 2 parameters ($classes and $item).

Comments are closed.