Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
01/17/2010 07:42:57 PM (16 years ago)
Author:
apeatling
Message:

Improved profile page performance.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-xprofile/bp-xprofile-templatetags.php

    r2168 r2320  
    2020
    2121    function bp_xprofile_data_template( $user_id, $profile_group_id ) {
    22 
    23         if ( !$profile_group_id ) {
    24             if ( !$this->groups = wp_cache_get( 'xprofile_groups', 'bp' ) ) {
    25                 $this->groups = BP_XProfile_Group::get_all(true);
    26                 wp_cache_set( 'xprofile_groups', $this->groups, 'bp' );
    27             }
    28         } else {
    29             if ( !$this->groups = wp_cache_get( 'xprofile_group_' . $profile_group_id, 'bp' ) ) {
    30                 $this->groups = new BP_XProfile_Group( $profile_group_id );
    31                 wp_cache_set( 'xprofile_group_' . $profile_group_id, 'bp' );
    32             }
    33 
    34             /* We need to put this single group into the same format as multiple group (an array) */
    35             $this->groups = array( $this->groups );
    36         }
     22        $this->groups = BP_XProfile_Group::get( array(
     23            'profile_group_id' => $profile_group_id,
     24            'user_id' => $user_id,
     25            'hide_empty_groups' => true,
     26            'fetch_fields' => true,
     27            'fetch_field_data' => true
     28        ) );
    3729
    3830        $this->group_count = count($this->groups);
     
    5143
    5244        $this->group = $this->groups[$this->current_group];
    53 
    54         if ( !$fields = wp_cache_get( 'xprofile_fields_' . $this->group->id . '_' . $this->user_id, 'bp' ) ) {
    55             for ( $i = 0; $i < count($this->group->fields); $i++ ) {
    56                 /* Don't try and fetch any existing profile data if we are using this loop on the registration page */
    57                 $get_data = ( !bp_is_register_page() ) ? true : false;
    58 
    59                 $field = new BP_XProfile_Field( $this->group->fields[$i]->id, $this->user_id, $get_data );
    60                 $fields[$i] = $field;
    61             }
    62 
    63             wp_cache_set( 'xprofile_fields_' . $this->group->id . '_' . $this->user_id, $fields, 'bp' );
    64         }
    65 
    66         $this->group->fields = apply_filters( 'xprofile_group_fields', $fields, $this->group->id );
     45        $this->group->fields = apply_filters( 'xprofile_group_fields', $this->group->fields, $this->group->id );
    6746        $this->field_count = count( $this->group->fields );
    6847
     
    386365        $r = wp_parse_args( $args, $defaults );
    387366        extract( $r, EXTR_SKIP );
     367
     368        if ( !method_exists( $field, 'get_children' ) )
     369            $field = new BP_XProfile_Field( $field->id );
    388370
    389371        $options = $field->get_children();
     
    584566
    585567    if ( !$groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' ) ) {
    586         $groups = BP_XProfile_Group::get_all();
     568        $groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
    587569        wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
    588570    }
Note: See TracChangeset for help on using the changeset viewer.