Skip to content

Commit 264f7e0

Browse files
Nikschavanmatticbot
authored andcommitted
Connection: enqueue the SSO login and users-table styles (#51460)
Committed via a GitHub action: https://github.com/Automattic/jetpack/actions/runs/32828361053 Upstream-Ref: Automattic/jetpack@a6b4a10
1 parent f648565 commit 264f7e0

9 files changed

Lines changed: 195 additions & 158 deletions

File tree

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"automattic/jetpack-autoloader": "^5.0.23",
99
"automattic/jetpack-composer-plugin": "^4.0.9",
1010
"automattic/jetpack-config": "^3.1.3",
11-
"automattic/jetpack-connection": "^8.11.1-alpha",
11+
"automattic/jetpack-connection": "^8.12.0-alpha",
1212
"automattic/jetpack-my-jetpack": "^5.44.1-alpha",
1313
"automattic/jetpack-search": "^7.4.1",
1414
"automattic/jetpack-stats": "^0.20.4-alpha",

jetpack_vendor/automattic/jetpack-connection/CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,16 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8-
## [8.11.1-alpha] - unreleased
8+
## [8.12.0-alpha] - unreleased
99

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

1212
### Changed
1313
- Enqueue the connection owner notice script through wp_add_inline_script() instead of printing a script element.
14+
- SSO: enqueue the login and user-admin styles through wp_add_inline_style() instead of printing style elements.
15+
16+
### Deprecated
17+
- SSO: deprecate print_inline_admin_css() in favour of enqueue_login_styles().
1418

1519
## [8.11.0] - 2026-08-20
1620
### Added
@@ -2025,7 +2029,7 @@ This is an alpha version! The changes listed here are not final.
20252029

20262030
- Separate the connection library into its own package.
20272031

2028-
[8.11.1-alpha]: https://github.com/Automattic/jetpack-connection/compare/v8.11.0...v8.11.1-alpha
2032+
[8.12.0-alpha]: https://github.com/Automattic/jetpack-connection/compare/v8.11.0...v8.12.0-alpha
20292033
[8.11.0]: https://github.com/Automattic/jetpack-connection/compare/v8.10.4...v8.11.0
20302034
[8.10.4]: https://github.com/Automattic/jetpack-connection/compare/v8.10.3...v8.10.4
20312035
[8.10.3]: https://github.com/Automattic/jetpack-connection/compare/v8.10.2...v8.10.3

jetpack_vendor/automattic/jetpack-connection/src/class-package-version.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
*/
1313
class Package_Version {
1414

15-
const PACKAGE_VERSION = '8.11.1-alpha';
15+
const PACKAGE_VERSION = '8.12.0-alpha';
1616

1717
const PACKAGE_SLUG = 'connection';
1818

jetpack_vendor/automattic/jetpack-connection/src/sso/class-sso.php

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -319,21 +319,40 @@ public function login_body_class( $classes ) {
319319
}
320320

321321
/**
322-
* Inlined admin styles for SSO.
322+
* Print the SSO styles for the login screen.
323+
*
324+
* @deprecated 8.12.0-alpha Use enqueue_login_styles().
323325
*/
324326
public function print_inline_admin_css() {
325-
?>
326-
<style>
327-
.jetpack-sso .message {
328-
margin-top: 20px;
329-
}
327+
_deprecated_function( __METHOD__, 'connection-8.12.0-alpha', __CLASS__ . '::enqueue_login_styles' );
328+
$this->enqueue_login_styles();
329+
}
330330

331-
.jetpack-sso #login .message:first-child,
332-
.jetpack-sso #login h1 + .message {
333-
margin-top: 0;
334-
}
335-
</style>
336-
<?php
331+
/**
332+
* Enqueue the SSO styles for the login screen.
333+
*/
334+
public function enqueue_login_styles() {
335+
$handle = 'jetpack-sso-login-styles';
336+
337+
// No src: the handle only carries the inline CSS below. Core enqueues `login` before `login_enqueue_scripts` fires,
338+
// so these rules already print after the core login stylesheet, which sets `.message` margins at the same
339+
// specificity. No dependency on `login`: plugins that replace the login screen deregister that handle, and a
340+
// missing dependency would drop this one from the queue.
341+
wp_register_style( $handle, false, array(), Package_Version::PACKAGE_VERSION );
342+
wp_enqueue_style( $handle );
343+
344+
$css = <<<'CSS'
345+
.jetpack-sso .message {
346+
margin-top: 20px;
347+
}
348+
349+
.jetpack-sso #login .message:first-child,
350+
.jetpack-sso #login h1 + .message {
351+
margin-top: 0;
352+
}
353+
CSS;
354+
355+
wp_add_inline_style( $handle, $css );
337356
}
338357

339358
/**
@@ -559,7 +578,7 @@ public function login_init() {
559578
*/
560579
public function display_sso_login_form() {
561580
add_filter( 'login_body_class', array( $this, 'login_body_class' ) );
562-
add_action( 'login_head', array( $this, 'print_inline_admin_css' ) );
581+
add_action( 'login_enqueue_scripts', array( $this, 'enqueue_login_styles' ) );
563582

564583
if ( ( new Status() )->in_safe_mode() ) {
565584
add_filter( 'login_message', array( Notices::class, 'sso_not_allowed_in_safe_mode' ) );

jetpack_vendor/automattic/jetpack-connection/src/sso/class-user-admin.php

Lines changed: 81 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public function __construct() {
7373
add_action( 'admin_post_jetpack_invite_user_to_wpcom', array( $this, 'invite_user_to_wpcom' ) );
7474
add_action( 'admin_post_jetpack_revoke_invite_user_to_wpcom', array( $this, 'handle_request_revoke_invite' ) );
7575
add_action( 'admin_post_jetpack_resend_invite_user_to_wpcom', array( $this, 'handle_request_resend_invite' ) );
76-
add_action( 'admin_print_styles-users.php', array( $this, 'jetpack_user_table_styles' ) );
7776
add_filter( 'users_list_table_query_args', array( $this, 'set_user_query' ), 100, 1 );
7877
add_action( 'admin_print_styles-user-new.php', array( $this, 'jetpack_new_users_styles' ) );
7978
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ) );
@@ -1222,77 +1221,89 @@ public function create_error_notice_and_redirect( $query_params ) {
12221221
}
12231222

12241223
/**
1225-
* Style the Jetpack user rows and columns.
1224+
* Enqueue the styles for the Jetpack user rows and columns.
12261225
*/
12271226
public function jetpack_user_table_styles() {
1228-
?>
1229-
<style>
1230-
#the-list tr:has(.sso-disconnected-user) {
1231-
background: #F5F1E1;
1232-
}
1233-
#the-list tr:has(.sso-pending-invite) {
1234-
background: #E9F0F5;
1235-
}
1236-
.jetpack-sso-invitation {
1237-
background: none;
1238-
border: none;
1239-
color: #50575e;
1240-
padding: 0;
1241-
text-align: unset;
1242-
}
1243-
.jetpack-sso-invitation.sso-disconnected-user {
1244-
color: #0073aa;
1245-
cursor: pointer;
1246-
text-decoration: underline;
1247-
}
1248-
.jetpack-sso-invitation.sso-disconnected-user:hover,
1249-
.jetpack-sso-invitation.sso-disconnected-user:focus,
1250-
.jetpack-sso-invitation.sso-disconnected-user:active {
1251-
color: #0096dd;
1252-
}
1227+
$handle = 'jetpack-sso-users-styles';
12531228

1254-
.sso-disconnected-user-icon {
1255-
cursor: pointer;
1256-
background: gray;
1257-
border-radius: 10px;
1258-
}
1229+
// No src: the handle only carries the inline CSS below.
1230+
wp_register_style( $handle, false, array(), Package_Version::PACKAGE_VERSION );
1231+
wp_enqueue_style( $handle );
12591232

1260-
.sso-disconnected-user-icon.dashicons {
1261-
font-size: 1rem;
1262-
height: 1rem;
1263-
width: 1rem;
1264-
background-color: #9D6E00;
1265-
color: #F5F1E1;
1266-
}
1267-
.jetpack-sso-invitation-tooltip-icon{
1268-
position: relative;
1269-
cursor: pointer;
1270-
display: inline-flex;
1271-
align-items: center;
1272-
column-gap: 6px;
1273-
}
1274-
.jetpack-sso-td-tooltip {
1275-
left: -256px;
1276-
}
1277-
.jetpack-sso-invitation-tooltip {
1278-
position: absolute;
1279-
background: #f6f7f7;
1280-
top: -85px;
1281-
width: 250px;
1282-
padding: 7px;
1283-
color: #3c434a;
1284-
font-size: .75rem;
1285-
line-height: 17px;
1286-
text-align: left;
1287-
margin: 0;
1288-
display: none;
1289-
border-radius: 4px;
1290-
font-family: sans-serif;
1291-
box-shadow: 5px 10px 10px rgba(0, 0, 0, 0.1);
1292-
}
1233+
$css = <<<'CSS'
1234+
#the-list tr:has(.sso-disconnected-user) {
1235+
background: #F5F1E1;
1236+
}
1237+
1238+
#the-list tr:has(.sso-pending-invite) {
1239+
background: #E9F0F5;
1240+
}
1241+
1242+
.jetpack-sso-invitation {
1243+
background: none;
1244+
border: none;
1245+
color: #50575e;
1246+
padding: 0;
1247+
text-align: unset;
1248+
}
12931249
1294-
</style>
1295-
<?php
1250+
.jetpack-sso-invitation.sso-disconnected-user {
1251+
color: #0073aa;
1252+
cursor: pointer;
1253+
text-decoration: underline;
1254+
}
1255+
1256+
.jetpack-sso-invitation.sso-disconnected-user:hover,
1257+
.jetpack-sso-invitation.sso-disconnected-user:focus,
1258+
.jetpack-sso-invitation.sso-disconnected-user:active {
1259+
color: #0096dd;
1260+
}
1261+
1262+
.sso-disconnected-user-icon {
1263+
cursor: pointer;
1264+
background: gray;
1265+
border-radius: 10px;
1266+
}
1267+
1268+
.sso-disconnected-user-icon.dashicons {
1269+
font-size: 1rem;
1270+
height: 1rem;
1271+
width: 1rem;
1272+
background-color: #9D6E00;
1273+
color: #F5F1E1;
1274+
}
1275+
1276+
.jetpack-sso-invitation-tooltip-icon {
1277+
position: relative;
1278+
cursor: pointer;
1279+
display: inline-flex;
1280+
align-items: center;
1281+
column-gap: 6px;
1282+
}
1283+
1284+
.jetpack-sso-td-tooltip {
1285+
left: -256px;
1286+
}
1287+
1288+
.jetpack-sso-invitation-tooltip {
1289+
position: absolute;
1290+
background: #f6f7f7;
1291+
top: -85px;
1292+
width: 250px;
1293+
padding: 7px;
1294+
color: #3c434a;
1295+
font-size: .75rem;
1296+
line-height: 17px;
1297+
text-align: left;
1298+
margin: 0;
1299+
display: none;
1300+
border-radius: 4px;
1301+
font-family: sans-serif;
1302+
box-shadow: 5px 10px 10px rgba(0, 0, 0, 0.1);
1303+
}
1304+
CSS;
1305+
1306+
wp_add_inline_style( $handle, $css );
12961307
}
12971308

12981309
/**
@@ -1306,6 +1317,9 @@ public function enqueue_scripts( $hook ) {
13061317
}
13071318

13081319
parent::enqueue_scripts( $hook );
1320+
1321+
$this->jetpack_user_table_styles();
1322+
13091323
// Enqueue the SSO users script.
13101324
Assets::register_script(
13111325
'jetpack-sso-users',

jetpack_vendor/i18n-map.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
),
3535
'jetpack-connection' => array(
3636
'path' => 'jetpack_vendor/automattic/jetpack-connection',
37-
'ver' => '8.11.1-alpha1787549563',
37+
'ver' => '8.12.0-alpha1787647579',
3838
),
3939
'jetpack-explat' => array(
4040
'path' => 'jetpack_vendor/automattic/jetpack-explat',

0 commit comments

Comments
 (0)