WordPress.org

Make WordPress Core

Changeset 37227


Ignore:
Timestamp:
04/17/2016 10:18:39 AM (4 years ago)
Author:
swissspidy
Message:

Admin: Fix default avatar handling in Settings -> Discussion.

By passing the force_default argument to get_avatar() instead of using preg_replace, we make it easier for developers to override the output.

Props henry.wright.
Fixes #34744.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-discussion.php

    r35331 r37227  
    241241$avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );
    242242$default = get_option( 'avatar_default', 'mystery' );
    243 $size = 32;
    244243$avatar_list = '';
    245244
     
    250249    $selected = ($default == $default_key) ? 'checked="checked" ' : '';
    251250    $avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> ";
    252 
    253     $avatar = get_avatar( $user_email, $size, $default_key );
    254     $avatar = preg_replace( "/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar );
    255     $avatar = preg_replace( "/srcset='(.+?) 2x'/", "srcset='\$1&amp;forcedefault=1 2x'", $avatar );
    256     $avatar_list .= $avatar;
    257 
     251    $avatar_list .= get_avatar( $user_email, 32, $default_key, '', array( 'force_default' => true ) );
    258252    $avatar_list .= ' ' . $default_name . '</label>';
    259253    $avatar_list .= '<br />';
Note: See TracChangeset for help on using the changeset viewer.