Admin color selector. see #6167

git-svn-id: http://svn.automattic.com/wordpress/trunk@7249 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-11 21:06:03 +00:00
parent 66e8bdb87f
commit f0479dbc17
5 changed files with 64 additions and 8 deletions

View File

@ -28,9 +28,11 @@ get_admin_page_title();
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php echo get_option('blog_charset'); ?>" />
<title><?php bloginfo('name') ?> &rsaquo; <?php echo wp_specialchars( strip_tags( $title ) ); ?> &#8212; WordPress</title>
<?php
wp_admin_css_color('classic', __('Classic'), get_option( 'siteurl' ) . "/wp-admin/css/colors-classic.css", array('#07273E', '#14568A', '#D54E21', '#2683AE'));
wp_admin_css_color('fresh', __('Fresh'), get_option( 'siteurl' ) . "/wp-admin/css/colors-fresh.css", array('#464646', '#CEE1EF', '#D54E21', '#2683AE'));
wp_admin_css( 'css/global' );
wp_admin_css();
wp_admin_css( 'css/colors-classic' );
wp_admin_css( 'css/colors' );
?>
<!--[if gte IE 6]>
<?php wp_admin_css( 'css/ie' );

View File

@ -73,6 +73,13 @@ function edit_user( $user_id = 0 ) {
else
$user->rich_editing = 'false';
if ( !$update )
$user->admin_color = 'classic'; // Default to classic for new users.
else if ( isset( $_POST['admin_color'] ) )
$user->admin_color = $_POST['admin_color'];
else
$user->admin_color = 'classic';
$errors = new WP_Error();
/* checking that username has been typed */

View File

@ -146,13 +146,35 @@ include ('admin-header.php');
<h3><?php _e('Personal Options'); ?></h3>
<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
<table class="form-table">
<?php if ( rich_edit_exists() ) : // don't bother showing the option if the editor has been removed ?>
<tr>
<td colspan="2"><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></td>
<th scope="row"><?php _e('Visual Editor')?></th>
<td><label for="rich_editing"><input name="rich_editing" type="checkbox" id="rich_editing" value="true" <?php checked('true', $profileuser->rich_editing); ?> /> <?php _e('Use the visual editor when writing'); ?></label></td>
</tr>
</table>
<?php endif; ?>
<tr>
<th scope="row"><?php _e('Admin Color Scheme')?></th>
<td>
<?php
foreach ( $_wp_admin_css_colors as $color => $color_info ): ?>
<p><label>
<input name="admin_color" type="radio" value="<?php echo $color ?>" class="tog" <?php checked($color, get_user_option('admin_color')); ?> />
<?php echo $color_info->name ?>
</label>
<table>
<tr>
<?php
foreach ( $color_info->colors as $color ): ?>
<td style="background-color: <?php echo $color ?>" title="<?php echo $color ?>"></td>
<?php endforeach; ?>
</tr>
</table>
</p>
<?php endforeach; ?>
</td>
</table>
<?php
if ( $is_profile_page ) {

View File

@ -1100,17 +1100,37 @@ function paginate_links( $args = '' ) {
return $r;
}
function wp_admin_css_color($key, $name, $url, $colors = array()) {
global $_wp_admin_css_colors;
if ( !isset($_wp_admin_css_colors) )
$_wp_admin_css_colors = array();
$_wp_admin_css_colors[$key] = (object) array('name' => $name, 'url' => $url, 'colors' => $colors);
}
function wp_admin_css_uri( $file = 'wp-admin' ) {
if ( defined('WP_INSTALLING') )
{
$_file = add_query_arg( 'version', get_bloginfo( 'version' ), "./$file.css" );
if ( defined('WP_INSTALLING') ) {
$_file = "./$file.css";
} else {
$_file = add_query_arg( 'version', get_bloginfo( 'version' ), get_option( 'siteurl' ) . "/wp-admin/$file.css" );
if ( 'css/colors' == $file || 'css/colors-rtl' == $file ) {
global $_wp_admin_css_colors;
$color = get_user_option('admin_color');
if ( empty($color) || !isset($_wp_admin_css_colors[$color]) )
$color = 'classic';
$color = $_wp_admin_css_colors[$color];
$_file = $color->url;
} else {
$_file = get_option( 'siteurl' ) . "/wp-admin/$file.css";
}
}
$_file = add_query_arg( 'version', get_bloginfo( 'version' ), $_file );
return apply_filters( 'wp_admin_css_uri', $_file, $file );
}
function wp_admin_css( $file = 'wp-admin' ) {
echo apply_filters( 'wp_admin_css', "<link rel='stylesheet' href='" . wp_admin_css_uri( $file ) . "' type='text/css' />\n", $file );
if ( 'rtl' == get_bloginfo( 'text_direction' ) ) {
$rtl = ( 'wp-admin' == $file ) ? 'rtl' : "$file-rtl";

View File

@ -154,6 +154,10 @@ function wp_insert_user($userdata) {
if ( empty($rich_editing) )
$rich_editing = 'true';
if ( empty($admin_color) )
$admin_color = 'classic';
$admin_color = preg_replace('|[^a-z0-9 _.\-@]|i', '', $admin_color);
if ( empty($user_registered) )
$user_registered = gmdate('Y-m-d H:i:s');
@ -176,6 +180,7 @@ function wp_insert_user($userdata) {
update_usermeta( $user_id, 'aim', $aim );
update_usermeta( $user_id, 'yim', $yim );
update_usermeta( $user_id, 'rich_editing', $rich_editing);
update_usermeta( $user_id, 'admin_color', $admin_color);
if ( $update && isset($role) ) {
$user = new WP_User($user_id);