Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
<?php
/**
* AMP Block Container Unique IDs plugin bootstrap.
*
* @package Google\AmpBlockContainerUniqueIds
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2021 Google Inc.
*
* @wordpress-plugin
<?php
/**
* PWA: Page-Specific Start URLs plugin bootstrap.
*
* @package PWA\PageSpecificStartUrls
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2021 Google Inc.
*
* @wordpress-plugin
<?php
use Sabberworm\CSS\Parser;
use Sabberworm\CSS\RuleSet\DeclarationBlock;
$dom = new DOMDocument();
$dom->loadHTML(
'
<!DOCTYPE html>
<html>
<?php
const TEST_ID = 'foo';
foreach ( [ 'sans_id_removal', 'with_id_removal' ] as $scenario ) {
echo "$scenario: ";
$dom = new DOMDocument();
$dom->loadHTML(
'<!DOCTYPE html><html><head><meta charset=utf-8></head><body></body></html>'
<?php
/**
* AMP Sandboxing Levels Experimental Opt-in plugin bootstrap.
*
* @package Google\AMP_Sandboxing_Levels_Experimental_Optin
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2021 Google Inc.
*
* @wordpress-plugin
<!-- wp:paragraph -->
<p>Page setup:</p>
<!-- /wp:paragraph -->
<!-- wp:list {"ordered":true} -->
<ol><li>Commenting is enabled.</li><li>There is at least one comment.</li><li>There is a custom script on the page.</li></ol>
<!-- /wp:list -->
<!-- wp:paragraph -->
<p>Therefore, in loose sandboxing:</p>
document.addEventListener( 'DOMContentLoaded', () => {
document.getElementById( 'custom-scripts-container' ).classList.add( 'loaded' );
document.querySelector( '#custom-scripts-container .results' ).innerHTML += '<li>External script ran!</li>';
} );
<?php
/**
* Postpone loading non-critical AMP scripts.
*
* @package Google\AmpPostponeScriptLoading
*/
namespace Google\AmpPostponeScriptLoading;
use AmpProject\Dom\Document;
<?php
/**
* FormActionRewriteSanitizer file.
*
* @package Google\AMP_Form_Submission_Proxy
*/
namespace Google\AMP_Form_Submission_Proxy;
use AMP_Base_Sanitizer;