update_option( string $option, mixed $value, bool|null $autoload = null ): bool
- Since
- 1.0.0, 4.2.0, 6.7.0
- Source
wp-includes/option.php:844
Save a setting to the options table with update_option(), which serializes non-scalar values and creates the option if it does not exist yet. It returns true only when the stored value actually changed. The third $autoload argument controls whether the option loads on every request; pass false for data only a few admin screens read.
Description
You do not need to serialize values. If the value needs to be serialized, then it will be serialized before it is inserted into the database.
Remember, resources cannot be serialized or added as an option.
If the option does not exist, it will be created.
This function is designed to work with or without a logged-in user. In terms of security, plugin developers should check the current user's capabilities before updating any options.
Compatibility
- WordPress
- since 6.7.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
$optionstring- Name of the option to update. Expected to not be SQL-escaped.
$valuemixed- Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
$autoloadbool|nulloptional- Whether to load the option when WordPress starts up.
Accepts a boolean, ornullto stick with the initial value or, if no initial value is set, to leave the decision up to default heuristics in WordPress.
For existing options,$autoloadcan only be updated usingupdate_option()if$valueis also changed.
For backward compatibility 'yes' and 'no' are also accepted, though using these values is deprecated.
Autoloading too many options can lead to performance problems, especially if the options are not frequently used. For options which are accessed across several places in the frontend, it is recommended to autoload them, by using true.
For options which are accessed only on few specific URLs, it is recommended to not autoload them, by using false.
For non-existent options, the default is null, which means WordPress will determine the autoload value.Default:null
Return value
bool- True if the value was updated, false otherwise.
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.
Save a plugin settings array
Options hold arrays directly, so a plugin's whole settings screen can live under one key.
$settings = get_option( 'wppaste_settings', array() );
$settings['accent_color'] = sanitize_hex_color( '#0055aa' );
$settings['show_promo'] = true;
update_option( 'wppaste_settings', $settings );
print_r( get_option( 'wppaste_settings' ) );update_option() creates the option when it does not exist, so add_option() is rarely needed.
Store rarely-read data without autoloading it
Autoloaded options are fetched on every single request, so anything read on one screen should opt out.
$log = get_option( 'wppaste_import_log', array() );
$log[] = array( 'time' => current_time( 'mysql' ), 'result' => 'ok' );
// false: never autoload, this is read on one admin screen only.
update_option( 'wppaste_import_log', $log, false );
echo 'rows stored: ', count( get_option( 'wppaste_import_log' ) ), "\n";
echo 'autoloaded: ', isset( wp_load_alloptions()['wppaste_import_log'] ) ? 'yes' : 'no';The autoload flag is only applied when the option is first created, not on later updates.
Performance profile
How much work a call to update_option() 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
- Constant
- Instructions
- 9–171
- Plugin surface
- 6 hooks
- Called by
- 50
Reaches the database via ->get_var().
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 248.
Third-party callbacks on 'pre_update_option_{$option}', 'pre_update_option', 'default_option_{$option}' run inside this call, and their cost is not bounded by anything here.
50 places in core call this, so the cost is paid more often than your own code shows.
What it touches
- optionoption read or write
update_option()this function does it - hookthird-party callbacks
apply_filters()called directly - serializeserialisation
maybe_serialize()called directly - cacheobject cache
wp_cache_get()called directly - sqldatabase query
->get_var()called directly
Further down the call graph this can also reach query and transient. Those are the worst case, several calls deep and usually down an error path, not what a normal call pays.
What one call costs · 74 distinct outcomes
One number would be a lie: the work depends on which branch runs. These are every distinct cost update_option() can have, taken from its control-flow graph on PHP 8.5.
| When | Instructions | Calls it makes |
|---|---|---|
empty($option) | 9–11 | none |
!empty($option) && isset([…][$option]) && !wp_installing() | 36–38 | wp_installing(), __(), sprintf(), _deprecated_argument(), update_option() |
!empty($option) && !isset([…][$option]) && $value === false | 43–47 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters() |
!empty($option) && isset([…][$option]) && wp_installing() && $value === false | 46–50 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters() |
!empty($option) && !isset([…][$option]) && $value !== false | 51–55 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false | 54–58 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value === false | 66–70 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), add_option() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value === false | 69–73 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), add_option() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null | 92–96 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload !== null | 95–99 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload | 97–101 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload | 100–104 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name() |
62 further outcomes, up to 171 instructions
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload | 106–112 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && $raw_autoload | 109–115 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && wp_installing() | 115–121 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload !== null | 118–124 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && wp_installing() | 120–126 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && wp_installing() | 123–127 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload | 123–129 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) | 126–130 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && wp_installing() | 128–132 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && wp_installing() | 129–137 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && !wp_installing() && !isset($update_args) | 129–137 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) | 131–135 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && $raw_autoload | 132–140 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && !isset($update_args) | 132–140 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && !wp_installing() && !isset($update_args) | 134–142 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 134–140 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && wp_installing() | 137–143 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && !isset($update_args) | 137–143 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && !isset($update_args) | 137–145 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && isset($update_args) && !isset($alloptions[$option]) | 137–143 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 139–145 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && !wp_installing() && isset($update_args) | 139–145 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 140–146 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && wp_installing() && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) | 140–146 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && !isset($update_args) | 140–146 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && !isset($update_args) | 142–148 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 142–146 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && isset($update_args) && !isset($alloptions[$option]) | 142–148 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && isset($update_args) | 142–148 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && !wp_installing() && !isset($update_args) | 143–153 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && isset($update_args) && isset($alloptions[$option]) | 143–149 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && !wp_installing() && isset($update_args) | 144–150 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 145–151 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !isset($update_args) | 145–151 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && !isset($alloptions[$option]) | 145–149 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && !isset($update_args) | 146–156 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 147–151 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) | 147–151 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && isset($update_args) | 147–153 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 148–156 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 148–152 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && isset($update_args) && isset($alloptions[$option]) | 148–154 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && !isset($alloptions[$option]) | 150–154 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) | 150–154 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && !isset($update_args) | 151–159 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && isset($update_args) && !isset($alloptions[$option]) | 151–159 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload !== null && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && isset($alloptions[$option]) | 151–155 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) | 152–156 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 153–157 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && !wp_installing() && isset($update_args) | 153–161 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 154–162 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !isset($update_args) | 154–162 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) | 155–159 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && !isset($alloptions[$option]) | 156–162 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && !$raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && isset($alloptions[$option]) | 156–160 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && isset($update_args) | 156–164 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && isset($update_args) && isset($alloptions[$option]) | 157–165 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && !isset($alloptions[$option]) | 159–165 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) | 161–167 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && !isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && !wp_installing() && isset($update_args) && isset($alloptions[$option]) | 162–168 | wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) | 164–170 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_cache_delete(), wp_load_alloptions(), wp_cache_set(), do_action(), do_action() |
!empty($option) && isset([…][$option]) && $value !== false && $old_value !== false && $autoload === null && $raw_autoload && is_array($notoptions) && isset($notoptions[$option]) && isset($update_args) && isset($alloptions[$option]) | 165–171 | wp_installing(), wp_protect_special_option(), sanitize_option(), get_option(), apply_filters(), apply_filters(), maybe_serialize(), maybe_serialize(), apply_filters(), maybe_serialize(), do_action(), ->prepare(), ->get_var(), wp_determine_option_autoload_value(), option_name(), wp_cache_get(), wp_cache_set(), wp_installing(), wp_autoload_values_to_autoload(), wp_load_alloptions(), wp_cache_set(), wp_cache_set(), do_action(), do_action() |
Across PHP versions
| PHP | Compiled | Executed | Branches | Notes |
|---|---|---|---|---|
| 8.6-dev | 248 | 9–171 | 19 | |
| 8.5 | 248 | 9–171 | 19 | |
| 8.4 | 248 | 9–171 | 19 | 5 fewer instructions than PHP 8.3 |
| 8.3 | 253 | 9–176 | 19 | |
| 8.2 | 253 | 9–176 | 19 | |
| 8.1 | 253 | 9–176 | 19 | 2 fewer instructions than PHP 7.4 |
| 7.4 | 255 | 11–178 | 19 |
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 · 6
6 hooks fire while update_option() runs, in this order:
- apply_filters( pre_update_option_{$option} )filterline 899 (+55 into the body)
Filters a specific option before its value is (maybe) serialized and updated.
- apply_filters( pre_update_option )filterline 910 (+66 into the body)
Filters an option before its value is (maybe) serialized and updated.
- apply_filters( default_option_{$option} )filterline 926 (+82 into the body)
Filters the default value for an option.
- do_action( update_option )actionline 941 (+97 into the body)
Fires immediately before an option value is updated.
- do_action( update_option_{$option} )actionline 1017 (+173 into the body)
Fires after the value of a specific option has been successfully updated.
- do_action( updated_option )actionline 1028 (+184 into the body)
Fires after the value of an option has been successfully updated.
Uses · 17
- wp_installing()Checks or sets whether WordPress is in "installation" mode.
- _deprecated_argument()Marks a function argument as deprecated and inform when it has been used.
- __()Retrieves the translation of $text.
- update_option()Updates the value of an option that was already added.
- wp_protect_special_option()Protects WordPress special option from being modified.
- sanitize_option()Sanitizes various option values based on the nature of the option.
- get_option()Retrieves an option value based on an option name.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- maybe_serialize()Serializes data, if needed.
- add_option()Adds a new option.
- do_action()Calls the callback functions that have been added to an action hook.
- wp_determine_option_autoload_value()Determines the appropriate autoload value for an option based on input.
Show all 17
- wp_cache_get()Retrieves the cache contents from the cache by key and group.
- wp_cache_set()Saves the data to the cache.
- wp_load_alloptions()Loads and caches all autoloaded options, if available or all options.
- wp_autoload_values_to_autoload()Returns the values that trigger autoloading from the options table.
- wp_cache_delete()Removes the cache contents matching key and group.
Used by · 50
- Featured_Content::delete_post_tag()Resets tag option when the saved tag is deleted.
- Plugin_Upgrader::bulk_upgrade()Upgrades several plugins at once.
- Plugin_Upgrader::upgrade()Upgrades a plugin.
- Theme_Upgrader::bulk_upgrade()Upgrades several themes at once.
- Theme_Upgrader::upgrade()Upgrades a theme.
- WP_Automatic_Updater::send_plugin_theme_email()Sends an email upon the completion or failure of a plugin or theme background update.
- WP_Customize_Manager::save_changeset_post()Saves the post for the loaded changeset.
- WP_Customize_Manager::update_stashed_theme_mod_settings()Updates stashed theme mod settings.
- WP_Customize_Nav_Menu_Setting::update()Create/update the nav_menu term for this setting.
- WP_Customize_Setting::set_root_value()Set the root value for a setting, especially for multidimensional ones.
- WP_Paused_Extensions_Storage::delete()Forgets a previously recorded extension error.
- WP_Paused_Extensions_Storage::delete_all()Remove all paused extensions.
Show all 50
- WP_Paused_Extensions_Storage::set()Records an extension error.
- WP_Plugins_List_Table::prepare_items()
- WP_Privacy_Policy_Content::text_change_check()Performs a quick check to determine whether any privacy info has changed.
- WP_REST_Menus_Controller::handle_auto_add()Updates the menu's auto add from a REST request.
- WP_REST_Settings_Controller::update_item()Updates settings for the settings object.
- WP_Recovery_Mode_Email_Service::maybe_send_recovery_mode_email()Sends the recovery mode email if the rate limit has not been sent.
- WP_Recovery_Mode_Key_Service::update_keys()Updates the recovery key records.
- WP_Rewrite::refresh_rewrite_rules()Refreshes the rewrite rules, saving the fresh value to the database.
- WP_Rewrite::set_category_base()Sets the category base for the category permalink.
- WP_Rewrite::set_permalink_structure()Sets the main permalink structure for the site.
- WP_Rewrite::set_tag_base()Sets the tag base for the tag permalink.
- WP_Roles::add_cap()Adds a capability to role.
- WP_Roles::add_role()Adds a role name with capabilities to the list.
- WP_Roles::remove_cap()Removes a capability from role.
- WP_Roles::remove_role()Removes a role by name.
- WP_Theme::get_allowed_on_site()Returns array of stylesheet names of themes allowed on the site.
- WP_Upgrader::create_lock()Creates a lock using WordPress options.
- WP_Widget::save_settings()Saves the settings for all instances of the widget class.
- _delete_option_fresh_site()Deletes the fresh site option.
- _get_term_hierarchy()Retrieves children of taxonomy as term IDs.
- _reset_front_page_settings_for_post()Resets the page_on_front, show_on_front, and page_for_post settings when a linked page is deleted or trashed.
- _set_cron_array()Updates the cron option with the new cron array.
- _split_shared_term()Creates a new term for a term_taxonomy item that currently shares its term with another term_taxonomy.
- _sync_custom_logo_to_site_logo()Updates the site_logo option when the custom_logo theme-mod gets updated.
- _upgrade_core_deactivate_incompatible_plugins()
- _upgrade_cron_array()Upgrades a cron info array.
- _wp_batch_split_terms()Splits a batch of shared taxonomy terms.
- _wp_batch_update_comment_type()Updates the comment type for a batch of comments.
- _wp_check_split_default_terms()Checks default categories when a term gets split to see if any of them need to be updated.
- _wp_connectors_rest_settings_dispatch()Masks and validates connector API keys in REST responses.
- _wp_upgrade_revisions_of_post()Upgrades the revisions author, adds the current post as a revision and sets the revisions version to 1.
- activate_plugin()Attempts activation of plugin in a "sandbox" and redirects on success.
- block_core_calendar_update_has_published_posts()Queries the database for any published post and saves a flag whether any published post exists or not.
- check_theme_switched()Checks if a theme has been changed and runs 'after_switch_theme' hook on the next WP load.
- deactivate_plugins()Deactivates a single plugin or multiple plugins.
- deactivated_plugins_notice()Renders an admin notice when a plugin was deactivated during an update.
- get_theme_mods()Retrieves all theme modifications.
- install_blog()Install an empty blog.
Source code
function update_option( $option, $value, $autoload = null ) { global $wpdb; if ( is_scalar( $option ) ) { $option = trim( $option ); } if ( empty( $option ) ) { return false; } /* * Until a proper _deprecated_option() function can be introduced, * redirect requests to deprecated keys to the new, correct ones. */ $deprecated_keys = array( 'blacklist_keys' => 'disallowed_keys', 'comment_whitelist' => 'comment_previously_approved', ); if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) { _deprecated_argument( __FUNCTION__, '5.5.0', sprintf( /* translators: 1: Deprecated option key, 2: New option key. */ __( 'The "%1$s" option key has been renamed to "%2$s".' ), $option, $deprecated_keys[ $option ] ) ); return update_option( $deprecated_keys[ $option ], $value, $autoload ); } wp_protect_special_option( $option ); if ( is_object( $value ) ) { $value = clone $value; } $value = sanitize_option( $option, $value ); $old_value = get_option( $option ); /** * Filters a specific option before its value is (maybe) serialized and updated. * * The dynamic portion of the hook name, `$option`, refers to the option name. * * @since 2.6.0 * @since 4.4.0 The `$option` parameter was added. * * @param mixed $value The new, unserialized option value. * @param mixed $old_value The old option value. * @param string $option Option name. */ $value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option ); /** * Filters an option before its value is (maybe) serialized and updated. * * @since 3.9.0 * * @param mixed $value The new, unserialized option value. * @param string $option Name of the option. * @param mixed $old_value The old option value. */ $value = apply_filters( 'pre_update_option', $value, $option, $old_value ); /* * If the new and old values are the same, no need to update. * * Unserialized values will be adequate in most cases. If the unserialized * data differs, the (maybe) serialized data is checked to avoid * unnecessary database calls for otherwise identical object instances. * * See https://core.trac.wordpress.org/ticket/38903 */ if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) { return false; }Changelog
Introduced in 1.0.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
$autoload parameter was added.from the docblockAbout this page
- Parsed data
- Generated from the wordpress-develop 7.0.4 tag, from
src/wp-includes/option.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.