Skip to content

Commit

Permalink
Revert "refactor: remove unnecessary if condition"
Browse files Browse the repository at this point in the history
This reverts commit 61b9130.
  • Loading branch information
ravinderk committed Sep 19, 2023
1 parent 6abb041 commit 7cfd753
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,25 +353,28 @@ public function get_simple_local_avatar_url( $id_or_email, $size ) {
}
}

// If using shared avatars, make sure we validate the URL on the main site.
if ( $this->is_avatar_shared() ) {
$origin_blog_id = ! empty( $local_avatars['blog_id'] ) ? $local_avatars['blog_id'] : get_main_site_id();
switch_to_blog( $origin_blog_id );
}
// handle "real" media
if ( ! empty( $local_avatars['media_id'] ) ) {
// If using shared avatars, make sure we validate the URL on the main site.
if ( $this->is_avatar_shared() ) {
$origin_blog_id = isset( $local_avatars['blog_id'] ) && ! empty( $local_avatars['blog_id'] ) ? $local_avatars['blog_id'] : get_main_site_id();
switch_to_blog( $origin_blog_id );
}

$avatar_full_path = get_attached_file( $local_avatars['media_id'] );
$avatar_full_path = get_attached_file( $local_avatars['media_id'] );

if ( $this->is_avatar_shared() ) {
restore_current_blog();
}
if ( $this->is_avatar_shared() ) {
restore_current_blog();
}

// has the media been deleted?
if ( ! $avatar_full_path ) {
return '';
}
// has the media been deleted?
if ( ! $avatar_full_path ) {
return '';
}

// Use dynamic full url in favour of host/domain change.
$local_avatars['full'] = wp_get_attachment_image_url( $local_avatars['media_id'], 'full' );
// Use dynamic full url in favour of host/domain change.
$local_avatars['full'] = wp_get_attachment_image_url( $local_avatars['media_id'], 'full' );
}

$size = (int) $size;

Expand Down Expand Up @@ -416,7 +419,7 @@ public function get_simple_local_avatar_url( $id_or_email, $size ) {
endif;
}

if ( strpos( $local_avatars[ $size ], 'http' ) !== 0 ) {
if ( 'http' !== substr( $local_avatars[ $size ], 0, 4 ) ) {
$local_avatars[ $size ] = home_url( $local_avatars[ $size ] );
}

Expand Down

0 comments on commit 7cfd753

Please sign in to comment.