Skip to content

Instantly share code, notes, and snippets.

@devonwaldon
Created March 6, 2018 17:44
Show Gist options
  • Save devonwaldon/7117693cb578b15628604335d06c6d51 to your computer and use it in GitHub Desktop.
Save devonwaldon/7117693cb578b15628604335d06c6d51 to your computer and use it in GitHub Desktop.
Generate Taxonomy Labels
/**
* Generates the label array for use in creating WP taxonomies. Takes a singular
* root as well as an optional plural form; if the plural is not supplied, then
* a root+'s' will be used instead.
*/
function generate_taxonomy_labels($singular, $plural=false) {
if ( !$plural ) {
$plural = $singular . 's';
}
return array(
'name' => $plural,
'singular_name' => $singular,
'menu_name' => $singular,
'all_items' => 'All '.$plural,
'edit_item' => 'Edit '.$singular,
'view_item' => 'View '.$plural,
'update_item' => 'Update '.$singular,
'add_new_item' => 'Add New '.$singular,
'new_item_name' => 'New '.$singular.' Name',
'parent_item' => 'Parent '.$singular,
'parent_item_colon' => 'Parent '.$singular.':',
'search_items' => 'Search '.$plural,
'popular_items' => 'Popular '.$plural,
'separate_items_with_commas' => 'Separate '.strtolower($plural).' with commas',
'add_or_remove_items' => 'Add or remove '.strtolower($plural),
'choose_from_most_used' => 'Choose from the most used '.strtolower($plural),
'not_found' => 'No '.strtolower($plural).' found'
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment