diff --git a/packages/playground/personal-wp/src/components/menu-overlay/index.tsx b/packages/playground/personal-wp/src/components/menu-overlay/index.tsx index a61a653a80..de850c8e40 100644 --- a/packages/playground/personal-wp/src/components/menu-overlay/index.tsx +++ b/packages/playground/personal-wp/src/components/menu-overlay/index.tsx @@ -11,6 +11,10 @@ import { OverlaySection, } from '../overlay'; import css from './style.module.css'; +import { + getBlueprintUrl, + healthCheckRecoveryBlueprint, +} from '../../lib/health-check-recovery'; interface MenuOverlayProps { onClose: () => void; @@ -21,6 +25,7 @@ export function MenuOverlay({ onClose }: MenuOverlayProps) { const [showDeleteButton, setShowDeleteButton] = useState(false); const [isDeleting, setIsDeleting] = useState(false); + const [showRecoveryButton, setShowRecoveryButton] = useState(false); async function handleStartOver() { if (!activeSite || activeSite.metadata.storage === 'none') { @@ -107,6 +112,29 @@ export function MenuOverlay({ onClose }: MenuOverlayProps) { )} + + +

+ If WordPress crashed,{' '} + + . +

+ {showRecoveryButton && ( + + Install Health Check & Troubleshoot + + )} +
); diff --git a/packages/playground/personal-wp/src/lib/health-check-recovery.ts b/packages/playground/personal-wp/src/lib/health-check-recovery.ts new file mode 100644 index 0000000000..8e79f44466 --- /dev/null +++ b/packages/playground/personal-wp/src/lib/health-check-recovery.ts @@ -0,0 +1,80 @@ +import type { Blueprint } from '@wp-playground/blueprints'; +import { encodeStringAsBase64 } from './base64'; + +// +// The Health Check MU-plugin requires a database option 'health-check-disable-plugin-hash' +// that matches: cookieValue + md5(REMOTE_ADDR). We add an earlier MU-plugin (alphabetically) +// that uses pre_option filter to return the expected hash, bypassing the database check. +export const healthCheckRecoveryBlueprint: Blueprint = { + steps: [ + { + step: 'installPlugin', + pluginData: { + resource: 'wordpress.org/plugins', + slug: 'health-check', + }, + options: { + activate: false, + }, + }, + { + step: 'mkdir', + path: '/wordpress/wp-content/mu-plugins', + }, + { + step: 'cp', + fromPath: + '/wordpress/wp-content/plugins/health-check/mu-plugin/health-check-troubleshooting-mode.php', + toPath: '/wordpress/wp-content/mu-plugins/health-check-troubleshooting-mode.php', + }, + { + // Add an MU-plugin that loads before health-check (alphabetically: "0" < "h") + // to provide the expected hash via pre_option filter + step: 'writeFile', + path: '/wordpress/wp-content/mu-plugins/0-health-check-hash-bypass.php', + data: ` +
+

Troubleshooting Mode Active

+

All plugins have been disabled. You can now activate them one by one to find the problematic one.

+

Once fixed, disable troubleshooting mode via Site Health → Troubleshoot.

+
+