Skip to:
Content

BuddyPress.org

Changeset 7347


Ignore:
Timestamp:
08/12/2013 10:30:52 PM (13 years ago)
Author:
johnjamesjacoby
Message:

Audit loader classes, and remove $bp global touches in lieu of using the buddypress() function. Also some whitespace clean-up.

Location:
trunk
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-activity/bp-activity-loader.php

    r7277 r7347  
    5353                // Load Akismet support if Akismet is configured
    5454                $akismet_key = bp_get_option( 'wordpress_api_key' );
    55                 if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) )
     55                if ( defined( 'AKISMET_VERSION' ) && ( !empty( $akismet_key ) || defined( 'WPCOM_API_KEY' ) ) && apply_filters( 'bp_activity_use_akismet', bp_is_akismet_active() ) ) {
    5656                        $includes[] = 'akismet';
    57 
    58                 if ( is_admin() )
     57                }
     58
     59                if ( is_admin() ) {
    5960                        $includes[] = 'admin';
     61                }
    6062
    6163                parent::includes( $includes );
    … …  
    6971         *
    7072         * @since BuddyPress (1.5)
    71          *
    72          * @global object $bp BuddyPress global settings
    7373         */
    7474        public function setup_globals( $args = array() ) {
    75                 global $bp;
     75                $bp = buddypress();
    7676
    7777                // Define a slug, if necessary
    … …  
    8787                // All globals for activity component.
    8888                // Note that global_tables is included in this array.
    89                 $globals = array(
     89                $args = array(
    9090                        'slug'                  => BP_ACTIVITY_SLUG,
    9191                        'root_slug'             => isset( $bp->pages->activity->slug ) ? $bp->pages->activity->slug : BP_ACTIVITY_SLUG,
    … …  
    9696                );
    9797
    98                 parent::setup_globals( $globals );
     98                parent::setup_globals( $args );
    9999        }
    100100
    … …  
    111111         */
    112112        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    113 
    114                 $sub_nav = array();
    115113
    116114                // Add 'Activity' to the main navigation
    … …  
    218216         */
    219217        public function setup_admin_bar( $wp_admin_nav = array() ) {
    220                 global $bp;
    221 
    222                 // Prevent debug notices
    223                 $wp_admin_nav = array();
     218                $bp = buddypress();
    224219
    225220                // Menus for logged in user
    … …  
    309304         */
    310305        function setup_title() {
    311                 global $bp;
     306                $bp = buddypress();
    312307
    313308                // Adjust title based on view
    … …  
    342337
    343338function bp_setup_activity() {
    344         global $bp;
    345 
    346         $bp->activity = new BP_Activity_Component();
     339        buddypress()->activity = new BP_Activity_Component();
    347340}
    348341add_action( 'bp_setup_components', 'bp_setup_activity', 6 );
  • trunk/bp-blogs/bp-blogs-loader.php

    r7277 r7347  
    3535         *
    3636         * @since BuddyPress (1.5)
    37          * @global BuddyPress $bp The one true BuddyPress instance
    3837         */
    3938        public function setup_globals( $args = array() ) {
    40                 global $bp;
     39                $bp = buddypress();
    4140
    4241                if ( !defined( 'BP_BLOGS_SLUG' ) )
    … …  
    5150                // All globals for messaging component.
    5251                // Note that global_tables is included in this array.
    53                 $globals = array(
     52                $args = array(
    5453                        'slug'                  => BP_BLOGS_SLUG,
    5554                        'root_slug'             => isset( $bp->pages->blogs->slug ) ? $bp->pages->blogs->slug : BP_BLOGS_SLUG,
    … …  
    6261
    6362                // Setup the globals
    64                 parent::setup_globals( $globals );
     63                parent::setup_globals( $args );
    6564        }
    6665
    … …  
    9190        /**
    9291         * Setup BuddyBar navigation
    93          *
    94          * @global BuddyPress $bp The one true BuddyPress instance
    9592         */
    9693        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    97                 global $bp;
     94                $bp = buddypress();
    9895
    9996                /**
    … …  
    104101                if ( !is_multisite() )
    105102                        return false;
    106 
    107                 $sub_nav = array();
    108103
    109104                // Add 'Sites' to the main navigation
    … …  
    147142         */
    148143        public function setup_admin_bar( $wp_admin_nav = array() ) {
    149                 global $bp;
     144                $bp = buddypress();
    150145
    151146                /**
    … …  
    156151                if ( !is_multisite() )
    157152                        return false;
    158 
    159                 // Prevent debug notices
    160                 $wp_admin_nav = array();
    161153
    162154                // Menus for logged in user
    … …  
    197189        /**
    198190         * Sets up the title for pages and <title>
    199          *
    200          * @global BuddyPress $bp The one true BuddyPress instance
    201191         */
    202192        function setup_title() {
    203                 global $bp;
     193                $bp = buddypress();
    204194
    205195                // Set up the component options navigation for Blog
    … …  
    227217
    228218function bp_setup_blogs() {
    229         global $bp;
    230         $bp->blogs = new BP_Blogs_Component();
     219        buddypress()->blogs = new BP_Blogs_Component();
    231220}
    232221add_action( 'bp_setup_components', 'bp_setup_blogs', 6 );
  • trunk/bp-core/bp-core-loader.php

    r7277 r7347  
    3939         *
    4040         * @since BuddyPress (1.5)
    41          *
    42          * @global BuddyPress $bp
    4341         */
    4442        private function bootstrap() {
    45                 global $bp;
     43                $bp = buddypress();
    4644
    4745                /**
    … …  
    128126         *
    129127         * @since BuddyPress (1.5)
    130          *
    131          * @global BuddyPress $bp
    132128         */
    133129        public function setup_globals( $args = array() ) {
    134                 global $bp;
     130                $bp = buddypress();
    135131
    136132                /** Database **********************************************************/
    … …  
    192188         *
    193189         * @since BuddyPress (1.5)
    194          *
    195          * @global BuddyPress $bp
    196190         */
    197191        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    198                 global $bp;
     192                $bp = buddypress();
    199193
    200194                 // If xprofile component is disabled, revert to WordPress profile
    201195                if ( !bp_is_active( 'xprofile' ) ) {
    202 
    203                         // Define local variable
    204                         $sub_nav = array();
    205196
    206197                        // Fallback values if xprofile is disabled
    … …  
    244235 */
    245236function bp_setup_core() {
    246         global $bp;
    247         $bp->core = new BP_Core();
     237        buddypress()->core = new BP_Core();
    248238}
    249239add_action( 'bp_setup_components', 'bp_setup_core', 2 );
  • trunk/bp-forums/bp-forums-loader.php

    r7277 r7347  
    156156         */
    157157        public function setup_admin_bar( $wp_admin_nav = array() ) {
    158 
    159                 // Prevent debug notices
    160                 $wp_admin_nav = array();
    161158
    162159                // Menus for logged in user
  • trunk/bp-friends/bp-friends-loader.php

    r7277 r7347  
    3131         */
    3232        public function includes( $includes = array() ) {
    33                 // Files to include
    3433                $includes = array(
    3534                        'actions',
    … …  
    5352         *
    5453         * @since BuddyPress (1.5)
    55          * @global BuddyPress $bp The one true BuddyPress instance
    5654         */
    5755        public function setup_globals( $args = array() ) {
    58                 global $bp;
     56                $bp = buddypress();
    5957
    6058                define ( 'BP_FRIENDS_DB_VERSION', '1800' );
    … …  
    7270                // All globals for the friends component.
    7371                // Note that global_tables is included in this array.
    74                 $globals = array(
     72                $args = array(
    7573                        'slug'                  => BP_FRIENDS_SLUG,
    7674                        'has_directory'         => false,
    … …  
    8078                );
    8179
    82                 parent::setup_globals( $globals );
     80                parent::setup_globals( $args );
    8381        }
    8482
    8583        /**
    8684         * Setup BuddyBar navigation
    87          *
    88          * @global BuddyPress $bp The one true BuddyPress instance
    8985         */
    9086        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    91                 global $bp;
    92 
    93                 $sub_nav = array();
     87                $bp = buddypress();
    9488
    9589                // Add 'Friends' to the main navigation
    … …  
    140134        /**
    141135         * Set up the Toolbar
    142          *
    143          * @global BuddyPress $bp The one true BuddyPress instance
    144136         */
    145137        public function setup_admin_bar( $wp_admin_nav = array() ) {
    146                 global $bp;
    147 
    148                 // Prevent debug notices
    149                 $wp_admin_nav = array();
     138                $bp = buddypress();
    150139
    151140                // Menus for logged in user
    … …  
    196185        /**
    197186         * Sets up the title for pages and <title>
    198          *
    199          * @global BuddyPress $bp The one true BuddyPress instance
    200187         */
    201188        function setup_title() {
    202                 global $bp;
     189                $bp = buddypress();
    203190
    204191                // Adjust title
    … …  
    221208
    222209function bp_setup_friends() {
    223         global $bp;
    224         $bp->friends = new BP_Friends_Component();
     210        buddypress()->friends = new BP_Friends_Component();
    225211}
    226212add_action( 'bp_setup_components', 'bp_setup_friends', 6 );
  • trunk/bp-groups/bp-groups-loader.php

    r7277 r7347  
    119119         *
    120120         * @since BuddyPress (1.5)
    121          * @global BuddyPress $bp The one true BuddyPress instance
    122121         */
    123122        public function setup_globals( $args = array() ) {
    124                 global $bp;
     123                $bp = buddypress();
    125124
    126125                // Define a slug, if necessary
    … …  
    137136                // All globals for groups component.
    138137                // Note that global_tables is included in this array.
    139                 $globals = array(
     138                $args = array(
    140139                        'slug'                  => BP_GROUPS_SLUG,
    141140                        'root_slug'             => isset( $bp->pages->groups->slug ) ? $bp->pages->groups->slug : BP_GROUPS_SLUG,
    … …  
    146145                );
    147146
    148                 parent::setup_globals( $globals );
     147                parent::setup_globals( $args );
    149148
    150149                /** Single Group Globals **********************************************/
    … …  
    339338        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    340339
    341                 // Define local variables
    342                 $sub_nav = array();
    343 
    344340                // Add 'Groups' to the main navigation
    345341                $main_nav = array(
    … …  
    489485                }
    490486
    491                 if ( isset( $this->current_group->user_has_access ) )
     487                if ( isset( $this->current_group->user_has_access ) ) {
    492488                        do_action( 'groups_setup_nav', $this->current_group->user_has_access );
    493                 else
     489                } else {
    494490                        do_action( 'groups_setup_nav');
     491                }
    495492        }
    496493
    497494        /**
    498495         * Set up the Toolbar
    499          *
    500          * @global BuddyPress $bp The one true BuddyPress instance
    501496         */
    502497        public function setup_admin_bar( $wp_admin_nav = array() ) {
    503                 global $bp;
    504 
    505                 // Prevent debug notices
    506                 $wp_admin_nav = array();
     498                $bp = buddypress();
    507499
    508500                // Menus for logged in user
    … …  
    563555        /**
    564556         * Sets up the title for pages and <title>
    565          *
    566          * @global BuddyPress $bp The one true BuddyPress instance
    567557         */
    568558        function setup_title() {
    569                 global $bp;
     559                $bp = buddypress();
    570560
    571561                if ( bp_is_groups_component() ) {
    572562
    573563                        if ( bp_is_my_profile() && !bp_is_single_item() ) {
    574 
    575564                                $bp->bp_options_title = __( 'Memberships', 'buddypress' );
    576565
    577566                        } else if ( !bp_is_my_profile() && !bp_is_single_item() ) {
    578 
    579567                                $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    580568                                        'item_id' => bp_displayed_user_id(),
    … …  
    595583                                        'alt'        => __( 'Group Avatar', 'buddypress' )
    596584                                ) );
     585
    597586                                if ( empty( $bp->bp_options_avatar ) ) {
    598                                         $bp->bp_options_avatar = '<img src="' . esc_attr( $group->avatar_full ) . '" class="avatar" alt="' . esc_attr( $group->name ) . '" />';
     587                                        $bp->bp_options_avatar = bp_group_current_avatar();
    599588                                }
    600589                        }
    … …  
    607596
    608597function bp_setup_groups() {
    609         global $bp;
    610 
    611         $bp->groups = new BP_Groups_Component();
     598        buddypress()->groups = new BP_Groups_Component();
    612599}
    613600add_action( 'bp_setup_components', 'bp_setup_groups', 6 );
  • trunk/bp-members/bp-members-loader.php

    r7277 r7347  
    5353         *
    5454         * @since BuddyPress (1.5)
    55          * @global BuddyPress $bp The one true BuddyPress instance
    5655         */
    5756        public function setup_globals( $args = array() ) {
    58                 global $bp;
     57                $bp = buddypress();
    5958
    6059                // Define a slug, if necessary
    … …  
    6261                        define( 'BP_MEMBERS_SLUG', $this->id );
    6362
    64                 $globals = array(
     63                parent::setup_globals( array(
    6564                        'slug'          => BP_MEMBERS_SLUG,
    6665                        'root_slug'     => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
    6766                        'has_directory' => true,
    6867                        'search_string' => __( 'Search Members...', 'buddypress' ),
    69                 );
    70 
    71                 parent::setup_globals( $globals );
     68                ) );
    7269
    7370                /** Logged in user ****************************************************/
    … …  
    105102
    106103                /** Default Profile Component *****************************************/
     104
    107105                if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
    108                         if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) )
     106                        if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
    109107                                $bp->default_component = bp_get_activity_slug();
    110                         else
    111                                 $bp->default_component = ( 'xprofile' == $bp->profile->id ) ? 'profile' : $bp->profile->id;
     108                        } else {
     109                                $bp->default_component = ( 'xprofile' === $bp->profile->id ) ? 'profile' : $bp->profile->id;
     110                        }
    112111
    113112                } else {
    … …  
    141140        /**
    142141         * Setup BuddyBar navigation
    143          *
    144          * @global BuddyPress $bp The one true BuddyPress instance
    145142         */
    146143        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    147                 global $bp;
     144                $bp = buddypress();
    148145
    149146                // Add 'Profile' to the main navigation
    … …  
    151148
    152149                        // Don't set up navigation if there's no user
    153                         if ( !is_user_logged_in() && !bp_is_user() )
     150                        if ( !is_user_logged_in() && !bp_is_user() ) {
    154151                                return;
    155 
    156                         $sub_nav  = array();
     152                        }
     153
    157154                        $main_nav = array(
    158155                                'name'                => __( 'Profile', 'buddypress' ),
    … …  
    165162
    166163                        // User links
    167                         $user_domain   = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
    168                         $profile_link  = trailingslashit( $user_domain . $bp->profile->slug );
     164                        $user_domain  = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
     165                        $profile_link = trailingslashit( $user_domain . $bp->profile->slug );
    169166
    170167                        // Add the subnav items to the profile
    … …  
    188185         */
    189186        function setup_title() {
    190                 global $bp;
     187                $bp = buddypress();
    191188
    192189                if ( bp_is_my_profile() ) {
    … …  
    206203
    207204function bp_setup_members() {
    208         global $bp;
    209         $bp->members = new BP_Members_Component();
     205        buddypress()->members = new BP_Members_Component();
    210206}
    211207add_action( 'bp_setup_components', 'bp_setup_members', 1 );
  • trunk/bp-messages/bp-messages-loader.php

    r7277 r7347  
    4040         */
    4141        public function includes( $includes = array() ) {
     42
    4243                // Files to include
    4344                $includes = array(
    … …  
    6364         *
    6465         * @since BuddyPress (1.5)
    65          * @global BuddyPress $bp The one true BuddyPress instance
    6666         */
    6767        public function setup_globals( $args = array() ) {
    68                 global $bp;
     68                $bp = buddypress();
    6969
    7070                // Define a slug, if necessary
    … …  
    9696        /**
    9797         * Setup BuddyBar navigation
    98          *
    99          * @global BuddyPress $bp The one true BuddyPress instance
    10098         */
    10199        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    102100
    103                 $sub_nav = array();
    104                 $name    = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
     101                $name = sprintf( __( 'Messages <span>%s</span>', 'buddypress' ), bp_get_total_unread_messages_count() );
    105102
    106103                // Add 'Messages' to the main navigation
    … …  
    175172        /**
    176173         * Set up the Toolbar
    177          *
    178          * @global BuddyPress $bp The one true BuddyPress instance
    179174         */
    180175        public function setup_admin_bar( $wp_admin_nav = array() ) {
    181                 global $bp;
    182 
    183                 // Prevent debug notices
    184                 $wp_admin_nav = array();
     176                $bp = buddypress();
    185177
    186178                // Menus for logged in user
    … …  
    249241        /**
    250242         * Sets up the title for pages and <title>
    251          *
    252          * @global BuddyPress $bp The one true BuddyPress instance
    253243         */
    254244        function setup_title() {
    255                 global $bp;
     245                $bp = buddypress();
    256246
    257247                if ( bp_is_messages_component() ) {
    … …  
    273263
    274264function bp_setup_messages() {
    275         global $bp;
    276         $bp->messages = new BP_Messages_Component();
     265        buddypress()->messages = new BP_Messages_Component();
    277266}
    278267add_action( 'bp_setup_components', 'bp_setup_messages', 6 );
  • trunk/bp-settings/bp-settings-loader.php

    r7289 r7347  
    6565         */
    6666        public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
    67 
    68                 // Define local variable
    69                 $sub_nav = array();
    7067
    7168                // Add the settings navigation item
    … …  
    149146                $bp = buddypress();
    150147
    151                 // Prevent debug notices
    152                 $wp_admin_nav = array();
    153 
    154148                // Menus for logged in user
    155149                if ( is_user_logged_in() ) {
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r7228 r7347  
    773773 * AJAX spam an activity item or comment
    774774 *
    775  * @global BuddyPress $bp The one true BuddyPress instance
    776775 * @return mixed String on error, void on success
    777776 * @since BuddyPress (1.6)
    778777 */
    779778function bp_legacy_theme_spam_activity() {
    780         global $bp;
     779        $bp = buddypress();
    781780
    782781        // Bail if not a POST action
    … …  
    12401239 * AJAX handler for autocomplete. Displays friends only, unless BP_MESSAGES_AUTOCOMPLETE_ALL is defined.
    12411240 *
    1242  * @global BuddyPress $bp The one true BuddyPress instance
    12431241 * @return string HTML
    12441242 * @since BuddyPress (1.2)
  • trunk/bp-xprofile/bp-xprofile-loader.php

    r7277 r7347  
    7575         *
    7676         * @since BuddyPress (1.5)
    77          * @global BuddyPress $bp The one true BuddyPress instance
    7877         */
    7978        public function setup_globals( $args = array() ) {
    80                 global $bp;
     79                $bp = buddypress();
    8180
    8281                // Define a slug, if necessary
    … …  
    208207        /**
    209208         * Set up the Toolbar
    210          *
    211          * @global BuddyPress $bp The one true BuddyPress instance
    212209         */
    213210        public function setup_admin_bar( $wp_admin_nav = array() ) {
    214                 global $bp;
     211                $bp = buddypress();
    215212
    216213                // Prevent debug notices
    … …  
    262259        /**
    263260         * Sets up the title for pages and <title>
    264          *
    265          * @global BuddyPress $bp The one true BuddyPress instance
    266261         */
    267262        function setup_title() {
    268                 global $bp;
     263                $bp = buddypress();
    269264
    270265                if ( bp_is_profile_component() ) {
    … …  
    286281
    287282function bp_setup_xprofile() {
    288         global $bp;
     283        $bp = buddypress();
    289284
    290285        if ( !isset( $bp->profile->id ) )
Note: See TracChangeset for help on using the changeset viewer.