View list-document-images.js
function getDocumentImages() {
return performance.getEntriesByType('resource')
.map( ( entry ) => entry.name )
.filter( ( url ) => {
const parsedUrl = new URL( url );
return /\.(png|jpe?g|gif|webp|svg)$/i.test( parsedUrl.pathname );
} );
}
View class-img-noloading-sanitizer.php
<?php
/**
* Make sure that all <amp-img> elements have the noloading attribute.
*/
class Img_Noloading_Sanitizer extends AMP_Base_Sanitizer {
public function sanitize() {
foreach ( $this->dom->getElementsByTagName( 'amp-img' ) as $img ) {
$img->setAttribute( 'noloading', '' );
}
}
View amp-gravity-form-submission-shim.php
<?php
// Shim support for Gravity Form submissions on AMP pages.
add_action( 'gform_post_submission', function() {
$location = null;
foreach ( headers_list() as $header ) {
if ( preg_match( '/^Location:\s*(.+)/i', $header, $matches ) ) {
$location = $matches[1];
break;
}
View comments.php
<?php
/**
* The template for displaying comments
*
* The area of the page that contains both current comments
* and the comment form.
*
* @package Twenty_Fifteen_AMP
*/
View amp.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View amp-jetpack-hacks.php
<?php
/**
* Plugin Name: Jetpack Hacks for AMP
* Description: Temporary workarounds to get Jetpack features to play nice with AMP theme support.
* Plugin URI: https://gist.github.com/westonruter/034e15dd7bfd011a9c73c96df86aa291
* Author: Weston Ruter, XWP
* Author URI: https://make.xwp.co
*
* @package AMP_Jetpack_Hacks
*/
View remember-me.php
<?php
/**
* Plugin Name: Remember Me
* Description: Play song from Coco when checking the Remember Me checkbox on the login screen.
* Plugin URI: https://gist.github.com/westonruter/86a191a898015f26e603d6594cc282d2
* Author: Weston Ruter
* Author URI: https://weston.ruter.net
*/
add_action( 'login_footer', function() {
View test-object-cache-availability-in-output-buffer-callback-at-shutdown.php
<?php
/**
* Plugin Name: Test $wp_object_cache availability in output buffer callback in shutdown.
* Author: Weston Ruter, XWP
* Description: Add ?erasable=false to the URL to try calling ob_start() with its erasable=false.
*/
if ( ! isset( $_SERVER['REQUEST_URI'] ) || false !== strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) ) {
return;
}
View amp-content-styles-workaround.php
<?php
/**
* Plugin Name: AMP Content Styles Workaround
* Description: Temporary measure for dealing with external stylesheets and style elements in content.
* Author: Weston Ruter, XWP
*/
add_action( 'amp_init', function() {
// Version compare because this should be addressed by 1.0.
View add-notice-block-edit.js
wp.hooks.addFilter(
'blocks.BlockEdit',
'example/add-notice',
function( BlockEdit ) {
var NewBlockEdit = function( props ) {
return [
wp.element.createElement(
BlockEdit,
_.extend( {}, props, { key: 'example-original-edit' } )
)