From 51b2389d2ec888848ca96c3b610a97fba92543de Mon Sep 17 00:00:00 2001 From: Bunty Date: Sun, 10 Mar 2024 12:15:33 +0530 Subject: [PATCH] Fix - #224 Avoid php warnings --- includes/class-simple-local-avatars.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/includes/class-simple-local-avatars.php b/includes/class-simple-local-avatars.php index 5b47f3f..103e117 100644 --- a/includes/class-simple-local-avatars.php +++ b/includes/class-simple-local-avatars.php @@ -342,10 +342,13 @@ public function get_simple_local_avatar_url( $id_or_email, $size ) { } // check rating - $avatar_rating = get_user_meta( $user_id, $this->rating_key, true ); - $site_rating = get_option( 'avatar_rating' ); - if ( ! empty( $avatar_rating ) && 'G' !== $avatar_rating && $site_rating ) { - $ratings = array_keys( $this->avatar_ratings ); + $avatar_rating = get_user_meta( $user_id, $this->rating_key, true ); + $site_rating = get_option( 'avatar_rating' ); + $all_avatar_ratings = ! empty( $this->avatar_ratings ) && is_array( $this->avatar_ratings ) + ? $this->avatar_ratings + : array(); + if ( ! empty( $avatar_rating ) && 'G' !== $avatar_rating && $site_rating && $all_avatar_ratings ) { + $ratings = array_keys( $all_avatar_ratings ); $site_rating_weight = array_search( $site_rating, $ratings, true ); $avatar_rating_weight = array_search( $avatar_rating, $ratings, true ); if ( false !== $avatar_rating_weight && $avatar_rating_weight > $site_rating_weight ) {