Skip to:
Content

BuddyPress.org

Changeset 5758


Ignore:
Timestamp:
02/13/2012 05:46:52 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Clean up $bp->current_component, $bp->current_action, and $bp->current_item usage. Fixes #3738.

Location:
trunk
Files:
9 edited

Legend:

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

    r5705 r5758  
    191191                return false;
    192192
    193         if ( empty( $bp->current_action ) || !is_numeric( $bp->current_action ) )
     193        if ( ! bp_current_action() || !is_numeric( bp_current_action() ) )
    194194                return false;
    195195
     
    248248                is_user_logged_in() ?
    249249                        bp_core_redirect( bp_loggedin_user_domain() ) :
    250                         bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . $bp->current_action . '/' ) ) );
     250                        bp_core_redirect( site_url( 'wp-login.php?redirect_to=' . esc_url( bp_get_root_domain() . '/' . bp_get_activity_root_slug() . '/p/' . bp_current_action() . '/' ) ) );
    251251        }
    252252
     
    260260 * @since 1.2.0
    261261 *
    262  * @global object $bp BuddyPress global settings
    263262 * @uses bp_get_user_meta()
    264263 * @uses bp_core_get_username()
     
    266265 */
    267266function bp_activity_screen_notification_settings() {
    268         global $bp;
    269267
    270268        if ( !$mention = bp_get_user_meta( bp_displayed_user_id(), 'notification_activity_new_mention', true ) )
  • trunk/bp-activity/bp-activity-template.php

    r5729 r5758  
    277277
    278278        // The default scope should recognize custom slugs
    279         if ( array_key_exists( $bp->current_action, (array) $bp->loaded_components ) ) {
    280                 $scope = $bp->loaded_components[$bp->current_action];
     279        if ( array_key_exists( bp_current_action(), (array) $bp->loaded_components ) ) {
     280                $scope = $bp->loaded_components[bp_current_action()];
    281281        }
    282282        else
     
    18121812         * @since 1.2.0
    18131813         *
    1814          * @global object $bp BuddyPress global settings
    18151814         * @uses apply_filters() To call the 'bp_get_activity_permalink_id' hook
    18161815         *
     
    18181817         */
    18191818        function bp_get_activity_permalink_id() {
    1820                 global $bp;
    1821 
    1822                 return apply_filters( 'bp_get_activity_permalink_id', $bp->current_action );
     1819                return apply_filters( 'bp_get_activity_permalink_id', bp_current_action() );
    18231820        }
    18241821
  • trunk/bp-core/bp-core-buddybar.php

    r5751 r5758  
    125125        }
    126126
    127         if ( $bp->current_component == $parent_slug && !$bp->current_action ) {
    128                 if ( !is_object( $screen_function[0] ) )
     127        if ( bp_is_current_component( $parent_slug ) && !bp_current_action() ) {
     128                if ( !is_object( $screen_function[0] ) ) {
    129129                        add_action( 'bp_screens', $screen_function );
    130                 else
     130                } else {
    131131                        add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
     132                }
    132133
    133134                if ( $subnav_slug ) {
     
    237238
    238239        // If we *don't* meet condition (1), return
    239         if ( $bp->current_component != $parent_slug && $bp->current_item != $parent_slug )
     240        if ( ! bp_is_current_component( $parent_slug ) && ! bp_is_current_item( $parent_slug ) )
    240241                return;
    241242
    242243        // If we *do* meet condition (2), then the added subnav item is currently being requested
    243         if ( ( !empty( $bp->current_action ) && $slug == $bp->current_action ) || ( bp_is_user() && empty( $bp->current_action ) && $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) {
     244        if ( ( bp_current_action() && bp_is_current_action( $slug ) ) || ( bp_is_user() && ! bp_current_action() && ( $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) ) {
    244245
    245246                // Before hooking the screen function, check user access
    246                 if ( $user_has_access ) {
    247                         if ( !is_object( $screen_function[0] ) )
     247                if ( !empty( $user_has_access ) ) {
     248                        if ( !is_object( $screen_function[0] ) ) {
    248249                                add_action( 'bp_screens', $screen_function );
    249                         else
     250                        } else {
    250251                                add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
     252                        }
    251253                } else {
    252254                        // When the content is off-limits, we handle the situation differently
  • trunk/bp-core/bp-core-filters.php

    r5729 r5758  
    287287        // A single group
    288288        } elseif ( bp_is_active( 'groups' ) && !empty( $bp->groups->current_group ) && !empty( $bp->bp_options_nav[$bp->groups->current_group->slug] ) ) {
    289                 $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][$bp->current_action]['name'] : '';
     289                $subnav = isset( $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] ) ? $bp->bp_options_nav[$bp->groups->current_group->slug][bp_current_action()]['name'] : '';
    290290                // translators: "group name | group nav section name"
    291291                $title = sprintf( __( '%1$s | %2$s', 'buddypress' ), $bp->bp_options_title, $subnav );
     
    294294        } elseif ( bp_is_single_item() ) {
    295295                // translators: "component item name | component nav section name | root component name"
    296                 $title = sprintf( __( '%1$s | %2$s | %3$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[$bp->current_item][$bp->current_action]['name'], bp_get_name_from_root_slug( bp_get_root_slug() ) );
     296                $title = sprintf( __( '%1$s | %2$s | %3$s', 'buddypress' ), $bp->bp_options_title, $bp->bp_options_nav[bp_current_item()][bp_current_action()]['name'], bp_get_name_from_root_slug( bp_get_root_slug() ) );
    297297
    298298        // An index or directory
  • trunk/bp-core/bp-core-template.php

    r5729 r5758  
    2323        // If we are looking at a member profile, then the we can use the current component as an
    2424        // index. Otherwise we need to use the component's root_slug
    25         $component_index = !empty( $bp->displayed_user ) ? $bp->current_component : bp_get_root_slug( $bp->current_component );
     25        $component_index = !empty( $bp->displayed_user ) ? bp_current_component() : bp_get_root_slug( bp_current_component() );
    2626
    2727        if ( !bp_is_single_item() ) {
     
    3232                }
    3333        } else {
    34                 if ( !isset( $bp->bp_options_nav[$bp->current_item] ) || count( $bp->bp_options_nav[$bp->current_item] ) < 1 ) {
     34                if ( !isset( $bp->bp_options_nav[bp_current_item()] ) || count( $bp->bp_options_nav[bp_current_item()] ) < 1 ) {
    3535                        return false;
    3636                } else {
    37                         $the_index = $bp->current_item;
     37                        $the_index = bp_current_item();
    3838                }
    3939        }
     
    4545
    4646                // If the current action or an action variable matches the nav item id, then add a highlight CSS class.
    47                 if ( $subnav_item['slug'] == $bp->current_action ) {
     47                if ( $subnav_item['slug'] == bp_current_action() ) {
    4848                        $selected = ' class="current selected"';
    4949                } else {
     
    661661                // Use current global component if none passed
    662662                if ( empty( $component ) )
    663                         $component = $bp->current_component;
     663                        $component = bp_current_component();
    664664
    665665                // Component is active
     
    695695        // If no slug is passed, look at current_component
    696696        if ( empty( $root_slug ) )
    697                 $root_slug = $bp->current_component;
     697                $root_slug = bp_current_component();
    698698
    699699        // No current component or root slug, so flee
     
    763763
    764764        if ( !empty( $bp->current_component ) ) {
     765
    765766                // First, check to see whether $component_name and the current
    766767                // component are a simple match
     
    781782                // corresponding slug from $bp->active_components.
    782783                } else if ( $key = array_search( $component, $bp->active_components ) ) {
    783                         if ( strstr( $bp->current_component, $key ) )
     784                        if ( strstr( $bp->current_component, $key ) ) {
    784785                                $is_current_component = true;
     786                        }
    785787
    786788                // If we haven't found a match yet, check against the root_slugs
     
    790792                                // If the $component parameter does not match the current_component,
    791793                                // then move along, these are not the droids you are looking for
    792                                 if ( empty( $bp->{$id}->root_slug ) || $bp->{$id}->root_slug != $bp->current_component )
     794                                if ( empty( $bp->{$id}->root_slug ) || $bp->{$id}->root_slug != $bp->current_component ) {
    793795                                        continue;
     796                                }
    794797
    795798                                if ( $id == $component ) {
     
    808811
    809812                // Component name is in the page template name
    810                 if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) )
     813                if ( !empty( $page_template ) && strstr( strtolower( $page_template ), strtolower( $component ) ) ) {
    811814                        $is_current_component = true;
     815                }
    812816        }
    813817
     
    833837 */
    834838function bp_is_current_action( $action = '' ) {
    835         global $bp;
    836 
    837         if ( $action == $bp->current_action )
     839        if ( $action == bp_current_action() )
    838840                return true;
    839841
     
    10811083
    10821084function bp_is_single_activity() {
    1083         global $bp;
    1084 
    1085         if ( bp_is_activity_component() && is_numeric( $bp->current_action ) )
     1085        if ( bp_is_activity_component() && is_numeric( bp_current_action() ) )
    10861086                return true;
    10871087
  • trunk/bp-groups/bp-groups-loader.php

    r5714 r5758  
    159159
    160160                // If the user was attempting to access a group, but no group by that name was found, 404
    161                 if ( bp_is_groups_component() && empty( $this->current_group ) && !empty( $bp->current_action ) && !in_array( $bp->current_action, $this->forbidden_names ) ) {
     161                if ( bp_is_groups_component() && empty( $this->current_group ) && bp_current_action() && !in_array( bp_current_action(), $this->forbidden_names ) ) {
    162162                        bp_do_404();
    163163                        return;
     
    169169                        // Prepare for a redirect to the canonical URL
    170170                        $bp->redirect_stack['base_url']  = bp_get_group_permalink( $this->current_group );
    171                         $bp->redirect_stack['action']    = $bp->current_action;
     171                        $bp->redirect_stack['action']    = bp_current_action();
    172172                }
    173173
  • trunk/bp-groups/bp-groups-template.php

    r5729 r5758  
    246246
    247247        // Type
    248         if ( 'my-groups' == $bp->current_action ) {
     248        if ( bp_is_current_action( 'my-groups' ) ) {
    249249                if ( 'most-popular' == $order ) {
    250250                        $type = 'popular';
     
    252252                        $type = 'alphabetical';
    253253                }
    254         } elseif ( 'invites' == $bp->current_action ) {
     254        } elseif ( bp_is_current_action( 'invites' ) ) {
    255255                $type = 'invites';
    256256        } elseif ( isset( $bp->groups->current_group->slug ) && $bp->groups->current_group->slug ) {
  • trunk/bp-members/bp-members-template.php

    r5729 r5758  
    706706
    707707                // If the current component matches the nav item id, then add a highlight CSS class.
    708                 if ( !bp_is_directory() && $bp->active_components[$bp->current_component] == $nav_item['css_id'] ) {
     708                if ( !bp_is_directory() && $bp->active_components[bp_current_component()] == $nav_item['css_id'] ) {
    709709                        $selected = ' class="current selected"';
    710710                }
     
    751751
    752752                $selected = '';
    753                 if ( $bp->current_component == $user_nav_item['slug'] ) {
     753                if ( bp_is_current_component( $user_nav_item['slug'] ) ) {
    754754                        $selected = ' class="current selected"';
    755755                }
  • trunk/bp-messages/bp-messages-template.php

    r5729 r5758  
    128128                $this->thread = $this->next_thread();
    129129
    130                 if ( 'notices' != $bp->current_action ) {
     130                if ( ! bp_is_current_action( 'notices' ) ) {
    131131                        $last_message_index = count( $this->thread->messages ) - 1;
    132132                        $this->thread->messages = array_reverse( (array) $this->thread->messages );
     
    168168
    169169        $defaults = array(
    170                 'user_id' => bp_loggedin_user_id(),
    171                 'box' => 'inbox',
     170                'user_id'  => bp_loggedin_user_id(),
     171                'box'      => 'inbox',
    172172                'per_page' => 10,
    173                 'max' => false,
    174                 'type' => 'all'
     173                'max'      => false,
     174                'type'     => 'all'
    175175        );
    176176
     
    178178        extract( $r, EXTR_SKIP );
    179179
    180         if ( 'notices' == $bp->current_action && !bp_current_user_can( 'bp_moderate' ) ) {
     180        if ( bp_is_current_action( 'notices' ) && !bp_current_user_can( 'bp_moderate' ) ) {
    181181                wp_redirect( bp_displayed_user_id() );
    182182        } else {
    183                 if ( 'inbox' == $bp->current_action )
     183                if ( bp_is_current_action( 'inbox' ) ) {
    184184                        bp_core_delete_notifications_by_type( bp_loggedin_user_id(), $bp->messages->id, 'new_message' );
    185 
    186                 if ( 'sentbox' == $bp->current_action )
     185                }
     186
     187                if ( bp_is_current_action( 'sentbox' ) )
    187188                        $box = 'sentbox';
    188189
    189                 if ( 'notices' == $bp->current_action )
     190                if ( bp_is_current_action( 'notices' ) )
    190191                        $box = 'notices';
    191192
     
    247248        function bp_get_message_thread_to() {
    248249                global $messages_template;
    249                 return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients) );
     250                return apply_filters( 'bp_message_thread_to', BP_Messages_Thread::get_recipient_links($messages_template->thread->recipients ) );
    250251        }
    251252
     
    263264        function bp_get_message_thread_delete_link() {
    264265                global $messages_template, $bp;
    265                 return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug . '/' . $bp->current_action . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
     266                return apply_filters( 'bp_get_message_thread_delete_link', wp_nonce_url( trailingslashit( bp_loggedin_user_domain() . $bp->messages->slug . '/' . bp_current_action() . '/delete/' . $messages_template->thread->thread_id ), 'messages_delete_thread' ) );
    266267        }
    267268
     
    416417        </select> &nbsp;
    417418
    418         <?php if ( $bp->current_action != 'sentbox' && $bp->current_action != 'notices' ) : ?>
     419        <?php if ( ! bp_is_current_action( 'sentbox' ) && bp_is_current_action( 'notices' ) ) : ?>
    419420
    420421                <a href="#" id="mark_as_read"><?php _e('Mark as Read', 'buddypress') ?></a> &nbsp;
     
    423424        <?php endif; ?>
    424425
    425         <a href="#" id="delete_<?php echo $bp->current_action ?>_messages"><?php _e('Delete Selected', 'buddypress') ?></a> &nbsp;
     426        <a href="#" id="delete_<?php echo bp_current_action(); ?>_messages"><?php _e( 'Delete Selected', 'buddypress' ); ?></a> &nbsp;
    426427
    427428<?php
Note: See TracChangeset for help on using the changeset viewer.