From 0b5e19e4d3a722e906b9c7579859f5c8101cdc76 Mon Sep 17 00:00:00 2001 From: oskosk Date: Fri, 24 Nov 2017 17:18:16 -0300 Subject: [PATCH] Default to not log out from wpcom when clicking on the Masterbar Sign Out link --- modules/masterbar/masterbar.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/modules/masterbar/masterbar.php b/modules/masterbar/masterbar.php index 9bf54cda6b606..a62e1e622c67e 100644 --- a/modules/masterbar/masterbar.php +++ b/modules/masterbar/masterbar.php @@ -31,10 +31,13 @@ function __construct() { return; } - // Atomic only - override user setting that hides masterbar from site's front. - // https://github.com/Automattic/jetpack/issues/7667 + // Atomic only if ( jetpack_is_atomic_site() ) { + // override user setting that hides masterbar from site's front. + // https://github.com/Automattic/jetpack/issues/7667 add_filter( 'show_admin_bar', '__return_true' ); + // Always sign out from .com from the masterbar + add_filter( 'jetpack_masterbar_should_logout_from_wpcom', '__return_true' ); } $this->user_data = Jetpack::get_connected_user_data( $this->user_id ); @@ -75,7 +78,19 @@ function __construct() { } public function maybe_logout_user_from_wpcom() { - if ( isset( $_GET['context'] ) && 'masterbar' === $_GET['context'] ) { + /** + * Whether we should sign out from wpcom too when signing out from the masterbar. + * + * @since 5.6.0 + * + * @param bool $masterbar_should_logout_from_wpcom False by default. + */ + $masterbar_should_logout_from_wpcom = apply_filters( 'jetpack_masterbar_should_logout_from_wpcom', false ); + if ( + isset( $_GET['context'] ) && + 'masterbar' === $_GET['context'] && + $masterbar_should_logout_from_wpcom + ) { do_action( 'wp_masterbar_logout' ); } }