Joining all class names:
Please try:
$item_output .= sprintf( '<span class="%s"></span>', join( ' ', $item->classes ) );
instead of
$item_output .= '<span class="'. $item->classes .'"></span>';
to join the array elements of $item->classes
into a string.
If you add for example aaa bbb ccc
to an item’s class text field, it will show up like this:
Array
(
[0] => aaa
[1] => bbb
[2] => ccc
[3] => menu-item
[4] => menu-item-type-post_type
[5] => menu-item-object-post
)
Filter out class names:
If you want to eliminate all class names containing item
you can use:
$item_output .= sprintf( '<span class="%s"></span>',
join( ' ', array_filter( $item->classes, 'custom_filter' ) )
);
where the array filter callback is
/**
* Only keep items not containing the string 'item'
*
* @param string $var
* @return string $var | '' Empty if contains 'item'
*/
function custom_filter( $var )
{
return ( FALSE === strpos( $var, 'item' ) ) ? $var : '';
}
ps: I think we are save with eliminating class names containg item
, else you can modify it to your needs