Advertisement
sgaffney

Untitled

Jan 12th, 2012
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.25 KB | None | 0 0
  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. /**
  44. * Shortcode globals
  45. *
  46. * @since bbPress (r3143)
  47. * @access private
  48. *
  49. * @uses apply_filters()
  50. */
  51. private function setup_globals() {
  52.  
  53. // Setup the shortcodes
  54. $this->codes = apply_filters( 'bbp_shortcodes', array(
  55.  
  56. /** Forums ********************************************************/
  57.  
  58. // Forum Index
  59. 'bbp-forum-index' => array( $this, 'display_forum_index' ),
  60.  
  61. 'bbp-single-forum' => array( $this, 'display_forum' ),
  62.  
  63. /** Topics ********************************************************/
  64.  
  65. // Topic index
  66. 'bbp-topic-index' => array( $this, 'display_topic_index' ),
  67.  
  68. // Topic form
  69. 'bbp-topic-form' => array( $this, 'display_topic_form' ),
  70.  
  71. // Specific topic - pass an 'id' attribute
  72. 'bbp-single-topic' => array( $this, 'display_topic' ),
  73.  
  74. /** Topic Tags ****************************************************/
  75.  
  76. // All topic tags in a cloud
  77. 'bbp-topic-tags' => array( $this, 'display_topic_tags' ),
  78.  
  79. // Topics of tag Tag
  80. 'bbp-single-topic-tag' => array( $this, 'display_topics_of_tag' ),
  81.  
  82. /** Replies *******************************************************/
  83.  
  84. // Reply form
  85. 'bbp-reply-form' => array( $this, 'display_reply_form' ),
  86.  
  87. /** Views *********************************************************/
  88.  
  89. // Single view
  90. 'bbp-single-view' => array( $this, 'display_view' ),
  91.  
  92. /** Account *******************************************************/
  93.  
  94. // Login
  95. 'bbp-login' => array( $this, 'display_login' ),
  96.  
  97. // Register
  98. 'bbp-register' => array( $this, 'display_register' ),
  99.  
  100. // LOst Password
  101. 'bbp-lost-pass' => array( $this, 'display_lost_pass' ),
  102.  
  103. ) );
  104. }
  105.  
  106. /**
  107. * Register the bbPress shortcodes
  108. *
  109. * @since bbPress (r3031)
  110. *
  111. * @uses add_shortcode()
  112. * @uses do_action()
  113. */
  114. private function add_shortcodes() {
  115.  
  116. // Loop through and add the shortcodes
  117. foreach( $this->codes as $code => $function )
  118. add_shortcode( $code, $function );
  119.  
  120. // Custom shortcodes
  121. do_action( 'bbp_register_shortcodes' );
  122. }
  123.  
  124. /**
  125. * Unset some globals in the $bbp object that hold query related info
  126. *
  127. * @since bbPress (r3034)
  128. *
  129. * @global bbPress $bbp
  130. */
  131. private function unset_globals() {
  132. global $bbp;
  133.  
  134. // Unset global queries
  135. $bbp->forum_query = new stdClass;
  136. $bbp->topic_query = new stdClass;
  137. $bbp->reply_query = new stdClass;
  138.  
  139. // Unset global ID's
  140. $bbp->current_forum_id = 0;
  141. $bbp->current_topic_id = 0;
  142. $bbp->current_reply_id = 0;
  143.  
  144. // Reset the post data
  145. wp_reset_postdata();
  146. }
  147.  
  148. /** Output Buffers ********************************************************/
  149.  
  150. /**
  151. * Start an output buffer.
  152. *
  153. * This is used to put the contents of the shortcode into a variable rather
  154. * than outputting the HTML at run-time. This allows shortcodes to appear
  155. * in the correct location in the_content() instead of when it's created.
  156. *
  157. * @since bbPress (r3079)
  158. *
  159. * @param string $query_name
  160. *
  161. * @uses bbp_set_query_name()
  162. * @uses ob_start()
  163. */
  164. private function start( $query_name = '' ) {
  165.  
  166. // Set query name
  167. bbp_set_query_name( $query_name );
  168.  
  169. // Start output buffer
  170. ob_start();
  171. }
  172.  
  173. /**
  174. * Return the contents of the output buffer and flush its contents.
  175. *
  176. * @since bbPress( r3079)
  177. *
  178. * @uses BBP_Shortcodes::unset_globals() Cleans up global values
  179. * @return string Contents of output buffer.
  180. */
  181. private function end() {
  182.  
  183. // Put output into usable variable
  184. $output = ob_get_contents();
  185.  
  186. // Unset globals
  187. $this->unset_globals();
  188.  
  189. // Flush the output buffer
  190. ob_end_clean();
  191.  
  192. // Reset the query name
  193. bbp_reset_query_name();
  194.  
  195. return $output;
  196. }
  197.  
  198. /** Forum shortcodes ******************************************************/
  199.  
  200. /**
  201. * Display an index of all visible root level forums in an output buffer
  202. * and return to ensure that post/page contents are displayed first.
  203. *
  204. * @since bbPress (r3031)
  205. *
  206. * @param array $attr
  207. * @param string $content
  208. * @uses bbp_has_forums()
  209. * @uses current_theme_supports()
  210. * @uses get_template_part()
  211. * @return string
  212. */
  213. public function display_forum_index( $attr ) {
  214.  
  215. //Use the $tumbledata global to check for breadcrumbs inclusion
  216. global $tumbledata;
  217.  
  218. extract(shortcode_atts( array( 'breadcrumbs' => 'true',
  219. 'recent_topics' => 'true' ), $attr));
  220.  
  221. // Unset globals
  222. $this->unset_globals();
  223.  
  224. // Start output buffer
  225. $this->start( 'bbp_forum_archive' );
  226.  
  227. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  228.  
  229. if ( $breadcrumbs == 'true' ) {
  230.  
  231. // Get Primary Header
  232. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  233.  
  234. }
  235.  
  236. }
  237.  
  238. // Template notices
  239. do_action( 'bbp_template_notices' );
  240.  
  241. // Before forums index
  242. do_action( 'bbp_template_before_forums_index' );
  243.  
  244. // Load the forums index
  245. if ( bbp_has_forums() )
  246. bbp_get_template_part( 'bbpress/content', 'archive-forum' );
  247.  
  248. // No forums
  249. else
  250. bbp_get_template_part( 'bbpress/feedback', 'no-forums' );
  251.  
  252. // After forums index
  253. do_action( 'bbp_template_after_forums_index' );
  254.  
  255. if($tumbledata['activate_topics_home_block'] == 1) {
  256.  
  257. if ( $recent_topics == 'true' ) {
  258.  
  259. // List Topics
  260. bbp_get_template_part( 'bbpress/loop', 'topics-custom' );
  261.  
  262. }
  263.  
  264. }
  265.  
  266. // Return contents of output buffer
  267. return $this->end();
  268. }
  269.  
  270. /**
  271. * Display the contents of a specific forum ID in an output buffer
  272. * and return to ensure that post/page contents are displayed first.
  273. *
  274. * @since bbPress (r3031)
  275. *
  276. * @param array $attr
  277. * @param string $content
  278. * @uses bbp_has_topics()
  279. * @uses current_theme_supports()
  280. * @uses get_template_part()
  281. * @uses bbp_single_forum_description()
  282. * @return string
  283. */
  284. public function display_forum( $attr, $content = '' ) {
  285. global $bbp;
  286. global $tumbledata;
  287.  
  288. extract(shortcode_atts( array( 'breadcrumbs' => 'true',
  289. 'recent_topics' => 'true' ), $attr));
  290.  
  291. // Sanity check required info
  292. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) )
  293. return $content;
  294.  
  295. // Set passed attribute to $forum_id for clarity
  296. $forum_id = $attr['id'];
  297.  
  298. // Bail if ID passed is not a forum
  299. if ( !bbp_is_forum( $forum_id ) )
  300. return $content;
  301.  
  302. // Start output buffer
  303. $this->start( 'bbp_single_forum' );
  304.  
  305. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  306.  
  307. if ( $breadcrumbs == 'true' ) {
  308.  
  309. // Get Primary Header
  310. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  311.  
  312. }
  313.  
  314. }
  315.  
  316. // Check forum caps
  317. if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
  318.  
  319. // Before single forum
  320. do_action( 'bbp_template_before_single_forum' );
  321.  
  322. // Password protected
  323. if ( post_password_required() ) {
  324.  
  325. // Output the password form
  326. bbp_get_template_part( 'bbpress/form', 'protected' );
  327.  
  328. // Not password protected, or password is already approved
  329. } else {
  330.  
  331. /** Sub forums ****************************************************/
  332.  
  333. // Check if forum has subforums first
  334. if ( bbp_get_forum_subforum_count( $forum_id ) ) {
  335.  
  336. // Forum query
  337. $forum_query = array( 'post_parent' => $forum_id );
  338.  
  339. // Load the sub forums
  340. if ( bbp_has_forums( $forum_query ) )
  341. bbp_get_template_part( 'bbpress/loop', 'forums' );
  342. }
  343.  
  344. /** Topics ********************************************************/
  345.  
  346. // Skip if forum is a category
  347. if ( !bbp_is_forum_category( $forum_id ) ) {
  348.  
  349. // Unset globals
  350. $this->unset_globals();
  351.  
  352. // Reset necessary forum_query attributes for topics loop to function
  353. $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
  354. $bbp->forum_query->in_the_loop = true;
  355. $bbp->forum_query->post = get_post( $forum_id );
  356.  
  357. // Query defaults
  358. $topics_query = array(
  359. 'author' => 0,
  360. 'post_parent' => $forum_id,
  361. 'show_stickies' => true,
  362. );
  363.  
  364. // Load the topic index
  365. if ( bbp_has_topics( $topics_query ) ) {
  366.  
  367. bbp_get_template_part( 'bbpress/loop', 'topics-wrap' );
  368.  
  369. // No topics
  370. } else {
  371. bbp_get_template_part( 'bbpress/feedback', 'no-topics' );
  372. }
  373.  
  374. bbp_get_template_part( 'bbpress/form', 'topic' );
  375. }
  376.  
  377. // After single forum
  378. do_action( 'bbp_template_after_single_forum' );
  379. }
  380.  
  381. // Forum is private and user does not have caps
  382. } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
  383. bbp_get_template_part( 'bbpress/feedback', 'no-access' );
  384. }
  385.  
  386. // Return contents of output buffer
  387. return $this->end();
  388. }
  389.  
  390. /**
  391. * Display the forum form in an output buffer and return to ensure
  392. * post/page contents are displayed first.
  393. *
  394. * @since bbPress (r3566)
  395. *
  396. * @uses current_theme_supports()
  397. * @uses get_template_part()
  398. */
  399. public function display_forum_form() {
  400.  
  401. // Start output buffer
  402. $this->start( 'bbp_forum_form' );
  403.  
  404. // Output templates
  405. bbp_get_template_part( 'bbpress/form', 'forum' );
  406.  
  407. // Return contents of output buffer
  408. return $this->end();
  409. }
  410.  
  411. /** Topic shortcodes ******************************************************/
  412.  
  413. /**
  414. * Display an index of all visible root level topics in an output buffer
  415. * and return to ensure that post/page contents are displayed first.
  416. *
  417. * @since bbPress (r3031)
  418. *
  419. * @param array $attr
  420. * @param string $content
  421. * @uses bbp_get_hidden_forum_ids()
  422. * @uses bbp_has_topics()
  423. * @uses current_theme_supports()
  424. * @uses get_template_part()
  425. * @return string
  426. */
  427. public function display_topic_index( $attr ) {
  428. global $tumbledata;
  429.  
  430. // Query defaults
  431. $topics_query = array(
  432. 'author' => 0,
  433. 'show_stickies' => true,
  434. 'order' => 'DESC',
  435. );
  436.  
  437. extract(shortcode_atts(array( 'breadcrumbs' => 'true' ), $attr));
  438.  
  439. // Unset globals
  440. $this->unset_globals();
  441.  
  442. // Start output buffer
  443. $this->start( 'bbp_topic_archive' );
  444.  
  445. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  446.  
  447. if ( $breadcrumbs == 'true' ) {
  448.  
  449. // Get Primary Header
  450. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  451.  
  452. }
  453.  
  454. }
  455.  
  456. // Before topics index
  457. do_action( 'bbp_template_before_topics_index' );
  458.  
  459. // Load the topic index
  460. if ( bbp_has_topics( $topics_query ) ) {
  461.  
  462. bbp_get_template_part( 'bbpress/loop', 'topics-wrap' );
  463.  
  464. // No topics
  465. } else {
  466. bbp_get_template_part( 'bbpress/feedback', 'no-topics' );
  467. }
  468.  
  469. // After topics index
  470. do_action( 'bbp_template_after_topics_index' );
  471.  
  472. // Return contents of output buffer
  473. return $this->end();
  474. }
  475.  
  476. /**
  477. * Display the contents of a specific topic ID in an output buffer
  478. * and return to ensure that post/page contents are displayed first.
  479. *
  480. * @since bbPress (r3031)
  481. *
  482. * @global bbPress $bbp
  483. *
  484. * @param array $attr
  485. * @param string $content
  486. * @uses current_theme_supports()
  487. * @uses get_template_part()
  488. * @return string
  489. */
  490. public function display_topic( $attr, $content = '' ) {
  491. global $bbp;
  492. global $tumbledata;
  493.  
  494. // Sanity check required info
  495. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) )
  496. return $content;
  497.  
  498. // Set passed attribute to $forum_id for clarity
  499. $topic_id = $attr['id'];
  500. $forum_id = bbp_get_topic_forum_id( $topic_id );
  501.  
  502. extract(shortcode_atts(array( 'breadcrumbs' => 'true' ), $attr));
  503.  
  504. // Bail if ID passed is not a forum
  505. if ( !bbp_is_topic( $topic_id ) )
  506. return $content;
  507.  
  508. // Setup the meta_query
  509. $replies_query['meta_query'] = array( array(
  510. 'key' => '_bbp_topic_id',
  511. 'value' => $topic_id,
  512. 'compare' => '='
  513. ) );
  514.  
  515. // Unset globals
  516. $this->unset_globals();
  517.  
  518. // Reset the queries if not in theme compat
  519. if ( !bbp_is_theme_compat_active() ) {
  520.  
  521. // Reset necessary forum_query attributes for topics loop to function
  522. $bbp->forum_query->query_vars['post_type'] = bbp_get_forum_post_type();
  523. $bbp->forum_query->in_the_loop = true;
  524. $bbp->forum_query->post = get_post( $forum_id );
  525.  
  526. // Reset necessary topic_query attributes for topics loop to function
  527. $bbp->topic_query->query_vars['post_type'] = bbp_get_topic_post_type();
  528. $bbp->topic_query->in_the_loop = true;
  529. $bbp->topic_query->post = get_post( $topic_id );
  530. }
  531.  
  532. // Start output buffer
  533. $this->start( 'bbp_single_topic' );
  534.  
  535. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  536.  
  537. if ( $breadcrumbs == 'true' ) {
  538.  
  539. // Get Primary Header
  540. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  541.  
  542. }
  543.  
  544. }
  545.  
  546. do_action( 'bbp_template_notices' );
  547.  
  548. // Check forum caps
  549. if ( bbp_user_can_view_forum( array( 'forum_id' => $forum_id ) ) ) {
  550.  
  551. // Before single topic
  552. do_action( 'bbp_template_before_single_topic' );
  553.  
  554. // Password protected
  555. if ( post_password_required() ) {
  556.  
  557. // Output the password form
  558. bbp_get_template_part( 'bbpress/form', 'protected' );
  559.  
  560. // Not password protected, or password is already approved
  561. } else {
  562.  
  563. // Template files
  564. if ( bbp_show_lead_topic() )
  565. bbp_get_template_part( 'bbpress/content', 'single-topic-lead' );
  566.  
  567. // Load the topic
  568. if ( bbp_has_replies( $replies_query ) ) {
  569. bbp_get_template_part( 'bbpress/loop', 'replies' );
  570. }
  571.  
  572. // Reply form
  573. bbp_get_template_part( 'bbpress/form', 'reply' );
  574. }
  575.  
  576. // After single topic
  577. do_action( 'bbp_template_after_single_topic' );
  578.  
  579. // Forum is private and user does not have caps
  580. } elseif ( bbp_is_forum_private( $forum_id, false ) ) {
  581. bbp_get_template_part( 'bbpress/feedback', 'no-access' );
  582. }
  583.  
  584. // Return contents of output buffer
  585. return $this->end();
  586. }
  587.  
  588. /**
  589. * Display the topic form in an output buffer and return to ensure
  590. * post/page contents are displayed first.
  591. *
  592. * @since bbPress (r3031)
  593. *
  594. * @uses current_theme_supports()
  595. * @uses get_template_part()
  596. */
  597. public function display_topic_form() {
  598.  
  599. // Start output buffer
  600. $this->start( 'bbp_topic_form' );
  601.  
  602. // Output templates
  603. bbp_get_template_part( 'bbpress/form', 'topic' );
  604.  
  605. // Return contents of output buffer
  606. return $this->end();
  607. }
  608.  
  609. /** Replies ***************************************************************/
  610.  
  611. /**
  612. * Display the reply form in an output buffer and return to ensure
  613. * post/page contents are displayed first.
  614. *
  615. * @since bbPress (r3031)
  616. *
  617. * @uses current_theme_supports()
  618. * @uses get_template_part()
  619. */
  620. public function display_reply_form() {
  621.  
  622. // Start output buffer
  623. $this->start( 'bbp_reply_form' );
  624.  
  625. // Output templates
  626. bbp_get_template_part( 'bbpress/form', 'reply' );
  627.  
  628. // Return contents of output buffer
  629. return $this->end();
  630. }
  631.  
  632. /** Topic Tags ************************************************************/
  633.  
  634. /**
  635. * Display a tag cloud of all topic tags in an output buffer and return to
  636. * ensure that post/page contents are displayed first.
  637. *
  638. * @since bbPress (r3110)
  639. *
  640. * @return string
  641. */
  642. public function display_topic_tags() {
  643.  
  644. // Unset globals
  645. $this->unset_globals();
  646.  
  647. // Start output buffer
  648. $this->start( 'bbp_topic_tags' );
  649.  
  650. // Output the topic tags
  651. wp_tag_cloud( array(
  652. 'smallest' => 9,
  653. 'largest' => 38,
  654. 'number' => 80,
  655. 'taxonomy' => bbp_get_topic_tag_tax_id()
  656. ) );
  657.  
  658. // Return contents of output buffer
  659. return $this->end();
  660. }
  661.  
  662. /**
  663. * Display the contents of a specific topic tag in an output buffer
  664. * and return to ensure that post/page contents are displayed first.
  665. *
  666. * @since bbPress (r3110)
  667. *
  668. * @param array $attr
  669. * @param string $content
  670. * @uses current_theme_supports()
  671. * @uses get_template_part()
  672. * @return string
  673. */
  674. public function display_topics_of_tag( $attr, $content = '' ) {
  675. global $tumbledata;
  676.  
  677. // Sanity check required info
  678. if ( !empty( $content ) || ( empty( $attr['id'] ) || !is_numeric( $attr['id'] ) ) )
  679. return $content;
  680.  
  681. // Set passed attribute to $ag_id for clarity
  682. $tag_id = $attr['id'];
  683.  
  684. // Setup tax query
  685. $args = array( 'tax_query' => array( array(
  686. 'taxonomy' => bbp_get_topic_tag_tax_id(),
  687. 'field' => 'id',
  688. 'terms' => $tag_id
  689. ) ) );
  690.  
  691. // Unset globals
  692. $this->unset_globals();
  693.  
  694. // Start output buffer
  695. $this->start( 'bbp_topics_of_tag' );
  696.  
  697. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  698.  
  699. // Get Primary Header
  700. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  701.  
  702. }
  703.  
  704. // Before tag topics
  705. do_action( 'bbp_template_before_topic_tag' );
  706.  
  707. // Load the topics
  708. if ( bbp_has_topics( $args ) ) {
  709.  
  710. bbp_get_template_part( 'bbpress/loop', 'topics-wrap' );
  711.  
  712. // No topics
  713. } else {
  714. bbp_get_template_part( 'bbpress/feedback', 'no-topics' );
  715. }
  716.  
  717. // After tag topics
  718. do_action( 'bbp_template_after_topic_tag' );
  719.  
  720. // Return contents of output buffer
  721. return $this->end();
  722. }
  723.  
  724. /**
  725. * Display the contents of a specific topic tag in an output buffer
  726. * and return to ensure that post/page contents are displayed first.
  727. *
  728. * @since bbPress (r3346)
  729. *
  730. * @param array $attr
  731. * @param string $content
  732. * @uses current_theme_supports()
  733. * @uses get_template_part()
  734. * @return string
  735. */
  736. public function display_topic_tag_form() {
  737. global $tumbledata;
  738.  
  739. // Unset globals
  740. $this->unset_globals();
  741.  
  742. // Start output buffer
  743. $this->start( 'bbp_topic_tag_edit' );
  744.  
  745. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  746.  
  747. // Get Primary Header
  748. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  749.  
  750. }
  751.  
  752. // Before tag topics
  753. do_action( 'bbp_template_before_topic_tag_edit' );
  754.  
  755. // Tag editing form
  756. bbp_get_template_part( 'bbpress/form', 'topic-tag' );
  757.  
  758. // After tag topics
  759. do_action( 'bbp_template_after_topic_tag_edit' );
  760.  
  761. // Return contents of output buffer
  762. return $this->end();
  763. }
  764.  
  765. /** Views *****************************************************************/
  766.  
  767. /**
  768. * Display the contents of a specific view in an output buffer and return to
  769. * ensure that post/page contents are displayed first.
  770. *
  771. * @since bbPress (r3031)
  772. *
  773. * @param array $attr
  774. * @param string $content
  775. * @uses bbp_has_topics()
  776. * @uses current_theme_supports()
  777. * @uses get_template_part()
  778. * @uses bbp_single_forum_description()
  779. * @return string
  780. */
  781. public function display_view( $attr, $content = '' ) {
  782. global $bbp;
  783. global $tumbledata;
  784.  
  785. // Sanity check required info
  786. if ( empty( $attr['id'] ) )
  787. return $content;
  788.  
  789. // Set passed attribute to $view_id for clarity
  790. $view_id = $attr['id'];
  791.  
  792. // Start output buffer
  793. $this->start( 'bbp_single_view' );
  794.  
  795. if($tumbledata['activate_breadcrumbs_block'] == 1) {
  796.  
  797. // Get Primary Header
  798. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  799.  
  800. }
  801.  
  802. // Password protected
  803. if ( post_password_required() ) {
  804.  
  805. // Output the password form
  806. bbp_get_template_part( 'bbpress/form', 'protected' );
  807.  
  808. // Not password protected, or password is already approved
  809. } else {
  810.  
  811. /** Topics ********************************************************/
  812.  
  813. // Unset globals
  814. $this->unset_globals();
  815.  
  816. // Load the topic index
  817. if ( bbp_view_query( $view_id ) ) {
  818.  
  819. bbp_get_template_part( 'bbpress/loop', 'topics-wrap' );
  820.  
  821. // No topics
  822. } else {
  823. bbp_get_template_part( 'bbpress/feedback', 'no-topics' );
  824. }
  825. }
  826.  
  827. // Return contents of output buffer
  828. return $this->end();
  829. }
  830.  
  831. /** Account ***************************************************************/
  832.  
  833. /**
  834. * Display a login form
  835. *
  836. * @since bbPress (r3302)
  837. *
  838. * @return string
  839. */
  840. public function display_login() {
  841.  
  842. // Unset globals
  843. $this->unset_globals();
  844.  
  845. // Start output buffer
  846. $this->start( 'bbp_login' );
  847.  
  848. // Output templates
  849. if ( !is_user_logged_in() )
  850. bbp_get_template_part( 'bbpress/form', 'user-login' );
  851. else
  852. bbp_get_template_part( 'bbpress/feedback', 'logged-in' );
  853.  
  854. // Return contents of output buffer
  855. return $this->end();
  856. }
  857.  
  858. /**
  859. * Display a register form
  860. *
  861. * @since bbPress (r3302)
  862. *
  863. * @return string
  864. */
  865. public function display_register() {
  866.  
  867. // Unset globals
  868. $this->unset_globals();
  869.  
  870. // Start output buffer
  871. $this->start( 'bbp_register' );
  872.  
  873. // Get Primary Header
  874. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  875.  
  876. // Output templates
  877. if ( !is_user_logged_in() )
  878. bbp_get_template_part( 'bbpress/form', 'user-register' );
  879. else
  880. bbp_get_template_part( 'bbpress/feedback', 'logged-in' );
  881.  
  882. // Return contents of output buffer
  883. return $this->end();
  884. }
  885.  
  886. /**
  887. * Display a lost password form
  888. *
  889. * @since bbPress (r3302)
  890. *
  891. * @return string
  892. */
  893. public function display_lost_pass() {
  894.  
  895. // Unset globals
  896. $this->unset_globals();
  897.  
  898. // Start output buffer
  899. $this->start( 'bbp_lost_pass' );
  900.  
  901. // Get Primary Header
  902. bbp_get_template_part( 'bbpress/content', 'forum-header' );
  903.  
  904. // Output templates
  905. if ( !is_user_logged_in() )
  906. bbp_get_template_part( 'bbpress/form', 'user-lost-pass' );
  907. else
  908. bbp_get_template_part( 'bbpress/feedback', 'logged-in' );
  909.  
  910. // Return contents of output buffer
  911. return $this->end();
  912. }
  913.  
  914. /** Other *****************************************************************/
  915.  
  916. /**
  917. * Display a breadcrumb
  918. *
  919. * @since bbPress (r3302)
  920. *
  921. * @return string
  922. */
  923. public function display_breadcrumb() {
  924.  
  925. // Unset globals
  926. $this->unset_globals();
  927.  
  928. // Start output buffer
  929. $this->ob_start();
  930.  
  931. // Output breadcrumb
  932. bbp_breadcrumb();
  933.  
  934. // Return contents of output buffer
  935. return $this->end();
  936. }
  937. }
  938. endif;
  939.  
  940. /*---------------------------------------------------------------------------------*/
  941. /* Register tumbleboard shortcodes replaces bbp-shortcdes
  942. /*---------------------------------------------------------------------------------*/
  943.  
  944. function wptumble_register_shortcodes() {
  945.  
  946. global $bbp;
  947.  
  948. // Bail if bbPress is not loaded
  949. if ( 'bbPress' !== get_class( $bbp ) ) return;
  950.  
  951. $bbp->shortcodes = new BBP_Shortcodes();
  952.  
  953. }
  954.  
  955. add_action('bbp_loaded','wptumble_actions_modification');
  956.  
  957. function wptumble_actions_modification() {
  958.  
  959. remove_action('bbp_init', 'bbp_register_shortcodes', 18);
  960. add_action('bbp_init', 'wptumble_register_shortcodes', 19);
  961.  
  962. }
  963. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement