Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active June 2, 2020 06:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/d168c290d6c01c107da960d48fa3dad3 to your computer and use it in GitHub Desktop.
Save westonruter/d168c290d6c01c107da960d48fa3dad3 to your computer and use it in GitHub Desktop.
[OBSOLETE] Update to Jetpack 8.4.2 to fix this issue.
<?php
/**
* AMP Jetpack Admin Bar Workaround initialization file.
*
* @package AMP_Jetpack_Admin_Bar_Workaround
* @author Weston Ruter, Google
* @link https://gist.github.com/westonruter/d168c290d6c01c107da960d48fa3dad3
* @license GPL-2.0-or-later
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
* Plugin Name: AMP Jetpack Admin Bar Workaround
* Plugin URI: https://gist.github.com/westonruter/d168c290d6c01c107da960d48fa3dad3
* Description: Workaround for <a href="https://github.com/Automattic/jetpack/issues/15353">Automattic/jetpack#15353</a>.
* Version: 0.3
* Author: Weston Ruter, Google
* Author URI: https://weston.ruter.net/
* License: GNU General Public License v2 (or later)
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
* Gist Plugin URI: https://gist.github.com/westonruter/d168c290d6c01c107da960d48fa3dad3
*/
namespace AMP_Jetpack_Admin_Bar_Workaround;
// Move up Jetpack AMP support initialization so we can unhook the show_admin_bar filter before other init actions run.
add_action(
'plugins_loaded',
function () {
$priority = has_action( 'init', [ 'Jetpack_AMP_Support', 'init' ] );
if ( false === $priority ) {
return;
}
remove_action( 'init', [ 'Jetpack_AMP_Support', 'init' ], $priority );
add_action(
'init',
function () {
\Jetpack_AMP_Support::init();
// Unhook the show_admin_bar filter added in Jetpack_AMP_Support::init().
remove_filter( 'show_admin_bar', [ 'Jetpack_AMP_Support', 'show_admin_bar' ] );
},
-1
);
}
);
@westonruter
Copy link
Author

Jetpack v8.4.2 is now available which fixes this issue. Please update and uninstall this workaround plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment