Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/11/2012 02:29:55 AM (14 years ago)
Author:
johnjamesjacoby
Message:

Remove unneeded globals and clean up some code in Members component. Remove signup file and move its code into screens and functions. See #3989.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-members/bp-members-template.php

    r5646 r5700  
    11<?php
     2
    23/**
    34 * BuddyPress Member Template Tags
     
    169170    var $total_member_count;
    170171
    171     function bp_core_members_template( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value ) {
    172         $this->__construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value );
    173     }
    174 
    175172    function __construct( $type, $page_number, $per_page, $max, $user_id, $search_terms, $include, $populate_extras, $exclude, $meta_key, $meta_value ) {
    176         global $bp;
    177 
    178         $this->pag_page  = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number;
    179         $this->pag_num   = !empty( $_REQUEST['num'] )   ? intval( $_REQUEST['num'] )   : (int)$per_page;
    180         $this->type      = $type;
     173
     174        $this->pag_page = !empty( $_REQUEST['upage'] ) ? intval( $_REQUEST['upage'] ) : (int)$page_number;
     175        $this->pag_num  = !empty( $_REQUEST['num'] )   ? intval( $_REQUEST['num'] )   : (int)$per_page;
     176        $this->type     = $type;
    181177
    182178        if ( isset( $_REQUEST['letter'] ) && '' != $_REQUEST['letter'] )
     
    250246
    251247    function the_member() {
    252         global $member, $bp;
    253248
    254249        $this->in_the_loop = true;
    255         $this->member = $this->next_member();
    256 
    257         if ( 0 == $this->current_member ) // loop has just started
    258             do_action('member_loop_start');
     250        $this->member      = $this->next_member();
     251
     252        // loop has just started
     253        if ( 0 == $this->current_member )
     254            do_action( 'member_loop_start' );
    259255    }
    260256}
     
    267263
    268264function bp_has_members( $args = '' ) {
    269     global $bp, $members_template;
     265    global $members_template;
    270266
    271267    /***
     
    339335}
    340336    function bp_get_members_pagination_count() {
    341         global $bp, $members_template;
     337        global $members_template;
    342338
    343339        if ( empty( $members_template->type ) )
     
    464460
    465461function bp_member_is_loggedin_user() {
    466     global $bp, $members_template;
     462    global $members_template;
    467463    return apply_filters( 'bp_member_is_loggedin_user', bp_loggedin_user_id() == $members_template->member->id ? true : false );
    468464}
     
    472468}
    473469    function bp_get_member_avatar( $args = '' ) {
    474         global $bp, $members_template;
     470        global $members_template;
    475471
    476472        $fullname = !empty( $members_template->member->fullname ) ? $members_template->member->fullname : $members_template->member->display_name;
    477473
    478474        $defaults = array(
    479             'type' => 'thumb',
    480             'width' => false,
     475            'type'   => 'thumb',
     476            'width'  => false,
    481477            'height' => false,
    482             'class' => 'avatar',
    483             'id' => false,
    484             'alt' => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname )
     478            'class'  => 'avatar',
     479            'id'     => false,
     480            'alt'    => sprintf( __( 'Profile picture of %s', 'buddypress' ), $fullname )
    485481        );
    486482
     
    568564}
    569565    function bp_get_member_latest_update( $args = '' ) {
    570         global $bp, $members_template;
     566        global $members_template;
    571567
    572568        $defaults = array(
     
    598594}
    599595    function bp_get_member_profile_data( $args = '' ) {
    600         global $bp, $members_template;
     596        global $members_template;
    601597
    602598        if ( !bp_is_active( 'xprofile' ) )
     
    665661
    666662function bp_directory_members_search_form() {
    667     global $bp;
    668663
    669664    $default_search_value = bp_get_search_default_text( 'members' );
     
    707702    // Loop through each navigation item
    708703    foreach( (array) $bp->bp_nav as $nav_item ) {
     704
     705        $selected = '';
     706
    709707        // If the current component matches the nav item id, then add a highlight CSS class.
    710         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'] ) {
    711709            $selected = ' class="current selected"';
    712         else
    713             $selected = '';
    714 
    715         /* If we are viewing another person (current_userid does not equal loggedin_user->id)
    716            then check to see if the two users are friends. if they are, add a highlight CSS class
    717            to the friends nav item if it exists. */
     710        }
     711
     712        // If we are viewing another person (current_userid does not equal
     713        // loggedin_user->id then check to see if the two users are friends.
     714        // if they are, add a highlight CSS class to the friends nav item
     715        // if it exists.
    718716        if ( !bp_is_my_profile() && bp_displayed_user_id() ) {
    719717            $selected = '';
     
    721719            if ( bp_is_active( 'friends' ) ) {
    722720                if ( $nav_item['css_id'] == $bp->friends->id ) {
    723                     if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) )
     721                    if ( friends_check_friendship( bp_loggedin_user_id(), bp_displayed_user_id() ) ) {
    724722                        $selected = ' class="current selected"';
     723                    }
    725724                }
    726725            }
     
    751750            continue;
    752751
    753         if ( $bp->current_component == $user_nav_item['slug'] )
     752        $selected = '';
     753        if ( $bp->current_component == $user_nav_item['slug'] ) {
    754754            $selected = ' class="current selected"';
    755         else
    756             $selected = '';
    757 
    758         if ( $bp->loggedin_user->domain )
     755        }
     756
     757        if ( $bp->loggedin_user->domain ) {
    759758            $link = str_replace( $bp->loggedin_user->domain, $bp->displayed_user->domain, $user_nav_item['link'] );
    760         else
     759        } else {
    761760            $link = trailingslashit( $bp->displayed_user->domain . $user_nav_item['link'] );
     761        }
    762762
    763763        echo apply_filters_ref_array( 'bp_get_displayed_user_nav_' . $user_nav_item['css_id'], array( '<li id="' . $user_nav_item['css_id'] . '-personal-li" ' . $selected . '><a id="user-' . $user_nav_item['css_id'] . '" href="' . $link . '">' . $user_nav_item['name'] . '</a></li>', &$user_nav_item ) );
     
    771771}
    772772    function bp_get_loggedin_user_avatar( $args = '' ) {
    773         global $bp;
    774773
    775774        $defaults = array(
     
    791790}
    792791    function bp_get_displayed_user_avatar( $args = '' ) {
    793         global $bp;
    794792
    795793        $defaults = array(
     
    826824}
    827825    function bp_get_last_activity( $user_id = 0 ) {
    828         global $bp;
    829826
    830827        if ( empty( $user_id ) )
     
    967964}
    968965    function bp_get_signup_page() {
    969         global $bp;
    970966
    971967        if ( bp_has_custom_signup_page() ) {
Note: See TracChangeset for help on using the changeset viewer.