Changeset 7781
- Timestamp:
- 02/04/2014 02:19:11 AM (11 years ago)
- Location:
- trunk/bp-xprofile
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/bp-xprofile/bp-xprofile-cache.php
r6342 r7781 18 18 wp_cache_delete( 'xprofile_group_' . $group_obj->id, 'bp' ); 19 19 } 20 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' ); 21 add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' ); 20 22 21 23 function xprofile_clear_profile_data_object_cache( $group_id ) { 22 24 wp_cache_delete( 'bp_user_fullname_' . bp_loggedin_user_id(), 'bp' ); 23 25 } 26 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 24 27 25 // List actions to clear object caches on 26 add_action( 'xprofile_groups_deleted_group', 'xprofile_clear_profile_groups_object_cache' ); 27 add_action( 'xprofile_groups_saved_group', 'xprofile_clear_profile_groups_object_cache' ); 28 add_action( 'xprofile_updated_profile', 'xprofile_clear_profile_data_object_cache' ); 28 /** 29 * Clear caches when a field object is modified. 30 * 31 * @since BuddyPress (2.0.0) 32 * 33 * @param BP_XProfile_Field 34 */ 35 function xprofile_clear_profile_field_object_cache( $field_obj ) { 36 // Clear default visibility level cache 37 wp_cache_delete( 'xprofile_default_visibility_levels', 'bp' ); 38 } 39 add_action( 'xprofile_fields_saved_field', 'xprofile_clear_profile_field_object_cache' ); 40 add_aciton( 'xprofile_fields_deleted_field', 'xprofile_clear_profile_field_object_cache' ); 29 41 30 42 // List actions to clear super cached pages on, if super cache is installed -
trunk/bp-xprofile/bp-xprofile-classes.php
r7780 r7781 389 389 390 390 /** 391 * Fetch the admin-set preferences for all fields 392 * 393 * @since BuddyPress (1.6) 394 * 395 * @return array $default_visibility_levels An array, keyed by field_id, of default 396 * visibility level + allow_custom (whether the admin allows this field to be set by user) 391 * Fetch the admin-set preferences for all fields. 392 * 393 * @since BuddyPress (1.6.0) 394 * 395 * @return array $default_visibility_levels An array, keyed by 396 * field_id, of default visibility level + allow_custom 397 * (whether the admin allows this field to be set by user) 397 398 */ 398 399 public static function fetch_default_visibility_levels() { 399 400 global $wpdb, $bp; 400 401 401 $levels = $wpdb->get_results( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" ); 402 403 // Arrange so that the field id is the key and the visibility level the value 404 $default_visibility_levels = array(); 405 foreach( $levels as $level ) { 406 if ( 'default_visibility' == $level->meta_key ) { 407 $default_visibility_levels[$level->object_id]['default'] = $level->meta_value; 408 } else if ( 'allow_custom_visibility' == $level->meta_key ) { 409 $default_visibility_levels[$level->object_id]['allow_custom'] = $level->meta_value; 410 } 402 $default_visibility_levels = wp_cache_get( 'xprofile_default_visibility_levels', 'bp' ); 403 404 if ( false === $default_visibility_levels ) { 405 $levels = $wpdb->get_results( "SELECT object_id, meta_key, meta_value FROM {$bp->profile->table_name_meta} WHERE object_type = 'field' AND ( meta_key = 'default_visibility' OR meta_key = 'allow_custom_visibility' )" ); 406 407 // Arrange so that the field id is the key and the visibility level the value 408 $default_visibility_levels = array(); 409 foreach ( $levels as $level ) { 410 if ( 'default_visibility' == $level->meta_key ) { 411 $default_visibility_levels[ $level->object_id ]['default'] = $level->meta_value; 412 } else if ( 'allow_custom_visibility' == $level->meta_key ) { 413 $default_visibility_levels[ $level->object_id ]['allow_custom'] = $level->meta_value; 414 } 415 } 416 417 wp_cache_set( 'xprofile_default_visibility_levels', $default_visibility_levels, 'bp' ); 411 418 } 412 419
Note: See TracChangeset
for help on using the changeset viewer.