wp_installing( bool $is_installing = null ): bool
- Since
- 4.4.0
- Source
wp-includes/load.php:1633
Toggles or reports whether WordPress is currently running in installation mode by reading a static flag seeded from the WP_INSTALLING constant. Passing true or false overrides that flag for the rest of the request and hands back whatever state was in effect before the change, not the new one. Several core functions, including get_option(), add_option(), and delete_transient(), call it internally to skip normal caching while WordPress is being installed or upgraded, so flipping it by hand outside of that context can change how those functions behave for the rest of the request.
Description
If the WP_INSTALLING constant is defined during the bootstrap, wp_installing() will default to true.
Compatibility
- WordPress
- since 4.4.0
- PHP
- 7.4–8.6-dev
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0), and compiles on PHP 7.4 through 8.6-dev.
Parameters
$is_installingbooloptional- True to set WP into Installing mode, false to turn Installing mode off.
Omit this parameter if you only want to fetch the current status.Default:null
Return value
bool- True if WP is installing, otherwise false. When a
$is_installingis passed, the function will report whether WP was in installing mode prior to the change to$is_installing.
Code examples
Every example is editable and runs in a real WordPress booted in your browser by WordPress Playground. Press Run, then edit the code: clicking away re-runs it. Nothing is sent anywhere until you do.
Check whether the current request is running in WordPress installation mode
A quick status check useful when a plugin needs to behave differently while the site is being set up.
$status = wp_installing();
printf(
'wp_installing() currently reports: %s',
esc_html( var_export( $status, true ) )
);On a normal, already-installed site with WP_INSTALLING undefined, this prints false.
Temporarily flip installation mode and read back the previous state
Demonstrates that passing a value both sets the flag and returns the value it held immediately before the change.
$previous = wp_installing( true );
echo 'State before the change: ' . esc_html( var_export( $previous, true ) ) . "\n";
$current = wp_installing();
echo 'State after setting to true: ' . esc_html( var_export( $current, true ) ) . "\n";
$restored = wp_installing( false );
echo 'State restored to: ' . esc_html( var_export( $restored, true ) ) . "\n";Always set the flag back to its original value in the same request, since it is stored in a static variable that persists for every subsequent call.
Common problems and fixes · 4
- Why does wp_installing() return true even though I never called it with a parameter?
- Why did my call to wp_installing( false ) seem to do nothing?
- Why does the value I passed in never show up as the return value?
- Why do get_option() and delete_transient() behave inconsistently when installation mode is on?
Why does wp_installing() return true even though I never called it with a parameter?
Why did my call to wp_installing( false ) seem to do nothing?
Why does the value I passed in never show up as the return value?
$old_installing = $installing; $installing = $is_installing; return (bool) $old_installing;. So wp_installing( true ) never returns true, it returns whatever the flag was before your call.Why do get_option() and delete_transient() behave inconsistently when installation mode is on?
Alternatives and related functions
wp_doing_ajax- When you need to detect whether the current request is an admin-ajax.php call rather than whether WordPress is being installed.
wp_doing_cron- When the check you actually need is whether the code is executing during a WP-Cron event.
is_multisite- When the behavior you want to branch on depends on network configuration rather than install state.
Performance profile
How much work a call to wp_installing() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.
- Cost class
- Trivial
- Scaling
- Constant
- Instructions
- 8–15
- Plugin surface
- None
- Called by
- 49
Touches nothing outside its own arguments.
No loop in the body: the same number of instructions runs whatever you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 17.
Nothing here hands control to plugin code.
49 places in core call this, so the cost is paid more often than your own code shows.
What one call costs · 1 distinct outcome
One number would be a lie: the work depends on which branch runs. These are every distinct cost wp_installing() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
| always | 8–15 | none |
Across PHP versions
Compiles the same on PHP 7.4, 8.1, 8.2, 8.3, 8.4, 8.5 and 8.6-dev: 17 instructions, 8–15 executed per call, 3 branches. The work does not change between versions.
An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.
Used by · 49
- WP_Automatic_Updater::is_disabled()Determines whether the entire automatic updater is disabled.
- WP_Recovery_Mode::initialize()Initialize recovery mode for the current request.
- WP_Site_Health::maybe_create_scheduled_event()Creates a weekly cron event, if one does not already exist.
- WP_Upgrader::init()Initializes the upgrader.
- _wp_theme_json_webfonts_handler()Runs the theme.json webfonts handler.
- add_option()Adds a new option.
- build_template_part_block_instance_variations()Returns an array of instance variation objects for the template part block
- dead_db()Loads custom DB error or display WordPress DB error.
- delete_option()Removes an option by name. Prevents removal of protected WordPress options.
- delete_site_transient()Deletes a site transient.
- delete_transient()Deletes a transient.
- determine_locale()Determines the current locale desired for the request.
Show all 49
- filter_default_metadata()Filters into default_{$object_type}_metadata and adds in default value.
- get_locale()Retrieves the current locale.
- get_option()Retrieves an option value based on an option name.
- get_site_transient()Retrieves the value of a site transient.
- get_transient()Retrieves the value of a transient.
- is_blog_installed()Determines whether WordPress is already installed.
- load_default_textdomain()Loads default translated strings based on locale.
- ms_load_current_site_and_network()Identifies the network and site of a requested domain and path and populates the corresponding network and site global objects as part of the multisite bootstrap process.
- request_filesystem_credentials()Displays a form to the user to request for their FTP/SSH details in order to connect to the filesystem.
- script_concat_settings()Determines the concatenation and compression settings for scripts and styles.
- set_site_transient()Sets/updates the value of a site transient.
- set_transient()Sets/updates the value of a transient.
- update_home_siteurl()Flushes rewrite rules if `siteurl`, `home` or `page_on_front` changed.
- update_option()Updates the value of an option that was already added.
- validate_current_theme()Checks that the active theme has the required files.
- wp_default_packages_inline_scripts()Adds inline scripts required for the WordPress JavaScript packages.
- wp_default_scripts()Registers all WordPress scripts.
- wp_get_active_and_valid_plugins()Retrieves an array of active and valid plugin files.
- wp_get_active_and_valid_themes()Retrieves an array of active and valid themes.
- wp_get_available_translations()Get available translations from the WordPress.org API.
- wp_initialize_site()Runs the initialization routine for a given site.
- wp_is_maintenance_mode()Checks if maintenance mode is enabled.
- wp_load_alloptions()Loads and caches all autoloaded options, if available or all options.
- wp_load_core_site_options()Loads and primes caches of certain often requested network options if is_multisite().
- wp_not_installed()Redirects to the installer if WordPress is not installed.
- wp_prime_network_option_caches()Primes specific network options into the cache with a single database query.
- wp_schedule_delete_old_privacy_export_files()Schedules a `WP_Cron` job to delete expired export files.
- wp_schedule_personal_data_cleanup_requests()Schedules a WP-Cron job to clean up personal data requests.
- wp_schedule_update_checks()Schedules core, theme, and plugin update checks.
- wp_schedule_update_network_counts()Schedules update of the network-wide counts for the current network.
- wp_schedule_update_user_counts()Schedules a recurring recalculation of the total count of users.
- wp_style_loader_src()Administration Screen CSS for changing the styles.
- wp_update_https_migration_required()Updates the 'https_migration_required' option if needed when the given URL has been updated from HTTP to HTTPS.
- wp_update_plugins()Checks for available updates to plugins based on the latest versions hosted on WordPress.org.
- wp_update_themes()Checks for available updates to themes based on the latest versions hosted on WordPress.org.
- wp_version_check()Checks WordPress version against the newest version.
- wpmu_create_blog()Creates a site.
Source code
function wp_installing( $is_installing = null ) { static $installing = null; // Support for the `WP_INSTALLING` constant, defined before WP is loaded. if ( is_null( $installing ) ) { $installing = defined( 'WP_INSTALLING' ) && WP_INSTALLING; } if ( ! is_null( $is_installing ) ) { $old_installing = $installing; $installing = $is_installing; return (bool) $old_installing; } return (bool) $installing;}Changelog
Introduced in 4.4.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/load.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.