+if( class_exists( 'JCK_Helper_Post_Types' ) )
+ * Helper Class for dealing with Post Types
+class JCK_Helper_Post_Types {
+ * Array of all post types registered by this plugin
+ * @var array $registered
+ public $registered = array();
+ * @param array $options
+ public function add( $options ) {
+ "plural" => "", // !required
+ "singular" => "", // !required
+ "key" => false, // !required
+ "rewrite_slug" => false, // !recommended if has frontend visibility
+ "rewrite_with_front" => false,
+ "rewrite_feeds" => true,
+ "rewrite_pages" => true,
+ "menu_icon" => "dashicons-admin-post",
+ 'hierarchical' => false,
+ 'supports' => array( 'title' ),
+ 'show_in_menu' => true,
+ 'show_in_nav_menus' => true,
+ 'publicly_queryable' => true,
+ 'exclude_from_search' => false,
+ 'capability_type' => 'post'
+ $options = wp_parse_args( $options, $defaults );
+ if( $options['key'] ) {
+ 'name' => $options['plural'],
+ 'singular_name' => $options['singular'],
+ 'add_new' => _x( 'Add New', 'jck' ),
+ 'add_new_item' => _x( sprintf('Add New %s', $options['singular']), 'jck' ),
+ 'edit_item' => _x( sprintf('Edit %s', $options['singular']), 'jck' ),
+ 'new_item' => _x( sprintf('New %s', $options['singular']), 'jck' ),
+ 'view_item' => _x( sprintf('View %s', $options['singular']), 'jck' ),
+ 'search_items' => _x( sprintf('Search %s', $options['plural']), 'jck' ),
+ 'not_found' => _x( sprintf('No %s found', strtolower($options['plural'])), 'jck' ),
+ 'not_found_in_trash' => _x( sprintf('No %s found in Trash', strtolower($options['plural'])), 'jck' ),
+ 'parent_item_colon' => _x( sprintf('Parent %s:', $options['singular']), 'jck' ),
+ 'menu_name' => $options['plural']
+ 'hierarchical' => $options['hierarchical'],
+ 'supports' => $options['supports'],
+ 'public' => $options['public'],
+ 'show_ui' => $options['show_ui'],
+ 'show_in_menu' => $options['show_in_menu'],
+ 'menu_icon' => $options['menu_icon'],
+ 'show_in_nav_menus' => $options['show_in_nav_menus'],
+ 'publicly_queryable' => $options['publicly_queryable'],
+ 'exclude_from_search' => $options['exclude_from_search'],
+ 'has_archive' => $options['has_archive'],
+ 'query_var' => $options['query_var'],
+ 'can_export' => $options['can_export'],
+ 'capability_type' => $options['capability_type'],
+ if( $options['rewrite_slug'] ) {
+ $args['rewrite'] = array(
+ "slug" => $options['rewrite_slug'],
+ "with_front" => $options['rewrite_with_front'],
+ "feeds" => $options['rewrite_feeds'],
+ "pages" => $options['rewrite_pages']
+ $post_type = register_post_type( $options['key'], $args );
+ $this->registered[] = $post_type;