Edit File by line
/home/zeestwma/richards.../wp-inclu...
File: option.php
wp_cache_set( 'alloptions', $alloptions, 'options' );
[500] Fix | Delete
}
[501] Fix | Delete
[502] Fix | Delete
return $results;
[503] Fix | Delete
}
[504] Fix | Delete
[505] Fix | Delete
/**
[506] Fix | Delete
* Sets the autoload value for multiple options in the database.
[507] Fix | Delete
*
[508] Fix | Delete
* This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set different autoload values for
[509] Fix | Delete
* each option at once.
[510] Fix | Delete
*
[511] Fix | Delete
* @since 6.4.0
[512] Fix | Delete
* @since 6.7.0 The autoload values 'yes' and 'no' are deprecated.
[513] Fix | Delete
*
[514] Fix | Delete
* @see wp_set_option_autoload_values()
[515] Fix | Delete
*
[516] Fix | Delete
* @param string[] $options List of option names. Expected to not be SQL-escaped.
[517] Fix | Delete
* @param bool $autoload Autoload value to control whether to load the options when WordPress starts up.
[518] Fix | Delete
* For backward compatibility 'yes' and 'no' are also accepted, though using these values is
[519] Fix | Delete
* deprecated.
[520] Fix | Delete
* @return array Associative array of all provided $options as keys and boolean values for whether their autoload value
[521] Fix | Delete
* was updated.
[522] Fix | Delete
*/
[523] Fix | Delete
function wp_set_options_autoload( array $options, $autoload ) {
[524] Fix | Delete
return wp_set_option_autoload_values(
[525] Fix | Delete
array_fill_keys( $options, $autoload )
[526] Fix | Delete
);
[527] Fix | Delete
}
[528] Fix | Delete
[529] Fix | Delete
/**
[530] Fix | Delete
* Sets the autoload value for an option in the database.
[531] Fix | Delete
*
[532] Fix | Delete
* This is a wrapper for {@see wp_set_option_autoload_values()}, which can be used to set the autoload value for
[533] Fix | Delete
* multiple options at once.
[534] Fix | Delete
*
[535] Fix | Delete
* @since 6.4.0
[536] Fix | Delete
* @since 6.7.0 The autoload values 'yes' and 'no' are deprecated.
[537] Fix | Delete
*
[538] Fix | Delete
* @see wp_set_option_autoload_values()
[539] Fix | Delete
*
[540] Fix | Delete
* @param string $option Name of the option. Expected to not be SQL-escaped.
[541] Fix | Delete
* @param bool $autoload Autoload value to control whether to load the option when WordPress starts up.
[542] Fix | Delete
* For backward compatibility 'yes' and 'no' are also accepted, though using these values is
[543] Fix | Delete
* deprecated.
[544] Fix | Delete
* @return bool True if the autoload value was modified, false otherwise.
[545] Fix | Delete
*/
[546] Fix | Delete
function wp_set_option_autoload( $option, $autoload ) {
[547] Fix | Delete
$result = wp_set_option_autoload_values( array( $option => $autoload ) );
[548] Fix | Delete
if ( isset( $result[ $option ] ) ) {
[549] Fix | Delete
return $result[ $option ];
[550] Fix | Delete
}
[551] Fix | Delete
return false;
[552] Fix | Delete
}
[553] Fix | Delete
[554] Fix | Delete
/**
[555] Fix | Delete
* Protects WordPress special option from being modified.
[556] Fix | Delete
*
[557] Fix | Delete
* Will die if $option is in protected list. Protected options are 'alloptions'
[558] Fix | Delete
* and 'notoptions' options.
[559] Fix | Delete
*
[560] Fix | Delete
* @since 2.2.0
[561] Fix | Delete
*
[562] Fix | Delete
* @param string $option Option name.
[563] Fix | Delete
*/
[564] Fix | Delete
function wp_protect_special_option( $option ) {
[565] Fix | Delete
if ( 'alloptions' === $option || 'notoptions' === $option ) {
[566] Fix | Delete
wp_die(
[567] Fix | Delete
sprintf(
[568] Fix | Delete
/* translators: %s: Option name. */
[569] Fix | Delete
__( '%s is a protected WP option and may not be modified' ),
[570] Fix | Delete
esc_html( $option )
[571] Fix | Delete
)
[572] Fix | Delete
);
[573] Fix | Delete
}
[574] Fix | Delete
}
[575] Fix | Delete
[576] Fix | Delete
/**
[577] Fix | Delete
* Prints option value after sanitizing for forms.
[578] Fix | Delete
*
[579] Fix | Delete
* @since 1.5.0
[580] Fix | Delete
*
[581] Fix | Delete
* @param string $option Option name.
[582] Fix | Delete
*/
[583] Fix | Delete
function form_option( $option ) {
[584] Fix | Delete
echo esc_attr( get_option( $option ) );
[585] Fix | Delete
}
[586] Fix | Delete
[587] Fix | Delete
/**
[588] Fix | Delete
* Loads and caches all autoloaded options, if available or all options.
[589] Fix | Delete
*
[590] Fix | Delete
* @since 2.2.0
[591] Fix | Delete
* @since 5.3.1 The `$force_cache` parameter was added.
[592] Fix | Delete
*
[593] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[594] Fix | Delete
*
[595] Fix | Delete
* @param bool $force_cache Optional. Whether to force an update of the local cache
[596] Fix | Delete
* from the persistent cache. Default false.
[597] Fix | Delete
* @return array List of all options.
[598] Fix | Delete
*/
[599] Fix | Delete
function wp_load_alloptions( $force_cache = false ) {
[600] Fix | Delete
global $wpdb;
[601] Fix | Delete
[602] Fix | Delete
/**
[603] Fix | Delete
* Filters the array of alloptions before it is populated.
[604] Fix | Delete
*
[605] Fix | Delete
* Returning an array from the filter will effectively short circuit
[606] Fix | Delete
* wp_load_alloptions(), returning that value instead.
[607] Fix | Delete
*
[608] Fix | Delete
* @since 6.2.0
[609] Fix | Delete
*
[610] Fix | Delete
* @param array|null $alloptions An array of alloptions. Default null.
[611] Fix | Delete
* @param bool $force_cache Whether to force an update of the local cache from the persistent cache. Default false.
[612] Fix | Delete
*/
[613] Fix | Delete
$alloptions = apply_filters( 'pre_wp_load_alloptions', null, $force_cache );
[614] Fix | Delete
if ( is_array( $alloptions ) ) {
[615] Fix | Delete
return $alloptions;
[616] Fix | Delete
}
[617] Fix | Delete
[618] Fix | Delete
if ( ! wp_installing() || ! is_multisite() ) {
[619] Fix | Delete
$alloptions = wp_cache_get( 'alloptions', 'options', $force_cache );
[620] Fix | Delete
} else {
[621] Fix | Delete
$alloptions = false;
[622] Fix | Delete
}
[623] Fix | Delete
[624] Fix | Delete
if ( ! $alloptions ) {
[625] Fix | Delete
$suppress = $wpdb->suppress_errors();
[626] Fix | Delete
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload IN ( '" . implode( "', '", esc_sql( wp_autoload_values_to_autoload() ) ) . "' )" );
[627] Fix | Delete
[628] Fix | Delete
if ( ! $alloptions_db ) {
[629] Fix | Delete
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
[630] Fix | Delete
}
[631] Fix | Delete
$wpdb->suppress_errors( $suppress );
[632] Fix | Delete
[633] Fix | Delete
$alloptions = array();
[634] Fix | Delete
foreach ( (array) $alloptions_db as $o ) {
[635] Fix | Delete
$alloptions[ $o->option_name ] = $o->option_value;
[636] Fix | Delete
}
[637] Fix | Delete
[638] Fix | Delete
if ( ! wp_installing() || ! is_multisite() ) {
[639] Fix | Delete
/**
[640] Fix | Delete
* Filters all options before caching them.
[641] Fix | Delete
*
[642] Fix | Delete
* @since 4.9.0
[643] Fix | Delete
*
[644] Fix | Delete
* @param array $alloptions Array with all options.
[645] Fix | Delete
*/
[646] Fix | Delete
$alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );
[647] Fix | Delete
[648] Fix | Delete
wp_cache_add( 'alloptions', $alloptions, 'options' );
[649] Fix | Delete
}
[650] Fix | Delete
}
[651] Fix | Delete
[652] Fix | Delete
/**
[653] Fix | Delete
* Filters all options after retrieving them.
[654] Fix | Delete
*
[655] Fix | Delete
* @since 4.9.0
[656] Fix | Delete
*
[657] Fix | Delete
* @param array $alloptions Array with all options.
[658] Fix | Delete
*/
[659] Fix | Delete
return apply_filters( 'alloptions', $alloptions );
[660] Fix | Delete
}
[661] Fix | Delete
[662] Fix | Delete
/**
[663] Fix | Delete
* Primes specific network options for the current network into the cache with a single database query.
[664] Fix | Delete
*
[665] Fix | Delete
* Only network options that do not already exist in cache will be loaded.
[666] Fix | Delete
*
[667] Fix | Delete
* If site is not multisite, then call wp_prime_option_caches().
[668] Fix | Delete
*
[669] Fix | Delete
* @since 6.6.0
[670] Fix | Delete
*
[671] Fix | Delete
* @see wp_prime_network_option_caches()
[672] Fix | Delete
*
[673] Fix | Delete
* @param string[] $options An array of option names to be loaded.
[674] Fix | Delete
*/
[675] Fix | Delete
function wp_prime_site_option_caches( array $options ) {
[676] Fix | Delete
wp_prime_network_option_caches( null, $options );
[677] Fix | Delete
}
[678] Fix | Delete
[679] Fix | Delete
/**
[680] Fix | Delete
* Primes specific network options into the cache with a single database query.
[681] Fix | Delete
*
[682] Fix | Delete
* Only network options that do not already exist in cache will be loaded.
[683] Fix | Delete
*
[684] Fix | Delete
* If site is not multisite, then call wp_prime_option_caches().
[685] Fix | Delete
*
[686] Fix | Delete
* @since 6.6.0
[687] Fix | Delete
*
[688] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[689] Fix | Delete
*
[690] Fix | Delete
* @param int|null $network_id ID of the network. Can be null to default to the current network ID.
[691] Fix | Delete
* @param string[] $options An array of option names to be loaded.
[692] Fix | Delete
*/
[693] Fix | Delete
function wp_prime_network_option_caches( $network_id, array $options ) {
[694] Fix | Delete
global $wpdb;
[695] Fix | Delete
[696] Fix | Delete
if ( wp_installing() ) {
[697] Fix | Delete
return;
[698] Fix | Delete
}
[699] Fix | Delete
[700] Fix | Delete
if ( ! is_multisite() ) {
[701] Fix | Delete
wp_prime_option_caches( $options );
[702] Fix | Delete
return;
[703] Fix | Delete
}
[704] Fix | Delete
[705] Fix | Delete
if ( $network_id && ! is_numeric( $network_id ) ) {
[706] Fix | Delete
return;
[707] Fix | Delete
}
[708] Fix | Delete
[709] Fix | Delete
$network_id = (int) $network_id;
[710] Fix | Delete
[711] Fix | Delete
// Fallback to the current network if a network ID is not specified.
[712] Fix | Delete
if ( ! $network_id ) {
[713] Fix | Delete
$network_id = get_current_network_id();
[714] Fix | Delete
}
[715] Fix | Delete
[716] Fix | Delete
$cache_keys = array();
[717] Fix | Delete
foreach ( $options as $option ) {
[718] Fix | Delete
$cache_keys[ $option ] = "{$network_id}:{$option}";
[719] Fix | Delete
}
[720] Fix | Delete
[721] Fix | Delete
$cache_group = 'site-options';
[722] Fix | Delete
$cached_options = wp_cache_get_multiple( array_values( $cache_keys ), $cache_group );
[723] Fix | Delete
[724] Fix | Delete
$notoptions_key = "$network_id:notoptions";
[725] Fix | Delete
$notoptions = wp_cache_get( $notoptions_key, $cache_group );
[726] Fix | Delete
[727] Fix | Delete
if ( ! is_array( $notoptions ) ) {
[728] Fix | Delete
$notoptions = array();
[729] Fix | Delete
}
[730] Fix | Delete
[731] Fix | Delete
// Filter options that are not in the cache.
[732] Fix | Delete
$options_to_prime = array();
[733] Fix | Delete
foreach ( $cache_keys as $option => $cache_key ) {
[734] Fix | Delete
if (
[735] Fix | Delete
( ! isset( $cached_options[ $cache_key ] ) || false === $cached_options[ $cache_key ] )
[736] Fix | Delete
&& ! isset( $notoptions[ $option ] )
[737] Fix | Delete
) {
[738] Fix | Delete
$options_to_prime[] = $option;
[739] Fix | Delete
}
[740] Fix | Delete
}
[741] Fix | Delete
[742] Fix | Delete
// Bail early if there are no options to be loaded.
[743] Fix | Delete
if ( empty( $options_to_prime ) ) {
[744] Fix | Delete
return;
[745] Fix | Delete
}
[746] Fix | Delete
[747] Fix | Delete
$query_args = $options_to_prime;
[748] Fix | Delete
$query_args[] = $network_id;
[749] Fix | Delete
$results = $wpdb->get_results(
[750] Fix | Delete
$wpdb->prepare(
[751] Fix | Delete
sprintf(
[752] Fix | Delete
"SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN (%s) AND site_id = %s",
[753] Fix | Delete
implode( ',', array_fill( 0, count( $options_to_prime ), '%s' ) ),
[754] Fix | Delete
'%d'
[755] Fix | Delete
),
[756] Fix | Delete
$query_args
[757] Fix | Delete
)
[758] Fix | Delete
);
[759] Fix | Delete
[760] Fix | Delete
$data = array();
[761] Fix | Delete
$options_found = array();
[762] Fix | Delete
foreach ( $results as $result ) {
[763] Fix | Delete
$key = $result->meta_key;
[764] Fix | Delete
$cache_key = $cache_keys[ $key ];
[765] Fix | Delete
$data[ $cache_key ] = maybe_unserialize( $result->meta_value );
[766] Fix | Delete
$options_found[] = $key;
[767] Fix | Delete
}
[768] Fix | Delete
wp_cache_set_multiple( $data, $cache_group );
[769] Fix | Delete
// If all options were found, no need to update `notoptions` cache.
[770] Fix | Delete
if ( count( $options_found ) === count( $options_to_prime ) ) {
[771] Fix | Delete
return;
[772] Fix | Delete
}
[773] Fix | Delete
[774] Fix | Delete
$options_not_found = array_diff( $options_to_prime, $options_found );
[775] Fix | Delete
[776] Fix | Delete
// Add the options that were not found to the cache.
[777] Fix | Delete
$update_notoptions = false;
[778] Fix | Delete
foreach ( $options_not_found as $option_name ) {
[779] Fix | Delete
if ( ! isset( $notoptions[ $option_name ] ) ) {
[780] Fix | Delete
$notoptions[ $option_name ] = true;
[781] Fix | Delete
$update_notoptions = true;
[782] Fix | Delete
}
[783] Fix | Delete
}
[784] Fix | Delete
[785] Fix | Delete
// Only update the cache if it was modified.
[786] Fix | Delete
if ( $update_notoptions ) {
[787] Fix | Delete
wp_cache_set( $notoptions_key, $notoptions, $cache_group );
[788] Fix | Delete
}
[789] Fix | Delete
}
[790] Fix | Delete
[791] Fix | Delete
/**
[792] Fix | Delete
* Loads and primes caches of certain often requested network options if is_multisite().
[793] Fix | Delete
*
[794] Fix | Delete
* @since 3.0.0
[795] Fix | Delete
* @since 6.3.0 Also prime caches for network options when persistent object cache is enabled.
[796] Fix | Delete
* @since 6.6.0 Uses wp_prime_network_option_caches().
[797] Fix | Delete
*
[798] Fix | Delete
* @param int $network_id Optional. Network ID of network for which to prime network options cache. Defaults to current network.
[799] Fix | Delete
*/
[800] Fix | Delete
function wp_load_core_site_options( $network_id = null ) {
[801] Fix | Delete
if ( ! is_multisite() || wp_installing() ) {
[802] Fix | Delete
return;
[803] Fix | Delete
}
[804] Fix | Delete
$core_options = array( 'site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled', 'ms_files_rewriting', 'WPLANG' );
[805] Fix | Delete
[806] Fix | Delete
wp_prime_network_option_caches( $network_id, $core_options );
[807] Fix | Delete
}
[808] Fix | Delete
[809] Fix | Delete
/**
[810] Fix | Delete
* Updates the value of an option that was already added.
[811] Fix | Delete
*
[812] Fix | Delete
* You do not need to serialize values. If the value needs to be serialized,
[813] Fix | Delete
* then it will be serialized before it is inserted into the database.
[814] Fix | Delete
* Remember, resources cannot be serialized or added as an option.
[815] Fix | Delete
*
[816] Fix | Delete
* If the option does not exist, it will be created.
[817] Fix | Delete
[818] Fix | Delete
* This function is designed to work with or without a logged-in user. In terms of security,
[819] Fix | Delete
* plugin developers should check the current user's capabilities before updating any options.
[820] Fix | Delete
*
[821] Fix | Delete
* @since 1.0.0
[822] Fix | Delete
* @since 4.2.0 The `$autoload` parameter was added.
[823] Fix | Delete
* @since 6.7.0 The autoload values 'yes' and 'no' are deprecated.
[824] Fix | Delete
*
[825] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[826] Fix | Delete
*
[827] Fix | Delete
* @param string $option Name of the option to update. Expected to not be SQL-escaped.
[828] Fix | Delete
* @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
[829] Fix | Delete
* @param bool|null $autoload Optional. Whether to load the option when WordPress starts up.
[830] Fix | Delete
* Accepts a boolean, or `null` to stick with the initial value or, if no initial value is
[831] Fix | Delete
* set, to leave the decision up to default heuristics in WordPress.
[832] Fix | Delete
* For existing options, `$autoload` can only be updated using `update_option()` if `$value`
[833] Fix | Delete
* is also changed.
[834] Fix | Delete
* For backward compatibility 'yes' and 'no' are also accepted, though using these values is
[835] Fix | Delete
* deprecated.
[836] Fix | Delete
* Autoloading too many options can lead to performance problems, especially if the
[837] Fix | Delete
* options are not frequently used. For options which are accessed across several places
[838] Fix | Delete
* in the frontend, it is recommended to autoload them, by using true.
[839] Fix | Delete
* For options which are accessed only on few specific URLs, it is recommended
[840] Fix | Delete
* to not autoload them, by using false.
[841] Fix | Delete
* For non-existent options, the default is null, which means WordPress will determine
[842] Fix | Delete
* the autoload value.
[843] Fix | Delete
* @return bool True if the value was updated, false otherwise.
[844] Fix | Delete
*/
[845] Fix | Delete
function update_option( $option, $value, $autoload = null ) {
[846] Fix | Delete
global $wpdb;
[847] Fix | Delete
[848] Fix | Delete
if ( is_scalar( $option ) ) {
[849] Fix | Delete
$option = trim( $option );
[850] Fix | Delete
}
[851] Fix | Delete
[852] Fix | Delete
if ( empty( $option ) ) {
[853] Fix | Delete
return false;
[854] Fix | Delete
}
[855] Fix | Delete
[856] Fix | Delete
/*
[857] Fix | Delete
* Until a proper _deprecated_option() function can be introduced,
[858] Fix | Delete
* redirect requests to deprecated keys to the new, correct ones.
[859] Fix | Delete
*/
[860] Fix | Delete
$deprecated_keys = array(
[861] Fix | Delete
'blacklist_keys' => 'disallowed_keys',
[862] Fix | Delete
'comment_whitelist' => 'comment_previously_approved',
[863] Fix | Delete
);
[864] Fix | Delete
[865] Fix | Delete
if ( isset( $deprecated_keys[ $option ] ) && ! wp_installing() ) {
[866] Fix | Delete
_deprecated_argument(
[867] Fix | Delete
__FUNCTION__,
[868] Fix | Delete
'5.5.0',
[869] Fix | Delete
sprintf(
[870] Fix | Delete
/* translators: 1: Deprecated option key, 2: New option key. */
[871] Fix | Delete
__( 'The "%1$s" option key has been renamed to "%2$s".' ),
[872] Fix | Delete
$option,
[873] Fix | Delete
$deprecated_keys[ $option ]
[874] Fix | Delete
)
[875] Fix | Delete
);
[876] Fix | Delete
return update_option( $deprecated_keys[ $option ], $value, $autoload );
[877] Fix | Delete
}
[878] Fix | Delete
[879] Fix | Delete
wp_protect_special_option( $option );
[880] Fix | Delete
[881] Fix | Delete
if ( is_object( $value ) ) {
[882] Fix | Delete
$value = clone $value;
[883] Fix | Delete
}
[884] Fix | Delete
[885] Fix | Delete
$value = sanitize_option( $option, $value );
[886] Fix | Delete
$old_value = get_option( $option );
[887] Fix | Delete
[888] Fix | Delete
/**
[889] Fix | Delete
* Filters a specific option before its value is (maybe) serialized and updated.
[890] Fix | Delete
*
[891] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[892] Fix | Delete
*
[893] Fix | Delete
* @since 2.6.0
[894] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[895] Fix | Delete
*
[896] Fix | Delete
* @param mixed $value The new, unserialized option value.
[897] Fix | Delete
* @param mixed $old_value The old option value.
[898] Fix | Delete
* @param string $option Option name.
[899] Fix | Delete
*/
[900] Fix | Delete
$value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
[901] Fix | Delete
[902] Fix | Delete
/**
[903] Fix | Delete
* Filters an option before its value is (maybe) serialized and updated.
[904] Fix | Delete
*
[905] Fix | Delete
* @since 3.9.0
[906] Fix | Delete
*
[907] Fix | Delete
* @param mixed $value The new, unserialized option value.
[908] Fix | Delete
* @param string $option Name of the option.
[909] Fix | Delete
* @param mixed $old_value The old option value.
[910] Fix | Delete
*/
[911] Fix | Delete
$value = apply_filters( 'pre_update_option', $value, $option, $old_value );
[912] Fix | Delete
[913] Fix | Delete
/*
[914] Fix | Delete
* If the new and old values are the same, no need to update.
[915] Fix | Delete
*
[916] Fix | Delete
* Unserialized values will be adequate in most cases. If the unserialized
[917] Fix | Delete
* data differs, the (maybe) serialized data is checked to avoid
[918] Fix | Delete
* unnecessary database calls for otherwise identical object instances.
[919] Fix | Delete
*
[920] Fix | Delete
* See https://core.trac.wordpress.org/ticket/38903
[921] Fix | Delete
*/
[922] Fix | Delete
if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) {
[923] Fix | Delete
return false;
[924] Fix | Delete
}
[925] Fix | Delete
[926] Fix | Delete
/** This filter is documented in wp-includes/option.php */
[927] Fix | Delete
if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
[928] Fix | Delete
return add_option( $option, $value, '', $autoload );
[929] Fix | Delete
}
[930] Fix | Delete
[931] Fix | Delete
$serialized_value = maybe_serialize( $value );
[932] Fix | Delete
[933] Fix | Delete
/**
[934] Fix | Delete
* Fires immediately before an option value is updated.
[935] Fix | Delete
*
[936] Fix | Delete
* @since 2.9.0
[937] Fix | Delete
*
[938] Fix | Delete
* @param string $option Name of the option to update.
[939] Fix | Delete
* @param mixed $old_value The old option value.
[940] Fix | Delete
* @param mixed $value The new option value.
[941] Fix | Delete
*/
[942] Fix | Delete
do_action( 'update_option', $option, $old_value, $value );
[943] Fix | Delete
[944] Fix | Delete
$update_args = array(
[945] Fix | Delete
'option_value' => $serialized_value,
[946] Fix | Delete
);
[947] Fix | Delete
[948] Fix | Delete
if ( null !== $autoload ) {
[949] Fix | Delete
$update_args['autoload'] = wp_determine_option_autoload_value( $option, $value, $serialized_value, $autoload );
[950] Fix | Delete
} else {
[951] Fix | Delete
// Retrieve the current autoload value to reevaluate it in case it was set automatically.
[952] Fix | Delete
$raw_autoload = $wpdb->get_var( $wpdb->prepare( "SELECT autoload FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
[953] Fix | Delete
$allow_values = array( 'auto-on', 'auto-off', 'auto' );
[954] Fix | Delete
if ( in_array( $raw_autoload, $allow_values, true ) ) {
[955] Fix | Delete
$autoload = wp_determine_option_autoload_value( $option, $value, $serialized_value, $autoload );
[956] Fix | Delete
if ( $autoload !== $raw_autoload ) {
[957] Fix | Delete
$update_args['autoload'] = $autoload;
[958] Fix | Delete
}
[959] Fix | Delete
}
[960] Fix | Delete
}
[961] Fix | Delete
[962] Fix | Delete
$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
[963] Fix | Delete
if ( ! $result ) {
[964] Fix | Delete
return false;
[965] Fix | Delete
}
[966] Fix | Delete
[967] Fix | Delete
$notoptions = wp_cache_get( 'notoptions', 'options' );
[968] Fix | Delete
[969] Fix | Delete
if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
[970] Fix | Delete
unset( $notoptions[ $option ] );
[971] Fix | Delete
wp_cache_set( 'notoptions', $notoptions, 'options' );
[972] Fix | Delete
}
[973] Fix | Delete
[974] Fix | Delete
if ( ! wp_installing() ) {
[975] Fix | Delete
if ( ! isset( $update_args['autoload'] ) ) {
[976] Fix | Delete
// Update the cached value based on where it is currently cached.
[977] Fix | Delete
$alloptions = wp_load_alloptions( true );
[978] Fix | Delete
[979] Fix | Delete
if ( isset( $alloptions[ $option ] ) ) {
[980] Fix | Delete
$alloptions[ $option ] = $serialized_value;
[981] Fix | Delete
wp_cache_set( 'alloptions', $alloptions, 'options' );
[982] Fix | Delete
} else {
[983] Fix | Delete
wp_cache_set( $option, $serialized_value, 'options' );
[984] Fix | Delete
}
[985] Fix | Delete
} elseif ( in_array( $update_args['autoload'], wp_autoload_values_to_autoload(), true ) ) {
[986] Fix | Delete
// Delete the individual cache, then set in alloptions cache.
[987] Fix | Delete
wp_cache_delete( $option, 'options' );
[988] Fix | Delete
[989] Fix | Delete
$alloptions = wp_load_alloptions( true );
[990] Fix | Delete
[991] Fix | Delete
$alloptions[ $option ] = $serialized_value;
[992] Fix | Delete
wp_cache_set( 'alloptions', $alloptions, 'options' );
[993] Fix | Delete
} else {
[994] Fix | Delete
// Delete the alloptions cache, then set the individual cache.
[995] Fix | Delete
$alloptions = wp_load_alloptions( true );
[996] Fix | Delete
[997] Fix | Delete
if ( isset( $alloptions[ $option ] ) ) {
[998] Fix | Delete
unset( $alloptions[ $option ] );
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function