Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/16/2011 08:02:09 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Add single view shortcode, and add single views to theme compatibility. Fix issue with theme compat where error could occur if output buffer content was somehow empty.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-core-shortcodes.php

    r3160 r3167  
    9494
    9595            // Reply form
    96             'bbp-reply-form' => array( $this, 'display_reply_form'    )
     96            'bbp-reply-form' => array( $this, 'display_reply_form'    ),
     97
     98            /** Views *********************************************************/
     99
     100            // Single view
     101            'bbp-single-view' => array( $this, 'display_view'         )
     102
    97103        ) );
    98104    }
     
    595601        } else {
    596602            bbp_get_template_part( 'bbpress/no', 'topics' );
     603        }
     604
     605        // Return contents of output buffer
     606        return $this->_ob_end();
     607    }
     608
     609    /** Views *****************************************************************/
     610
     611    /**
     612     * Display the contents of a specific view in an output buffer and return to
     613     * ensure that post/page contents are displayed first.
     614     *
     615     * @since bbPress (r3031)
     616     *
     617     * @param array $attr
     618     * @param string $content
     619     * @uses bbp_has_topics()
     620     * @uses current_theme_supports()
     621     * @uses get_template_part()
     622     * @uses bbp_single_forum_description()
     623     * @return string
     624     */
     625    function display_view( $attr, $content = '' ) {
     626        global $bbp;
     627
     628        // Sanity check required info
     629        if ( empty( $attr['id'] ) )
     630            return $content;
     631
     632        // Set passed attribute to $view_id for clarity
     633        $view_id = $attr['id'];
     634
     635        // Start output buffer
     636        $this->_ob_start();
     637
     638        // Display breadcrumb if a subforum
     639        bbp_get_template_part( 'bbpress/nav', 'breadcrumb' );
     640
     641        // Password protected
     642        if ( post_password_required() ) {
     643
     644            // Output the password form
     645            bbp_get_template_part( 'bbpress/form', 'protected' );
     646
     647        // Not password protected, or password is already approved
     648        } else {
     649
     650            /** Topics ********************************************************/
     651
     652            // Unset globals
     653            $this->_unset_globals();
     654
     655            // Load the topic index
     656            if ( bbp_view_query( $view_id ) ) {
     657                bbp_get_template_part( 'bbpress/pagination', 'topics' );
     658                bbp_get_template_part( 'bbpress/loop',       'topics' );
     659                bbp_get_template_part( 'bbpress/pagination', 'topics' );
     660                bbp_get_template_part( 'bbpress/form',       'topic'  );
     661
     662            // No topics
     663            } else {
     664                bbp_get_template_part( 'bbpress/no',   'topics' );
     665                bbp_get_template_part( 'bbpress/form', 'topic'  );
     666            }
    597667        }
    598668
Note: See TracChangeset for help on using the changeset viewer.