Skip to content

Commit

Permalink
Replace the language selector with a link to WPCOM (#39013)
Browse files Browse the repository at this point in the history
* Replace language selector with a link to WPCOM

* changelog

* Bump version
  • Loading branch information
okmttdhr authored Aug 22, 2024
1 parent a6c16b2 commit 34fa923
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 11 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: changed

Replace language selector with a link to WPCOM
2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
},
"autotagger": true,
"branch-alias": {
"dev-trunk": "5.57.x-dev"
"dev-trunk": "5.58.x-dev"
},
"textdomain": "jetpack-mu-wpcom",
"version-constants": {
Expand Down
2 changes: 1 addition & 1 deletion projects/packages/jetpack-mu-wpcom/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"name": "@automattic/jetpack-mu-wpcom",
"version": "5.57.2-alpha",
"version": "5.58.0-alpha",
"description": "Enhances your site with features powered by WordPress.com",
"homepage": "https://github.com/Automattic/jetpack/tree/HEAD/projects/packages/jetpack-mu-wpcom/#readme",
"bugs": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* Jetpack_Mu_Wpcom main class.
*/
class Jetpack_Mu_Wpcom {
const PACKAGE_VERSION = '5.57.2-alpha';
const PACKAGE_VERSION = '5.58.0-alpha';
const PKG_DIR = __DIR__ . '/../';
const BASE_DIR = __DIR__ . '/';
const BASE_FILE = __FILE__;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ function wpcom_profile_settings_add_links_to_wpcom() {
'wpcom-profile-settings-link-to-wpcom',
'wpcomProfileSettingsLinkToWpcom',
array(
'language' => array(
'link' => esc_url( $wpcom_host . '/me/account' ),
'text' => __( 'Your admin interface language is managed on WordPress.com Account settings', 'jetpack-mu-wpcom' ),
),
'synced' => array(
'link' => esc_url( $wpcom_host . '/me' ),
'text' => __( 'You can manage your profile on WordPress.com Profile settings (First / Last / Display Names, Website, and Biographical Info)', 'jetpack-mu-wpcom' ),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,28 @@ const wpcom_profile_settings_disable_email_field = () => {
* Add a link to the WordPress.com profile settings page.
*/
const wpcom_profile_settings_add_links_to_wpcom = () => {
const usernameSection = document.querySelector( '.user-user-login-wrap' )?.querySelector( 'td' );
const emailSection = document.querySelector( '.user-email-wrap' )?.querySelector( 'td' );
const newPasswordSection = document.getElementById( 'password' )?.querySelector( 'td' );
const userSessionSection = document.querySelector( '.user-sessions-wrap' );

userSessionSection?.remove();

// We cannot set a password in wp-admin except on Atomic Classic sites.
const newPasswordSection = document.getElementById( 'password' )?.querySelector( 'td' );
if ( ! window.wpcomProfileSettingsLinkToWpcom?.isWpcomAtomicClassic && newPasswordSection ) {
newPasswordSection.innerHTML = '';
}

const languageSection = document.querySelector( '.user-language-wrap' )?.querySelector( 'td' );
const languageSelect = document.getElementById( 'locale' );
const languageSettingsLink = window.wpcomProfileSettingsLinkToWpcom?.language?.link;
const languageSettingsLinkText = window.wpcomProfileSettingsLinkToWpcom?.language?.text;
if ( languageSettingsLink && languageSettingsLinkText ) {
const notice = document.createElement( 'p' );
notice.className = 'description';
notice.innerHTML = `<a href="${ languageSettingsLink }">${ languageSettingsLinkText }</a>.`;
languageSection?.appendChild( notice );
languageSelect?.remove();
}

const emailSection = document.querySelector( '.user-email-wrap' )?.querySelector( 'td' );
const emailSettingsLink = window.wpcomProfileSettingsLinkToWpcom?.email?.link;
const emailSettingsLinkText = window.wpcomProfileSettingsLinkToWpcom?.email?.text;
if ( emailSection && emailSettingsLink && emailSettingsLinkText ) {
Expand All @@ -48,6 +58,7 @@ const wpcom_profile_settings_add_links_to_wpcom = () => {
newPasswordSection.appendChild( notice );
}

const usernameSection = document.querySelector( '.user-user-login-wrap' )?.querySelector( 'td' );
const syncedSettingsLink = window.wpcomProfileSettingsLinkToWpcom?.synced?.link;
const syncedSettingsLinkText = window.wpcomProfileSettingsLinkToWpcom?.synced?.text;
if ( usernameSection && syncedSettingsLink && syncedSettingsLinkText ) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
declare global {
interface Window {
wpcomProfileSettingsLinkToWpcom: {
language: {
link: string;
text: string;
};
synced: {
link: string;
text: string;
};
email: {
link: string;
text: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/mu-wpcom-plugin/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions projects/plugins/wpcomsh/changelog/update-locale-to-wpcom
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Significance: patch
Type: changed
Comment: Updated composer.lock.


4 changes: 2 additions & 2 deletions projects/plugins/wpcomsh/composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 34fa923

Please sign in to comment.