@@ 295-309 (lines=15) @@ | ||
292 | // Prefer the core function get_avatar_url() if available, WP 4.2+ |
|
293 | $image['src'] = get_avatar_url( $author->user_email, array( 'size' => $width ) ); |
|
294 | } |
|
295 | else { |
|
296 | $has_filter = has_filter( 'pre_option_show_avatars', '__return_true' ); |
|
297 | if ( ! $has_filter ) { |
|
298 | add_filter( 'pre_option_show_avatars', '__return_true' ); |
|
299 | } |
|
300 | $avatar = get_avatar( $author->user_email, $width ); |
|
301 | if ( ! $has_filter ) { |
|
302 | remove_filter( 'pre_option_show_avatars', '__return_true' ); |
|
303 | } |
|
304 | ||
305 | if ( ! empty( $avatar ) && ! is_wp_error( $avatar ) ) { |
|
306 | if ( preg_match( '/src=["\']([^"\']+)["\']/', $avatar, $matches ) ); |
|
307 | $image['src'] = wp_specialchars_decode( $matches[1], ENT_QUOTES ); |
|
308 | } |
|
309 | } |
|
310 | } |
|
311 | ||
312 | if ( empty( $image ) ) { |
|
@@ 433-448 (lines=16) @@ | ||
430 | else |
|
431 | $image = $avatar; |
|
432 | } |
|
433 | } else { |
|
434 | $has_filter = has_filter( 'pre_option_show_avatars', '__return_true' ); |
|
435 | if ( !$has_filter ) { |
|
436 | add_filter( 'pre_option_show_avatars', '__return_true' ); |
|
437 | } |
|
438 | $avatar = get_avatar( $email, $width ); |
|
439 | ||
440 | if ( !$has_filter ) { |
|
441 | remove_filter( 'pre_option_show_avatars', '__return_true' ); |
|
442 | } |
|
443 | ||
444 | if ( !empty( $avatar ) && !is_wp_error( $avatar ) ) { |
|
445 | if ( preg_match( '/src=["\']([^"\']+)["\']/', $avatar, $matches ) ) |
|
446 | $image = wp_specialchars_decode($matches[1], ENT_QUOTES); |
|
447 | } |
|
448 | } |
|
449 | ||
450 | return $image; |
|
451 | } |