Runtime Code
Some WordPress settings can only be set very early, before WordPress starts. They are PHP constants, such as WP_POST_REVISIONS or WP_DEBUG, and they normally live in the wp-config.php file. To change one, you have to open that file and edit it by hand.
The Docket Cache runtime code makes this easier. It is a small piece of code that you add to wp-config.php once. After that, you can change these settings under Runtime Options on the Docket Cache Configuration screen, and Docket Cache sets the constants for you.
How it works#
The runtime code sits in wp-config.php, just above the line that starts WordPress. When a page loads, it reads a second file, runtime.php, from the Docket Cache data folder (wp-content/docket-cache-data by default). That file holds the settings you chose under Runtime Options.
A few things keep this safe.
runtime.phponly sets a constant if it is not set already. Ifwp-config.phpalready sets the same constant, your value inwp-config.phpwins, and Docket Cache tells you that the change has no effect.- If a setting is left at "Default", Docket Cache does not set it at all, so WordPress uses its normal value.
- If the Docket Cache plugin files are deleted,
runtime.phpstops straight away, and the runtime code does nothing ifruntime.phpis missing. Your site keeps working.
Installing the runtime code#
We do not add the code without asking you first. When you change a Runtime Option, Docket Cache checks wp-config.php for the code. It reads the file with PHP's token_get_all function, which looks through the file without running it. If the code is missing, Docket Cache shows an install box with the code inside.
You then have two choices.
- Copy the code yourself. Paste it into
wp-config.phpjust above the linerequire_once ABSPATH . 'wp-settings.php';. - Click Install. Docket Cache adds the code for you. This button only appears if WordPress is allowed to write to
wp-config.php. After adding the code, Docket Cache loads your home page to check that the site still works. If it does not, Docket Cache puts the old file back.
On a Bedrock site, the settings live in config/application.php instead, and the code goes just after the line Config::apply();. There is no Install button on Bedrock, so copy the code yourself.
Updating or removing it#
The Runtime Code box under Actions, on the right of the Configuration screen, lets you update or remove the code at any time. As with installing, you can do it by hand, or click Install or Un-Install.
From the command line, use these commands.
wp cache runtime:install
wp cache runtime:remove
See WP-CLI for more.
The Runtime Options#
Each Runtime Option sets one WordPress constant.
| Runtime Option | WordPress constant | What it does |
|---|---|---|
| Auto Save Interval | AUTOSAVE_INTERVAL |
How often the editor saves a draft while you write |
| Post Revisions | WP_POST_REVISIONS |
How many old versions of each post to keep |
| Trash Bin | EMPTY_TRASH_DAYS |
How many days deleted items stay in the bin |
| Cleanup Image Edits | IMAGE_EDIT_OVERWRITE |
Keeps only the latest copy when you edit an image, instead of every version |
| Disallows WP Auto Update Core | WP_AUTO_UPDATE_CORE |
Turns off automatic WordPress updates |
| Disallows Plugin / Theme Editor | DISALLOW_FILE_EDIT |
Hides the plugin and theme file editor in the admin |
| Disallows Plugin / Theme Update and Installation | DISALLOW_FILE_MODS |
Stops anyone installing or updating plugins, themes and WordPress from the admin |
| Deactivate Concatenate WP-Admin Scripts | CONCATENATE_SCRIPTS |
Loads admin scripts one by one instead of joined into one file |
| Deactivate WP Cron | DISABLE_WP_CRON |
Stops WordPress running scheduled tasks when pages load |
| WP Debug | WP_DEBUG |
Turns on WordPress debug mode |
| WP Debug Display | WP_DEBUG_DISPLAY |
Shows errors on the page while debug mode is on |
| WP Debug Log | WP_DEBUG_LOG |
Saves errors to a log file while debug mode is on |
WP Debug Display and WP Debug Log only appear when WP Debug is turned on. On a multisite network, Runtime Options are only shown on the main site. See Admin Interface for the rest of the Configuration screen.