function pb_custom_post_cases() {
$labels = array(
'name' => _x( 'Recent Cases', 'post type general name' ),
'singular_name' => _x( 'Recent Case', 'post type singular name' ),
'add_new' => _x( 'Add New', 'case' ),
'add_new_item' => __( 'Add New Case' ),
'edit_item' => __( 'Edit Case' ),
'new_item' => __( 'New Case' ),
'all_items' => __( 'All Cases' ),
'view_item' => __( 'View Cases' ),
'search_items' => __( 'Search Cases' ),
'not_found' => __( 'No cases found' ),
'not_found_in_trash' => __( 'No cases found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Recent Cases'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our recent cases specific data',
'public' => true,
'menu_position' => 5,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments', 'custom-fields' ),
'has_archive' => true,
'rewrite' => array('slug' => 'cases', 'with_front'=> false)
);
register_post_type( 'cases', $args );
}
add_action( 'init', 'pb_custom_post_cases' );
/* Taxonomy Recent cases */
function my_taxonomies_cases() {
$labels = array(
'name' => _x( 'Case Categories', 'taxonomy general name' ),
'singular_name' => _x( 'Case Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Case Categories' ),
'all_items' => __( 'All Case Categories' ),
'parent_item' => __( 'Parent Case Category' ),
'parent_item_colon' => __( 'Parent Case Category:' ),
'edit_item' => __( 'Edit Case Category' ),
'update_item' => __( 'Update Case Category' ),
'add_new_item' => __( 'Add New Case Category' ),
'new_item_name' => __( 'New Case Category' ),
'menu_name' => __( 'Case Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'cases_category', 'cases', $args );
}
add_action( 'init', 'my_taxonomies_cases', 0 );
/* Custom Messages - Recent Cases */
function pb_cases_updated_messages( $messages ) {
global $post, $post_ID;
$messages['cases'] = array(
0 => '',
1 => sprintf( __('Recent Case Updated. <a href="%s">View case</a>'), esc_url( get_permalink($post_ID) ) ),
2 => __('Custom field updated.'),
3 => __('Custom field deleted.'),
4 => __('Case updated.'),
5 => isset($_GET['revision']) ? sprintf( __('Case restored to revision from %s'), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
6 => sprintf( __('Recent Case published. <a href="%s">View Case</a>'), esc_url( get_permalink($post_ID) ) ),
7 => __('Product saved.'),
8 => sprintf( __('Case submitted. <a target="_blank" href="%s">Preview case</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
9 => sprintf( __('Case scheduled for: <strong>%1$s</strong>. <a target="_blank" href="%2$s">Preview case</a>'), date_i18n( __( 'M j, Y @ G:i' ), strtotime( $post->post_date ) ), esc_url( get_permalink($post_ID) ) ),
10 => sprintf( __('RecentCase draft updated. <a target="_blank" href="%s">Preview case</a>'), esc_url( add_query_arg( 'preview', 'true', get_permalink($post_ID) ) ) ),
);
return $messages;
}
add_filter( 'post_updated_messages', 'pb_cases_updated_messages' );