/includes/common/shortcodes.php

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