| 1181 | if ( !function_exists( 'get_avatar' ) ) : |
| 1182 | function get_avatar( $id_or_email, $size = '80', $default = '' ) { |
| 1183 | if ( ! get_option('show_avatars') ) |
| 1184 | return false; |
| 1185 | |
| 1186 | if ( is_numeric($id_or_email) ) { |
| 1187 | $id = (int) $id_or_email; |
| 1188 | $user = get_userdata($id); |
| 1189 | if ( !$user) |
| 1190 | $email = ''; |
| 1191 | else |
| 1192 | $email = $user->user_email; |
| 1193 | } else { |
| 1194 | $email = $id_or_email; |
| 1195 | } |
| 1196 | |
| 1197 | if ( !empty($email) ) { |
| 1198 | $default = urlencode( $default ); |
| 1199 | |
| 1200 | $out = 'http://www.gravatar.com/avatar.php?gravatar_id='; |
| 1201 | $out .= md5( $email ); |
| 1202 | $out .= "&size={$size}"; |
| 1203 | $out .= "&default={$default}"; |
| 1204 | |
| 1205 | $rating = get_option('avatar_rating'); |
| 1206 | if ( !empty( $rating ) ) |
| 1207 | $out .= "&rating={$rating}"; |
| 1208 | |
| 1209 | $avatar = "<img alt='' src='{$out}' class='avatar avatar-{$size}' height='{$size}' width='{$size}' />"; |
| 1210 | } else { |
| 1211 | $avatar = "<img alt='' src='{$default}' />"; |
| 1212 | } |
| 1213 | |
| 1214 | return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default); |
| 1215 | } |
| 1216 | endif; |
| 1217 | |