Skip to content

Instantly share code, notes, and snippets.

Avatar

Weston Ruter westonruter

View GitHub Profile
View amp-collect-spec-names.php
<?php
$spec_names = [];
foreach ( AMP_Allowed_Tags_Generated::get_allowed_tags() as $tag => $tag_rules ) {
foreach ( $tag_rules as $tag_rule ) {
if ( isset( $tag_rule['tag_spec']['spec_name'] ) ) {
$spec_name = strtolower( $tag_rule['tag_spec']['spec_name'] );
} elseif ( isset( $tag_rule['tag_spec']['extension_spec']['name'] ) ) {
$spec_name = sprintf(
'script[%s=%s]',
View amp-suppress-eager-loading-images.php
<?php
/**
* AMP Suppress Eager Loading Images plugin bootstrap.
*
* @package Google\AMP_Suppress_Eager_Loading_Images
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
@westonruter
westonruter / class-amp-base-sanitizer.php.diff
Created Nov 25, 2020
Gathering all validation errors generated during AMP plugin unit tests
View class-amp-base-sanitizer.php.diff
diff --git a/includes/sanitizers/class-amp-base-sanitizer.php b/includes/sanitizers/class-amp-base-sanitizer.php
index 32badf460..312fc2431 100644
--- a/includes/sanitizers/class-amp-base-sanitizer.php
+++ b/includes/sanitizers/class-amp-base-sanitizer.php
@@ -542,10 +542,12 @@ abstract class AMP_Base_Sanitizer {
* @return bool Whether to sanitize.
*/
public function should_sanitize_validation_error( $validation_error, $data = [] ) {
+ $validation_error = $this->prepare_validation_error( $validation_error, $data );
+ file_put_contents( AMP__DIR__ . '/error-key-dump.txt', json_encode( $validation_error ) . PHP_EOL, FILE_APPEND );
View PrefixUrlStructure.php
<?php
/**
* Class PrefixUrlStructure.
*
* @package Google\AMP_Path_Prefix_Paired_URLs
*/
namespace AMP_Path_Prefix_Paired_URLs;
use AmpProject\AmpWP\PairedUrlStructure;
View jetpack-amp-infinite-scroll-disable.php
<?php
/**
* Jetpack AMP Infinite Scroll Disable plugin bootstrap.
*
* @package Google\Mini_Plugin_Template
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
View SubdomainUrlStructure.php
<?php
/**
* Class SubdomainUrlStructure.
*
* @package Google\AMP_Path_Prefix_Paired_URLs
*/
namespace AMP_Subdomain_Paired_URLs;
use AmpProject\AmpWP\PairedUrlStructure;
@westonruter
westonruter / amp-sidebar-shortcode.php
Last active Oct 7, 2020
Proof of concept for how an amp-sidebar could be used in both an AMP and non-AMP page. ⚠️ Warning: The amp-sidebar component is not yet intended for this purpose! Wait until Bento AMP for official support.
View amp-sidebar-shortcode.php
<?php
/**
* AMP Sidebar Shortcode plugin bootstrap.
*
* @package Google\AMP_Sidebar_Shortcode
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2020 Google Inc.
*
* @wordpress-plugin
View Sanitizer.php
<?php
/**
* Sanitizer file.
*
* @package Google\AMP_Comment_Form_YesValidate
*/
namespace Google\AMP_Comment_Form_YesValidate;
use AMP_Base_Sanitizer;
View Sanitizer.php
<?php
/**
* Sanitizer file.
*
* @package Google\AMP_SVG_Inliner
*/
namespace Google\AMP_SVG_Inliner;
use AMP_Base_Sanitizer;
View amp-add-hide-content-class-to-main-menu-on-page-2906.php
<?php
/**
* Plugin Name: AMP add hide-content class name to nav.main_menu on page with ID 2906.
* Plugin URI: https://wordpress.org/support/topic/how-to-use-custom-script-in-amp-page/
* Author: Weston Ruter
*/
namespace Add_Hide_Content_Class_Name_To_Main_Menu_On_Page_2906;
add_filter(