By Greg Nowak. Updated 19 November 2026.
A WordPress plugin update is unavailable in production but works on staging. The theme file editor has disappeared. Before changing permissions or disabling plugins, check whether a PHP constant controls the behaviour.
The technical check is small. The useful outcome is understanding whether you have found a configuration mistake or an intentional deployment safeguard. For business owners and agency teams, that distinction determines who needs to act and whether anything should change.
The quick answer: use defined() before reading a constant
Pass the constant’s name as a quoted string:
if (defined('MY_FLAG')) {
$value = constant('MY_FLAG');
}PHP’s defined() function checks whether the name exists. It does not tell you whether its value is true. A constant defined as false still exists.
When the name is stored in a variable, constant($name) retrieves its value. Keep that call inside the existence check: since PHP 8.0, constant() throws an Error for an undefined name.
For a known Boolean flag, this checks whether its value evaluates as true:
if (defined('DISALLOW_FILE_EDIT') && DISALLOW_FILE_EDIT) {
// The flag is active.
}The second condition runs only when the first succeeds. If the setting expects a Boolean, inspect unexpected strings or numbers rather than relying on truthiness alone.
Inspect only the settings connected to the problem
For missing WordPress file editors or update controls, start with these two names. Have the maintainer run this in a protected diagnostic context after WordPress has loaded:
<?php
$names = ['DISALLOW_FILE_EDIT', 'DISALLOW_FILE_MODS'];
foreach ($names as $name) {
if (!defined($name)) {
echo $name . ': undefined' . PHP_EOL;
continue;
}
echo $name . ': ' . var_export(constant($name), true) . PHP_EOL;
}This reads the settings without changing them. var_export() makes Boolean values, strings and numbers distinguishable; a plain echo can make false look blank. Do not paste the snippet into a public template or leave an accessible diagnostic PHP file on the server.
| Finding | Meaning | Next step |
|---|---|---|
| Undefined | This runtime has no constant with that name. | Check application defaults and whether the expected configuration loaded. |
| Boolean false | The constant exists with a false value. | Investigate permissions or other controls if the action remains unavailable. |
| Boolean true | The restriction is explicitly enabled. | Confirm its purpose and owner before proposing a change. |
| A string or number | The value needs interpretation. | Check the consuming code and configuration format. |
What the WordPress flags actually control
DISALLOW_FILE_EDIT disables the built-in plugin and theme file editors. It does not disable ordinary page or post editing.
DISALLOW_FILE_MODS blocks plugin and theme installation and updates through WordPress administration, and also disables those file editors. The WordPress configuration handbook documents this broader restriction.
That can be a deliberate arrangement: an agency may deploy code through a repository while keeping dashboard editing unavailable. Before removing a restriction, establish how updates are supposed to reach production and who handles urgent fixes.
These constants are useful evidence, but they do not fully explain every unavailable action. User capabilities, Multisite rules and plugin controls may also matter. An undefined or false flag is a reason to continue investigating.
Compare staging and production in the right context
A standalone PHP script does not automatically load WordPress. Likewise, a command-line process may use different configuration or environment variables from a web request. Record how the check ran, the PHP version, the site path and when in the application bootstrap it ran.
Run the same narrow check in each environment. If the affected behaviour occurs in a web request, confirm any command-line finding in an equivalent protected web context before drawing conclusions.
When values differ, trace the definition through wp-config.php, included configuration files, deployment templates and host-managed bootstrap code. The runtime result tells you what exists at that point; it does not identify the source file or explain the decision behind it.
If you do not yet know the name, get_defined_constants(true) provides a grouped snapshot. The expression get_defined_constants(true)['user'] ?? [] retrieves the user category when present. Review it privately: configuration constants can contain credentials, and a complete dump rarely belongs in a support ticket.
Avoid the common implementation traps
For a namespaced constant, include the namespace in the string. For a class constant, include the class and :::
defined('App\Config\FEATURE_ENABLED');
if (defined('App\Config::TIMEOUT')) {
$timeout = constant('App\Config::TIMEOUT');
}String names do not inherit the current namespace or use aliases. Reflection is another option for inspecting a class: (new ReflectionClass(App\Config::class))->hasConstant('TIMEOUT'), assuming that class is available.
If you are writing fallback configuration, guard the definition:
if (!defined('MY_FLAG')) {
define('MY_FLAG', false);
}define() creates the constant at runtime. This guard supplies a default when absent; it does not override an existing value. Fix a conflicting setting at its source instead of adding another definition later.
For variables, use the appropriate variable check: isset($var) means set and not null. It is not a substitute for checking constants.
Leave the next maintainer a clear decision
Finish the investigation with a short record: the affected action and user role, each setting’s actual state, where it originates, and who owns the policy. If a change is needed, test it on staging, deploy through the normal process, and verify the intended action with the affected role. Remove temporary diagnostics afterwards.
If configuration differences keep delaying releases or complicating agency handovers, Greg can help trace the setup, clarify ownership and document a practical delivery process. Bring the symptom and the environment details; those provide a useful starting point.
Related on GrN.dk
- Drupal Deployments: Keep Small Fixes From Rewriting Live Settings
- Agentic AI: How It Works and When It’s Worth Using
- Before you launch a vibe-coded feature, plan the production handoff
Need help with this kind of work?
Talk to Greg about your delivery setup Get in touch with Greg.