Skip to:
Content

bbPress.org


Ignore:
Timestamp:
02/25/2012 08:50:27 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Turn bbPress into a singleton.

  • Introduce bbpress() function to get the bbPress instance
  • Replace all $bbp global references with calls to bbpress()
  • Update bbPress class with matching singleton private static $instance variable and public static method
  • Fixes #1759.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-forum-template.php

    r3737 r3758  
    3232     */
    3333    function bbp_get_forum_post_type() {
    34         global $bbp;
    35 
    36         return apply_filters( 'bbp_get_forum_post_type', $bbp->forum_post_type );
     34        return apply_filters( 'bbp_get_forum_post_type', bbpress()->forum_post_type );
    3735    }
    3836
     
    5957 */
    6058function bbp_has_forums( $args = '' ) {
    61     global $bbp;
     59    $bbp = bbpress();
    6260
    6361    // Setup possible post__not_in array
     
    115113 */
    116114function bbp_forums() {
    117     global $bbp;
    118115
    119116    // Put into variable to check against next
    120     $have_posts = $bbp->forum_query->have_posts();
     117    $have_posts = bbpress()->forum_query->have_posts();
    121118
    122119    // Reset the post data when finished
     
    136133 */
    137134function bbp_the_forum() {
    138     global $bbp;
    139     return $bbp->forum_query->the_post();
     135    return bbpress()->forum_query->the_post();
    140136}
    141137
     
    171167     */
    172168    function bbp_get_forum_id( $forum_id = 0 ) {
    173         global $bbp, $wp_query;
     169        global $wp_query;
     170
     171        $bbp = bbpress();
    174172
    175173        // Easy empty checking
     
    329327     * @since bbPress (r3249)
    330328     *
    331      * @global bbPress $bbp The main bbPress class
    332329     * @param string $title Default text to use as title
    333330     *
     
    342339     */
    343340    function bbp_get_forum_archive_title( $title = '' ) {
    344         global $bbp;
    345341
    346342        // If no title was passed
     
    348344
    349345            // Set root text to page title
    350             $page = bbp_get_page_by_path( $bbp->root_slug );
     346            $page = bbp_get_page_by_path( bbpress()->root_slug );
    351347            if ( !empty( $page ) ) {
    352348                $title = get_the_title( $page->ID );
     
    17591755     */
    17601756    function bbp_get_forum_class( $forum_id = 0 ) {
    1761         global $bbp;
    1762 
     1757        $bbp       = bbpress();
    17631758        $forum_id  = bbp_get_forum_id( $forum_id );
    17641759        $count     = isset( $bbp->forum_query->current_post ) ? $bbp->forum_query->current_post : 1;
     
    20522047     */
    20532048    function bbp_get_form_forum_visibility() {
    2054         global $bbp;
    20552049
    20562050        // Get _POST data
     
    20642058        // No data
    20652059        else
    2066             $forum_visibility = $bbp->public_status_id;
     2060            $forum_visibility = bbpress()->public_status_id;
    20672061
    20682062        return apply_filters( 'bbp_get_form_forum_visibility', esc_attr( $forum_visibility ) );
Note: See TracChangeset for help on using the changeset viewer.