onetone_bbPress_Breadcrumb_Trail

Extends the Breadcrumb_Trail class for bbPress.

Defined (1)

The class is defined in the following location(s).

/includes/breadcrumbs.php  
  1. class onetone_bbPress_Breadcrumb_Trail extends onetone_Breadcrumb_Trail { 
  2. /** 
  3. * Runs through the various bbPress conditional tags to check the current page being viewed. Once 
  4. * a condition is met, add items to the $items array. 
  5. * @since 0.6.0 
  6. * @access public 
  7. * @return void 
  8. */ 
  9. public function do_trail_items() { 
  10. /** Add the network and site home links. */ 
  11. $this->do_network_home_link(); 
  12. $this->do_site_home_link(); 
  13. /** Get the forum post type object. */ 
  14. $post_type_object = get_post_type_object( bbp_get_forum_post_type() ); 
  15. /** If not viewing the forum root/archive page and a forum archive exists, add it. */ 
  16. if ( !empty( $post_type_object->has_archive ) && !bbp_is_forum_archive() ) 
  17. $this->items[] = '<a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '">' . bbp_get_forum_archive_title() . '</a>'; 
  18. /** If viewing the forum root/archive. */ 
  19. if ( bbp_is_forum_archive() ) { 
  20. if ( true === $this->args['show_title'] ) 
  21. $this->items[] = bbp_get_forum_archive_title(); 
  22. /** If viewing the topics archive. */ 
  23. elseif ( bbp_is_topic_archive() ) { 
  24. if ( true === $this->args['show_title'] ) 
  25. $this->items[] = bbp_get_topic_archive_title(); 
  26. /** If viewing a topic tag archive. */ 
  27. elseif ( bbp_is_topic_tag() ) { 
  28. if ( true === $this->args['show_title'] ) 
  29. $this->items[] = bbp_get_topic_tag_name(); 
  30. /** If viewing a topic tag edit page. */ 
  31. elseif ( bbp_is_topic_tag_edit() ) { 
  32. $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>'; 
  33. if ( true === $this->args['show_title'] ) 
  34. $this->items[] = __( 'Edit', 'onetone' ); 
  35. /** If viewing a "view" page. */ 
  36. elseif ( bbp_is_single_view() ) { 
  37. if ( true === $this->args['show_title'] ) 
  38. $this->items[] = bbp_get_view_title(); 
  39. /** If viewing a single topic page. */ 
  40. elseif ( bbp_is_single_topic() ) { 
  41. /** Get the queried topic. */ 
  42. $topic_id = get_queried_object_id(); 
  43. /** Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */ 
  44. $this->do_post_parents( bbp_get_topic_forum_id( $topic_id ) ); 
  45. /** If viewing a split, merge, or edit topic page, show the link back to the topic. Else, display topic title. */ 
  46. if ( bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit() ) 
  47. $this->items[] = '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . bbp_get_topic_title( $topic_id ) . '</a>'; 
  48. elseif ( true === $this->args['show_title'] ) 
  49. $this->items[] = bbp_get_topic_title( $topic_id ); 
  50. /** If viewing a topic split page. */ 
  51. if ( bbp_is_topic_split() && true === $this->args['show_title'] ) 
  52. $this->items[] = __( 'Split', 'onetone' ); 
  53. /** If viewing a topic merge page. */ 
  54. elseif ( bbp_is_topic_merge() && true === $this->args['show_title'] ) 
  55. $this->items[] = __( 'Merge', 'onetone' ); 
  56. /** If viewing a topic edit page. */ 
  57. elseif ( bbp_is_topic_edit() && true === $this->args['show_title'] ) 
  58. $this->items[] = __( 'Edit', 'onetone' ); 
  59. /** If viewing a single reply page. */ 
  60. elseif ( bbp_is_single_reply() ) { 
  61. /** Get the queried reply object ID. */ 
  62. $reply_id = get_queried_object_id(); 
  63. /** Get the parent items for the reply, which should be its topic. */ 
  64. $this->do_post_parents( bbp_get_reply_topic_id( $reply_id ) ); 
  65. /** If viewing a reply edit page, link back to the reply. Else, display the reply title. */ 
  66. if ( bbp_is_reply_edit() ) { 
  67. $this->items[] = '<a href="' . bbp_get_reply_url( $reply_id ) . '">' . bbp_get_reply_title( $reply_id ) . '</a>'; 
  68. if ( true === $this->args['show_title'] ) 
  69. $this->items[] = __( 'Edit', 'onetone' ); 
  70. } elseif ( true === $this->args['show_title'] ) { 
  71. $this->items[] = bbp_get_reply_title( $reply_id ); 
  72. /** If viewing a single forum. */ 
  73. elseif ( bbp_is_single_forum() ) { 
  74. /** Get the queried forum ID and its parent forum ID. */ 
  75. $forum_id = get_queried_object_id(); 
  76. $forum_parent_id = bbp_get_forum_parent_id( $forum_id ); 
  77. /** If the forum has a parent forum, get its parent(s). */ 
  78. if ( 0 !== $forum_parent_id) 
  79. $this->do_post_parents( $forum_parent_id ); 
  80. /** Add the forum title to the end of the trail. */ 
  81. if ( true === $this->args['show_title'] ) 
  82. $this->items[] = bbp_get_forum_title( $forum_id ); 
  83. /** If viewing a user page or user edit page. */ 
  84. elseif ( bbp_is_single_user() || bbp_is_single_user_edit() ) { 
  85. if ( bbp_is_single_user_edit() ) { 
  86. $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field( 'display_name' ) . '</a>'; 
  87. if ( true === $this->args['show_title'] ) 
  88. $this->items[] = __( 'Edit', 'onetone' ); 
  89. } elseif ( true === $this->args['show_title'] ) { 
  90. $this->items[] = bbp_get_displayed_user_field( 'display_name' ); 
  91. /** Return the bbPress breadcrumb trail items. */ 
  92. $this->items = apply_filters( 'breadcrumb_trail_get_bbpress_items', $this->items, $this->args );