Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions modules/sso.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ private function __construct() {
add_action( 'login_form_logout', array( $this, 'store_wpcom_profile_cookies_on_logout' ) );
add_action( 'jetpack_unlinked_user', array( $this, 'delete_connection_for_user') );
add_action( 'wp_login', array( 'Jetpack_SSO', 'clear_cookies_after_login' ) );
add_action( 'jetpack_jitm_received_envelopes', array( $this, 'inject_sso_jitm' ) );
add_action( 'jetpack_jitm_received_envelopes', array( $this, 'inject_sso_jitm' ), 10, 2 );

// Adding this action so that on login_init, the action won't be sanitized out of the $action global.
add_action( 'login_form_jetpack-sso', '__return_true' );
Expand Down Expand Up @@ -1087,13 +1087,21 @@ public function get_user_data( $user_id ) {
*
* @since 6.9.0
*
* @param array $envelopes Array of JITM messages received after API call.
* @param array $envelopes Array of JITM messages received after API call.
* @param string $message_path The message path to ask for.
*
* @return array $envelopes New array of JITM messages. May now contain only one message, about SSO.
*/
public function inject_sso_jitm( $envelopes ) {
// Bail early if that's not the first time the user uses SSO.
if ( true != Jetpack_Options::get_option( 'sso_first_login' ) ) {
public function inject_sso_jitm( $envelopes, $message_path = null) {
/*
* Bail early if:
* - the request does not originate from wp-admin main dashboard.
* - that's not the first time the user uses SSO.
*/
if (
'wp:dashboard:admin_notices' !== $message_path
|| true !== Jetpack_Options::get_option( 'sso_first_login' )
) {
return $envelopes;
}

Expand Down
6 changes: 4 additions & 2 deletions packages/jitm/src/class-jitm.php
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,12 @@ public function get_messages( $message_path, $query ) {
* Allow adding your own custom JITMs after a set of JITMs has been received.
*
* @since 6.9.0
* @since 8.3.0 - Added Message path.
*
* @param array $envelopes array of existing JITMs.
* @param array $envelopes array of existing JITMs.
* @param string $message_path The message path to ask for.
*/
$envelopes = apply_filters( 'jetpack_jitm_received_envelopes', $envelopes );
$envelopes = apply_filters( 'jetpack_jitm_received_envelopes', $envelopes, $message_path );

foreach ( $envelopes as $idx => &$envelope ) {

Expand Down