populate_options( array $options = array() )
- Since
- 1.5.0, 5.1.0
- Source
wp-admin/includes/schema.php:362
Compatibility
- WordPress
- since 5.1.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
$optionsarrayoptional- Custom option $key => $value pairs to use. Default empty array.Default:
array()
Performance profile
How much work a call to populate_options() 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
- Heavy
- Scaling
- Scales with input
- Instructions
- 202–242
- Plugin surface
- 1 hook
- Called by
- 4
Reaches the database via ->get_col().
The body loops, so the work grows with what you pass in.
Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 277.
Third-party callbacks on 'populate_options' run inside this call, and their cost is not bounded by anything here.
4 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- hookthird-party callbacks
do_action()called directly - serializeserialisation
maybe_serialize()called directly - optionoption read or write
update_option()called directly - sqldatabase query
->get_col()called directly - cacheobject cache
wp_cache_get()one call below populate_options()
Further down the call graph this can also reach transient and query. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 32 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost populate_options() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
->exists() && empty($insert) && __get_option() | 202–215 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && empty($insert) && __get_option() | 205–218 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
->exists() && empty($insert) && !__get_option() | 206–219 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && empty($insert) && __get_option() | 208–221 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
->exists() && empty($insert) && __get_option() | 208–221 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && empty($insert) && !__get_option() | 209–222 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !empty($insert) && __get_option() | 210–223 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && empty($insert) && __get_option() | 211–224 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && empty($insert) && __get_option() | 211–224 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && empty($insert) && !__get_option() | 212–225 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && empty($insert) && !__get_option() | 212–225 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !empty($insert) && __get_option() | 213–226 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
20 further outcomes, up to 242 instructions
->exists() && !empty($insert) && !__get_option() | 214–227 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && empty($insert) && __get_option() | 214–227 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && empty($insert) && !__get_option() | 215–228 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && empty($insert) && !__get_option() | 215–228 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && !empty($insert) && __get_option() | 216–229 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
->exists() && !empty($insert) && __get_option() | 216–229 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && !empty($insert) && !__get_option() | 217–230 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && empty($insert) && __get_option() | 217–230 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && empty($insert) && !__get_option() | 218–231 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && !empty($insert) && __get_option() | 219–232 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && !empty($insert) && __get_option() | 219–232 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && !empty($insert) && !__get_option() | 220–233 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !empty($insert) && !__get_option() | 220–233 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && empty($insert) && !__get_option() | 221–234 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), __get_option(), update_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && !empty($insert) && __get_option() | 222–235 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && !empty($insert) && !__get_option() | 223–236 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !empty($insert) && !__get_option() | 223–236 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && !empty($insert) && __get_option() | 225–238 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), ->query(), delete_expired_transients() |
->exists() && !$offset_or_tz && !empty($insert) && !__get_option() | 226–239 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
!->exists() && !$offset_or_tz && !empty($insert) && !__get_option() | 229–242 | wp_guess_url(), do_action(), wp_get_theme(), ->exists(), ::WP_Theme(), ->get_stylesheet(), ->get_template(), _x(), timezone_identifiers_list(), __(), _x(), __(), __(), __(), time(), is_multisite(), is_multisite(), wp_parse_args(), array_keys(), ->get_col(), ->query(), __get_option(), update_option(), ->query(), delete_expired_transients() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 277 | 202–242 | 18 | |
| 8.5 | 277 | 202–242 | 18 | |
| 8.4 | 277 | 202–242 | 18 | 11 fewer instructions than PHP 8.3 |
| 8.3 | 288 | 207–250 | 18 | |
| 8.2 | 288 | 207–250 | 18 | |
| 8.1 | 288 | 207–250 | 18 | |
| 7.4 | 288 | 207–250 | 18 |
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.
Hooks and filters fired · 1
One hook fires while populate_options() runs, in this order:
- do_action( populate_options )actionline 371 (+9 into the body)
Fires before creating WordPress options and populating their default values.
Uses · 14
- wp_guess_url()Guesses the URL for the site.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_get_theme()Gets a WP_Theme object for a theme.
- _x()Retrieves translated string with gettext context.
- __()Retrieves the translation of $text.
- is_multisite()Determines whether Multisite is enabled.
- wp_parse_args()Merges user defined arguments into defaults array.
- maybe_serialize()Serializes data, if needed.
- sanitize_option()Sanitizes various option values based on the nature of the option.
- __get_option()Utility version of get_option that is private to installation/upgrade.
- update_option()Updates the value of an option that was already added.
- delete_option()Removes an option by name. Prevents removal of protected WordPress options.
Show all 14
- delete_expired_transients()Deletes all expired transients.
- WP_Theme::get_core_default_theme()Determines the latest WordPress default theme that is installed.
Used by · 4
- install_blog()Install an empty blog.
- upgrade_all()Functions to be called in installation and upgrade scripts.
- wp_initialize_site()Runs the initialization routine for a given site.
- wp_install()Installs the site.
Source code
function populate_options( array $options = array() ) { global $wpdb, $wp_db_version, $wp_current_db_version; $guessurl = wp_guess_url(); /** * Fires before creating WordPress options and populating their default values. * * @since 2.6.0 */ do_action( 'populate_options' ); // If WP_DEFAULT_THEME doesn't exist, fall back to the latest core default theme. $stylesheet = WP_DEFAULT_THEME; $template = WP_DEFAULT_THEME; $theme = wp_get_theme( WP_DEFAULT_THEME ); if ( ! $theme->exists() ) { $theme = WP_Theme::get_core_default_theme(); } // If we can't find a core default theme, WP_DEFAULT_THEME is the best we can do. if ( $theme ) { $stylesheet = $theme->get_stylesheet(); $template = $theme->get_template(); } $timezone_string = ''; $gmt_offset = 0; /* * translators: default GMT offset or timezone string. Must be either a valid offset (-12 to 14) * or a valid timezone string (America/New_York). See https://www.php.net/manual/en/timezones.php * for all timezone strings currently supported by PHP. * * Important: When a previous timezone string, like `Europe/Kiev`, has been superseded by an * updated one, like `Europe/Kyiv`, as a rule of thumb, the **old** timezone name should be used * in the "translation" to allow for the default timezone setting to be PHP cross-version compatible, * as old timezone names will be recognized in new PHP versions, while new timezone names cannot * be recognized in old PHP versions. * * To verify which timezone strings are available in the _oldest_ PHP version supported, you can * use https://3v4l.org/6YQAt#v5.6.20 and replace the "BR" (Brazil) in the code line with the * country code for which you want to look up the supported timezone names. */ $offset_or_tz = _x( '0', 'default GMT offset or timezone string' ); if ( is_numeric( $offset_or_tz ) ) { $gmt_offset = $offset_or_tz; } elseif ( $offset_or_tz && in_array( $offset_or_tz, timezone_identifiers_list( DateTimeZone::ALL_WITH_BC ), true ) ) { $timezone_string = $offset_or_tz; } $defaults = array( 'siteurl' => $guessurl, 'home' => $guessurl, 'blogname' => __( 'My Site' ), 'blogdescription' => '', 'users_can_register' => 0, 'admin_email' => '[email protected]', /* translators: Default start of the week. 0 = Sunday, 1 = Monday. */ 'start_of_week' => _x( '1', 'start of week' ), 'use_balanceTags' => 0, 'use_smilies' => 1, 'require_name_email' => 1, 'comments_notify' => 1, 'posts_per_rss' => 10, 'rss_use_excerpt' => 0, 'mailserver_url' => 'mail.example.com', 'mailserver_login' => '[email protected]', 'mailserver_pass' => '', 'mailserver_port' => 110, 'default_category' => 1, 'default_comment_status' => 'open', 'default_ping_status' => 'open', 'default_pingback_flag' => 1, 'posts_per_page' => 10, /* translators: Default date format, see https://www.php.net/manual/datetime.format.php */ 'date_format' => __( 'F j, Y' ), /* translators: Default time format, see https://www.php.net/manual/datetime.format.php */ 'time_format' => __( 'g:i a' ), /* translators: Links last updated date format, see https://www.php.net/manual/datetime.format.php */ 'links_updated_date_format' => __( 'F j, Y g:i a' ), 'comment_moderation' => 0,Changelog
Introduced in 1.5.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.0.4 tag, from
src/wp-admin/includes/schema.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.