- Timestamp:
- 01/19/2022 09:21:45 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/classes/class-bp-attachment-avatar.php
r13175 r13215 247 247 } 248 248 249 // Delete the existing avatar files for the object. 250 $existing_avatar = bp_core_fetch_avatar( array( 251 'object' => $args['object'], 252 'item_id' => $args['item_id'], 253 'html' => false, 254 ) ); 249 // Get the existing avatar files for the object. 250 $existing_avatar = bp_core_fetch_avatar( 251 array( 252 'object' => $args['object'], 253 'item_id' => $args['item_id'], 254 'html' => false, 255 ) 256 ); 255 257 256 258 /** … … 259 261 */ 260 262 if ( ! empty( $existing_avatar ) && $existing_avatar !== $this->url . $relative_path ) { 261 // Add a new revision for the existing avatar. 262 $avatars = bp_attachments_list_directory_files( $avatar_folder_dir ); 263 264 if ( $avatars ) { 265 foreach ( $avatars as $avatar_file ) { 266 if ( ! isset( $avatar_file->name, $avatar_file->id, $avatar_file->path ) ) { 267 continue; 268 } 269 270 $is_full = preg_match( "/-bpfull/", $avatar_file->name ); 271 $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name ); 272 273 if ( $is_full || $is_thumb ) { 274 $revision = $this->add_revision( 275 'avatar', 276 array( 277 'file_abspath' => $avatar_file->path, 278 'file_id' => $avatar_file->id, 279 ) 280 ); 281 282 if ( is_wp_error( $revision ) ) { 283 error_log( $revision->get_error_message() ); 263 // Avatar history is disabled, simply delete the existing avatar files. 264 if ( bp_avatar_history_is_disabled() ) { 265 bp_core_delete_existing_avatar( 266 array( 267 'object' => $args['object'], 268 'item_id' => $args['item_id'], 269 'avatar_path' => $avatar_folder_dir, 270 ) 271 ); 272 } else { 273 // Add a new revision for the existing avatar. 274 $avatars = bp_attachments_list_directory_files( $avatar_folder_dir ); 275 276 if ( $avatars ) { 277 foreach ( $avatars as $avatar_file ) { 278 if ( ! isset( $avatar_file->name, $avatar_file->id, $avatar_file->path ) ) { 279 continue; 280 } 281 282 $is_full = preg_match( "/-bpfull/", $avatar_file->name ); 283 $is_thumb = preg_match( "/-bpthumb/", $avatar_file->name ); 284 285 if ( $is_full || $is_thumb ) { 286 $revision = $this->add_revision( 287 'avatar', 288 array( 289 'file_abspath' => $avatar_file->path, 290 'file_id' => $avatar_file->id, 291 ) 292 ); 293 294 if ( is_wp_error( $revision ) ) { 295 error_log( $revision->get_error_message() ); 296 } 284 297 } 285 298 }
Note: See TracChangeset
for help on using the changeset viewer.