Skip to:
Content

BuddyPress.org

Changeset 8439


Ignore:
Timestamp:
05/21/2014 03:21:05 PM (11 years ago)
Author:
johnjamesjacoby
Message:

Whitespace, code formatting, and inline doc clean-up in BP_Members_Component.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-members/bp-members-loader.php

    r8319 r8439  
    11<?php
     2
    23/**
    34 * BuddyPress Member Loader
     
    3637     */
    3738    public function includes( $includes = array() ) {
     39
     40        // Always include these files
    3841        $includes = array(
    3942            'actions',
     
    4851        );
    4952
     53        // Include these only if in admin
    5054        if ( is_admin() ) {
    5155            $includes[] = 'admin';
     
    7074        $bp = buddypress();
    7175
    72         // Define a slug, if necessary
    73         if ( !defined( 'BP_MEMBERS_SLUG' ) )
     76        /** Component Globals *************************************************/
     77
     78        // Define a slug, as a fallback for backpat
     79        if ( !defined( 'BP_MEMBERS_SLUG' ) ) {
    7480            define( 'BP_MEMBERS_SLUG', $this->id );
    75 
    76         $members_globals = array(
    77             'slug'          => BP_MEMBERS_SLUG,
    78             'root_slug'     => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
    79             'has_directory' => true,
     81        }
     82
     83        // Override any passed args
     84        $args = array(
     85            'slug'            => BP_MEMBERS_SLUG,
     86            'root_slug'       => isset( $bp->pages->members->slug ) ? $bp->pages->members->slug : BP_MEMBERS_SLUG,
     87            'has_directory'   => true,
    8088            'directory_title' => _x( 'Members', 'component directory title', 'buddypress' ),
    81             'global_tables' => array(
     89            'search_string'   => __( 'Search Members...', 'buddypress' ),
     90            'global_tables'   => array(
    8291                'table_name_last_activity' => bp_core_get_table_prefix() . 'bp_activity',
    8392                'table_name_signups'       => bp_core_get_table_prefix() . 'signups',
    84             ),
    85             'search_string' => __( 'Search Members...', 'buddypress' ),
    86         );
    87 
    88         parent::setup_globals( $members_globals );
     93            )
     94        );
     95
     96        parent::setup_globals( $args );
    8997
    9098        /** Logged in user ****************************************************/
     
    113121        $bp->displayed_user->fullname = bp_core_get_user_displayname( bp_displayed_user_id() );
    114122
    115         /** Signup ***************************************************/
     123        /** Signup ************************************************************/
     124
    116125        $bp->signup = new stdClass;
    117126
     
    126135        /** Default Profile Component *****************************************/
    127136
    128         if ( !defined( 'BP_DEFAULT_COMPONENT' ) ) {
     137        if ( defined( 'BP_DEFAULT_COMPONENT' ) && BP_DEFAULT_COMPONENT ) {
     138            $bp->default_component = BP_DEFAULT_COMPONENT;
     139        } else {
    129140            if ( bp_is_active( 'activity' ) && isset( $bp->pages->activity ) ) {
    130141                $bp->default_component = bp_get_activity_slug();
     
    132143                $bp->default_component = ( 'xprofile' === $bp->profile->id ) ? 'profile' : $bp->profile->id;
    133144            }
    134 
    135         } else {
    136             $bp->default_component = BP_DEFAULT_COMPONENT;
    137         }
     145        }
     146
     147        /** Canonical Component Stack *****************************************/
    138148
    139149        if ( bp_displayed_user_id() ) {
     
    152162            }
    153163
    154             if ( !bp_current_component() ) {
     164            // Looking at the single member root/home, so assume the default
     165            if ( ! bp_current_component() ) {
    155166                $bp->current_component = $bp->default_component;
    156             } else if ( bp_is_current_component( $bp->default_component ) && !bp_current_action() ) {
    157                 // The canonical URL will not contain the default component
     167
     168            // The canonical URL will not contain the default component
     169            } elseif ( bp_is_current_component( $bp->default_component ) && ! bp_current_action() ) {
    158170                unset( $bp->canonical_stack['component'] );
    159171            }
     
    172184
    173185    /**
    174      * Set up component navigation.
     186     * Set up fall-back component navigation if XProfile is inactive.
    175187     *
    176188     * @since BuddyPress (1.5.0)
     
    184196     */
    185197    public function setup_nav( $main_nav = array(), $sub_nav = array() ) {
     198
     199        // Bail if XProfile component is active
     200        if ( bp_is_active( 'xprofile' ) ) {
     201            return;
     202        }
     203
     204        // Don't set up navigation if there's no member
     205        if ( ! is_user_logged_in() && ! bp_is_user() ) {
     206            return;
     207        }
     208
    186209        $bp = buddypress();
    187210
    188         // Add 'Profile' to the main navigation
    189         if ( !bp_is_active( 'xprofile' ) ) {
    190 
    191             // Don't set up navigation if there's no user
    192             if ( !is_user_logged_in() && !bp_is_user() ) {
    193                 return;
    194             }
    195 
    196             $main_nav = array(
    197                 'name'                => __( 'Profile', 'buddypress' ),
    198                 'slug'                => $bp->profile->slug,
    199                 'position'            => 20,
    200                 'screen_function'     => 'bp_members_screen_display_profile',
    201                 'default_subnav_slug' => 'public',
    202                 'item_css_id'         => $bp->profile->id
    203             );
    204 
    205             // User links
    206             $user_domain  = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
    207             $profile_link = trailingslashit( $user_domain . $bp->profile->slug );
    208 
    209             // Add the subnav items to the profile
    210             $sub_nav[] = array(
    211                 'name'            => __( 'View', 'buddypress' ),
    212                 'slug'            => 'public',
    213                 'parent_url'      => $profile_link,
    214                 'parent_slug'     => $bp->profile->slug,
    215                 'screen_function' => 'bp_members_screen_display_profile',
    216                 'position'        => 10
    217             );
    218 
    219             parent::setup_nav( $main_nav, $sub_nav );
    220         }
     211        // Setup the main navigation
     212        $main_nav = array(
     213            'name'                => __( 'Profile', 'buddypress' ),
     214            'slug'                => $bp->profile->slug,
     215            'position'            => 20,
     216            'screen_function'     => 'bp_members_screen_display_profile',
     217            'default_subnav_slug' => 'public',
     218            'item_css_id'         => $bp->profile->id
     219        );
     220
     221        // User links
     222        $user_domain  = bp_displayed_user_domain() ? bp_displayed_user_domain() : bp_loggedin_user_domain();
     223        $profile_link = trailingslashit( $user_domain . $bp->profile->slug );
     224
     225        // Setup the subnav items for the member profile
     226        $sub_nav[] = array(
     227            'name'            => __( 'View', 'buddypress' ),
     228            'slug'            => 'public',
     229            'parent_url'      => $profile_link,
     230            'parent_slug'     => $bp->profile->slug,
     231            'screen_function' => 'bp_members_screen_display_profile',
     232            'position'        => 10
     233        );
     234
     235        parent::setup_nav( $main_nav, $sub_nav );
    221236    }
    222237
     
    229244        if ( bp_is_my_profile() ) {
    230245            $bp->bp_options_title = __( 'You', 'buddypress' );
    231         } elseif( bp_is_user() ) {
     246        } elseif ( bp_is_user() ) {
     247            $bp->bp_options_title  = bp_get_displayed_user_fullname();
    232248            $bp->bp_options_avatar = bp_core_fetch_avatar( array(
    233249                'item_id' => bp_displayed_user_id(),
    234250                'type'    => 'thumb',
    235                 'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), bp_get_displayed_user_fullname() )
     251                'alt'     => sprintf( __( 'Profile picture of %s', 'buddypress' ), $bp->bp_options_title )
    236252            ) );
    237             $bp->bp_options_title = bp_get_displayed_user_fullname();
    238253        }
    239254
Note: See TracChangeset for help on using the changeset viewer.