wp/wp-admin/options-discussion.php
changeset 7 cf61fcea0001
parent 5 5e2f62d02dcd
child 9 177826044cd9
equal deleted inserted replaced
6:490d5cc509ed 7:cf61fcea0001
     7  */
     7  */
     8 /** WordPress Administration Bootstrap */
     8 /** WordPress Administration Bootstrap */
     9 require_once( dirname( __FILE__ ) . '/admin.php' );
     9 require_once( dirname( __FILE__ ) . '/admin.php' );
    10 
    10 
    11 if ( ! current_user_can( 'manage_options' ) )
    11 if ( ! current_user_can( 'manage_options' ) )
    12 	wp_die( __( 'You do not have sufficient permissions to manage options for this site.' ) );
    12 	wp_die( __( 'Sorry, you are not allowed to manage options for this site.' ) );
    13 
    13 
    14 $title = __('Discussion Settings');
    14 $title = __('Discussion Settings');
    15 $parent_file = 'options-general.php';
    15 $parent_file = 'options-general.php';
    16 
    16 
    17 /**
       
    18  * Output JavaScript to toggle display of additional settings if avatars are disabled.
       
    19  *
       
    20  * @since 4.2.0
       
    21  */
       
    22 function options_discussion_add_js() {
       
    23 ?>
       
    24 	<script>
       
    25 	(function($){
       
    26 		var parent = $( '#show_avatars' ),
       
    27 			children = $( '.avatar-settings' );
       
    28 		parent.change(function(){
       
    29 			children.toggleClass( 'hide-if-js', ! this.checked );
       
    30 		});
       
    31 	})(jQuery);
       
    32 	</script>
       
    33 <?php
       
    34 }
       
    35 add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
    17 add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
    36 
    18 
    37 get_current_screen()->add_help_tab( array(
    19 get_current_screen()->add_help_tab( array(
    38 	'id'      => 'overview',
    20 	'id'      => 'overview',
    39 	'title'   => __('Overview'),
    21 	'title'   => __('Overview'),
    41 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
    23 		'<p>' . __('You must click the Save Changes button at the bottom of the screen for new settings to take effect.') . '</p>',
    42 ) );
    24 ) );
    43 
    25 
    44 get_current_screen()->set_help_sidebar(
    26 get_current_screen()->set_help_sidebar(
    45 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    27 	'<p><strong>' . __('For more information:') . '</strong></p>' .
    46 	'<p>' . __('<a href="https://codex.wordpress.org/Settings_Discussion_Screen" target="_blank">Documentation on Discussion Settings</a>') . '</p>' .
    28 	'<p>' . __('<a href="https://codex.wordpress.org/Settings_Discussion_Screen">Documentation on Discussion Settings</a>') . '</p>' .
    47 	'<p>' . __('<a href="https://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
    29 	'<p>' . __('<a href="https://wordpress.org/support/">Support Forums</a>') . '</p>'
    48 );
    30 );
    49 
    31 
    50 include( ABSPATH . 'wp-admin/admin-header.php' );
    32 include( ABSPATH . 'wp-admin/admin-header.php' );
    51 ?>
    33 ?>
    52 
    34 
    53 <div class="wrap">
    35 <div class="wrap">
    54 <h2><?php echo esc_html( $title ); ?></h2>
    36 <h1><?php echo esc_html( $title ); ?></h1>
    55 
    37 
    56 <form method="post" action="options.php">
    38 <form method="post" action="options.php">
    57 <?php settings_fields('discussion'); ?>
    39 <?php settings_fields('discussion'); ?>
    58 
    40 
    59 <table class="form-table">
    41 <table class="form-table">
    64 <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
    46 <input name="default_pingback_flag" type="checkbox" id="default_pingback_flag" value="1" <?php checked('1', get_option('default_pingback_flag')); ?> />
    65 <?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
    47 <?php _e('Attempt to notify any blogs linked to from the article'); ?></label>
    66 <br />
    48 <br />
    67 <label for="default_ping_status">
    49 <label for="default_ping_status">
    68 <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
    50 <input name="default_ping_status" type="checkbox" id="default_ping_status" value="open" <?php checked('open', get_option('default_ping_status')); ?> />
    69 <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks)'); ?></label>
    51 <?php _e('Allow link notifications from other blogs (pingbacks and trackbacks) on new articles'); ?></label>
    70 <br />
    52 <br />
    71 <label for="default_comment_status">
    53 <label for="default_comment_status">
    72 <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
    54 <input name="default_comment_status" type="checkbox" id="default_comment_status" value="open" <?php checked('open', get_option('default_comment_status')); ?> />
    73 <?php _e('Allow people to post comments on new articles'); ?></label>
    55 <?php _e('Allow people to post comments on new articles'); ?></label>
    74 <br />
    56 <br />
    76 </fieldset></td>
    58 </fieldset></td>
    77 </tr>
    59 </tr>
    78 <tr>
    60 <tr>
    79 <th scope="row"><?php _e('Other comment settings'); ?></th>
    61 <th scope="row"><?php _e('Other comment settings'); ?></th>
    80 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
    62 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Other comment settings'); ?></span></legend>
    81 <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and e-mail'); ?></label>
    63 <label for="require_name_email"><input type="checkbox" name="require_name_email" id="require_name_email" value="1" <?php checked('1', get_option('require_name_email')); ?> /> <?php _e('Comment author must fill out name and email'); ?></label>
    82 <br />
    64 <br />
    83 <label for="comment_registration">
    65 <label for="comment_registration">
    84 <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
    66 <input name="comment_registration" type="checkbox" id="comment_registration" value="1" <?php checked('1', get_option('comment_registration')); ?> />
    85 <?php _e('Users must be registered and logged in to comment'); ?>
    67 <?php _e('Users must be registered and logged in to comment'); ?>
    86 <?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
    68 <?php if ( !get_option( 'users_can_register' ) && is_multisite() ) echo ' ' . __( '(Signup has been disabled. Only members of this site can comment.)' ); ?>
    87 </label>
    69 </label>
    88 <br />
    70 <br />
    89 
    71 
    90 <label for="close_comments_for_old_posts">
    72 <label for="close_comments_for_old_posts">
    91 <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
    73 <input name="close_comments_for_old_posts" type="checkbox" id="close_comments_for_old_posts" value="1" <?php checked('1', get_option('close_comments_for_old_posts')); ?> />
    92 <?php printf( __('Automatically close comments on articles older than %s days'), '</label><label for="close_comments_days_old"><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="' . esc_attr(get_option('close_comments_days_old')) . '" class="small-text" />'); ?>
    74 <?php printf(
       
    75 	__( 'Automatically close comments on articles older than %s days' ),
       
    76 	'</label> <label for="close_comments_days_old"><input name="close_comments_days_old" type="number" min="0" step="1" id="close_comments_days_old" value="' . esc_attr( get_option( 'close_comments_days_old' ) ) . '" class="small-text" />'
       
    77 ); ?>
    93 </label>
    78 </label>
    94 <br />
    79 <br />
       
    80 
       
    81 <label for="show_comments_cookies_opt_in">
       
    82 <input name="show_comments_cookies_opt_in" type="checkbox" id="show_comments_cookies_opt_in" value="1" <?php checked( '1', get_option( 'show_comments_cookies_opt_in' ) ); ?> />
       
    83 <?php _e( 'Show comments cookies opt-in checkbox.' ); ?>
       
    84 </label>
       
    85 <br />
       
    86 
    95 <label for="thread_comments">
    87 <label for="thread_comments">
    96 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
    88 <input name="thread_comments" type="checkbox" id="thread_comments" value="1" <?php checked('1', get_option('thread_comments')); ?> />
    97 <?php
    89 <?php
    98 /**
    90 /**
    99  * Filter the maximum depth of threaded/nested comments.
    91  * Filters the maximum depth of threaded/nested comments.
   100  *
    92  *
   101  * @since 2.7.0.
    93  * @since 2.7.0.
   102  *
    94  *
   103  * @param int $max_depth The maximum depth of threaded comments. Default 10.
    95  * @param int $max_depth The maximum depth of threaded comments. Default 10.
   104  */
    96  */
   105 $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
    97 $maxdeep = (int) apply_filters( 'thread_comments_depth_max', 10 );
   106 
    98 
   107 $thread_comments_depth = '</label><label for="thread_comments_depth"><select name="thread_comments_depth" id="thread_comments_depth">';
    99 $thread_comments_depth = '</label> <label for="thread_comments_depth"><select name="thread_comments_depth" id="thread_comments_depth">';
   108 for ( $i = 2; $i <= $maxdeep; $i++ ) {
   100 for ( $i = 2; $i <= $maxdeep; $i++ ) {
   109 	$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
   101 	$thread_comments_depth .= "<option value='" . esc_attr($i) . "'";
   110 	if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
   102 	if ( get_option('thread_comments_depth') == $i ) $thread_comments_depth .= " selected='selected'";
   111 	$thread_comments_depth .= ">$i</option>";
   103 	$thread_comments_depth .= ">$i</option>";
   112 }
   104 }
   115 printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
   107 printf( __('Enable threaded (nested) comments %s levels deep'), $thread_comments_depth );
   116 
   108 
   117 ?></label>
   109 ?></label>
   118 <br />
   110 <br />
   119 <label for="page_comments">
   111 <label for="page_comments">
   120 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked('1', get_option('page_comments')); ?> />
   112 <input name="page_comments" type="checkbox" id="page_comments" value="1" <?php checked( '1', get_option( 'page_comments' ) ); ?> />
   121 <?php
   113 <?php
   122 
   114 $default_comments_page = '</label> <label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
   123 $default_comments_page = '</label><label for="default_comments_page"><select name="default_comments_page" id="default_comments_page"><option value="newest"';
       
   124 if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
   115 if ( 'newest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
   125 $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
   116 $default_comments_page .= '>' . __('last') . '</option><option value="oldest"';
   126 if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
   117 if ( 'oldest' == get_option('default_comments_page') ) $default_comments_page .= ' selected="selected"';
   127 $default_comments_page .= '>' . __('first') . '</option></select>';
   118 $default_comments_page .= '>' . __('first') . '</option></select>';
   128 
   119 printf(
   129 printf( __('Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default'), '</label><label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr(get_option('comments_per_page')) . '" class="small-text" />', $default_comments_page );
   120 	/* translators: 1: Form field control for number of top level comments per page, 2: Form field control for the 'first' or 'last' page */
   130 
   121 	__( 'Break comments into pages with %1$s top level comments per page and the %2$s page displayed by default' ),
       
   122 	'</label> <label for="comments_per_page"><input name="comments_per_page" type="number" step="1" min="0" id="comments_per_page" value="' . esc_attr( get_option( 'comments_per_page' ) ) . '" class="small-text" />',
       
   123 	$default_comments_page
       
   124 );
   131 ?></label>
   125 ?></label>
   132 <br />
   126 <br />
   133 <label for="comment_order"><?php
   127 <label for="comment_order"><?php
   134 
   128 
   135 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
   129 $comment_order = '<select name="comment_order" id="comment_order"><option value="asc"';
   142 
   136 
   143 ?></label>
   137 ?></label>
   144 </fieldset></td>
   138 </fieldset></td>
   145 </tr>
   139 </tr>
   146 <tr>
   140 <tr>
   147 <th scope="row"><?php _e('E-mail me whenever'); ?></th>
   141 <th scope="row"><?php _e('Email me whenever'); ?></th>
   148 <td><fieldset><legend class="screen-reader-text"><span><?php _e('E-mail me whenever'); ?></span></legend>
   142 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Email me whenever'); ?></span></legend>
   149 <label for="comments_notify">
   143 <label for="comments_notify">
   150 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
   144 <input name="comments_notify" type="checkbox" id="comments_notify" value="1" <?php checked('1', get_option('comments_notify')); ?> />
   151 <?php _e('Anyone posts a comment'); ?> </label>
   145 <?php _e('Anyone posts a comment'); ?> </label>
   152 <br />
   146 <br />
   153 <label for="moderation_notify">
   147 <label for="moderation_notify">
   168 <tr>
   162 <tr>
   169 <th scope="row"><?php _e('Comment Moderation'); ?></th>
   163 <th scope="row"><?php _e('Comment Moderation'); ?></th>
   170 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
   164 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Moderation'); ?></span></legend>
   171 <p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
   165 <p><label for="comment_max_links"><?php printf(__('Hold a comment in the queue if it contains %s or more links. (A common characteristic of comment spam is a large number of hyperlinks.)'), '<input name="comment_max_links" type="number" step="1" min="0" id="comment_max_links" value="' . esc_attr(get_option('comment_max_links')) . '" class="small-text" />' ); ?></label></p>
   172 
   166 
   173 <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
   167 <p><label for="moderation_keys"><?php _e('When a comment contains any of these words in its content, name, URL, email, or IP address, it will be held in the <a href="edit-comments.php?comment_status=moderated">moderation queue</a>. One word or IP address per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
   174 <p>
   168 <p>
   175 <textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
   169 <textarea name="moderation_keys" rows="10" cols="50" id="moderation_keys" class="large-text code"><?php echo esc_textarea( get_option( 'moderation_keys' ) ); ?></textarea>
   176 </p>
   170 </p>
   177 </fieldset></td>
   171 </fieldset></td>
   178 </tr>
   172 </tr>
   179 <tr>
   173 <tr>
   180 <th scope="row"><?php _e('Comment Blacklist'); ?></th>
   174 <th scope="row"><?php _e('Comment Blacklist'); ?></th>
   181 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
   175 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Comment Blacklist'); ?></span></legend>
   182 <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, e-mail, or IP, it will be marked as spam. One word or IP per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
   176 <p><label for="blacklist_keys"><?php _e('When a comment contains any of these words in its content, name, URL, email, or IP address, it will be put in the trash. One word or IP address per line. It will match inside words, so &#8220;press&#8221; will match &#8220;WordPress&#8221;.'); ?></label></p>
   183 <p>
   177 <p>
   184 <textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
   178 <textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
   185 </p>
   179 </p>
   186 </fieldset></td>
   180 </fieldset></td>
   187 </tr>
   181 </tr>
   188 <?php do_settings_fields('discussion', 'default'); ?>
   182 <?php do_settings_fields('discussion', 'default'); ?>
   189 </table>
   183 </table>
   190 
   184 
   191 <h3 class="title"><?php _e('Avatars'); ?></h3>
   185 <h2 class="title"><?php _e('Avatars'); ?></h2>
   192 
   186 
   193 <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
   187 <p><?php _e('An avatar is an image that follows you from weblog to weblog appearing beside your name when you comment on avatar enabled sites. Here you can enable the display of avatars for people who comment on your site.'); ?></p>
   194 
   188 
   195 <?php
   189 <?php
   196 // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that?
   190 // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that?
   212 <th scope="row"><?php _e('Maximum Rating'); ?></th>
   206 <th scope="row"><?php _e('Maximum Rating'); ?></th>
   213 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
   207 <td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
   214 
   208 
   215 <?php
   209 <?php
   216 $ratings = array(
   210 $ratings = array(
   217 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
   211 	/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
   218 	'G' => __('G &#8212; Suitable for all audiences'),
   212 	'G' => __('G &#8212; Suitable for all audiences'),
   219 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
   213 	/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
   220 	'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
   214 	'PG' => __('PG &#8212; Possibly offensive, usually for audiences 13 and above'),
   221 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
   215 	/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
   222 	'R' => __('R &#8212; Intended for adult audiences above 17'),
   216 	'R' => __('R &#8212; Intended for adult audiences above 17'),
   223 	/* translators: Content suitability rating: http://bit.ly/89QxZA */
   217 	/* translators: Content suitability rating: https://en.wikipedia.org/wiki/Motion_Picture_Association_of_America_film_rating_system */
   224 	'X' => __('X &#8212; Even more mature than above')
   218 	'X' => __('X &#8212; Even more mature than above')
   225 );
   219 );
   226 foreach ($ratings as $key => $rating) :
   220 foreach ($ratings as $key => $rating) :
   227 	$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
   221 	$selected = (get_option('avatar_rating') == $key) ? 'checked="checked"' : '';
   228 	echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
   222 	echo "\n\t<label><input type='radio' name='avatar_rating' value='" . esc_attr($key) . "' $selected/> $rating</label><br />";
   233 </tr>
   227 </tr>
   234 <tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
   228 <tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
   235 <th scope="row"><?php _e('Default Avatar'); ?></th>
   229 <th scope="row"><?php _e('Default Avatar'); ?></th>
   236 <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
   230 <td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
   237 
   231 
   238 <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their e-mail address.'); ?><br />
   232 <?php _e('For users without a custom avatar of their own, you can either display a generic logo or a generated one based on their email address.'); ?><br />
   239 
   233 
   240 <?php
   234 <?php
   241 $avatar_defaults = array(
   235 $avatar_defaults = array(
   242 	'mystery' => __('Mystery Person'),
   236 	'mystery' => __('Mystery Person'),
   243 	'blank' => __('Blank'),
   237 	'blank' => __('Blank'),
   246 	'wavatar' => __('Wavatar (Generated)'),
   240 	'wavatar' => __('Wavatar (Generated)'),
   247 	'monsterid' => __('MonsterID (Generated)'),
   241 	'monsterid' => __('MonsterID (Generated)'),
   248 	'retro' => __('Retro (Generated)')
   242 	'retro' => __('Retro (Generated)')
   249 );
   243 );
   250 /**
   244 /**
   251  * Filter the default avatars.
   245  * Filters the default avatars.
   252  *
   246  *
   253  * Avatars are stored in key/value pairs, where the key is option value,
   247  * Avatars are stored in key/value pairs, where the key is option value,
   254  * and the name is the displayed avatar name.
   248  * and the name is the displayed avatar name.
   255  *
   249  *
   256  * @since 2.6.0
   250  * @since 2.6.0
   257  *
   251  *
   258  * @param array $avatar_defaults Array of default avatars.
   252  * @param array $avatar_defaults Array of default avatars.
   259  */
   253  */
   260 $avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );
   254 $avatar_defaults = apply_filters( 'avatar_defaults', $avatar_defaults );
   261 $default = get_option('avatar_default');
   255 $default = get_option( 'avatar_default', 'mystery' );
   262 if ( empty($default) )
       
   263 	$default = 'mystery';
       
   264 $size = 32;
       
   265 $avatar_list = '';
   256 $avatar_list = '';
   266 
   257 
   267 // Force avatars on to display these choices
   258 // Force avatars on to display these choices
   268 add_filter( 'pre_option_show_avatars', '__return_true', 100 );
   259 add_filter( 'pre_option_show_avatars', '__return_true', 100 );
   269 
   260 
   270 foreach ( $avatar_defaults as $default_key => $default_name ) {
   261 foreach ( $avatar_defaults as $default_key => $default_name ) {
   271 	$selected = ($default == $default_key) ? 'checked="checked" ' : '';
   262 	$selected = ($default == $default_key) ? 'checked="checked" ' : '';
   272 	$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> ";
   263 	$avatar_list .= "\n\t<label><input type='radio' name='avatar_default' id='avatar_{$default_key}' value='" . esc_attr($default_key) . "' {$selected}/> ";
   273 
   264 	$avatar_list .= get_avatar( $user_email, 32, $default_key, '', array( 'force_default' => true ) );
   274 	$avatar = get_avatar( $user_email, $size, $default_key );
       
   275 	$avatar = preg_replace( "/src='(.+?)'/", "src='\$1&amp;forcedefault=1'", $avatar );
       
   276 	$avatar = preg_replace( "/srcset='(.+?) 2x'/", "srcset='\$1&amp;forcedefault=1 2x'", $avatar );
       
   277 	$avatar_list .= $avatar;
       
   278 
       
   279 	$avatar_list .= ' ' . $default_name . '</label>';
   265 	$avatar_list .= ' ' . $default_name . '</label>';
   280 	$avatar_list .= '<br />';
   266 	$avatar_list .= '<br />';
   281 }
   267 }
   282 
   268 
   283 remove_filter( 'pre_option_show_avatars', '__return_true', 100 );
   269 remove_filter( 'pre_option_show_avatars', '__return_true', 100 );
   284 
   270 
   285 /**
   271 /**
   286  * Filter the HTML output of the default avatar list.
   272  * Filters the HTML output of the default avatar list.
   287  *
   273  *
   288  * @since 2.6.0
   274  * @since 2.6.0
   289  *
   275  *
   290  * @param string $avatar_list HTML markup of the avatar list.
   276  * @param string $avatar_list HTML markup of the avatar list.
   291  */
   277  */