Skip to:
Content

bbPress.org

Changeset 3167


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.

Location:
branches/plugin/bbp-includes
Files:
2 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
  • branches/plugin/bbp-includes/bbp-general-template.php

    r3132 r3167  
    20612061        global $bbp;
    20622062
     2063        // Prevent debug notice
     2064        $new_content = '';
     2065
    20632066        // Remove the filter that was added in bbp_template_include()
    20642067        remove_filter( 'the_content', 'bbp_replace_the_content', 99999 );
     
    21312134
    21322135        } elseif ( bbp_is_view() ) {
    2133 
     2136            $new_content = $bbp->shortcodes->display_view( array( 'id' => get_query_var( 'bbp_view' ) ) );
    21342137
    21352138        /** Topic Tags ********************************************************/
     
    21632166
    21642167        // Juggle the content around and try to prevent unsightly comments
    2165         if ( $new_content != $content ) {
     2168        if ( !empty( $new_content ) && ( $new_content != $content ) ) {
    21662169
    21672170            // Set the content to be the new content
Note: See TracChangeset for help on using the changeset viewer.