Guest User

Untitled

a guest
Jan 21st, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.61 KB | None | 0 0
  1. <?php
  2.  
  3. ///
  4. /// Register the custom post type
  5. ///
  6.  
  7. //Setting Up Your Custom Post Type
  8.  
  9. add_action('init', 'register_rc', 1); // Set priority to avoid plugin conflicts
  10.  
  11. function register_rc() { // A unique name for our function
  12. $labels = array( // Used in the WordPress admin
  13. 'name' => _x('Resources', 'post type general name'),
  14. 'singular_name' => _x('Resource', 'post type singular name'),
  15. 'add_new' => _x('Add New', 'Resource'),
  16. 'add_new_item' => __('Add New Resource'),
  17. 'edit_item' => __('Edit Resource'),
  18. 'new_item' => __('New Resource'),
  19. 'view_item' => __('View Resource '),
  20. 'search_items' => __('Search Resources'),
  21. 'not_found' => __('Nothing found'),
  22. 'not_found_in_trash' => __('Nothing found in Trash')
  23. );
  24. $args = array(
  25. 'labels' => $labels, // Set above
  26. 'public' => true, // Make it publicly accessible
  27. 'hierarchical' => false, // No parents and children here
  28. 'menu_position' => 5, // Appear right below "Posts"
  29. 'has_archive' => 'resources', // Activate the archive
  30. 'supports' => array('title','editor','comments','thumbnail','custom-fields'),
  31. );
  32. register_post_type( 'resource', $args ); // Create the post type, use options above
  33.  
  34.  
  35. ///
  36. /// Set up the presenter
  37. ///
  38.  
  39.  
  40. $labels_presenter = array(
  41. 'name' => _x( 'Presenters', 'taxonomy general name' ),
  42. 'singular_name' => _x( 'Presenter', 'taxonomy singular name' ),
  43. 'search_items' => __( 'Search Presenters' ),
  44. 'popular_items' => __( 'Popular Presenters' ),
  45. 'all_items' => __( 'All Presenters' ),
  46. 'edit_item' => __( 'Edit Presenter' ),
  47. 'update_item' => __( 'Update Presenter' ),
  48. 'add_new_item' => __( 'Add New Presenter' ),
  49. 'new_item_name' => __( 'New Presenter Name' ),
  50. 'separate_items_with_commas' => __( 'Separate presenters with commas' ),
  51. 'add_or_remove_items' => __( 'Add or remove presenters' ),
  52. 'choose_from_most_used' => __( 'Choose from the most used presenters' )
  53. );
  54.  
  55. register_taxonomy(
  56. 'presenters', // The name of the custom taxonomy
  57. array( 'resource' ), // Associate it with our custom post type
  58. array(
  59. 'rewrite' => array( // Use "presenter" instead of "presenters" in the permalink
  60. 'slug' => 'presenter'
  61. ),
  62. 'labels' => $labels_presenter
  63. )
  64. );
  65.  
  66.  
  67. ////
  68. //// This is for adding the topics
  69. ////
  70.  
  71.  
  72. $labels_topics = array(
  73. 'name' => _x( 'Topics', 'taxonomy general name' ),
  74. 'singular_name' => _x( 'Topic', 'taxonomy singular name' ),
  75. 'search_items' => __( 'Search Topics' ),
  76. 'all_items' => __( 'All Topics' ),
  77. 'parent_item' => __( 'Parent Topic' ),
  78. 'parent_item_colon' => __( 'Parent Topic:' ),
  79. 'edit_item' => __( 'Edit Topic' ),
  80. 'update_item' => __( 'Update Topic' ),
  81. 'add_new_item' => __( 'Add New Topic' ),
  82. 'new_item_name' => __( 'New Topic Name' ),
  83. );
  84.  
  85. register_taxonomy(
  86. 'topics', // The name of the custom taxonomy
  87. array( 'resource' ), // Associate it with our custom post type
  88. array(
  89. 'hierarchical' => true,
  90. 'rewrite' => array(
  91. 'slug' => 'topic', // Use "topic" instead of "topics" in permalinks
  92. 'hierarchical' => true // Allows sub-topics to appear in permalinks
  93. ),
  94. 'labels' => $labels_topics
  95. )
  96. );
  97.  
  98.  
  99.  
  100.  
  101. }
  102.  
  103.  
  104.  
  105.  
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114. ///
  115. ///
  116. /// This is for the menu code
  117. ///
  118. ///
  119.  
  120. add_action("bp_nav_items", "show_user_link");
  121.  
  122. function show_user_link() {
  123. if (!is_user_logged_in())
  124. return;
  125.  
  126. echo('<ul id="nav">');
  127.  
  128. if (bp_is_home())
  129. {
  130. echo('<li class="selected">');
  131. }
  132. else
  133. {
  134. echo('<li>');
  135. }
  136.  
  137. echo('<a href="' . bp_loggedin_user_domain() . 'profile">My Profile</a>');
  138. echo('</li>');
  139. echo('</ul>');
  140.  
  141.  
  142. }
  143.  
  144.  
  145.  
  146.  
  147.  
  148. ?>
Add Comment
Please, Sign In to add comment