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

Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/10503112751

Upstream-Ref: Automattic/jetpack@34fa923
  • Loading branch information
okmttdhr authored and matticbot committed Aug 22, 2024
1 parent e0d0ef4 commit 5272239
Show file tree
Hide file tree
Showing 12 changed files with 122 additions and 98 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"type": "wordpress-plugin",
"license": "GPL-2.0-or-later",
"require": {
"automattic/jetpack-mu-wpcom": "^5.57.2-alpha"
"automattic/jetpack-mu-wpcom": "^5.58.0-alpha"
},
"require-dev": {
"yoast/phpunit-polyfills": "^1.1.1",
Expand Down
60 changes: 30 additions & 30 deletions composer.lock

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

5 changes: 3 additions & 2 deletions vendor/automattic/jetpack-mu-wpcom/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [5.57.2-alpha] - unreleased
## [5.58.0-alpha] - unreleased

This is an alpha version! The changes listed here are not final.

### Changed
- Replace language selector with a link to WPCOM
- Updated package dependencies.

### Fixed
Expand Down Expand Up @@ -1173,7 +1174,7 @@ This is an alpha version! The changes listed here are not final.

- Testing initial package release.

[5.57.2-alpha]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.57.1...v5.57.2-alpha
[5.58.0-alpha]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.57.1...v5.58.0-alpha
[5.57.1]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.57.0...v5.57.1
[5.57.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.56.0...v5.57.0
[5.56.0]: https://github.com/Automattic/jetpack-mu-wpcom/compare/v5.55.0...v5.56.0
Expand Down
2 changes: 1 addition & 1 deletion vendor/automattic/jetpack-mu-wpcom/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,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
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'cb4c979436f36139782d');
<?php return array('dependencies' => array(), 'version' => 'e3eab4959d21b18015f5');

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

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
Loading

0 comments on commit 5272239

Please sign in to comment.