Make WordPress Core


Ignore:
Timestamp:
12/01/2013 07:49:55 PM (12 years ago)
Author:
azaozz
Message:

Improve the admin color scheme picker:

  • Easier to extend.
  • Remove the "drop-down" look, show all choices inline.
  • Some PHP and JS cleanup.

Props ryelle, fixes #26336.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/misc.php

    r26428 r26506  
    564564function admin_color_scheme_picker() {
    565565    global $_wp_admin_css_colors, $user_id;
    566     ksort($_wp_admin_css_colors);
     566
     567    ksort( $_wp_admin_css_colors );
     568
     569    if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
     570        // Set 'fresh' (the default option) to be the first array element
     571        $_wp_admin_css_colors = array_merge( array( 'fresh' => '' ), $_wp_admin_css_colors );
     572    }
    567573
    568574    $current_color = get_user_option( 'admin_color', $user_id );
    569575
    570     if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) )
     576    if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
    571577        $current_color = 'fresh';
    572 
    573     $color_info = $_wp_admin_css_colors[ $current_color ];
    574 ?>
    575 
    576     <fieldset id="color-picker">
     578    }
     579
     580    ?>
     581    <fieldset id="color-picker" class="scheme-list">
    577582        <legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
    578 
    579         <div class="picker-dropdown dropdown-current">
    580             <div class="picker-dropdown-arrow"></div>
    581             <label for="admin_color_<?php echo esc_attr( $current_color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
    582             <table class="color-palette">
    583                 <tr>
    584                 <?php foreach ( $color_info->colors as $html_color ): ?>
    585                     <td style="background-color: <?php echo esc_attr( $html_color ); ?>" title="<?php echo esc_attr( $current_color ); ?>">&nbsp;</td>
    586                 <?php endforeach; ?>
    587                 </tr>
    588             </table>
    589         </div>
    590 
    591         <div class="picker-dropdown dropdown-container">
    592 
    593         <?php foreach ( $_wp_admin_css_colors as $color => $color_info ) : ?>
    594 
     583        <?php
     584
     585        foreach ( $_wp_admin_css_colors as $color => $color_info ) :
     586
     587            ?>
    595588            <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
    596589                <input name="admin_color" id="admin_color_<?php echo esc_attr( $color ); ?>" type="radio" value="<?php echo esc_attr( $color ); ?>" class="tog" <?php checked( $color, $current_color ); ?> />
     
    600593                <table class="color-palette">
    601594                    <tr>
    602                     <?php foreach ( $color_info->colors as $html_color ): ?>
     595                    <?php
     596
     597                    foreach ( $color_info->colors as $html_color ) {
     598                        ?>
    603599                        <td style="background-color: <?php echo esc_attr( $html_color ); ?>" title="<?php echo esc_attr( $color ); ?>">&nbsp;</td>
    604                     <?php endforeach; ?>
     600                        <?php
     601                    }
     602
     603                    ?>
    605604                    </tr>
    606605                </table>
    607606            </div>
    608 
    609         <?php endforeach; ?>
    610 
    611         </div>
    612 
     607            <?php
     608
     609        endforeach;
     610
     611    ?>
    613612    </fieldset>
    614 
    615 <?php
     613    <?php
    616614}
    617615
Note: See TracChangeset for help on using the changeset viewer.