Skip to content

Commit 4f0e5ed

Browse files
committed
Admin: Change the default admin color scheme to Modern.
Rename the 'Modern' color scheme to 'Default' and the previous 'Default' scheme to 'Fresh'. Update all fallback references from 'fresh' to 'modern' across admin headers, the Customizer, the color scheme picker, the script loader, and user functions. Add an upgrade routine in `upgrade_700()` to migrate existing users with the 'fresh' admin color to 'modern'. Props fabiankaegy, audrasjb, mukesh27, westonruter, peterwilsoncc, jorbin, sabernhardt, joedolson, phpbits. Fixes #64546. git-svn-id: https://develop.svn.wordpress.org/trunk@61644 602fd350-edb4-49c9-b593-d223f7449a82
1 parent a76dd29 commit 4f0e5ed

9 files changed

Lines changed: 57 additions & 28 deletions

File tree

src/wp-admin/admin-header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193

194194
$admin_body_class .= ' branch-' . str_replace( array( '.', ',' ), '-', (float) get_bloginfo( 'version' ) );
195195
$admin_body_class .= ' version-' . str_replace( '.', '-', preg_replace( '/^([.0-9]+).*/', '$1', get_bloginfo( 'version' ) ) );
196-
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'fresh' );
196+
$admin_body_class .= ' admin-color-' . sanitize_html_class( get_user_option( 'admin_color' ), 'modern' );
197197
$admin_body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
198198

199199
if ( wp_is_mobile() ) {

src/wp-admin/customize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@
148148
}
149149
$body_class .= ' locale-' . sanitize_html_class( strtolower( str_replace( '_', '-', get_user_locale() ) ) );
150150
$admin_color = get_user_option( 'admin_color' );
151-
$body_class .= ' admin-color-' . sanitize_html_class( is_string( $admin_color ) ? $admin_color : '', 'fresh' );
151+
$body_class .= ' admin-color-' . sanitize_html_class( is_string( $admin_color ) ? $admin_color : '', 'modern' );
152152

153153
if ( wp_use_widgets_block_editor() ) {
154154
$body_class .= ' wp-embed-responsive';

src/wp-admin/includes/misc.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1004,14 +1004,14 @@ function admin_color_scheme_picker( $user_id ) {
10041004

10051005
ksort( $_wp_admin_css_colors );
10061006

1007-
if ( isset( $_wp_admin_css_colors['fresh'] ) ) {
1008-
// Set Default ('fresh') and Light should go first.
1007+
if ( isset( $_wp_admin_css_colors['modern'] ) ) {
1008+
// Set Modern (new default), Classic ('fresh'), and Light first.
10091009
$_wp_admin_css_colors = array_filter(
10101010
array_merge(
10111011
array(
1012+
'modern' => '',
10121013
'fresh' => '',
10131014
'light' => '',
1014-
'modern' => '',
10151015
),
10161016
$_wp_admin_css_colors
10171017
)
@@ -1021,7 +1021,7 @@ function admin_color_scheme_picker( $user_id ) {
10211021
$current_color = get_user_option( 'admin_color', $user_id );
10221022

10231023
if ( empty( $current_color ) || ! isset( $_wp_admin_css_colors[ $current_color ] ) ) {
1024-
$current_color = 'fresh';
1024+
$current_color = 'modern';
10251025
}
10261026
?>
10271027
<fieldset id="color-picker" class="scheme-list">
@@ -1067,13 +1067,13 @@ function wp_color_scheme_settings() {
10671067

10681068
// It's possible to have a color scheme set that is no longer registered.
10691069
if ( empty( $_wp_admin_css_colors[ $color_scheme ] ) ) {
1070-
$color_scheme = 'fresh';
1070+
$color_scheme = 'modern';
10711071
}
10721072

10731073
if ( ! empty( $_wp_admin_css_colors[ $color_scheme ]->icon_colors ) ) {
10741074
$icon_colors = $_wp_admin_css_colors[ $color_scheme ]->icon_colors;
1075-
} elseif ( ! empty( $_wp_admin_css_colors['fresh']->icon_colors ) ) {
1076-
$icon_colors = $_wp_admin_css_colors['fresh']->icon_colors;
1075+
} elseif ( ! empty( $_wp_admin_css_colors['modern']->icon_colors ) ) {
1076+
$icon_colors = $_wp_admin_css_colors['modern']->icon_colors;
10771077
} else {
10781078
// Fall back to the default set of icon colors if the default scheme is missing.
10791079
$icon_colors = array(

src/wp-admin/includes/upgrade.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -886,6 +886,10 @@ function upgrade_all() {
886886
upgrade_682();
887887
}
888888

889+
if ( $wp_current_db_version < 61644 ) {
890+
upgrade_700();
891+
}
892+
889893
maybe_disable_link_manager();
890894

891895
maybe_disable_automattic_widgets();
@@ -2481,6 +2485,31 @@ function ( $url ) {
24812485
}
24822486
}
24832487

2488+
/**
2489+
* Executes changes made in WordPress 7.0.
2490+
*
2491+
* @ignore
2492+
* @since 7.0.0
2493+
*
2494+
* @global int $wp_current_db_version The old (current) database version.
2495+
* @global wpdb $wpdb WordPress database abstraction object.
2496+
*/
2497+
function upgrade_700() {
2498+
global $wp_current_db_version, $wpdb;
2499+
2500+
// Migrate users with 'fresh' admin color to 'modern'.
2501+
if ( $wp_current_db_version < 61644 ) {
2502+
$wpdb->update(
2503+
$wpdb->usermeta,
2504+
array( 'meta_value' => 'modern' ),
2505+
array(
2506+
'meta_key' => 'admin_color',
2507+
'meta_value' => 'fresh',
2508+
)
2509+
);
2510+
}
2511+
}
2512+
24842513
/**
24852514
* Executes network-level upgrade routines.
24862515
*

src/wp-admin/includes/user.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ function edit_user( $user_id = 0 ) {
134134
if ( $update ) {
135135
$user->rich_editing = isset( $_POST['rich_editing'] ) && 'false' === $_POST['rich_editing'] ? 'false' : 'true';
136136
$user->syntax_highlighting = isset( $_POST['syntax_highlighting'] ) && 'false' === $_POST['syntax_highlighting'] ? 'false' : 'true';
137-
$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'fresh';
137+
$user->admin_color = isset( $_POST['admin_color'] ) ? sanitize_text_field( $_POST['admin_color'] ) : 'modern';
138138
$user->show_admin_bar_front = isset( $_POST['admin_bar_front'] ) ? 'true' : 'false';
139139
}
140140

src/wp-includes/general-template.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4892,8 +4892,20 @@ function register_admin_color_schemes() {
48924892
$suffix .= SCRIPT_DEBUG ? '' : '.min';
48934893

48944894
wp_admin_css_color(
4895-
'fresh',
4895+
'modern',
48964896
_x( 'Default', 'admin color scheme' ),
4897+
admin_url( "css/colors/modern/colors$suffix.css" ),
4898+
array( '#1e1e1e', '#3858e9', '#7b90ff' ),
4899+
array(
4900+
'base' => '#f3f1f1',
4901+
'focus' => '#fff',
4902+
'current' => '#fff',
4903+
)
4904+
);
4905+
4906+
wp_admin_css_color(
4907+
'fresh',
4908+
_x( 'Fresh', 'admin color scheme' ),
48974909
false,
48984910
array( '#1d2327', '#2c3338', '#2271b1', '#72aee6' ),
48994911
array(
@@ -4915,18 +4927,6 @@ function register_admin_color_schemes() {
49154927
)
49164928
);
49174929

4918-
wp_admin_css_color(
4919-
'modern',
4920-
_x( 'Modern', 'admin color scheme' ),
4921-
admin_url( "css/colors/modern/colors$suffix.css" ),
4922-
array( '#1e1e1e', '#3858e9', '#7b90ff' ),
4923-
array(
4924-
'base' => '#f3f1f1',
4925-
'focus' => '#fff',
4926-
'current' => '#fff',
4927-
)
4928-
);
4929-
49304930
wp_admin_css_color(
49314931
'blue',
49324932
_x( 'Blue', 'admin color scheme' ),

src/wp-includes/script-loader.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2105,7 +2105,7 @@ function wp_style_loader_src( $src, $handle ) {
21052105
$color = get_user_option( 'admin_color' );
21062106

21072107
if ( empty( $color ) || ! isset( $_wp_admin_css_colors[ $color ] ) ) {
2108-
$color = 'fresh';
2108+
$color = 'modern';
21092109
}
21102110

21112111
$color = $_wp_admin_css_colors[ $color ] ?? null;

src/wp-includes/user.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2184,7 +2184,7 @@ function validate_username( $username ) {
21842184
* @type string $comment_shortcuts Whether to enable comment moderation keyboard
21852185
* shortcuts for the user. Accepts 'true' or 'false'
21862186
* as a string literal, not boolean. Default 'false'.
2187-
* @type string $admin_color Admin color scheme for the user. Default 'fresh'.
2187+
* @type string $admin_color Admin color scheme for the user. Default 'modern'.
21882188
* @type bool $use_ssl Whether the user should always access the admin over
21892189
* https. Default false.
21902190
* @type string $user_registered Date the user registered in UTC. Format is 'Y-m-d H:i:s'.
@@ -2457,7 +2457,7 @@ function wp_insert_user( $userdata ) {
24572457

24582458
$meta['comment_shortcuts'] = empty( $userdata['comment_shortcuts'] ) || 'false' === $userdata['comment_shortcuts'] ? 'false' : 'true';
24592459

2460-
$admin_color = empty( $userdata['admin_color'] ) ? 'fresh' : $userdata['admin_color'];
2460+
$admin_color = empty( $userdata['admin_color'] ) ? 'modern' : $userdata['admin_color'];
24612461
$meta['admin_color'] = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $admin_color );
24622462

24632463
$meta['use_ssl'] = empty( $userdata['use_ssl'] ) ? '0' : '1';
@@ -2546,7 +2546,7 @@ function wp_insert_user( $userdata ) {
25462546
* @type string $rich_editing Whether to enable the rich-editor for the user. Default 'true'.
25472547
* @type string $syntax_highlighting Whether to enable the rich code editor for the user. Default 'true'.
25482548
* @type string $comment_shortcuts Whether to enable keyboard shortcuts for the user. Default 'false'.
2549-
* @type string $admin_color The color scheme for a user's admin screen. Default 'fresh'.
2549+
* @type string $admin_color The color scheme for a user's admin screen. Default 'modern'.
25502550
* @type int|bool $use_ssl Whether to force SSL on the user's admin area. 0|false if SSL
25512551
* is not forced.
25522552
* @type string $show_admin_bar_front Whether to show the admin bar on the front end for the user.

src/wp-includes/version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
*
2424
* @global int $wp_db_version
2525
*/
26-
$wp_db_version = 60717;
26+
$wp_db_version = 61644;
2727

2828
/**
2929
* Holds the TinyMCE version.

0 commit comments

Comments
 (0)