-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: user meta retrieval #302
Changes from 1 commit
93079b0
d9ff4bb
eeb66bc
4d775cc
946d757
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -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 ) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because this method is marked as |
||||||
$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. | ||||||
* | ||||||
|
@@ -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 ); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we change the above method to not be static, this will need updated:
Suggested change
|
||||||
if ( empty( $local_avatars['full'] ) ) { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This condition might cause a PHP notice or warning if the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a check in eeb66bc |
||||||
return ''; | ||||||
} | ||||||
|
@@ -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 ); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
if ( empty( $old_avatars ) ) { | ||||||
return; | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We use the variable
$user_id
but the only variable passed in is$user
. I think that just needs updated: