Inventory_Presser_Plugin::create_post_type()

create_POST_TYPE


Description Description

Registers the inventory_vehicle post type that holds vehicles.


Top ↑

Return Return

(void)


Top ↑

Source Source

File: inventory-presser.php

	static function create_post_type()
	{
		//creates a custom post type that will be used by this plugin
		register_post_type(
			INVP::POST_TYPE,
			apply_filters(
				'invp_post_type_args',
				array (
					'description'  => __( 'Vehicles for sale', 'inventory-presser' ),
					/**
					 * Check if the theme (or the parent theme) has a CPT
					 * archive template.  If not, we will assume that the
					 * inventory is going to be displayed via shortcode, and
					 * we won't be using the theme archive
					 */
					'has_archive'  => true,
					'hierarchical' => false,
					'labels'       => array (
						'name'                  => _x( 'Vehicles', 'Post type general name', 'inventory-presser' ),
						'singular_name'         => _x( 'Vehicle', 'Post type singular name', 'inventory-presser' ),
						'menu_name'             => _x( 'Vehicles', 'Admin Menu text', 'inventory-presser' ),
						'name_admin_bar'        => _x( 'Vehicle', 'Add New on Toolbar', 'inventory-presser' ),
						'add_new'               => __( 'Add New', 'inventory-presser' ),
						'add_new_item'          => __( 'Add New Vehicle', 'inventory-presser' ),
						'new_item'              => __( 'New Vehicle', 'inventory-presser' ),
						'edit_item'             => __( 'Edit Vehicle', 'inventory-presser' ),
						'view_item'             => __( 'View Vehicle', 'inventory-presser' ),
						'all_items'             => __( 'All Vehicles', 'inventory-presser' ),
						'search_items'          => __( 'Search Vehicles', 'inventory-presser' ),
						'parent_item_colon'     => __( 'Parent Vehicles:', 'inventory-presser' ),
						'not_found'             => __( 'No vehicles found.', 'inventory-presser' ),
						'not_found_in_trash'    => __( 'No vehicles found in Trash.', 'inventory-presser' ),
						'archives'              => _x( 'Inventory', 'The post type archive label used in nav menus. Default “Post Archives”. Added in 4.4', 'inventory-presser' ),
						'insert_into_item'      => _x( 'Insert into vehicle description', 'Overrides the “Insert into post”/”Insert into page” phrase (used when inserting media into a post). Added in 4.4', 'inventory-presser' ),
						'uploaded_to_this_item' => _x( 'Uploaded to this vehicle', 'Overrides the “Uploaded to this post”/”Uploaded to this page” phrase (used when viewing media attached to a post). Added in 4.4', 'inventory-presser' ),
						'filter_items_list'     => _x( 'Filter vehicles list', 'Screen reader text for the filter links heading on the post type listing screen. Default “Filter posts list”/”Filter pages list”. Added in 4.4', 'inventory-presser' ),
						'items_list_navigation' => _x( 'Vehicles list navigation', 'Screen reader text for the pagination heading on the post type listing screen. Default “Posts list navigation”/”Pages list navigation”. Added in 4.4', 'inventory-presser' ),
						'items_list'            => _x( 'Vehicles list', 'Screen reader text for the items list heading on the post type listing screen. Default “Posts list”/”Pages list”. Added in 4.4', 'inventory-presser' ),
					),
					'menu_icon'    => 'dashicons-admin-network',
					'menu_position'=> 5, //below Posts
					'public'       => true,
					'rest_base'    => 'inventory',
					'rewrite'      => array (
						'slug' => 'inventory',
						'with_front'   => false,
					),
					'show_in_rest' => true,
					'supports'     => array (
						'custom-fields',
						'editor',
						'title',
						'thumbnail',
					),
					'taxonomies'   => Inventory_Presser_Taxonomies::query_vars_array(),
				)
			)
		);
	}