Last active
January 21, 2021 19:27
-
-
Save westonruter/b6691407af1648b402b09371a9faf7f0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* AMP Auto-Lightbox Disable plugin bootstrap. | |
* | |
* @package Google\AMP_Auto_Lightbox_Disable | |
* @author Weston Ruter, Google | |
* @license GPL-2.0-or-later | |
* @copyright 2021 Google Inc. | |
* | |
* @wordpress-plugin | |
* Plugin Name: AMP Auto-Lightbox Disable | |
* Plugin URI: https://gist.github.com/westonruter/b6691407af1648b402b09371a9faf7f0 | |
* Description: Addresses <a href="https://github.com/ampproject/amp-wp/issues/5122">amp-wp#5122</a> by adding the <code>data-amp-auto-lightbox-disable</code> attribute to the <code>body</code>. | |
* Version: 0.1 | |
* 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/b6691407af1648b402b09371a9faf7f0 | |
*/ | |
namespace Google\AMP_Auto_Lightbox_Disable; | |
add_filter( | |
'amp_content_sanitizers', | |
function ( $sanitizers ) { | |
require_once __DIR__ . '/Sanitizer.php'; | |
$sanitizers[ __NAMESPACE__ . '\Sanitizer' ] = []; | |
return $sanitizers; | |
} | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Sanitizer file. | |
* | |
* @package Google\AMP_Auto_Lightbox_Disable | |
*/ | |
namespace Google\AMP_Auto_Lightbox_Disable; | |
use AMP_Base_Sanitizer; | |
/** | |
* Class Sanitizer | |
*/ | |
class Sanitizer extends AMP_Base_Sanitizer { | |
/** | |
* Add the data-amp-auto-lightbox-disable attribute to the body. | |
*/ | |
public function sanitize() { | |
$this->dom->body->setAttributeNode( $this->dom->createAttribute( 'data-amp-auto-lightbox-disable' ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Installation instructions: https://gist.github.com/westonruter/6110fbc4bef0c4b8c021a112012f7e9c