| @@ -9,11 +9,11 @@ | ||
| 9 | 9 | |
| 10 | 10 | class AvatarUploder |
| 11 | 11 | { |
| 12 | 12 | /** |
| 13 | - * @param $file - file object | |
| 14 | - * @param int $userid - user id | |
| 15 | - * @param string $type - Customer or Agent | |
| 13 | + * @param array $file | |
| 14 | + * @param int $userid Person id | |
| 15 | + * @param string $type 'customer' or 'agent' | |
| 16 | 16 | * @throws Exception |
| 17 | 17 | * @return array |
| 18 | 18 | */ |
| 19 | 19 | public function addOrUpdateProfileImage ( $file, $userid, $type ) |
| @@ -25,9 +25,9 @@ | ||
| 25 | 25 | $uploadedImage = FileSystem::setSubDir(strtolower($type).'_avatars')->put($file); |
| 26 | 26 | |
| 27 | 27 | |
| 28 | 28 | if ( !$uploadedImage ) { |
| 29 | - throw new Exception('Something went wrong while updating the profile picture', 403); | |
| 29 | + throw new Exception(esc_html__('Something went wrong while updating the profile picture', 'fluent-support'), 403); | |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | $user->avatar = $uploadedImage[0]['url']; |
| 33 | 33 | $user->save(); |
| @@ -39,10 +39,9 @@ | ||
| 39 | 39 | ]; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | /** |
| 43 | - * This Method Will Validate The Extension Of The File | |
| 44 | - * @param $file - file object | |
| 43 | + * @param array $file | |
| 45 | 44 | * @throws Exception |
| 46 | 45 | * @return bool |
| 47 | 46 | */ |
| 48 | 47 | private function validateExtension($file) |
| @@ -47,9 +46,9 @@ | ||
| 47 | 46 | */ |
| 48 | 47 | private function validateExtension($file) |
| 49 | 48 | { |
| 50 | 49 | /** |
| 51 | - * Filter profile picture upload types | |
| 50 | + * Filter allowed profile picture extensions. | |
| 52 | 51 | * @param array $allowedExtension |
| 53 | 52 | */ |
| 54 | 53 | $allowedExtension = apply_filters('fluent_support/allowed_customer_profile_picture_file_type', |
| 55 | 54 | array('jpeg', 'jpe', 'jpg', 'png')); |
| @@ -58,8 +57,9 @@ | ||
| 58 | 57 | |
| 59 | 58 | if( !in_array($ext, $allowedExtension) ) { |
| 60 | 59 | throw new Exception( |
| 61 | 60 | sprintf( |
| 61 | + // translators: %s is a comma-separated list of allowed file extensions (e.g., "jpg, png, gif") | |
| 62 | 62 | esc_html__('Unsupported file submitted, allowed image file types are: %s', 'fluent-support'), |
| 63 | 63 | esc_html(implode(", ", $allowedExtension)) |
| 64 | 64 | ), 403 |
| 65 | 65 | ); |