Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
<?php
/**
* Emoji Detection Script Deferred Plugin for WordPress
*
* @package EmojiDetectionScriptDeferred
* @author Weston Ruter
* @license GPL-2.0-or-later
*
* @wordpress-plugin
* Plugin Name: Emoji Detection Script Deferred
@westonruter
westonruter / facebook-pixel-strict-csp-compatible.php
Last active August 11, 2025 04:38
How to adapt the Base Code for Facebook Pixel to be compatible with Strict CSP: https://developers.facebook.com/docs/meta-pixel/get-started/#base-code
<?php
// This adaptation of the Base Code for Facebook Pixel is compatible with the Strict CSP plugin: https://wordpress.org/plugins/strict-csp/
add_action(
'wp_head',
static function () {
?>
<!-- Facebook Pixel Code -->
<?php
$js = <<<JS
!function(f,b,e,v,n,t,s)
<?php
/**
* Plugin Name: Sleepy Responses
* Plugin URI: https://gist.github.com/westonruter/b66cfc51397c75d6497b6ed0aeb68ce3
* Description: Slows down a response when a <code>sleep</code> query parameter is provided, with a value being an integer for the number of seconds passed into the PHP <code>sleep()</code> function. Only applies when <code>WP_DEBUG</code> is enabled or when <code>wp_get_environment_type()</code> returns <code>local</code> or <code>development</code>.
* Requires at least: 6.8
* Requires PHP: 7.4
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/

Status: Draft (The final form of this may move to a blog post or a full repo.)

This describes how to set up the repos for WordPress/wordpress-develop, WordPress/gutenberg, and WordPress/performance in one single place all using their own built-in environments (in Docker). Importantly, the latter two repos (for plugins) are configured to use the core files from the repos for both their development and tests environments.

Benefits:

  1. WordPress core files are shared across all environments, including when running unit tests. So if you run PHPUnit tests for Gutenberg or Performance Lab, any core changes you've made will be reflected. This resolves a big painpoint with trying out core patches in plugin unit tests.
  2. Plugins, mu-plugins, and themes and are shared across all environments, although you can add additional environment-specific extensions in your `.wp-e
--- before.prettier.html 2025-05-21 13:15:12
+++ after.prettier.html 2025-05-21 13:15:19
@@ -2150,28 +2150,34 @@
type="module"
src="http://localhost:10008/wp-includes/js/dist/script-modules/block-library/file/view.min.js?ver=fdc2f6842e015af83140"
id="@wordpress/block-library/file/view-js-module"
+ fetchpriority="low"
></script>
<script
type="module"
@westonruter
westonruter / README.md
Last active August 3, 2025 21:41
‼️ OBSOLETE: Plugin moved to a proper repo: https://github.com/westonruter/od-default-disabled

Installation

  1. Download the plugin ZIP from GitHub (see also link above).
  2. Visit Plugins > Add New Plugin in the WordPress Admin.
  3. Click Upload Plugin.
  4. Select the ZIP file on your system from step 1 and click Install Now.
  5. Click the Activate Plugin button.

You may also install and update via Git Updater.

<?php
/**
* Plugin Name: Speculative Loading: Eagerly Prerender Homepage from Singular Template
* Plugin URI: https://gist.github.com/westonruter/eb51e56c7e92f3cd6e3088eb87d9ce07
* Description: When viewing a singular post or page, eagerly prerender the homepage so that navigating there will be instant.
* Requires at least: 5.7
* Requires PHP: 7.2
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
<?php
/**
* Plugin Name: Speculative Loading: Eagerly Prerender First Post in Archive Loop
* Plugin URI: https://gist.github.com/westonruter/78c0640fb108e2e94e7b0a536e9a9140
* Description: For templates that list out one or more posts (i.e. blog index, archives, search results), eagerly prerender the first post in The Loop since it is the most likely link the user will visit.
* Requires at least: 5.7
* Requires PHP: 7.2
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
<?php
/**
* Plugin Name: Twenty Twenty-Five Stylesheet Inlining
* Plugin URI: https://gist.github.com/westonruter/09e553a7b66d1a2e68cd5a9ed351c59b
* Description: Minifies and adds <code>path</code> style data for the <code>twentytwenty-five-style</code> stylesheet so it can be inlined. See <a href="https://core.trac.wordpress.org/ticket/63007">#63007</a>.
* Requires at least: 6.5
* Requires PHP: 7.2
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/