Instantly share code, notes, and snippets.

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-revaliate.php
<?php
/**
* Plugin Name: Stale Whole Revalidate
* Author: Weston Ruter
*/
// 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.
add_filter( 'wp_service_worker_navigation_caching_strategy', function() {
View class-jetpack-related-posts-amplified-sanitizer.php
View amp-gist-embed-script.php
<?php
/**
* Plugin Name: Gist Script Embed for AMP
* Description: Convert Gist embed code as provided on gist.github.com (which is blocking <code>script</code> with <code>document.write()</code>) into an <code>amp-gist</code> component. For use with the <a href="https://github.com/Automattic/amp-wp">AMP plugin</a>.
* Plugin URI: https://gist.github.com/westonruter/eec8ab9d0abc7c9af320b94a004a5583
* Version: 0.1
* Author: Weston Ruter
* Author URI: https://weston.ruter.net
*
* @package AMP_Gist_Script_Embed
View jetpack-amp-gist.php
<?php
/**
* Plugin Name: Jetpack amp-gist
* Description: Temporary AMP compatibility shim for Gist embedding in Jetpack (until <a href="https://github.com/Automattic/jetpack/pull/10053">PR #10053</a> is merged). For use with the <a href="https://github.com/Automattic/amp-wp">AMP plugin</a>.
* Plugin URI: https://gist.github.com/westonruter/8c91e3a218eeb1403ce2eacb832c0783
* Version: 0.1
* Author: Weston Ruter
* Author URI: https://weston.ruter.net
*/
View error-page.html
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>504 Database not responding.</title>
<style type="text/css">
#page {width: 416px; padding: 10px; margin: 200px auto; border: 1px solid grey; background-color: #DFDFDF;}
body {background-color: #CCC; margin: auto;
font-family: Helvetica, Ariel, sans-serif;}
View wp-admin-links.txt
View registering-scripts.php
<?php
/*
* Everything registered here will be concatenated into a single script that is
* served via /?wp_service_worker=1 which is installed as the service worker.
*/
add_action( 'wp_front_service_worker', function( WP_Service_Workers $sw ) {
$sw->register_script(
'static-file',
plugin_dir_url( __FILE__ ) . 'example.js',
View simulate-500-error.php
<?php
/**
* Plugin Name: Simulate 500 Internal Server Error
* Description: Prints out a typically-looking PHP error when display_errors is enabled. To use, simply add <code>?internal_server_error</code> to any URL.
* Author: Weston Ruter
* Plugin URI: https://gist.github.com/westonruter/9b7330fffd24dd61aa1519004a2608b1
* Version: 1.0
* License: GPLv2 or later
*
* @package Simulate500Error
View amp-mathml-gutenberg.diff
diff --git a/blocks/amp-mathml/index.js b/blocks/amp-mathml/index.js
index 2b0662cb..52c897d4 100644
--- a/blocks/amp-mathml/index.js
+++ b/blocks/amp-mathml/index.js
@@ -33,17 +33,21 @@ export default registerBlockType(
}
},
- edit( { attributes, setAttributes } ) {
+ edit( { attributes, isSelected, setAttributes } ) {