Instantly share code, notes, and snippets.

View debug-mode.php
<?php
/**
* Plugin Name: Debug Mode
* Description: On environments where WP_DEBUG/WP_DEBUG_DISPLAY/WP_DEBUG_LOG cannot be set in the wp-config.php, this plugin will try to do the same as wp_debug_mode().
* Author Name: Weston Ruter
* Plugin URI: https://gist.github.com/westonruter/feb9d469065277af8731cbd68100428d
*/
error_reporting( E_ALL );
ini_set( 'display_errors', 1 );
View twentynineteen-empty-at-rule-removal.diff
1,36d0
< @media (min-width: 960px) {
< }
<
< @media (min-width: 782px) {
< }
<
< @media (min-width: 600px) {
< }
<
View scripts-to-footer-exclude-amp.php
View global.js.diff
diff --git a/../twentyseventeen/assets/js/global.js b/assets/js/global.js
index 6e2f429..c9dc97d 100644
--- a/../twentyseventeen/assets/js/global.js
+++ b/assets/js/global.js
@@ -3,8 +3,8 @@
// Variables and DOM Caching.
var $body = $( 'body' ),
+ $siteHeader = $body.find( '.site-header' ),
$customHeader = $body.find( '.custom-header' ),
View send-etag-header.php
<?php
/**
* Plugin Name: Try sending ETag Header
* Description: Testing sending ETag resposne header and ensure server can see the If-None-Match request header.
* Plugin Author: Weston Ruter
*/
add_action( 'template_redirect', function() {
if ( ! isset( $_GET['send_test_etag'] ) ) {
return;
View spinning-custom-logo.php
<?php
/**
* Plugin Name: Spinning Custom Logo
* Description: Make your custom logo spin!
* Plugin URI: https://gist.github.com/westonruter/6920e17a1afd828d446d913105f0b755
* Author Name: Weston Ruter
* Author URI: https://weston.ruter.net/
* License: GPLv2 or later
*/
View amp-validate-timeout-increase.php
<?php
/**
* Plugin Name: AMP Validate Timeout Increase
* Description: When attempting to revalidate a given URL, sometimes a timeout error happens. This is a workaround to increase that timeout. It is not a permanent solution, however.
* Author Name: Weston Ruter, Google
* License: GPLv2
*/
// Increase timeout for AMP validation requests from 15 to 60 seconds.
add_filter( 'http_request_args', function( $args, $url ) {
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' ) ) );
View stale-while-revalidate.php
<?php
/**
* Plugin Name: Stale While Revalidate
* Author: Weston Ruter
* Plugin URI: https://gist.github.com/westonruter/f848013108672568be6dcde153f9ca37
*/
// It is implied that the wp_service_worker_navigation_caching_strategy is for the front.
// @todo Instead of relying on filters, what if $scripts->navigation_routing->set_strategy( WP_Service_Worker_Caching_Routes::STRATEGY_STALE_WHILE_REVALIDATE )?
// @todo This could similarly be done to set navigation_preload, skip_waiting, clients_claim, etc.
View class-jetpack-related-posts-amplified-sanitizer.php