Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masterbar: allow logging out of wpcom when logging out of site. #12457

Merged
merged 1 commit into from
May 24, 2019
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
12 changes: 1 addition & 11 deletions modules/masterbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,4 @@

require dirname( __FILE__ ) . '/masterbar/masterbar.php';

// In order to be able to tell if it's an AMP request or not we have to hook into parse_query at a later priority.
add_action( 'admin_bar_init', 'jetpack_initialize_masterbar', 99 );

/**
* Initializes the Masterbar in case the request is not AMP.
*/
function jetpack_initialize_masterbar() {
if ( ! Jetpack_AMP_Support::is_amp_request() ) {
new A8C_WPCOM_Masterbar();
}
}
new A8C_WPCOM_Masterbar();
20 changes: 18 additions & 2 deletions modules/masterbar/masterbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@ class A8C_WPCOM_Masterbar {
* Constructor
*/
public function __construct() {
add_action( 'admin_bar_init', array( $this, 'init' ) );

// Post logout on the site, also log the user out of WordPress.com.
add_action( 'wp_logout', array( $this, 'maybe_logout_user_from_wpcom' ) );
}

/**
* Initialize our masterbar.
*/
public function init() {
$this->locale = $this->get_locale();
$this->user_id = get_current_user_id();

Expand All @@ -88,6 +98,14 @@ public function __construct() {
return;
}

// Disable the Masterbar on AMP views.
if (
class_exists( 'Jetpack_AMP_Support' )
&& Jetpack_AMP_Support::is_amp_request()
) {
return;
}

Jetpack::dns_prefetch(
array(
'//s0.wp.com',
Expand Down Expand Up @@ -141,8 +159,6 @@ public function __construct() {
// Override Notification module to include RTL styles.
add_action( 'a8c_wpcom_masterbar_enqueue_rtl_notification_styles', '__return_true' );
}

add_action( 'wp_logout', array( $this, 'maybe_logout_user_from_wpcom' ) );
}

/**
Expand Down