Skip to content

Instantly share code, notes, and snippets.

View westonruter's full-sized avatar
πŸ’­
#opentowork

Weston Ruter westonruter

πŸ’­
#opentowork
View GitHub Profile

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"
<?php
/**
* Plugin Name: Optimization Detective Default Disabled
* Plugin URI: https://gist.github.com/westonruter/9e9036e8dc11292279a90995273c7adc
* Description: Disables Optimization Detective by default unless you supply the <code>?optimization_detective_enabled=1</code> query parameter. This allows you to debug issues on a live site without visitors seeing a broken experience.
* Requires at least: 6.5
* Requires PHP: 7.2
* Requires Plugins: optimization-detective
* Version: 0.1.0
* Author: Weston Ruter
<?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/
<?php
/**
* Plugin Name: Always Print Script Modules in Head
* Plugin URI: https://gist.github.com/westonruter/f9e67442c674c3176b95cd1ed0e784c1
* Description: In classic themes script modules are forced to print in the footer since the HEAD is rendered before the rest of the page, so it is not yet known what script modules will be enqueued. This can be fixed with output buffering. This is a demonstration plugin for Core Trac ticket #43258 which adds output buffering for the rendered template.
* Requires at least: 6.8-beta1
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
* License: GPLv2 or later
<?php
/**
* Plugin Name: Always Load Block Styles on Demand
* Plugin URI: https://gist.github.com/westonruter/99af37489334927aaf04a46eaf2a11eb
* Description: In classic themes a lot more CSS is added to a page than is needed because when the HEAD is rendered before the rest of the page, so it is not yet known what blocks will be used. This can be fixed with output buffering. This is a demonstration plugin for Core Trac ticket #43258 which adds output buffering for the rendered template.
* Requires at least: 6.8-beta1
* Version: 0.1.0
* Author: Weston Ruter
* Author URI: https://weston.ruter.net/
* License: GPLv2 or later
<?php
/**
* Constructs a CSS selector for the current tag.
*
* @param WP_HTML_Processor $processor Processor.
* @return string Selector.
*/
function get_css_selector( WP_HTML_Processor $processor ): string {
$selector = join( ' > ', $processor->get_breadcrumbs() );