WordPress.org

Make WordPress Core


Ignore:
Timestamp:
11/13/2013 07:37:10 PM (6 years ago)
Author:
helen
Message:

Merge the color schemes component from MP6. Introduces Light, Blue, and Midnight.

Color scheme selection on your own profile page gives you a preview and autosaves the selection.

Also introduces the usage of a preprocessor for core files, namely Sass. For 3.8, we will not expand its implementation past the color schemes. This does require Ruby as well as Sass 3.3.0+ due to the usage of the sourcemap option.

Note that only the default color scheme is available when running out of src. Use build to test the rest as well as the color picker.

props ryelle, melchoyce, tillkruess, drw158, littlethingsstudio, helen. see #25858, #22862.

File:
1 edited

Legend:

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

    r25991 r26137  
    563563 */
    564564function admin_color_scheme_picker() {
    565     global $_wp_admin_css_colors, $user_id; ?>
    566 <fieldset><legend class="screen-reader-text"><span><?php _e('Admin Color Scheme')?></span></legend>
     565    global $_wp_admin_css_colors, $user_id;
     566    ksort($_wp_admin_css_colors);
     567
     568    $current_color = get_user_option( 'admin_color', $user_id );
     569
     570    if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) )
     571        $current_color = 'fresh';
     572
     573    $color_info = $_wp_admin_css_colors[ $current_color ];
     574?>
     575
     576    <fieldset id="color-picker">
     577        <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
     595            <div class="color-option <?php echo ( $color == $current_color ) ? 'selected' : ''; ?>">
     596                <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 ); ?> />
     597                <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
     598                <input type="hidden" class="icon_colors" value="<?php echo esc_attr( json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
     599                <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
     600                <table class="color-palette">
     601                    <tr>
     602                    <?php foreach ( $color_info->colors as $html_color ): ?>
     603                        <td style="background-color: <?php echo esc_attr( $html_color ); ?>" title="<?php echo esc_attr( $color ); ?>">&nbsp;</td>
     604                    <?php endforeach; ?>
     605                    </tr>
     606                </table>
     607            </div>
     608
     609        <?php endforeach; ?>
     610
     611        </div>
     612
     613    </fieldset>
     614
    567615<?php
    568 $current_color = get_user_option('admin_color', $user_id);
    569 if ( empty($current_color) )
    570     $current_color = 'fresh';
    571 foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
    572 <div class="color-option"><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); ?> />
    573     <table class="color-palette">
    574     <tr>
    575     <?php foreach ( $color_info->colors as $html_color ): ?>
    576     <td style="background-color: <?php echo esc_attr( $html_color ); ?>" title="<?php echo esc_attr( $color ); ?>">&nbsp;</td>
    577     <?php endforeach; ?>
    578     </tr>
    579     </table>
    580 
    581     <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
    582 </div>
    583     <?php endforeach; ?>
    584 </fieldset>
    585 <?php
    586 }
     616}
     617
     618function set_color_scheme_json() {
     619    global $_wp_admin_css_colors;
     620
     621    $color_scheme = get_user_option( 'admin_color' );
     622
     623    if ( isset( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
     624        echo '<script type="text/javascript">var mp6_color_scheme = ' . json_encode( array( 'icons' => $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) . ";</script>\n";
     625    }
     626}
     627add_action( 'admin_head', 'set_color_scheme_json' );
    587628
    588629function _ipad_meta() {
Note: See TracChangeset for help on using the changeset viewer.