Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar

Weston Ruter westonruter

View GitHub Profile
@westonruter
westonruter / 68-sample-page.diff
Last active October 29, 2025 01:03
Showing the Twenty Twenty theme with and without wp-block-styles them support in 6.8 and 6.9-beta2. See https://core.trac.wordpress.org/ticket/64166
--- 68-sample-page-without-theme-support.html 2025-10-28 17:56:40
+++ 68-sample-page-with-theme-support.html 2025-10-28 17:56:40
@@ -521,6 +521,179 @@
href="http://localhost:8000/wp-includes/css/dist/block-library/style.css?ver=6.8.3-src"
media="all"
/>
+ <style id="wp-block-library-theme-inline-css">
+ .wp-block-audio :where(figcaption) {
+ color: #555;
+ font-size: 13px;

As of 6.9-beta1:

Size (Bytes) File Path
19126 ./cover/style.min.css
16879 ./navigation/style.min.css
16120 ./gallery/style.min.css
11762 ./social-links/style.min.css
6758 ./image/style.min.css
3888 ./table/style.min.css
@westonruter
westonruter / benchmark.sh
Last active October 12, 2025 05:40
WordPress Theme Performance Benchmarking Script
#!/bin/bash
# =============================================================================
#
# WordPress Theme Performance Benchmarking Script
#
# This script automates the process of benchmarking the performance impact of a
# change across multiple WordPress themes. It activates each theme, runs
# Lighthouse multiple times for a "before" and "after" URL, calculates the
# median performance score, and outputs the results in a Markdown table.
<?php
/**
* Plugin Name: Active Plugins Override
* Description: Install this as an mu-plugin to override the active plugins via query parameters.
* Plugin URI: https://gist.github.com/westonruter/9c791f4f8cc1cc37e7b3f4bc2db9be97
* Requires PHP: 7.2
* Version: 0.1.0
* Author: WordPress Performance Team
* Author URI: https://make.wordpress.org/performance/
* License: GPLv2 or later

This plugin was generated by Gemini 2.5 Pro with the following prompt:

Create a WordPress plugin which does the following:

Create a new postmeta field in WordPress which contains an array of colors names. This gets stored as serialized data in one postmeta value.

Expose this as postmeta field so it is publicly accessible and editable via the REST API for any user who has the ability to edit posts.

On the frontend, when a user is logged-in and is able to edit a post, print out a JavaScript function in an inline script which fetches that REST API field to log out to the console, and then create another function which calls the REST API to update that postmeta field.

@westonruter
westonruter / increase-styles-inline-size-limit.php
Last active September 15, 2025 20:27
Sample Page in stock WordPress Twenty Twenty-Five theme with all stylesheets inlined
<?php
/**
* Plugin Name: Increase Styles Inline Size Limit (styles_inline_size_limit)
* Author: Weston Ruter
* Update URI: false
*/
add_filter(
'styles_inline_size_limit',
static function (): int {
@westonruter
westonruter / wp-trac-ticket-user-counter.js
Created September 12, 2025 18:00
Helper script to run from bookmarklet to get list of users to potentially prop in order of potential impact in a ticket
const authorContribCount = {};
Array.from(document.querySelectorAll('.trac-author')).forEach(
(link) => {
if ( ! ( link.textContent in authorContribCount ) ) {
authorContribCount[ link.textContent ] = 0;
}
authorContribCount[ link.textContent ]++;
}
);
@westonruter
westonruter / bar.js
Last active September 5, 2025 21:58
import foo from 'foo';
console.log( 'Executed script module bar.' );
export default {};
<?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