BBP_Shortcodes

BbPress Shortcode Class.

Defined (1)

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

/includes/common/shortcodes.php  
  1. class BBP_Shortcodes { 
  2.  
  3. /** Vars ******************************************************************/ 
  4.  
  5. /** 
  6. * @var array Shortcode => function 
  7. */ 
  8. public $codes = array(); 
  9.  
  10. /** Functions *************************************************************/ 
  11.  
  12. /** 
  13. * Add the register_shortcodes action to bbp_init 
  14. * @since bbPress (r3031) 
  15. * @uses setup_globals() 
  16. * @uses add_shortcodes() 
  17. */ 
  18. public function __construct() { 
  19. $this->setup_globals(); 
  20. $this->add_shortcodes(); 
  21.  
  22. /** 
  23. * Shortcode globals 
  24. * @since bbPress (r3143) 
  25. * @access private 
  26. * @uses apply_filters() 
  27. */ 
  28. private function setup_globals() { 
  29.  
  30. // Setup the shortcodes 
  31. $this->codes = apply_filters( 'bbp_shortcodes', array( 
  32.  
  33. /** Forums ********************************************************/ 
  34.  
  35. 'bbp-forum-index' => array( $this, 'display_forum_index' ), // Forum Index 
  36. 'bbp-forum-form' => array( $this, 'display_forum_form' ), // Topic form 
  37. 'bbp-single-forum' => array( $this, 'display_forum' ), // Specific forum - pass an 'id' attribute 
  38.  
  39. /** Topics ********************************************************/ 
  40.  
  41. 'bbp-topic-index' => array( $this, 'display_topic_index' ), // Topic index 
  42. 'bbp-topic-form' => array( $this, 'display_topic_form' ), // Topic form 
  43. 'bbp-single-topic' => array( $this, 'display_topic' ), // Specific topic - pass an 'id' attribute 
  44.  
  45. /** Topic Tags ****************************************************/ 
  46.  
  47. 'bbp-topic-tags' => array( $this, 'display_topic_tags' ), // All topic tags in a cloud 
  48. 'bbp-single-tag' => array( $this, 'display_topics_of_tag' ), // Topics of Tag 
  49.  
  50. /** Replies *******************************************************/ 
  51.  
  52. 'bbp-reply-form' => array( $this, 'display_reply_form' ), // Reply form 
  53. 'bbp-single-reply' => array( $this, 'display_reply' ), // Specific reply - pass an 'id' attribute 
  54.  
  55. /** Views *********************************************************/ 
  56.  
  57. 'bbp-single-view' => array( $this, 'display_view' ), // Single view 
  58.  
  59. /** Search ********************************************************/ 
  60.  
  61. 'bbp-search-form' => array( $this, 'display_search_form' ), // Search form 
  62. 'bbp-search' => array( $this, 'display_search' ), // Search 
  63.  
  64. /** Account *******************************************************/ 
  65.  
  66. 'bbp-login' => array( $this, 'display_login' ), // Login 
  67. 'bbp-register' => array( $this, 'display_register' ), // Register 
  68. 'bbp-lost-pass' => array( $this, 'display_lost_pass' ), // Lost Password 
  69.  
  70. /** Others *******************************************************/ 
  71.  
  72. 'bbp-stats' => array( $this, 'display_stats' ), // Stats 
  73. ) ); 
  74.  
  75. /** 
  76. * Register the bbPress shortcodes 
  77. * @since bbPress (r3031) 
  78. * @uses add_shortcode() 
  79. * @uses do_action() 
  80. */ 
  81. private function add_shortcodes() { 
  82. foreach ( (array) $this->codes as $code => $function ) { 
  83. add_shortcode( $code, $function ); 
  84.  
  85. /** 
  86. * Unset some globals in the $bbp object that hold query related info 
  87. * @since bbPress (r3034) 
  88. */ 
  89. private function unset_globals() { 
  90. $bbp = bbpress(); 
  91.  
  92. // Unset global queries 
  93. $bbp->forum_query = new WP_Query(); 
  94. $bbp->topic_query = new WP_Query(); 
  95. $bbp->reply_query = new WP_Query(); 
  96. $bbp->search_query = new WP_Query(); 
  97.  
  98. // Unset global ID's 
  99. $bbp->current_view_id = 0; 
  100. $bbp->current_forum_id = 0; 
  101. $bbp->current_topic_id = 0; 
  102. $bbp->current_reply_id = 0; 
  103. $bbp->current_topic_tag_id = 0; 
  104.  
  105. // Reset the post data 
  106. wp_reset_postdata(); 
  107.  
  108. /** Output Buffers ********************************************************/ 
  109.  
  110. /** 
  111. * Start an output buffer. 
  112. * This is used to put the contents of the shortcode into a variable rather 
  113. * than outputting the HTML at run-time. This allows shortcodes to appear 
  114. * in the correct location in the_content() instead of when it's created. 
  115. * @since bbPress (r3079) 
  116. * @param string $query_name 
  117. * @uses bbp_set_query_name() 
  118. * @uses ob_start() 
  119. */ 
  120. private function start( $query_name = '' ) { 
  121.  
  122. // Set query name 
  123. bbp_set_query_name( $query_name ); 
  124.  
  125. // Start output buffer 
  126. ob_start(); 
  127.  
  128. /** 
  129. * Return the contents of the output buffer and flush its contents. 
  130. * @since bbPress( r3079) 
  131. * @uses BBP_Shortcodes::unset_globals() Cleans up global values 
  132. * @return string Contents of output buffer. 
  133. */ 
  134. private function end() { 
  135.  
  136. // Unset globals 
  137. $this->unset_globals(); 
  138.  
  139. // Reset the query name 
  140. bbp_reset_query_name(); 
  141.  
  142. // Return and flush the output buffer 
  143. return ob_get_clean(); 
  144.  
  145. /** Forum shortcodes ******************************************************/ 
  146.  
  147. /** 
  148. * Display an index of all visible root level forums in an output buffer 
  149. * and return to ensure that post/page contents are displayed first. 
  150. * @since bbPress (r3031) 
  151. * @param array $attr 
  152. * @param string $content 
  153. * @uses bbp_has_forums() 
  154. * @uses get_template_part() 
  155. * @return string 
  156. */ 
  157. public function display_forum_index() { 
  158.  
  159. // Unset globals 
  160. $this->unset_globals(); 
  161.  
  162. // Start output buffer 
  163. $this->start( 'bbp_forum_archive' ); 
  164.  
  165. bbp_get_template_part( 'content', 'archive-forum' ); 
  166.  
  167. // Return contents of output buffer 
  168. return $this->end(); 
  169.  
  170. /** 
  171. * Display the contents of a specific forum ID in an output buffer 
  172. * and return to ensure that post/page contents are displayed first. 
  173. * @since bbPress (r3031) 
  174. * @param array $attr 
  175. * @param string $content 
  176. * @uses get_template_part() 
  177. * @uses bbp_single_forum_description() 
  178. * @return string 
  179. */ 
  180. public function display_forum( $attr, $content = '' ) { 
  181.  
  182. // Sanity check required info 
  183. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) ) 
  184. return $content; 
  185.  
  186. // Set passed attribute to $forum_id for clarity 
  187. $forum_id = bbpress()->current_forum_id = $attr['id']; 
  188.  
  189. // Bail if ID passed is not a forum 
  190. if ( !bbp_is_forum( $forum_id ) ) 
  191. return $content; 
  192.  
  193. // Start output buffer 
  194. $this->start( 'bbp_single_forum' ); 
  195.  
  196. // Check forum caps 
  197. if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { 
  198. bbp_get_template_part( 'content', 'single-forum' ); 
  199.  
  200. // Forum is private and user does not have caps 
  201. } elseif ( bbp_is_forum_private( $forum_id, false ) ) { 
  202. bbp_get_template_part( 'feedback', 'no-access' ); 
  203.  
  204. // Return contents of output buffer 
  205. return $this->end(); 
  206.  
  207. /** 
  208. * Display the forum form in an output buffer and return to ensure 
  209. * post/page contents are displayed first. 
  210. * @since bbPress (r3566) 
  211. * @uses get_template_part() 
  212. */ 
  213. public function display_forum_form() { 
  214.  
  215. // Start output buffer 
  216. $this->start( 'bbp_forum_form' ); 
  217.  
  218. // Output templates 
  219. bbp_get_template_part( 'form', 'forum' ); 
  220.  
  221. // Return contents of output buffer 
  222. return $this->end(); 
  223.  
  224. /** Topic shortcodes ******************************************************/ 
  225.  
  226. /** 
  227. * Display an index of all visible root level topics in an output buffer 
  228. * and return to ensure that post/page contents are displayed first. 
  229. * @since bbPress (r3031) 
  230. * @param array $attr 
  231. * @param string $content 
  232. * @uses bbp_get_hidden_forum_ids() 
  233. * @uses get_template_part() 
  234. * @return string 
  235. */ 
  236. public function display_topic_index() { 
  237.  
  238. // Unset globals 
  239. $this->unset_globals(); 
  240.  
  241. // Filter the query 
  242. if ( ! bbp_is_topic_archive() ) { 
  243. add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topic_index_query' ) ); 
  244.  
  245. // Start output buffer 
  246. $this->start( 'bbp_topic_archive' ); 
  247.  
  248. // Output template 
  249. bbp_get_template_part( 'content', 'archive-topic' ); 
  250.  
  251. // Return contents of output buffer 
  252. return $this->end(); 
  253.  
  254. /** 
  255. * Display the contents of a specific topic ID in an output buffer 
  256. * and return to ensure that post/page contents are displayed first. 
  257. * @since bbPress (r3031) 
  258. * @param array $attr 
  259. * @param string $content 
  260. * @uses get_template_part() 
  261. * @return string 
  262. */ 
  263. public function display_topic( $attr, $content = '' ) { 
  264.  
  265. // Sanity check required info 
  266. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) ) 
  267. return $content; 
  268.  
  269. // Unset globals 
  270. $this->unset_globals(); 
  271.  
  272. // Set passed attribute to $forum_id for clarity 
  273. $topic_id = bbpress()->current_topic_id = $attr['id']; 
  274. $forum_id = bbp_get_topic_forum_id( $topic_id ); 
  275.  
  276. // Bail if ID passed is not a topic 
  277. if ( !bbp_is_topic( $topic_id ) ) 
  278. return $content; 
  279.  
  280. // Reset the queries if not in theme compat 
  281. if ( !bbp_is_theme_compat_active() ) { 
  282.  
  283. $bbp = bbpress(); 
  284.  
  285. // Reset necessary forum_query attributes for topics loop to function 
  286. $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 
  287. $bbp->forum_query->in_the_loop = true; 
  288. $bbp->forum_query->post = get_post( $forum_id ); 
  289.  
  290. // Reset necessary topic_query attributes for topics loop to function 
  291. $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type(); 
  292. $bbp->topic_query->in_the_loop = true; 
  293. $bbp->topic_query->post = get_post( $topic_id ); 
  294.  
  295. // Start output buffer 
  296. $this->start( 'bbp_single_topic' ); 
  297.  
  298. // Check forum caps 
  299. if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { 
  300. bbp_get_template_part( 'content', 'single-topic' ); 
  301.  
  302. // Forum is private and user does not have caps 
  303. } elseif ( bbp_is_forum_private( $forum_id, false ) ) { 
  304. bbp_get_template_part( 'feedback', 'no-access' ); 
  305.  
  306. // Return contents of output buffer 
  307. return $this->end(); 
  308.  
  309. /** 
  310. * Display the topic form in an output buffer and return to ensure 
  311. * post/page contents are displayed first. 
  312. * Supports 'forum_id' attribute to display the topic form for a particular 
  313. * forum. This currently has styling issues from not being wrapped in 
  314. * <div id="bbpress-forums"></div> which will need to be sorted out later. 
  315. * @since bbPress (r3031) 
  316. * @param array $attr 
  317. * @param string $content 
  318. * @uses get_template_part() 
  319. * @return string 
  320. */ 
  321. public function display_topic_form( $attr = array(), $content = '' ) { 
  322.  
  323. // Sanity check supplied info 
  324. if ( !empty( $content ) || ( !empty( $attr['forum_id'] ) && ( !is_numeric( $attr['forum_id'] ) || !bbp_is_forum( $attr['forum_id'] ) ) ) ) 
  325. return $content; 
  326.  
  327. // Unset globals 
  328. $this->unset_globals(); 
  329.  
  330. // If forum id is set, use the 'bbp_single_forum' query name 
  331. if ( !empty( $attr['forum_id'] ) ) { 
  332.  
  333. // Set the global current_forum_id for future requests 
  334. bbpress()->current_forum_id = $forum_id = bbp_get_forum_id( $attr['forum_id'] ); 
  335.  
  336. // Start output buffer 
  337. $this->start( 'bbp_single_forum' ); 
  338.  
  339. // No forum id was passed 
  340. } else { 
  341.  
  342. // Set the $forum_id variable to satisfy checks below 
  343. $forum_id = 0; 
  344.  
  345. // Start output buffer 
  346. $this->start( 'bbp_topic_form' ); 
  347.  
  348. // If the forum id is set, check forum caps else display normal topic form 
  349. if ( empty( $forum_id ) || bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { 
  350. bbp_get_template_part( 'form', 'topic' ); 
  351.  
  352. // Forum is private and user does not have caps 
  353. } elseif ( bbp_is_forum_private( $forum_id, false ) ) { 
  354. bbp_get_template_part( 'feedback', 'no-access' ); 
  355.  
  356. // Return contents of output buffer 
  357. return $this->end(); 
  358.  
  359. /** Replies ***************************************************************/ 
  360.  
  361. /** 
  362. * Display the contents of a specific reply ID in an output buffer 
  363. * and return to ensure that post/page contents are displayed first. 
  364. * @since bbPress (r3031) 
  365. * @param array $attr 
  366. * @param string $content 
  367. * @uses get_template_part() 
  368. * @return string 
  369. */ 
  370. public function display_reply( $attr, $content = '' ) { 
  371.  
  372. // Sanity check required info 
  373. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) ) 
  374. return $content; 
  375.  
  376. // Unset globals 
  377. $this->unset_globals(); 
  378.  
  379. // Set passed attribute to $reply_id for clarity 
  380. $reply_id = bbpress()->current_reply_id = $attr['id']; 
  381. $forum_id = bbp_get_reply_forum_id( $reply_id ); 
  382.  
  383. // Bail if ID passed is not a reply 
  384. if ( !bbp_is_reply( $reply_id ) ) 
  385. return $content; 
  386.  
  387. // Reset the queries if not in theme compat 
  388. if ( !bbp_is_theme_compat_active() ) { 
  389.  
  390. $bbp = bbpress(); 
  391.  
  392. // Reset necessary forum_query attributes for replys loop to function 
  393. $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type(); 
  394. $bbp->forum_query->in_the_loop = true; 
  395. $bbp->forum_query->post = get_post( $forum_id ); 
  396.  
  397. // Reset necessary reply_query attributes for replys loop to function 
  398. $bbp->reply_query->query_vars['post_type'] = bbp_get_reply_post_type(); 
  399. $bbp->reply_query->in_the_loop = true; 
  400. $bbp->reply_query->post = get_post( $reply_id ); 
  401.  
  402. // Start output buffer 
  403. $this->start( 'bbp_single_reply' ); 
  404.  
  405. // Check forum caps 
  406. if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) { 
  407. bbp_get_template_part( 'content', 'single-reply' ); 
  408.  
  409. // Forum is private and user does not have caps 
  410. } elseif ( bbp_is_forum_private( $forum_id, false ) ) { 
  411. bbp_get_template_part( 'feedback', 'no-access' ); 
  412.  
  413. // Return contents of output buffer 
  414. return $this->end(); 
  415.  
  416. /** 
  417. * Display the reply form in an output buffer and return to ensure 
  418. * post/page contents are displayed first. 
  419. * @since bbPress (r3031) 
  420. * @uses get_template_part() 
  421. */ 
  422. public function display_reply_form() { 
  423.  
  424. // Start output buffer 
  425. $this->start( 'bbp_reply_form' ); 
  426.  
  427. // Output templates 
  428. bbp_get_template_part( 'form', 'reply' ); 
  429.  
  430. // Return contents of output buffer 
  431. return $this->end(); 
  432.  
  433. /** Topic Tags ************************************************************/ 
  434.  
  435. /** 
  436. * Display a tag cloud of all topic tags in an output buffer and return to 
  437. * ensure that post/page contents are displayed first. 
  438. * @since bbPress (r3110) 
  439. * @return string 
  440. */ 
  441. public function display_topic_tags() { 
  442.  
  443. // Unset globals 
  444. $this->unset_globals(); 
  445.  
  446. // Start output buffer 
  447. $this->start( 'bbp_topic_tags' ); 
  448.  
  449. // Output the topic tags 
  450. wp_tag_cloud( array( 
  451. 'smallest' => 9,  
  452. 'largest' => 38,  
  453. 'number' => 80,  
  454. 'taxonomy' => bbp_get_topic_tag_tax_id() 
  455. ) ); 
  456.  
  457. // Return contents of output buffer 
  458. return $this->end(); 
  459.  
  460. /** 
  461. * Display the contents of a specific topic tag in an output buffer 
  462. * and return to ensure that post/page contents are displayed first. 
  463. * @since bbPress (r3110) 
  464. * @param array $attr 
  465. * @param string $content 
  466. * @uses get_template_part() 
  467. * @return string 
  468. */ 
  469. public function display_topics_of_tag( $attr, $content = '' ) { 
  470.  
  471. // Sanity check required info 
  472. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) ) 
  473. return $content; 
  474.  
  475. // Unset globals 
  476. $this->unset_globals(); 
  477.  
  478. // Filter the query 
  479. if ( ! bbp_is_topic_tag() ) { 
  480. add_filter( 'bbp_before_has_topics_parse_args', array( $this, 'display_topics_of_tag_query' ) ); 
  481.  
  482. // Start output buffer 
  483. $this->start( 'bbp_topic_tag' ); 
  484.  
  485. // Set passed attribute to $ag_id for clarity 
  486. bbpress()->current_topic_tag_id = $tag_id = $attr['id']; 
  487.  
  488. // Output template 
  489. bbp_get_template_part( 'content', 'archive-topic' ); 
  490.  
  491. // Return contents of output buffer 
  492. return $this->end(); 
  493.  
  494. /** 
  495. * Display the contents of a specific topic tag in an output buffer 
  496. * and return to ensure that post/page contents are displayed first. 
  497. * @since bbPress (r3346) 
  498. * @param array $attr 
  499. * @param string $content 
  500. * @uses get_template_part() 
  501. * @return string 
  502. */ 
  503. public function display_topic_tag_form() { 
  504.  
  505. // Unset globals 
  506. $this->unset_globals(); 
  507.  
  508. // Start output buffer 
  509. $this->start( 'bbp_topic_tag_edit' ); 
  510.  
  511. // Output template 
  512. bbp_get_template_part( 'content', 'topic-tag-edit' ); 
  513.  
  514. // Return contents of output buffer 
  515. return $this->end(); 
  516.  
  517. /** Views *****************************************************************/ 
  518.  
  519. /** 
  520. * Display the contents of a specific view in an output buffer and return to 
  521. * ensure that post/page contents are displayed first. 
  522. * @since bbPress (r3031) 
  523. * @param array $attr 
  524. * @param string $content 
  525. * @uses get_template_part() 
  526. * @uses bbp_single_forum_description() 
  527. * @return string 
  528. */ 
  529. public function display_view( $attr, $content = '' ) { 
  530.  
  531. // Sanity check required info 
  532. if ( empty( $attr['id'] ) ) 
  533. return $content; 
  534.  
  535. // Set passed attribute to $view_id for clarity 
  536. $view_id = $attr['id']; 
  537.  
  538. // Start output buffer 
  539. $this->start( 'bbp_single_view' ); 
  540.  
  541. // Unset globals 
  542. $this->unset_globals(); 
  543.  
  544. // Set the current view ID 
  545. bbpress()->current_view_id = $view_id; 
  546.  
  547. // Load the view 
  548. bbp_view_query( $view_id ); 
  549.  
  550. // Output template 
  551. bbp_get_template_part( 'content', 'single-view' ); 
  552.  
  553. // Return contents of output buffer 
  554. return $this->end(); 
  555.  
  556. /** Search ****************************************************************/ 
  557.  
  558. /** 
  559. * Display the search form in an output buffer and return to ensure 
  560. * post/page contents are displayed first. 
  561. * @since bbPress (r4585) 
  562. * @uses get_template_part() 
  563. */ 
  564. public function display_search_form() { 
  565.  
  566. // Bail if search is disabled 
  567. if ( ! bbp_allow_search() ) { 
  568. return; 
  569.  
  570. // Start output buffer 
  571. $this->start( 'bbp_search_form' ); 
  572.  
  573. // Output templates 
  574. bbp_get_template_part( 'form', 'search' ); 
  575.  
  576. // Return contents of output buffer 
  577. return $this->end(); 
  578.  
  579. /** 
  580. * Display the contents of search results in an output buffer and return to 
  581. * ensure that post/page contents are displayed first. 
  582. * @since bbPress (r4579) 
  583. * @param array $attr 
  584. * @param string $content 
  585. * @uses bbp_search_query() 
  586. * @uses get_template_part() 
  587. */ 
  588. public function display_search( $attr, $content = '' ) { 
  589.  
  590. // Sanity check required info 
  591. if ( !empty( $content ) ) { 
  592. return $content; 
  593.  
  594. // Bail if search is disabled 
  595. if ( ! bbp_allow_search() ) { 
  596. return; 
  597.  
  598. // Trim search attribute if it's set 
  599. if ( isset( $attr['search'] ) ) { 
  600. $attr['search'] = trim( $attr['search'] ); 
  601.  
  602. // Set passed attribute to $search_terms for clarity 
  603. $search_terms = empty( $attr['search'] ) ? bbp_get_search_terms() : $attr['search']; 
  604.  
  605. // Unset globals 
  606. $this->unset_globals(); 
  607.  
  608. // Set terms for query 
  609. set_query_var( bbp_get_search_rewrite_id(), $search_terms ); 
  610.  
  611. // Start output buffer 
  612. $this->start( bbp_get_search_rewrite_id() ); 
  613.  
  614. // Output template 
  615. bbp_get_template_part( 'content', 'search' ); 
  616.  
  617. // Return contents of output buffer 
  618. return $this->end(); 
  619.  
  620. /** Account ***************************************************************/ 
  621.  
  622. /** 
  623. * Display a login form 
  624. * @since bbPress (r3302) 
  625. * @return string 
  626. */ 
  627. public function display_login() { 
  628.  
  629. // Unset globals 
  630. $this->unset_globals(); 
  631.  
  632. // Start output buffer 
  633. $this->start( 'bbp_login' ); 
  634.  
  635. // Output templates 
  636. if ( !is_user_logged_in() ) 
  637. bbp_get_template_part( 'form', 'user-login' ); 
  638. else 
  639. bbp_get_template_part( 'feedback', 'logged-in' ); 
  640.  
  641. // Return contents of output buffer 
  642. return $this->end(); 
  643.  
  644. /** 
  645. * Display a register form 
  646. * @since bbPress (r3302) 
  647. * @return string 
  648. */ 
  649. public function display_register() { 
  650.  
  651. // Unset globals 
  652. $this->unset_globals(); 
  653.  
  654. // Start output buffer 
  655. $this->start( 'bbp_register' ); 
  656.  
  657. // Output templates 
  658. if ( !is_user_logged_in() ) 
  659. bbp_get_template_part( 'form', 'user-register' ); 
  660. else 
  661. bbp_get_template_part( 'feedback', 'logged-in' ); 
  662.  
  663. // Return contents of output buffer 
  664. return $this->end(); 
  665.  
  666. /** 
  667. * Display a lost password form 
  668. * @since bbPress (r3302) 
  669. * @return string 
  670. */ 
  671. public function display_lost_pass() { 
  672.  
  673. // Unset globals 
  674. $this->unset_globals(); 
  675.  
  676. // Start output buffer 
  677. $this->start( 'bbp_lost_pass' ); 
  678.  
  679. // Output templates 
  680. if ( !is_user_logged_in() ) 
  681. bbp_get_template_part( 'form', 'user-lost-pass' ); 
  682. else 
  683. bbp_get_template_part( 'feedback', 'logged-in' ); 
  684.  
  685. // Return contents of output buffer 
  686. return $this->end(); 
  687.  
  688. /** Other *****************************************************************/ 
  689.  
  690. /** 
  691. * Display forum statistics 
  692. * @since bbPress (r4509) 
  693. * @return shring 
  694. */ 
  695. public function display_stats() { 
  696.  
  697. // Unset globals 
  698. $this->unset_globals(); 
  699.  
  700. // Start output buffer 
  701. $this->start(); 
  702.  
  703. // Output statistics 
  704. bbp_get_template_part( 'content', 'statistics' ); 
  705.  
  706. // Return contents of output buffer 
  707. return $this->end(); 
  708.  
  709. /** 
  710. * Display a breadcrumb 
  711. * @since bbPress (r3302) 
  712. * @return string 
  713. */ 
  714. public function display_breadcrumb() { 
  715.  
  716. // Unset globals 
  717. $this->unset_globals(); 
  718.  
  719. // Start output buffer 
  720. $this->start(); 
  721.  
  722. // Output breadcrumb 
  723. bbp_breadcrumb(); 
  724.  
  725. // Return contents of output buffer 
  726. return $this->end(); 
  727.  
  728. /** Query Filters *********************************************************/ 
  729.  
  730. /** 
  731. * Filter the query for the topic index 
  732. * @since bbPress (r3637) 
  733. * @param array $args 
  734. * @return array 
  735. */ 
  736. public function display_topic_index_query( $args = array() ) { 
  737. $args['author'] = 0; 
  738. $args['show_stickies'] = true; 
  739. $args['order'] = 'DESC'; 
  740. return $args; 
  741.  
  742. /** 
  743. * Filter the query for topic tags 
  744. * @since bbPress (r3637) 
  745. * @param array $args 
  746. * @return array 
  747. */ 
  748. public function display_topics_of_tag_query( $args = array() ) { 
  749. $args['tax_query'] = array( array( 
  750. 'taxonomy' => bbp_get_topic_tag_tax_id(),  
  751. 'field' => 'id',  
  752. 'terms' => bbpress()->current_topic_tag_id 
  753. ) ); 
  754.  
  755. return $args;