In the first function below, inside the foreach, I'm calling out to the 2nd function in order to test for the occurence of matching category ids that I want to remove from the category listing.
However, the way I'm doing it in the 2nd function seems to me to be pretty crude, for lack of a better term. How could I improve this lookup?
function admin_trim_category_description( $terms, $taxonomies )
{
if( 'category' != $taxonomies[0] )return $terms;
foreach( $terms as $key=>$term )
{
$terms[$key]->description = strip_tags(substr( $term->description, 0, 75 ))."...";
if(ce4_get_utility_cats($terms[$key]->term_id))
{
unset($terms[$key]);
}
}
return $terms;
}
function ce4_get_utility_cats($cat_id)
{
if($cat_id == get_cat_ID('category1') OR $cat_id == get_cat_ID('hidden') OR $cat_id == get_cat_ID('category2') OR $cat_id == get_cat_ID('category3'))
{
return true;
}
else
{
return false;
}
}
EDIT: The above functions are called in the following manner...
add_action( 'admin_head-edit-tags.php', 'admin_edit_tags' );
function admin_edit_tags(){
add_filter( 'get_terms', 'admin_trim_category_description', 10, 2 );
}
admin_trim_category_description()from? What's your context and use-case? Also, what does$termscontain? – MikeSchinkel♦ Jan 25 '11 at 5:20