WordPress.org

Make WordPress Core

Changeset 31095


Ignore:
Timestamp:
01/08/2015 05:00:15 PM (5 years ago)
Author:
helen
Message:

Collapse additional avatar settings if avatars are disabled.

props markjaquith, krogsgard, valendesigns.
fixes #30168.

File:
1 edited

Legend:

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

    r30089 r31095  
    1414$title = __('Discussion Settings');
    1515$parent_file = 'options-general.php';
     16
     17/**
     18 * Display JavaScript on the page.
     19 *
     20 * @since 4.2.0
     21 */
     22function 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}
     35add_action( 'admin_print_footer_scripts', 'options_discussion_add_js' );
    1636
    1737get_current_screen()->add_help_tab( array(
     
    173193<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>
    174194
    175 <?php // the above would be a good place to link to codex documentation on the gravatar functions, for putting it in themes. anything like that? ?>
     195<?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?
     197
     198$show_avatars = get_option( 'show_avatars' );
     199?>
    176200
    177201<table class="form-table">
     
    180204<td><fieldset><legend class="screen-reader-text"><span><?php _e('Avatar Display'); ?></span></legend>
    181205    <label for="show_avatars">
    182         <input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked( get_option('show_avatars'), 1 ); ?> />
     206        <input type="checkbox" id="show_avatars" name="show_avatars" value="1" <?php checked( $show_avatars, 1 ); ?> />
    183207        <?php _e( 'Show Avatars' ); ?>
    184208    </label>
    185209</fieldset></td>
    186210</tr>
    187 <tr>
     211<tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
    188212<th scope="row"><?php _e('Maximum Rating'); ?></th>
    189213<td><fieldset><legend class="screen-reader-text"><span><?php _e('Maximum Rating'); ?></span></legend>
     
    208232</fieldset></td>
    209233</tr>
    210 <tr>
     234<tr class="avatar-settings<?php if ( ! $show_avatars ) echo ' hide-if-js'; ?>">
    211235<th scope="row"><?php _e('Default Avatar'); ?></th>
    212236<td class="defaultavatarpicker"><fieldset><legend class="screen-reader-text"><span><?php _e('Default Avatar'); ?></span></legend>
     
    240264$size = 32;
    241265$avatar_list = '';
     266
     267// Force avatars on to display these choices
     268add_filter( 'pre_option_show_avatars', '__return_true', 100 );
     269
    242270foreach ( $avatar_defaults as $default_key => $default_name ) {
    243271    $selected = ($default == $default_key) ? 'checked="checked" ' : '';
     
    250278    $avatar_list .= '<br />';
    251279}
     280
     281remove_filter( 'pre_option_show_avatars', '__return_true', 100 );
     282
    252283/**
    253284 * Filter the HTML output of the default avatar list.
Note: See TracChangeset for help on using the changeset viewer.