Skip to content

Commit

Permalink
Masterbar: Proposal - Do not sign out by default from wpcom when clic…
Browse files Browse the repository at this point in the history
…king the Sign out link (#8243)

* Default to not log out from wpcom when clicking on the Masterbar Sign Out link

* Update the version this filter was introduced to 5.9.0

* Fix comments indentation
  • Loading branch information
oskosk authored Feb 20, 2018
1 parent b8954ce commit d7d2041
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions modules/masterbar/masterbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,13 @@ function __construct() {
'//2.gravatar.com',
) );

// 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 );
Expand Down Expand Up @@ -84,7 +87,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.9.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' );
}
}
Expand Down

0 comments on commit d7d2041

Please sign in to comment.