Need a unique gift idea?
A Pastebin account makes a great Christmas gift
SHARE
TWEET

Custom post type

foomagoo Mar 21st, 2011 906 Never
Upgrade to PRO!
ENDING IN00days00hours00mins00secs
 
  1. //Add role for managing coupons
  2. $coupon_manager = add_role("coupon_manager", "Coupon Manager");
  3.  
  4. //Add capabilities
  5. $coupon_manager->add_cap( 'edit_coupons' );
  6. $coupon_manager->add_cap( 'edit_coupon' );
  7. $coupon_manager->add_cap( 'delete_coupon' );
  8. $coupon_manager->add_cap( 'delete_coupons' );
  9. $coupon_manager->add_cap( 'read_coupons' );
  10. $coupon_manager->add_cap( 'read' );
  11.  
  12. //Get the admin role
  13. $admin_role = get_role( 'administrator' );
  14.  
  15. // Add more capabilities to the admin role only for this plugin.
  16. $admin_role->add_cap( 'edit_coupons' );
  17. $admin_role->add_cap( 'edit_coupon' );
  18. $admin_role->add_cap( 'edit_private_coupons' );
  19. $admin_role->add_cap( 'delete_coupon' );
  20. $admin_role->add_cap( 'delete_coupons' );
  21. $admin_role->add_cap( 'edit_others_coupons' );
  22. $admin_role->add_cap( 'read_coupons' );
  23. $admin_role->add_cap( 'read_private_coupons' );
  24. $admin_role->add_cap( 'publish_coupons' );
  25. $admin_role->add_cap( 'delete_others_coupons' );
  26. $admin_role->add_cap( 'delete_published_coupons' );
  27. $admin_role->add_cap( 'delete_private_coupons' );
  28.  
  29. //post_type labels
  30. $labels = array(
  31.         'name' => _x('Coupons', 'post type general name'),
  32.         'singular_name' => _x('Coupon', 'post type singular name'),
  33.         'add_new' => _x('Add Coupon', 'coupon'),
  34.         'add_new_item' => __('Add New Coupon'),
  35.         'edit_item' => __('Edit Coupon'),
  36.         'new_item' => __('New Coupon'),
  37.         'view_item' => __('View Coupon'),
  38.         'search_items' => __('Search Coupons'),
  39.         'not_found' =>  __('No coupons found'),
  40.         'not_found_in_trash' => __('No coupons found in Trash'),
  41.         'parent_item_colon' => '',
  42.         'parent' => 'Parent Coupon'
  43. );
  44.  
  45. //post_type settings
  46. $settings= array(
  47.         'labels' => $labels,
  48.         'public' => true,
  49.         'publicly_queryable' => true,
  50.         '_builtin' => false,
  51.         'show_ui' => true,
  52.         'query_var' => true,
  53.         'rewrite' => array('slug'=>'coupon'),
  54.         'hierarchical' => false,
  55.         'menu_position' => null,
  56.         'taxonomies' => array('couponbook'),
  57.         'supports' => array('title','author','thumbnail','page-attributes','revisions'),
  58.         'capability_type' => 'coupon'
  59. );
  60. register_post_type('coupon',$settings);
  61.  
  62.  
  63. //Custom taxonomy labels
  64. $labels = array(
  65.         'name' => _x( 'Coupon Books', 'taxonomy general name' ),
  66.         'singular_name' => _x( 'Coupon Book', 'taxonomy singular name' ),
  67.         'search_items' =>  __( 'Search Coupon Books' ),
  68.         'all_items' => __( 'All Coupon Books' ),
  69.         'parent_item' => __( 'Parent Coupon Book' ),
  70.         'parent_item_colon' => __( 'Parent Coupon Book:' ),
  71.         'edit_item' => __( 'Edit Coupon Book' ),
  72.         'update_item' => __( 'Update Coupon Book' ),
  73.         'add_new_item' => __( 'Add New Coupon Book' ),
  74.         'new_item_name' => __( 'New Coupon Book Name' )
  75. );
  76.  
  77. $settings = array(
  78.         'hierarchical' => true,
  79.         'capability_type' => 'couponbook',
  80.         'labels' => $labels,
  81.         'capabilities' => array('assign_terms'=>'edit_coupons','manage_terms' => 'manage_couponbooks','edit_terms' => 'manage_couponbooks','delete_terms' => 'manage_couponbooks'),
  82.         'show_ui' => true,
  83.         'rewrite' => array( 'slug' => 'couponbook' )
  84. );
  85.  
  86. register_taxonomy('couponbook', array('coupon'), $settings);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top