Skip to content

Commit

Permalink
fix: user meta retrieval
Browse files Browse the repository at this point in the history
  • Loading branch information
adekbadek authored Aug 28, 2024
1 parent 37508f5 commit 93079b0
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions includes/class-simple-local-avatars.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,20 @@ public function get_user_id( $id_or_email ) {
return $user_id;
}

/**
* Get the local avatar user meta.
*
* @param int $user_id User ID.
* @return array Array with avatar data.
*/
public static function get_user_local_avatar( $user ) {
$local_avatars = get_user_meta( $user_id, $this->user_key, true );
if ( ! is_array( $local_avatars ) || empty( $local_avatars ) ) {
return [];
}
return $local_avatars;
}

/**
* Get local avatar url.
*
Expand All @@ -343,7 +357,7 @@ public function get_simple_local_avatar_url( $id_or_email, $size ) {
}

// Fetch local avatar from meta and make sure it's properly set.
$local_avatars = get_user_meta( $user_id, $this->user_key, true );
$local_avatars = self::get_user_local_avatar( $user_id );
if ( empty( $local_avatars['full'] ) ) {
return '';
}
Expand Down Expand Up @@ -1181,7 +1195,7 @@ public function ajax_assign_simple_local_avatar_media() {
* @param int $user_id User ID.
*/
public function avatar_delete( $user_id ) {
$old_avatars = (array) get_user_meta( $user_id, $this->user_key, true );
$old_avatars = self::get_user_local_avatar( $user_id );

if ( empty( $old_avatars ) ) {
return;
Expand Down

0 comments on commit 93079b0

Please sign in to comment.