Ben,
Have a look at this code, I’ve retooled the function so that it should now work for both arrays and strings, seems to work for me but can you please run your eyey over it?
/**
* This is our way into manipulating registered taxonomies
* It’s fired at the end of the register_taxonomy function
*
* @param String $taxonomy – The name of the taxonomy being registered
* @param String $object – The object type the taxonomy is for; We only care if this is “user”
* @param Array $args – The user supplied + default arguments for registering the taxonomy
*/
public function registered_taxonomy($taxonomy, $object, $args) {
global $wp_taxonomies;
// Only modify user taxonomies, everything else can stay as is
if ((is_string($object) and ($object == ‘user’)) or (is_array($object) and in_array(“user”, $object)) ){
// We’re given an array, but expected to work with an object later on
$args = (object) $args;
// Register any hooks/filters that rely on knowing the taxonomy now
add_filter(“manage_edit-{$taxonomy}_columns”, array($this, ‘set_user_column’));
add_action(“manage_{$taxonomy}_custom_column”, array($this, ‘set_user_column_values’), 10, 3);
// Set the callback to update the count if not already set
if(empty($args->update_count_callback)) {
$args->update_count_callback = array($this, ‘update_count’);
}
// We’re finished, make sure we save out changes
$wp_taxonomies[$taxonomy] = $args;
self::$taxonomies[$taxonomy] = $args;
}
}
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button. Thanks.]
What do you think?
pete
-
This reply was modified 7 years, 11 months ago by
bdbrown.