T5 Test Types
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php # -*- coding: utf-8 -*- | |
/** | |
* Plugin Name: T5 Test Types | |
* Description: Adds some custom post types and taxonomies for testing purposes. | |
* Plugin URI: | |
* Version: 2013.04.12 | |
* Author: Thomas Scholz | |
* Author URI: http://toscho.de | |
* Licence: MIT | |
* License URI: http://opensource.org/licenses/MIT | |
*/ | |
$T5_Test_Types = new T5_Test_Types; | |
add_action( 'init', array( $T5_Test_Types, 'plugin_setup' ) ); | |
class T5_Test_Types | |
{ | |
public function plugin_setup() | |
{ | |
$post_types = array ( 'project', 'organization', 'place' ); | |
$taxonomies = array ( 'topic', 'type', 'collection' ); | |
foreach ( $post_types as $post_type ) | |
register_post_type( $post_type, $this->cpt_args( $post_type ) ); | |
foreach ( $taxonomies as $taxonomy ) | |
register_taxonomy( $taxonomy, $post_types, $this->tax_args( $taxonomy ) ); | |
} | |
protected function cpt_args( $post_type ) | |
{ | |
$u = ucfirst( $post_type ); | |
$l = mb_strtolower( $post_type ); | |
return array ( | |
'can_export' => TRUE, | |
//'capabilities' => $this->get_capabilities(), | |
//'capability_type' => 'post', | |
//'capability_type' => 'session', | |
'description' => '', | |
'exclude_from_search' => FALSE, | |
'has_archive' => TRUE, | |
'hierarchical' => FALSE, | |
'labels' => array ( | |
'add_new' => 'Add new', | |
'add_new_item' => "Add new $l", | |
'all_items' => "All {$l}s", | |
'edit_item' => "Edit $l", | |
'name' => $u . 's', | |
'name_admin_bar' => $u, | |
'new_item' => "New $l", | |
'not_found' => "No {$l}s found.", | |
'not_found_in_trash' => "No {$l}s in trash.", | |
'parent_item_colon' => "Parent $l:", | |
'search_items' => "Search {$l}s", | |
'singular_name' => $u, | |
'view_item' => "View $l" | |
), | |
//'map_meta_cap' => TRUE, | |
'menu_icon' => null, | |
'menu_position' => null, | |
'permalink_epmask' => EP_PERMALINK, | |
'public' => TRUE, | |
'publicly_queryable' => TRUE, | |
'query_var' => $l, | |
// Use a translated slug in pretty permalinks | |
'rewrite' => array ( | |
'slug' => $l, | |
'with_front' => FALSE | |
), | |
'show_in_nav_menus' => TRUE, | |
'show_in_menu' => TRUE, | |
'show_in_admin_bar' => TRUE, | |
'show_ui' => TRUE, | |
/* 'title', 'editor', 'comments', 'revisions', 'trackbacks', 'author', | |
* 'excerpt', 'page-attributes', 'thumbnail' or 'custom-fields' */ | |
'supports' => array( | |
'author', | |
'comments', | |
'editor', | |
'excerpt', | |
'revisions', | |
'thumbnail', | |
'title', | |
), | |
); | |
} | |
protected function tax_args( $taxonomy ) | |
{ | |
$u = ucfirst( $taxonomy ); | |
$l = mb_strtolower( $taxonomy ); | |
return array( | |
'hierarchical' => TRUE, | |
'public' => TRUE, | |
'query_var' => $taxonomy, | |
'rewrite' => TRUE, | |
'labels' => array( | |
'name' => $u . 's', | |
'singular_name' => $u, | |
'search_items' => "Search {$l}s", | |
'popular_items' => "Popular {$l}s", | |
'all_items' => "All {$l}s", | |
'parent_item' => "Parent {$l}", | |
'parent_item_colon' => "Parent {$l}:", | |
'edit_item' => "Edit $l", | |
'view_item' => "View $l", | |
'update_item' => "Update $l", | |
'add_new_item' => "Add new $l", | |
'new_item_name' => "New $l name", | |
'separate_items_with_commas' => "Separate {$l}s with commas", | |
'add_or_remove_items' => "Add or remove {$l}s", | |
'choose_from_most_used' => "Choose from the most used {$l}s", | |
), | |
'show_admin_column' => TRUE, | |
'show_in_nav_menus' => TRUE, | |
'show_tagcloud' => FALSE, | |
'show_ui' => TRUE, | |
'update_count_callback' => '', | |
); | |
} | |
} |
I'd recommend ucwords() instead of ucfirst(), to handle multi-word post types
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Why go against the grain here and lowercase "edit_item" etc? Core shows "Edit Post", not "Edit post".