admin_color_scheme_picker() WordPress Function

The admin_color_scheme_picker() function allows you to select a color scheme for the WordPress admin interface. There are eight color schemes to choose from, and you can preview each one before selecting it.

admin_color_scheme_picker( int $user_id ) #

Displays the default admin color scheme picker (Used in user-edit.php).


Parameters

$user_id

(int)(Required)User ID.


Top ↑

Source

File: wp-admin/includes/misc.php

989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
function admin_color_scheme_picker( $user_id ) {
    global $_wp_admin_css_colors;
 
    ksort( $_wp_admin_css_colors );
 
    if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
        // Set Default ('fresh') and Light should go first.
        $_wp_admin_css_colors = array_filter(
            array_merge(
                array(
                    'fresh'  => '',
                    'light'  => '',
                    'modern' => '',
                ),
                $_wp_admin_css_colors
            )
        );
    }
 
    $current_color = get_user_option( 'admin_color', $user_id );
 
    if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
        $current_color = 'fresh';
    }
    ?>
    <fieldset id="color-picker" class="scheme-list">
        <legend class="screen-reader-text"><span><?php _e( 'Admin Color Scheme' ); ?></span></legend>
        <?php
        wp_nonce_field( 'save-color-scheme', 'color-nonce', false );
        foreach ( $_wp_admin_css_colors as $color => $color_info ) :
 
            ?>
            <div class="color-option <?php echo ( $color === $current_color ) ? 'selected' : ''; ?>">
                <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 ); ?> />
                <input type="hidden" class="css_url" value="<?php echo esc_url( $color_info->url ); ?>" />
                <input type="hidden" class="icon_colors" value="<?php echo esc_attr( wp_json_encode( array( 'icons' => $color_info->icon_colors ) ) ); ?>" />
                <label for="admin_color_<?php echo esc_attr( $color ); ?>"><?php echo esc_html( $color_info->name ); ?></label>
                <table class="color-palette">
                    <tr>
                    <?php
                    foreach ( $color_info->colors as $html_color ) {
                        ?>
                        <td style="background-color: <?php echo esc_attr( $html_color ); ?>">&nbsp;</td>
                        <?php
                    }
                    ?>
                    </tr>
                </table>
            </div>
            <?php
 
        endforeach;
        ?>
    </fieldset>
    <?php
}


Top ↑

Changelog

Changelog
VersionDescription
3.0.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by the Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.