| 1 | <?php |
|---|
| 2 | /* |
|---|
| 3 | Plugin Name: Restore Auto-Generated Gravatars |
|---|
| 4 | Version: 0.1 |
|---|
| 5 | Plugin URI: http://core.trac.wordpress.org/ticket/25764 |
|---|
| 6 | Description: Restores auto-generated Gravatar images on Dashboard and Edit Comments screens. |
|---|
| 7 | Author: Sergey Biryukov |
|---|
| 8 | Author URI: http://profiles.wordpress.org/sergeybiryukov/ |
|---|
| 9 | */ |
|---|
| 10 | |
|---|
| 11 | function restore_auto_generated_gravatars_25764( $avatar, $id_or_email, $size, $default, $alt ) { |
|---|
| 12 | if ( ! is_admin() ) |
|---|
| 13 | return $avatar; |
|---|
| 14 | |
|---|
| 15 | $screen = get_current_screen(); |
|---|
| 16 | if ( ! in_array( $screen->id, array( 'dashboard', 'edit-comments' ) ) ) |
|---|
| 17 | return $avatar; |
|---|
| 18 | |
|---|
| 19 | remove_filter( 'get_avatar', 'restore_auto_generated_gravatars_25764' ); |
|---|
| 20 | |
|---|
| 21 | $default = get_option( 'avatar_default' ); |
|---|
| 22 | $avatar = get_avatar( $id_or_email, $size, $default, $alt ); |
|---|
| 23 | |
|---|
| 24 | add_filter( 'get_avatar', 'restore_auto_generated_gravatars_25764', 10, 5 ); |
|---|
| 25 | |
|---|
| 26 | return $avatar; |
|---|
| 27 | } |
|---|
| 28 | add_filter( 'get_avatar', 'restore_auto_generated_gravatars_25764', 10, 5 ); |
|---|