Skip to content

Commit

Permalink
Test user color-schema to Calypso settings
Browse files Browse the repository at this point in the history
  • Loading branch information
lupus2k committed Feb 2, 2024
1 parent 27450c8 commit cfa19b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'was_migration_trial' => '(bool) If the site ever used a migration trial.',
'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
'wpcom_site_setup' => '(string) The WP.com site setup identifier.',
'admin_color' => '(string) Admin color schema.',
);

/**
Expand Down Expand Up @@ -116,6 +117,7 @@ class WPCOM_JSON_API_GET_Site_Endpoint extends WPCOM_JSON_API_Endpoint {
'is_core_site_editor_enabled',
'is_wpcom_atomic',
'is_wpcom_staging_site',
'admin_color',
);

/**
Expand Down Expand Up @@ -611,6 +613,9 @@ protected function render_response_key( $key, &$response, $is_user_logged_in ) {
case 'was_upgraded_from_trial':
$response[ $key ] = $this->site->was_upgraded_from_trial();
break;
case 'admin_color':
$response[ $key ] = get_user_meta( get_current_user_id(), 'admin_color', true );
break;
}

do_action( 'post_render_site_response_key', $key );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class WPCOM_JSON_API_GET_Site_V1_2_Endpoint extends WPCOM_JSON_API_GET_Site_Endp
'was_upgraded_from_trial' => '(bool) If the site ever upgraded to a paid plan from a trial.',
'was_migration_trial' => '(bool) If the site ever used a migration trial.',
'was_hosting_trial' => '(bool) If the site ever used a hosting trial.',
'admin_color' => '(string) Admin color schema.',
);

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,6 @@ public function __construct() {
update_user_option( $this->user_id, 'locale', $this->user_locale, true );
update_user_option( $this->user_id, 'admin_color', $this->user_data['color_scheme'] );
}
if ( 'wp-admin' === get_option( 'wpcom_admin_interface' ) ) {
update_user_option( $this->user_id, 'admin_color', get_user_meta( $this->user_id, 'admin_color', true ) );
}
add_action( 'admin_bar_init', array( $this, 'init' ) );

if ( ! empty( $this->user_data['ID'] ) ) {
Expand Down Expand Up @@ -215,18 +212,7 @@ class_exists( 'Jetpack_AMP_Support' )
add_action( 'a8c_wpcom_masterbar_enqueue_rtl_notification_styles', '__return_true' );
}

if ( $this->site_woa ) {
if ( get_option( 'wpcom_admin_interface' ) === 'wp-admin' ) {
// If Atomic and using wp-admin interface, update the user_option with the user's color scheme.
update_user_option( $this->user_id, 'admin_color', get_user_meta( $this->user_id, 'admin_color', true ) );
} else {
// If Atomic and not using wp-admin interface, store, install user locale, and hide and replace the language dropdown for the current user.
$this->user_locale = $this->get_jetpack_locale( $this->user_locale );
$this->install_locale( $this->user_locale );
update_user_option( $this->user_id, 'locale', $this->user_locale, true );
update_user_option( $this->user_id, 'admin_color', $this->user_data['color_scheme'] );
}
}
// Hides and replaces the language dropdown for the current user, on WoA.
if ( $this->site_woa &&
'wp-admin' !== get_option( 'wpcom_admin_interface' ) &&
defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) {
Expand Down

0 comments on commit cfa19b1

Please sign in to comment.