Move Admin Colour Scheme picker to a hook. Props Jick. s/register_admin_color_themes()/register_admin_color_schemes/g. See #11625, Fixes #6837

git-svn-id: http://svn.automattic.com/wordpress/trunk@13487 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
dd32 2010-02-28 06:34:31 +00:00
parent dd78c07865
commit b1621c63ae
4 changed files with 36 additions and 25 deletions

View File

@ -662,4 +662,32 @@ function win_is_writable($path) {
function send_nosniff_header() {
@header( 'X-Content-Type-Options: nosniff' );
}
/**
* Display the default admin color scheme picker (Used in user-edit.php)
*
* @since 3.0
*/
function admin_color_scheme_picker() {
global $_wp_admin_css_colors, $user_id; ?>
<fieldset><legend class="screen-reader-text"><span><?php _e('Admin Color Scheme')?></span></legend>
<?php
$current_color = get_user_option('admin_color', $user_id);
if ( empty($current_color) )
$current_color = 'fresh';
foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
<div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo esc_attr($color) ?>" class="tog" <?php checked($color, $current_color); ?> />
<table class="color-palette">
<tr>
<?php foreach ( $color_info->colors as $html_color ): ?>
<td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>">&nbsp;</td>
<?php endforeach; ?>
</tr>
</table>
<label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
</div>
<?php endforeach; ?>
</fieldset>
<?php
}
?>

View File

@ -184,31 +184,13 @@ include ('admin-header.php');
<td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="false" <?php checked('false', $profileuser->rich_editing); ?> /> <?php _e('Disable the visual editor when writing'); ?></label></td>
</tr>
<?php endif; ?>
<?php if ( count($_wp_admin_css_colors) > 1 ) : ?>
<?php if ( count($_wp_admin_css_colors) > 1 && has_action('admin_color_scheme_picker') ) : ?>
<tr>
<th scope="row"><?php _e('Admin Color Scheme')?></th>
<td><fieldset><legend class="screen-reader-text"><span><?php _e('Admin Color Scheme')?></span></legend>
<?php
$current_color = get_user_option('admin_color', $user_id);
if ( empty($current_color) )
$current_color = 'fresh';
foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
<div class="color-option"><input name="admin_color" id="admin_color_<?php echo $color; ?>" type="radio" value="<?php echo esc_attr($color) ?>" class="tog" <?php checked($color, $current_color); ?> />
<table class="color-palette">
<tr>
<?php foreach ( $color_info->colors as $html_color ): ?>
<td style="background-color: <?php echo $html_color ?>" title="<?php echo $color ?>">&nbsp;</td>
<?php endforeach; ?>
</tr>
</table>
<label for="admin_color_<?php echo $color; ?>"><?php echo $color_info->name ?></label>
</div>
<?php endforeach; ?>
</fieldset></td>
<td><?php do_action( 'admin_color_scheme_picker' ); ?></td>
</tr>
<?php
endif;
endif; // $_wp_admin_css_colors
if ( !( IS_PROFILE_PAGE && !$user_can_edit ) ) : ?>
<tr>
<th scope="row"><?php _e( 'Keyboard Shortcuts' ); ?></th>

View File

@ -238,5 +238,6 @@ add_action( 'init', '_show_post_preview' );
// Timezone
add_filter( 'pre_option_gmt_offset','wp_timezone_override_offset' );
// Admin Themes
add_action('admin_init', 'register_admin_color_themes', 1);
// Admin Color Schemes
add_action( 'admin_init', 'register_admin_color_schemes', 1);
add_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );

View File

@ -2029,11 +2029,11 @@ function wp_admin_css_color($key, $name, $url, $colors = array()) {
}
/**
* Registers the default Admin color themes
* Registers the default Admin color schemes
*
* @since 3.0.0
*/
function register_admin_color_themes() {
function register_admin_color_schemes() {
wp_admin_css_color('classic', __('Blue'), admin_url("css/colors-classic.css"), array('#073447', '#21759B', '#EAF3FA', '#BBD8E7'));
wp_admin_css_color('fresh', __('Gray'), admin_url("css/colors-fresh.css"), array('#464646', '#6D6D6D', '#F1F1F1', '#DFDFDF'));}