Add SCRIPT_DEBUG and WP_ENVIRONMENT_TYPE toggles to site debug settings - #4344
Open
ryanwelcher wants to merge 2 commits into
Open
Add SCRIPT_DEBUG and WP_ENVIRONMENT_TYPE toggles to site debug settings#4344ryanwelcher wants to merge 2 commits into
ryanwelcher wants to merge 2 commits into
Conversation
SCRIPT_DEBUG lets developers load un-minified core scripts to get readable React errors in the block editor, and WP_ENVIRONMENT_TYPE controls what wp_get_environment_type() reports. Both previously required hand-editing wp-config.php, which Studio manages and can overwrite. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
ryanwelcher
requested review from
bcotrim and
fredrikekelund
and removed request for
bcotrim
July 24, 2026 20:03
Collaborator
📊 Performance Test ResultsComparing 7880fee vs trunk app-size
site-editor
site-startup
Results are median values from multiple test runs. Legend: 🟢 Improvement (faster) | 🔴 Regression (slower) | ⚪ No change (<50ms diff) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related issues
SCRIPT_DEBUGandWP_ENVIRONMENT_TYPEtoggles to site debug settings #4333How AI was used in this PR
Claude Code mapped the existing
WP_DEBUG_LOG/WP_DEBUG_DISPLAYchain across the shared schema, CLI, both renderers, and the local REST server, then mirrored it for the two new settings. I reviewed the design decisions before implementation — in particular theWP_ENVIRONMENT_TYPEdefault and the choice to keep both controls in the Debugging tab.Reviewers should pay closest attention to the
SCRIPT_DEBUG/WP_DEBUGrelationship (see below) and to the visual result of the new select in the legacy settings modal.Proposed Changes
Studio already lets you toggle the debug log and browser error display from a site's Debugging settings, but
SCRIPT_DEBUGandWP_ENVIRONMENT_TYPErequired editingwp-config.phpby hand. Since Studio manages that file, hand edits aren't reliably preserved. This adds both as first-class settings.SCRIPT_DEBUGis the one that matters day to day: with it on, WordPress loads the development builds of core scripts, so the block editor surfaces readable React errors and component stack traces instead of minified production noise. Anyone working on blocks or in the editor wants this on regularly.WP_ENVIRONMENT_TYPElets you set a site to local, development, staging, or production, which changes whatwp_get_environment_type()returns and how plugins and themes that branch on it behave.Two behavior notes:
SCRIPT_DEBUGdoes not implyWP_DEBUG. They're independent constants in WordPress, so enabling script debug deliberately leavesWP_DEBUGalone. There's a regression test for this specifically, since it's the easy thing to get wrong later.WP_ENVIRONMENT_TYPEaslocalwhen nothing else has, solocalis the effective default today and stays the default here. That mu-plugin fallback remains for imported sites whosewp-config.phpStudio hasn't rewritten.Both settings are wired through the whole stack — the CLI gains
--script-debugand--environment-typeonstudio site set, and both appear instudio config get. Changing either restarts a running site, matching the existing debug toggles.Testing Instructions
Script debug
define( 'SCRIPT_DEBUG', true );is in the site'swp-config.php.wp-includes/js/dist/blocks.jsrather thanblocks.min.js), and that React dev warnings appear in the console.WP_DEBUGwas not flipped on as a side effect.Environment type
define( 'WP_ENVIRONMENT_TYPE', 'staging' );lands inwp-config.phpand thatwp eval 'echo wp_get_environment_type();'reportsstaging.local.CLI
Both UIs — repeat the first two sections in the agentic UI (
studio ui) as well as the desktop settings modal, and check the read-only summary on the desktop Settings tab shows the new rows.Pre-merge Checklist