jamesabruce

Wordpress - Custom products database - MakeUseOf.com

Jul 16th, 2011
2,196
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. /*
  3. Plugin Name: Product Database
  4. Description: Versatile product database
  5. Version: 1.0.0
  6. Author: James Bruce
  7. Author URI: http://make-money-blogging-ideas.com/
  8.  */
  9. if (!class_exists("Products")) {
  10.     class Products {
  11.    
  12.         function Products(){
  13.             add_action('init', array(&$this,'products_init'));
  14.             register_activation_hook(__FILE__, 'my_rewrite_flush');
  15.         }
  16.    
  17.         // declare the new post type 'sites'
  18.         function products_init() {
  19.             $args = array(
  20.                 'labels' => array(
  21.                     'name' => __('Products'),
  22.                     'singular_name' => __('Product'),
  23.                 ),
  24.                 'public' => true,
  25.                 'rewrite' => array("slug" => "products"), // permalink structure
  26.                 'supports' => array('thumbnail','custom-fields','title','editor','comments'),
  27.                 'has_archive' => true
  28.             );
  29.  
  30.             register_post_type( 'products' , $args );
  31.  
  32.         }
  33.        
  34.         function my_rewrite_flush() {
  35.           products_init();
  36.           flush_rewrite_rules();
  37.         }
  38.        
  39.                
  40.        
  41.     }
  42. if (!isset($pd_plugin_instance)) $pd_plugin_instance = new Products();
  43.  
  44.  
  45.  
  46.  
  47. ?>
RAW Paste Data