Ah, I think I finally understand where you're going with this, sorry for my confusion.
Actually, the return value of the 'post_class' callback
custom_taxonomy_post_class() is not appropriate for direct concatenation to
$output because it returns an array of class strings while
start_el() of the walker class requires a single string, not an array. Fortunately, converting an array to a single string is simple with
If you want all of the post classes listed, not just the taxonomies, you could do this (the title part is omitted, add it back if need be):
$output .= $indent . '<li id="item_'.$page->ID.'"><span>'.join( " ", get_post_class( "", $page->ID )).'</span>';
If you just want the taxonomy classes as returned by the filter callback, without the other classes added by other portions of the code, replace the call to
custom_taxonomy_post_class(array(), "", $page->ID) (still as a parameter for the
join() function )
That will cover basic functionality, but there are improvements that would be a good idea to implement, depending on if this plugin is authored by you or is authored by others and will occasionally be updated, among other variables.
If you call
custom_taxonomy_post_class() directly from a plugin, there is a potential issue because the function might not be available since it is part of a theme. If the plugin is yours, it's best to move the declaration to the plugin. If not, you need to do the
if ( ! function_exists()) logic to avoid errors if the theme is switched. In your case using ternary operators would be slightly tidier than the
if ( ! function_exists()) syntax. The entire
join() function could be replaced with this:
!function_exists('custom_taxonomy_post_class')?join(" ", custom_taxonomy_post_class(array(), "", $page->ID)):''
If this plugin is subject to updates, you shouldn't really be altering it at all. Instead create your own site specific plugin that extends the Post_Types_Walker class and overrides the
start_el() function with your variation.
Your site will work without these improvements, but the improvements make your installation more robust, you will not lose modifications when plugins are updated and your site will not crash if the theme is switched.
I'm glad you are enjoying this. It gets even better once you develop an adequate knowledge base. Then you have the ability to have your site do practically anything you desire, which is very empowering!