Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
<?php
/*
Plugin Name: Add "Animal" custom taxonomy
Description: Add the new custom taxonomy "animal", don't forget to flush your permalinks!
Author: Julio Potier
Author URI: http://boiteaweb.fr
*/
/* !---------------------------------------------------------------------------- */
/* ! REGISTER TAXONOMIES */
/* Generated with http://screenfeed.fr/tools/i18n-pour-taxo/ */
/* ----------------------------------------------------------------------------- */
add_action( 'init', 'register_animal_taxonomy', 0 );
function register_animal_taxonomy() {
// !Load i18n
load_plugin_textdomain( 'my_plugin', false, basename( dirname( __FILE__ ) ) . '/languages/' );
// !Animal Taxonomy
$labels = array(
'name' => _x( 'Animals', 'taxonomy general name', 'my_plugin' ),
'singular_name' => _x( 'Animal', 'taxonomy singular name', 'my_plugin' ),
'menu_name' => _x( 'Animals', 'taxonomy general name', 'my_plugin' ),
'search_items' => __( 'Search Animals', 'my_plugin' ),
'popular_items' => __( 'Popular Animals', 'my_plugin' ),
'all_items' => __( 'All Animals', 'my_plugin' ),
'parent_item' => __( 'Parent Animal', 'my_plugin' ),
'parent_item_colon' => __( 'Parent Animal:', 'my_plugin' ),
'edit_item' => __( 'Edit Animal', 'my_plugin' ),
'view_item' => __( 'View Animal', 'my_plugin' ),
'update_item' => __( 'Update Animal', 'my_plugin' ),
'add_new_item' => __( 'Add New Animal', 'my_plugin' ),
'new_item_name' => __( 'New Animal Name', 'my_plugin' ),
'separate_items_with_commas' => __( 'Separate animals with commas', 'my_plugin' ),
'add_or_remove_items' => __( 'Add or remove animals', 'my_plugin' ),
'choose_from_most_used' => __( 'Choose from the most used animals', 'my_plugin' ),
'not_found' => __( 'No animals found.', 'my_plugin' ),
);
$rewrite = array(
'slug' => 'animal',
'with_front' => true,
'hierarchical' => false,
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_admin_column' => true,
'show_in_nav_menus' => true,
'show_tagcloud' => true,
'rewrite' => $rewrite,
);
register_taxonomy( 'animal', array( 'post' ), $args );
}
add_filter( 'term_updated_messages', 'animal_taxonomy_messages' );
function animal_taxonomy_messages( $messages ) {
$messages['animal'] = array(
0 => '', // Unused. Messages start at index 1.
1 => __( 'Animal added.', 'my_plugin' ),
2 => __( 'Animal deleted.', 'my_plugin' ),
3 => __( 'Animal updated.', 'my_plugin' ),
4 => __( 'Animal not added.', 'my_plugin' ),
5 => __( 'Animal not updated.', 'my_plugin' ),
6 => __( 'Animals deleted.', 'my_plugin' ),
);
return $messages;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment