String Replace Caching & Chance of Collisions

You would probably get at least equally good performance by simply adding the classes with a filter, and it is certainly neater and closer to the way the WordPress is meant to be modified: function add_classes_wpse_190966($classes) { if (in_array(‘current-menu-parent’,$classes)) { $classes[] = ‘active’; } return $classes; } add_filter(‘nav_menu_css_class’,’add_classes_wpse_190966′); Or, with an array of values: function …

Read more