Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
02/17/2014 07:54:32 PM (11 years ago)
Author:
boonebgorges
Message:

Don't use fetch_default_visibility_levels() method in bp_has_profile() loop

There's no need to do this custom pre-fetching of visibility levels within
the bp_has_profile() loop, because the values are already loaded into the cache
by bp_xprofile_update_meta_cache(). So we use bp_xprofile_get_meta() instead.

See #5398

File:
1 edited

Legend:

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

    r7914 r7915  
    266266        }
    267267
     268        // Prime the meta cache, if necessary
     269        if ( $update_meta_cache ) {
     270            bp_xprofile_update_meta_cache( $object_ids );
     271        }
     272
    268273        // Maybe fetch visibility levels
    269274        if ( !empty( $fetch_visibility_level ) ) {
     
    292297            // Reset indexes
    293298            $groups = array_values( $groups );
    294         }
    295 
    296         // Prime the meta cache, if necessary
    297         if ( $update_meta_cache ) {
    298             bp_xprofile_update_meta_cache( $object_ids );
    299299        }
    300300
     
    394394        $visibility_levels = bp_get_user_meta( $user_id, 'bp_xprofile_visibility_levels', true );
    395395
    396         // Get the admin-set preferences
    397         $admin_set_levels  = self::fetch_default_visibility_levels();
    398 
    399396        foreach( (array) $fields as $key => $field ) {
    400397
    401398            // Does the admin allow this field to be customized?
    402             $allow_custom = empty( $admin_set_levels[$field->id]['allow_custom'] ) || 'allowed' == $admin_set_levels[$field->id]['allow_custom'];
     399            $allow_custom = 'disabled' !== bp_xprofile_get_meta( $field->id, 'field', 'allow_custom_visibility' );
    403400
    404401            // Look to see if the user has set the visibility for this field
     
    408405            // If no admin-set default is saved, fall back on a global default
    409406            } else {
    410                 $field_visibility = !empty( $admin_set_levels[$field->id]['default'] ) ? $admin_set_levels[$field->id]['default'] : apply_filters( 'bp_xprofile_default_visibility_level', 'public' );
     407                $fallback_visibility = bp_xprofile_get_meta( $field->id, 'field', 'default_visibility' );
     408                $field_visibility = ! empty( $fallback_visibility ) ? $fallback_visibility : apply_filters( 'bp_xprofile_default_visibility_level', 'public' );
    411409            }
    412410
Note: See TracChangeset for help on using the changeset viewer.