RtThemesSupport

custom_post.php added revisions to post type

May 25th, 2013
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 9.10 KB | None | 0 0
  1. <?php
  2. #-----------------------------------------
  3. #   RT-Theme custom_posts.php
  4. #   version: 1.0
  5. #-----------------------------------------
  6.  
  7. #
  8. #   Custom Post Types
  9. #
  10.  
  11. function rt_theme_custom_posts(){
  12.    
  13.     #
  14.     #   Permalink slugs for the custom post types
  15.     #
  16.    
  17.     $portfolio_slug         = get_option(THEMESLUG."_portfolio_single_slug");   // singular portfolio item
  18.     $portfolio_categories_slug  = get_option(THEMESLUG."_portfolio_category_slug");     // portfolio categories
  19.     $product_slug               = get_option(THEMESLUG."_product_single_slug");         // singular product item
  20.     $product_categories_slug    = get_option(THEMESLUG."_product_category_slug");       // product categories
  21.    
  22.     #
  23.     #   Portfolio
  24.     #
  25.    
  26.     $labels = array(
  27.         'name'              => _x('Portfolio', 'portfolio', 'rt_theme_admin'),
  28.         'singular_name'         => _x('portfolio', 'portfolio', 'rt_theme_admin'),
  29.         'add_new'           => _x('Add New', 'portfolio item', 'rt_theme_admin'),
  30.         'add_new_item'      => __('Add New portfolio item', 'rt_theme_admin'),
  31.         'edit_item'             => __('Edit Portfolio Item', 'rt_theme_admin'),
  32.         'new_item'          => __('New Portfolio Item', 'rt_theme_admin'),
  33.         'view_item'             => __('View Portfolio Item', 'rt_theme_admin'),
  34.         'search_items'      => __('Search Portfolio Item', 'rt_theme_admin'),
  35.         'not_found'             =>  __('No portfolio item found', 'rt_theme_admin'),
  36.         'not_found_in_trash'    => __('No portfolio item found in Trash', 'rt_theme_admin'),
  37.         'parent_item_colon'     => ''
  38.     );
  39.    
  40.     $args = array(
  41.         'labels'                => $labels,
  42.         'public'                => true,
  43.         'publicly_queryable'    => true,
  44.         'exclude_from_search'   => false,
  45.         'show_ui'           => true,
  46.         'query_var'             => false,
  47.         'can_export'            => true,
  48.         'show_in_nav_menus'     => true,       
  49.         'capability_type'       => 'post',
  50.         'menu_position'         => null,
  51.         'rewrite'           => array( 'slug' => $portfolio_slug, 'with_front' => true, 'pages' => true, 'feeds'=>false ),
  52.         'menu_icon'             => THEMEADMINURI .'/images/portfolio-icon.png', // 16px16
  53.         'supports'          => array('title','editor','author','thumbnail','comments','revisions')
  54.     );
  55.    
  56.     register_post_type('portfolio',$args);
  57.    
  58.     // Portfolio Categories
  59.     $labels = array(
  60.         'name'              => _x( 'Portfolio Categories', 'taxonomy general name' , 'rt_theme_admin'),
  61.         'singular_name'         => _x( 'Portfolio Category', 'taxonomy singular name' , 'rt_theme_admin'),
  62.         'search_items'      =>  __( 'Search Portfolio Category' , 'rt_theme_admin'),
  63.         'all_items'             => __( 'All Portfolio Categories' , 'rt_theme_admin'),
  64.         'parent_item'           => __( 'Parent Portfolio Category' , 'rt_theme_admin'),
  65.         'parent_item_colon'     => __( 'Parent Portfolio Category:' , 'rt_theme_admin'),
  66.         'edit_item'             => __( 'Edit Portfolio Category' , 'rt_theme_admin'),
  67.         'update_item'           => __( 'Update Portfolio Category' , 'rt_theme_admin'),
  68.         'add_new_item'      => __( 'Add New Portfolio Category' , 'rt_theme_admin'),
  69.         'new_item_name'         => __( 'New Genre Portfolio Category' , 'rt_theme_admin'),
  70.     );  
  71.    
  72.     register_taxonomy('portfolio_categories',array('portfolio'), array(
  73.         'hierarchical'      => true,
  74.         'labels'                => $labels,
  75.         'show_ui'           => true,
  76.         'query_var'             => false,
  77.         '_builtin'          => false,
  78.         'paged'             =>true,
  79.         'rewrite'           => array('slug'=>$portfolio_categories_slug,'with_front'=>false),
  80.     ));
  81.    
  82.    
  83.    
  84.    
  85.     #
  86.     #   Products
  87.     #
  88.     if ( ! class_exists( 'Woocommerce' ) ) {
  89.         $labels = array(
  90.             'name'              => _x('Product', 'product', 'rt_theme_admin'),
  91.             'singular_name'         => _x('product', 'product', 'rt_theme_admin'),
  92.             'add_new'           => _x('Add New', 'product item', 'rt_theme_admin'),
  93.             'add_new_item'      => __('Add New Product Item', 'rt_theme_admin'),
  94.             'edit_item'             => __('Edit Product Item', 'rt_theme_admin'),
  95.             'new_item'          => __('New Product Item', 'rt_theme_admin'),
  96.             'view_item'             => __('View Product Item', 'rt_theme_admin'),
  97.             'search_items'      => __('Search Product Item', 'rt_theme_admin'),
  98.             'not_found'             =>  __('No Product Item Iound', 'rt_theme_admin'),
  99.             'not_found_in_trash'    => __('No product item found in trash', 'rt_theme_admin'),
  100.             'parent_item_colon'     => ''
  101.         );
  102.     }else{
  103.         $labels = array(
  104.             'name'              => _x('Product Showcase', 'product', 'rt_theme_admin'),
  105.             'singular_name'         => _x('product', 'product', 'rt_theme_admin'),
  106.             'add_new'           => _x('Add New', 'product item', 'rt_theme_admin'),
  107.             'add_new_item'      => __('Add New Product Item', 'rt_theme_admin'),
  108.             'edit_item'             => __('Edit Product Item', 'rt_theme_admin'),
  109.             'new_item'          => __('New Product Item', 'rt_theme_admin'),
  110.             'view_item'             => __('View Product Item', 'rt_theme_admin'),
  111.             'search_items'      => __('Search Product Item', 'rt_theme_admin'),
  112.             'not_found'             =>  __('No Product Item Iound', 'rt_theme_admin'),
  113.             'not_found_in_trash'    => __('No product item found in trash', 'rt_theme_admin'),
  114.             'parent_item_colon'     => ''
  115.         );
  116.     }
  117.  
  118.     $args = array(
  119.         'labels' => $labels,
  120.         'public' => true,
  121.         'publicly_queryable' => true,
  122.         'exclude_from_search' => false,
  123.         'show_ui' => true,
  124.         'query_var' => false,
  125.         'can_export' => true,
  126.         'show_in_nav_menus' => true,       
  127.         'capability_type' => 'post',
  128.         'menu_position' => null,
  129.         'rewrite' => array( 'slug' => $product_slug, 'with_front' => true, 'pages' => true, 'feeds'=>false ),
  130.         'menu_icon' => THEMEADMINURI .'/images/product-icon.png', // 16px16
  131.         'supports' => array('title','editor','author','comments','revisions')
  132.     );
  133.    
  134.     register_post_type('products',$args);
  135.    
  136.     // Product Categories
  137.     $labels = array(
  138.         'name' => _x( 'Product Categories', 'taxonomy general name' , 'rt_theme_admin'),
  139.         'singular_name' => _x( 'Product Category', 'taxonomy singular name' , 'rt_theme_admin'),
  140.         'search_items' =>  __( 'Search Product Category' , 'rt_theme_admin'),
  141.         'all_items' => __( 'All Product Categories' , 'rt_theme_admin'),
  142.         'parent_item' => __( 'Parent Product Category' , 'rt_theme_admin'),
  143.         'parent_item_colon' => __( 'Parent Product Category:' , 'rt_theme_admin'),
  144.         'edit_item' => __( 'Edit Product Category' , 'rt_theme_admin'),
  145.         'update_item' => __( 'Update Product Category' , 'rt_theme_admin'),
  146.         'add_new_item' => __( 'Add New Product Category' , 'rt_theme_admin'),
  147.         'new_item_name' => __( 'New Genre Product Category' , 'rt_theme_admin'),
  148.     );  
  149.    
  150.     register_taxonomy('product_categories',array('products'), array(
  151.         'hierarchical' => true,
  152.         'labels' => $labels,
  153.         'show_ui' => true,
  154.         'query_var' => false,
  155.         '_builtin' => false,
  156.         'paged'=>true,
  157.         'rewrite' => array('slug'=>$product_categories_slug,'with_front'=>false),
  158.     ));
  159.  
  160.  
  161.  
  162.     #
  163.     #   Home Page Slider
  164.     #  
  165.    
  166.     $labels = array(
  167.         'name' => _x('Slider', 'slider', 'rt_theme_admin'),
  168.         'singular_name' => _x('slider', 'slider', 'rt_theme_admin'),
  169.         'add_new' => _x('Add New', 'slider', 'rt_theme_admin'),
  170.         'add_new_item' => __('Add New Slide', 'rt_theme_admin'),
  171.         'edit_item' => __('Edit Slide', 'rt_theme_admin'),
  172.         'new_item' => __('New Slide', 'rt_theme_admin'),
  173.         'view_item' => __('View Slide', 'rt_theme_admin'),
  174.         'search_items' => __('Search Slide', 'rt_theme_admin'),
  175.         'not_found' =>  __('No slide found', 'rt_theme_admin'),
  176.         'not_found_in_trash' => __('No slide found in Trash', 'rt_theme_admin'),
  177.         'parent_item_colon' => ''
  178.     );
  179.     $args = array(
  180.         'labels' => $labels,
  181.         'public' => true,
  182.         'publicly_queryable' => true,
  183.         'show_ui' => true,
  184.         'query_var' => true,
  185.         'capability_type' => 'post',
  186.         'menu_position' => null,
  187.         'rewrite' => array('slug'=>'slide','with_front'=>false),
  188.         'menu_icon' => THEMEADMINURI .'/images/slides.png', // 16px16
  189.         'supports' => array( 'title', 'thumbnail' )
  190.     );
  191.     register_post_type('slider',$args);
  192.    
  193.     #
  194.     #   Home Page Contents
  195.     #  
  196.     $labels = array(
  197.         'name' => _x('Home Page', 'home_page', 'rt_theme_admin'),
  198.         'singular_name' => _x('home_page', 'home_page', 'rt_theme_admin'),
  199.         'add_new' => _x('Add New Box', 'home_page', 'rt_theme_admin'),
  200.         'add_new_item' => __('Add New Box', 'rt_theme_admin'),
  201.         'edit_item' => __('Edit Content', 'rt_theme_admin'),
  202.         'new_item' => __('New Content', 'rt_theme_admin'),
  203.         'view_item' => __('View Content', 'rt_theme_admin'),
  204.         'search_items' => __('Search Content', 'rt_theme_admin'),
  205.         'not_found' =>  __('No result found', 'rt_theme_admin'),
  206.         'not_found_in_trash' => __('No result found in Trash', 'rt_theme_admin'),
  207.         'parent_item_colon' => ''
  208.     );
  209.     $args = array(
  210.         'labels' => $labels,
  211.         'public' => true,
  212.         'publicly_queryable' => true,
  213.         'show_ui' => true,
  214.         'query_var' => true,
  215.         'capability_type' => 'post',
  216.         'menu_position' => null,
  217.         'menu_icon' => THEMEADMINURI .'/images/home_contents.png', // 16px16
  218.         'supports' => array( 'title','editor','author','thumbnail','revisions')
  219.     );
  220.     register_post_type('home_page',$args);  
  221.    
  222. }
  223.  
  224. add_action('init','rt_theme_custom_posts',0);
  225.  
  226.  
  227. #
  228. #   add productID column in product post types
  229. #
  230.  
  231. if(is_admin()){
  232.     // ADD NEW COLUMN
  233.     function ST4_columns_head($defaults) {
  234.      $defaults['product-id'] = 'Product ID';
  235.      return $defaults;
  236.     }
  237.    
  238.     // SHOW INFO IN THE NEW COLUMN
  239.     function ST4_columns_content($column_name, $post_ID) {
  240.        echo $post_ID;
  241.     }
  242.    
  243.     add_filter('manage_products_posts_columns', 'ST4_columns_head', 10);
  244.     add_action('manage_products_posts_custom_column', 'ST4_columns_content', 10, 2);
  245. }
  246.  
  247.  
  248.  
  249. ?>
Advertisement
Add Comment
Please, Sign In to add comment