class-post-types.php 7.89 KB
Newer Older
1 2 3 4 5
<?php
if ( ! defined( 'WPINC' )  ) { die; } 

class WC_QD_Post_Types {
    
Varun Sridharan's avatar
Varun Sridharan committed
6 7 8 9
   /**
    * Inits Post Types Class
    */
   public static function init(){
10 11 12 13 14
        add_action( 'init', array(__CLASS__,'register_donation_posttype'),5);
        add_action( 'init', array(__CLASS__,'register_donation_category'),5);
        add_action( 'init', array(__CLASS__,'register_donation_tags'    ), 5 );
   }
   
Varun Sridharan's avatar
Varun Sridharan committed
15 16 17
   /**
    * Registers Donation Post Type
    */
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
   public static function register_donation_posttype(){
        $args = array(
            'label'               => __( 'Quick Donation Project', WC_QD_TXT ),
            'description'         => __( 'WooCommerce Donation Projects', WC_QD_TXT ),
            'labels'              => self::get_post_types_labels(),
            'supports'            => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'custom-fields', ),
            'taxonomies'          => array( 'donation_category', 'donation_tags' ),
            'hierarchical'        => false,
            'public'              => true,
            'show_ui'             => true,
            'show_in_menu'        => true,
            //'menu_position'       => 5,
            'menu_icon'           => 'dashicons-smiley',
            'show_in_admin_bar'   => true,
            'show_in_nav_menus'   => true,
            'can_export'          => true,
            'has_archive'         => true,		
            'exclude_from_search' => false,
            'publicly_queryable'  => true,
            'rewrite'             => self::get_posttype_rewrite(),
            'capability_type'     => 'page',
        );
        register_post_type( WC_QD_PT, $args );
   }
Varun Sridharan's avatar
Varun Sridharan committed
42 43 44 45
    
   /**
    * Post Types Labels
    */
46 47 48 49 50
   public static function get_post_types_labels() {
       return array(
            'name'                => _x( 'Quick Donation Projects', 'Post Type General Name', WC_QD_TXT ),
            'singular_name'       => _x( 'Quick Donation Project', 'Post Type Singular Name', WC_QD_TXT ),
            'menu_name'           => __( 'Quick Donation', WC_QD_TXT ),
51
            'name_admin_bar'      => __( 'Donation', WC_QD_TXT ),
52 53 54 55 56 57 58 59 60 61 62 63 64 65
            'parent_item_colon'   => __( 'Parent Project :', WC_QD_TXT ),
            'all_items'           => __( 'All Project', WC_QD_TXT ),
            'add_new_item'        => __( 'Add New Project', WC_QD_TXT ),
            'add_new'             => __( 'Add Project', WC_QD_TXT ),
            'new_item'            => __( 'New Project', WC_QD_TXT ),
            'edit_item'           => __( 'Edit Project', WC_QD_TXT ),
            'update_item'         => __( 'Update ProjectNot found in Trash', WC_QD_TXT ),
            'view_item'           => __( 'View Project', WC_QD_TXT ),
            'search_items'        => __( 'Search Project', WC_QD_TXT ),
            'not_found'           => __( 'No Project Found', WC_QD_TXT ),
            'not_found_in_trash'  => __( 'No Project Found in Trash', WC_QD_TXT ),
        );
   }
                   
Varun Sridharan's avatar
Varun Sridharan committed
66 67 68
   /**
    * Returns Post Type Rewrites
    */
69 70 71 72 73 74 75 76 77 78 79
   public static function get_posttype_rewrite(){
       return array(
            'slug'                => 'donations',
            'with_front'          => true,
            'pages'               => true,
            'feeds'               => true,
        );
   }

    
    
Varun Sridharan's avatar
Varun Sridharan committed
80 81 82
   /**
    * Registers Post Type Category
    */
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126
   public static function register_donation_category(){
   
        $labels = array(
                'name'                       => _x( 'Project Categories', 'Taxonomy General Name', WC_QD_TXT ),
                'singular_name'              => _x( 'Project Category', 'Taxonomy Singular Name', WC_QD_TXT ),
                'menu_name'                  => __( 'Categories', WC_QD_TXT ),
                'all_items'                  => __( 'All Categories', WC_QD_TXT ),
                'parent_item'                => __( 'Parent Category', WC_QD_TXT ),
                'parent_item_colon'          => __( 'Parent Category:', WC_QD_TXT ),
                'new_item_name'              => __( 'New Category Name', WC_QD_TXT ),
                'add_new_item'               => __( 'Add New Project Category', WC_QD_TXT ),
                'edit_item'                  => __( 'Edit Category', WC_QD_TXT ),
                'update_item'                => __( 'Update Category', WC_QD_TXT ),
                'view_item'                  => __( 'View Category', WC_QD_TXT ),
                'separate_items_with_commas' => __( 'Separate Categories with commas', WC_QD_TXT ),
                'add_or_remove_items'        => __( 'Add or remove Categories', WC_QD_TXT ),
                'choose_from_most_used'      => __( 'Choose from the most used', WC_QD_TXT ),
                'popular_items'              => __( 'Popular Categories', WC_QD_TXT ),
                'search_items'               => __( 'Search Categories', WC_QD_TXT ),
                'not_found'                  => __( 'Not Found', WC_QD_TXT ),
        );
        $rewrite = array(
            'slug'                       => 'donation/category',
            'with_front'                 => true,
            'hierarchical'               => false,
        );
        $args = array(
            'labels'                     => $labels,
            'hierarchical'               => true,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
            'rewrite'                    => $rewrite,
            //'update_count_callback'      => 'f',
        );
        
        register_taxonomy( WC_QD_CAT, array( WC_QD_PT ), $args );
       
   }
    
    
    
Varun Sridharan's avatar
Varun Sridharan committed
127 128 129
    /**
     * Registers Donation Tags
     */
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
    public static function register_donation_tags() {

        $labels = array(
            'name'                       => _x( 'Project Tags', 'Taxonomy General Name', WC_QD_TXT ),
            'singular_name'              => _x( 'Project Tag', 'Taxonomy Singular Name', WC_QD_TXT ),
            'menu_name'                  => __( 'Tags', WC_QD_TXT ),
            'all_items'                  => __( 'All Tags', WC_QD_TXT ),
            'parent_item'                => __( 'Parent Tag', WC_QD_TXT ),
            'parent_item_colon'          => __( 'Parent Tag :', WC_QD_TXT ),
            'new_item_name'              => __( 'New Tag Name', WC_QD_TXT ),
            'add_new_item'               => __( 'Add New Tag', WC_QD_TXT ),
            'edit_item'                  => __( 'Edit Tag ', WC_QD_TXT ),
            'update_item'                => __( 'Update Tags', WC_QD_TXT ),
            'view_item'                  => __( 'View Tag', WC_QD_TXT ),
            'separate_items_with_commas' => __( 'Separate Tags with commas', WC_QD_TXT ),
            'add_or_remove_items'        => __( 'Add or remove Tags', WC_QD_TXT ),
            'choose_from_most_used'      => __( 'Choose from the most used', WC_QD_TXT ),
            'popular_items'              => __( 'Popular Tags', WC_QD_TXT ),
            'search_items'               => __( 'Search Tags', WC_QD_TXT ),
            'not_found'                  => __( 'Not Found', WC_QD_TXT ),
        );
        $rewrite = array(
            'slug'                       => 'donation/tags',
            'with_front'                 => true,
            'hierarchical'               => false,
        );
        $args = array(
            'labels'                     => $labels,
            'hierarchical'               => false,
            'public'                     => true,
            'show_ui'                    => true,
            'show_admin_column'          => true,
            'show_in_nav_menus'          => true,
            'show_tagcloud'              => true,
            'rewrite'                    => $rewrite,
           // 'update_count_callback'      => 'f',
        );
        register_taxonomy( 'wcqd_tags', array(WC_QD_PT ), $args );

    }    
}


 
WC_QD_Post_Types::init();
?>