Skip to content

Instantly share code, notes, and snippets.

Weston Ruter westonruter

Block or report user

Report or block westonruter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@westonruter
westonruter / amp-reader-nav-menu.php
Last active Nov 11, 2019
Basic plugin which adds a nav menu to Reader mode templates in the AMP plugin. When in Reader mode, upon activation a new “AMP Reader Sidebar” nav menu location is available for assigning the desired nav menu. Temporary until closed: https://github.com/ampproject/amp-wp/issues/2044
View amp-reader-nav-menu.php
<?php
/**
* Plugin Name: AMP Reader Nav Menu
*
* @package AMP_Reader_Nav_Menu
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
@westonruter
westonruter / get-the-date-filter.php
Last active Nov 8, 2019
Re: Warning: date() expects parameter 2 to be integer, string given in /www/wp-content/plugins/amp/includes/amp-helper-functions.php on line 659 https://wordpress.org/support/topic/line-error-shown-with-wp_debug/#post-10799506
View get-the-date-filter.php
<?php
function et_last_modified_date_blog( $the_date, $format ) {
if ( 'post' === get_post_type() && 'U' !== $format ) { // Make sure the Unix timestamp is not being requested.
$the_time = get_post_time( 'His' );
$the_modified = get_post_modified_time( 'His' );
$last_modified = sprintf( __( 'Last updated %s', 'Divi' ), esc_html( get_post_modified_time( 'M j, Y' ) ) );
$published = sprintf( __( 'Published on %s', 'Divi' ), esc_html( get_post_time( 'M j, Y' ) ) );
@westonruter
westonruter / functions.php
Last active Nov 5, 2019
Child theme of Noto Simple with full AMP compatibility
View functions.php
<?php
/**
* Noto Simple AMP functions and definitions
*
* @package Noto_Simple_AMP
*/
// Indicate that the theme works well in both Standard and Transitional template modes.
add_theme_support(
'amp',
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 2482db29..e2171079 100644
--- a/includes/sanitizers/class-amp-base-sanitizer.php
+++ b/includes/sanitizers/class-amp-base-sanitizer.php
@@ -486,8 +486,12 @@ abstract class AMP_Base_Sanitizer {
}
$should_remove = $this->should_sanitize_validation_error( $validation_error, compact( 'node' ) );
if ( $should_remove ) {
- $element->removeAttributeNode( $node );
- $this->clean_up_after_attribute_removal( $element, $node, $validation_error );
View wordpress-importer-post-id-preservation.php
<?php
/**
* Plugin Name: WordPress Importer Post ID Preservation
* Description: When importing posts make sure that post ID from the original site is used on the destination site. This should only be used when first setting up an environment, or if the destination site is not canonical (e.g. a dev or staging environment).
* Author: Weston Ruter, XWP
*/
/**
* Force WordPress Importer to never honor the post_exists() check, since we want to override existing posts.
*
View amp-to-amp.php
<?php
/**
* AMP-To-AMP plugin initialization file.
*
* @package AMP_To_AMP
* @author Weston Ruter, Google
* @link https://gist.github.com/westonruter/f9ee9ea717d52471bae092879e3d52b0
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
View amp-async-validation.php
<?php
/**
* AMP Async Validation
*
* Installation instructions:
* 1. Click the “Download ZIP” button.
* 2. Rename the downloaded ZIP file to “amp-async-validation.zip”
* 3. In the WordPress admin, go to Plugins > Add New
* 4. Click the Upload Plugin button.
* 5. Select the “amp-async-validation.zip” file and click “Install now”.
@westonruter
westonruter / amp-auto-ads.php
Last active Oct 29, 2019
Plugin code to add <amp-auto-ads> on WordPress sites powered by the official AMP plugin
View amp-auto-ads.php
<?php
/**
* AMP Auto Ads for AdSense (WordPress Plugin)
*
* Plugin installation instructions:
*
* 1. Click the “Download ZIP” button.
* 2. Rename the downloaded ZIP file to “amp-auto-ads.zip”
* 3. In the WordPress admin, go to Plugins > Add New
* 4. Click the Upload Plugin button.
@westonruter
westonruter / amp-brid-player.php
Last active Oct 29, 2019
AMP Brid Player plugin for WordPress, with support for non-AMP fallback: https://github.com/ampproject/amp-wp/issues/3638
View amp-brid-player.php
<?php
/**
* AMP Brid Player
*
* Installation instructions:
* 1. Click the “Download ZIP” button.
* 2. Rename the downloaded ZIP file to “amp-brid-player.zip”
* 3. In the WordPress admin, go to Plugins > Add New
* 4. Click the Upload Plugin button.
* 5. Select the “amp-brid-player.zip” file and click “Install now”.
@westonruter
westonruter / amp-inline-script-test.php
Last active Oct 25, 2019
Plugin to test inline amp-script support in the the AMP plugin. Depends on https://github.com/ampproject/amp-wp/pull/3619
View amp-inline-script-test.php
<?php
/**
* AMP Inline Script Test
*
* @package AMP_Inline_Script_Test
* @author Weston Ruter, Google
* @license GPL-2.0-or-later
* @copyright 2019 Google Inc.
*
* @wordpress-plugin
You can’t perform that action at this time.