WP Shipyard self-updates
Switch into any theme and prepare to launch your new website.
by Austin Ginder · github.com/wpshipyard/wp-shipyard · website
Install
The author publishes release zips, so WP-CLI can install straight from GitHub:
wp plugin install https://github.com/wpshipyard/wp-shipyard/releases/download/v1.0.0/wp-shipyard.zipShips its own WordPress updater (manifest.json updater), so new versions show up under Dashboard → Updates.
Switch into any theme and prepare to launch your new website.
WP Shipyard lets a WordPress administrator browse the site in a different installed theme while visitors, and everyone else who is logged in, keep seeing the live one. Fit the new theme out on the real content, then launch it from the same screen when it is ready.
Website and docs: https://wpshipyard.com
How it works
- Appearance → WP Shipyard lists every installed theme with its screenshot. Choose Switch
to. A
wp_shipyard_themecookie is set on your browser and, for your requests only, WordPress renders the site with that theme. Nothing in the database changes. Themes that are broken, not enabled for the site, or need a newer WordPress or PHP say so instead of offering the switch. - Customize (or Edit site for a block theme), assign menus, fill widget areas, populate fields. WordPress stores theme options per theme, so the work is waiting when the theme goes live. The admin bar shows a badge with the theme you are in, Exit, Customize / Edit site, and every other theme as a one-click switch. Appearance → Themes, Menus and Widgets carry a reminder that they are showing the shipyard theme.
- Exit WP Shipyard to return to the live theme, or Launch to make the theme live for
everyone. Launch is an ordinary theme activation (
switch_theme()) followed by clearing the cookie; it needs theswitch_themescapability.
The switch is honoured only for authenticated users with the manage_options capability (filter
wp_shipyard_capability to change that), and only when the cookie names an installed theme. The
stylesheet and template options are never written except by Launch.
Switched responses are sent with Cache-Control: no-store and DONOTCACHEPAGE, so a page cache
or CDN never stores the shipyard theme, plus an X-WP-Shipyard: <theme> header for debugging.
If a theme ever breaks the site for your browser, add ?wp_shipyard=exit to any URL of the
site: the switch is cleared before any theme code runs.
Multisite: the switch is per site (the cookie carries the site id) and per browser; themes must be enabled for the site. Site Health → Info has a WP Shipyard section for support.
Install
Download wp-shipyard.zip, upload it under Plugins → Add New → Upload Plugin, and activate.
wp plugin install wp-shipyard.zip --activate
Requires WordPress 6.2 or newer and PHP 7.4 or newer. No build step; there are no external scripts or styles. Tested with WordPress 7.1, block and classic themes, child themes, WooCommerce and Elementor.
For developers
wp_shipyard()->current(); // slug the browser is switched into, or "" when it is not
wp_shipyard()->live(); // the live theme's slug (the real option value)
add_filter( 'wp_shipyard_capability', fn() => 'edit_theme_options' ); // let editors preview
// Force or veto the theme per request (runs before init; $user_id is 0 for visitors).
add_filter( 'wp_shipyard_current', function ( $slug, $user_id ) {
return isset( $_GET['preview_theme'] ) && $user_id ? 'twentytwentyfour' : $slug;
}, 10, 2 );
REST (needs the capability above and a wp_rest nonce in X-WP-Nonce):
| Route | Does |
|---|---|
GET /wp-json/wp-shipyard/v1/themes |
{ live, current, themes[] } |
POST /wp-json/wp-shipyard/v1/switch { theme } |
switch this browser into a theme |
POST /wp-json/wp-shipyard/v1/exit |
leave the shipyard |
POST /wp-json/wp-shipyard/v1/launch { theme } |
activate the theme for everyone and leave |
The same three actions exist as nonce-protected admin-post.php handlers
(wp_shipyard_switch, wp_shipyard_exit, wp_shipyard_launch), which is what the admin bar links
and the no-JavaScript Tools page use.
| Constant | Effect |
|---|---|
WP_SHIPYARD_DEV_MODE |
Relax SSL verification and treat local hostnames as external for update checks. |
WP_SHIPYARD_DISABLE_UPDATER |
Turn off the GitHub update check. |
Updates
The plugin checks manifest.json on the main branch of this repository and offers the release
zip from GitHub Releases through the normal WordPress update screen.
License
MIT. See LICENSE.txt.
Releases
1 release. Each count is every asset in that release; expand a row for the breakdown.