Advertisement
Guest User

cpt_and_tax

a guest
Dec 21st, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.35 KB | None | 0 0
  1. // =============================
  2. // custom taxonomies (cats and tags)
  3. // =============================
  4. function custom_taxonomy() {
  5.  
  6. $labels = array(
  7. 'name' => _x( 'ifcc Categories', 'Taxonomy General Name', 'text_domain' ),
  8. 'singular_name' => _x( 'ifcc Category', 'Taxonomy Singular Name', 'text_domain' ),
  9. 'menu_name' => __( 'ifcc category', 'text_domain' ),
  10. 'all_items' => __( 'All Items', 'text_domain' ),
  11. 'parent_item' => __( 'Parent Item', 'text_domain' ),
  12. 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
  13. 'new_item_name' => __( 'New Item Name', 'text_domain' ),
  14. 'add_new_item' => __( 'Add New Item', 'text_domain' ),
  15. 'edit_item' => __( 'Edit Item', 'text_domain' ),
  16. 'update_item' => __( 'Update Item', 'text_domain' ),
  17. 'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
  18. 'search_items' => __( 'Search Items', 'text_domain' ),
  19. 'add_or_remove_items' => __( 'Add or remove items', 'text_domain' ),
  20. 'choose_from_most_used' => __( 'Choose from the most used items', 'text_domain' ),
  21. 'not_found' => __( 'Not Found', 'text_domain' ),
  22. );
  23. $args = array(
  24. 'labels' => $labels,
  25. 'hierarchical' => true,
  26. 'public' => true,
  27. 'show_ui' => true,
  28. 'show_admin_column' => true,
  29. 'show_in_nav_menus' => true,
  30. 'show_tagcloud' => true,
  31. 'rewrite' => array( 'slug' => 'ifcc-categories' ),
  32. 'query_var' => true
  33. );
  34. register_taxonomy( 'ifcc_cats', array( 'ifcc' ), $args );
  35.  
  36. $labels = array(
  37. 'name' => _x( 'Tags', 'Taxonomy General Name', 'text_domain' ),
  38. 'singular_name' => _x( 'Tag', 'Taxonomy Singular Name', 'text_domain' ),
  39. 'menu_name' => __( 'Tag', 'text_domain' ),
  40. 'all_items' => __( 'All Items', 'text_domain' ),
  41. 'parent_item' => __( 'Parent Item', 'text_domain' ),
  42. 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
  43. 'new_item_name' => __( 'New Item Name', 'text_domain' ),
  44. 'add_new_item' => __( 'Add New Item', 'text_domain' ),
  45. 'edit_item' => __( 'Edit Item', 'text_domain' ),
  46. 'update_item' => __( 'Update Item', 'text_domain' ),
  47. 'separate_items_with_commas' => __( 'Separate items with commas', 'text_domain' ),
  48. 'search_items' => __( 'Search Items', 'text_domain' ),
  49. 'add_or_remove_items' => __( 'Add or remove items', 'text_domain' ),
  50. 'choose_from_most_used' => __( 'Choose from the most used items', 'text_domain' ),
  51. 'not_found' => __( 'Not Found', 'text_domain' ),
  52. );
  53. $args = array(
  54. 'labels' => $labels,
  55. 'hierarchical' => false,
  56. 'public' => true,
  57. 'show_ui' => true,
  58. 'show_admin_column' => true,
  59. 'show_in_nav_menus' => true,
  60. 'show_tagcloud' => true,
  61. 'query_var' => true
  62. );
  63. register_taxonomy( 'ifcc_tags', array( 'ifcc' ), $args );
  64.  
  65. }
  66. add_action( 'init', 'custom_taxonomy', 20 );
  67.  
  68.  
  69.  
  70. // =============================
  71. // register ifcc custom post type for new tax up
  72. // =============================
  73. function custom_post_type() {
  74. global $woo_contest;
  75.  
  76. $labels = array(
  77. 'name' => _x( 'IFCC Submits', 'Post Type General Name', 'text_domain' ),
  78. 'singular_name' => _x( 'IFCC Submit', 'Post Type Singular Name', 'text_domain' ),
  79. 'menu_name' => __( 'IFCC Submit', 'text_domain' ),
  80. 'parent_item_colon' => __( 'Parent Item:', 'text_domain' ),
  81. 'all_items' => __( 'All Items', 'text_domain' ),
  82. 'view_item' => __( 'View Item', 'text_domain' ),
  83. 'add_new_item' => __( 'Add New Item', 'text_domain' ),
  84. 'add_new' => __( 'Add New', 'text_domain' ),
  85. 'edit_item' => __( 'Edit Item', 'text_domain' ),
  86. 'update_item' => __( 'Update Item', 'text_domain' ),
  87. 'search_items' => __( 'Search Item', 'text_domain' ),
  88. 'not_found' => __( 'Not found', 'text_domain' ),
  89. 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ),
  90. );
  91. $args = array(
  92. 'label' => __( 'post_type', 'text_domain' ),
  93. 'description' => __( 'ifcc submit', 'text_domain' ),
  94. 'labels' => $labels,
  95. 'supports' => array( 'title', 'editor', 'revisions', 'custom-fields', 'post-formats', 'author', 'thumbnail' ),
  96. 'taxonomies' => array( 'ifcc_cats', 'ifcc_tags' ),
  97. 'hierarchical' => false,
  98. 'public' => true,
  99. 'show_ui' => true,
  100. 'show_in_menu' => true,
  101. 'show_in_nav_menus' => true,
  102. 'show_in_admin_bar' => true,
  103. 'menu_position' => 20,
  104. 'can_export' => true,
  105. 'has_archive' => true,
  106. 'exclude_from_search' => true,
  107. 'publicly_queryable' => true,
  108. 'capability_type' => 'ifcc',
  109. 'capabilities' => array( 'read_ifcc', 'edit_ifcc', 'delete_ifcc' ),
  110. 'map_meta_cap' => true
  111. );
  112. register_post_type( 'ifcc', $args );
  113.  
  114. register_taxonomy_for_object_type( 'ifcc_cats', 'ifcc' );
  115. register_taxonomy_for_object_type( 'ifcc_tags', 'ifcc' );
  116. // flush_rewrite_rules();
  117.  
  118. if( $woo_contest['block-dashboard'] == '1' ){
  119. // block non admin users from dashboard!
  120. if ( is_admin() && ! current_user_can( 'administrator' ) &&
  121. ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
  122. wp_redirect( home_url() );
  123. exit;
  124. }
  125. }
  126.  
  127.  
  128. }
  129.  
  130. add_action( 'init', 'custom_post_type', 30 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement