morganestes
7/14/2014 - 5:12 PM

gt-offers-cpt.php

<?php
/*
Plugin Name: Golf Tailor Offers
Plugin URI: http://code.golftailor.com/
Description: Create an Offers Custom Post Type for use in sales pages.
Version: 0.1.0
Author: morganestes
Author URI: http://www.golftailor.com
Text Domain: golftailor
*/

class GT_CPT {

	function __construct() {
		add_action( 'init', array( $this, 'register_custom_post_type' ) );
	}

	/**
	 * Add the Offers custom post type for sales pages.
	 */
	function register_custom_post_type() {

		$labels = array(
			'name'               => _x( 'Offers', 'Post Type General Name', 'golftailor' ),
			'singular_name'      => _x( 'Offer', 'Post Type Singular Name', 'golftailor' ),
			'menu_name'          => __( 'Offers', 'golftailor' ),
			'parent_item_colon'  => __( 'Parent Offer:', 'golftailor' ),
			'all_items'          => __( 'All Offers', 'golftailor' ),
			'view_item'          => __( 'View Offer', 'golftailor' ),
			'add_new_item'       => __( 'Add New Offer', 'golftailor' ),
			'add_new'            => __( 'Add New', 'golftailor' ),
			'edit_item'          => __( 'Edit Offer', 'golftailor' ),
			'update_item'        => __( 'Update Offer', 'golftailor' ),
			'search_items'       => __( 'Search Offers', 'golftailor' ),
			'not_found'          => __( 'Not found', 'golftailor' ),
			'not_found_in_trash' => __( 'Not found in Trash', 'golftailor' ),
		);

		$args = array(
			'label'               => __( 'offers', 'golftailor' ),
			'description'         => __( 'Sales offers', 'golftailor' ),
			'labels'              => $labels,
			'supports'            => array(
				'title',
				'editor',
				'thumbnail',
				'revisions',
				'custom-fields',
				'page-attributes',
			),
			'taxonomies'          => array( 'category' ),
			'hierarchical'        => true,
			'public'              => true,
			'show_ui'             => true,
			'show_in_menu'        => true,
			'show_in_nav_menus'   => false,
			'show_in_admin_bar'   => true,
			'menu_position'       => 20,
			'menu_icon'           => 'dashicons-cart',
			'can_export'          => true,
			'has_archive'         => false,
			'exclude_from_search' => true,
			'publicly_queryable'  => true,
			'capability_type'     => 'page',
		);
		register_post_type( 'offers', $args );
	}

}

$gt_cpt = new GT_CPT;