Edit File by line
/home/barbar84/public_h.../wp-inclu...
File: option.php
<?php
[0] Fix | Delete
/**
[1] Fix | Delete
* Option API
[2] Fix | Delete
*
[3] Fix | Delete
* @package WordPress
[4] Fix | Delete
* @subpackage Option
[5] Fix | Delete
*/
[6] Fix | Delete
[7] Fix | Delete
/**
[8] Fix | Delete
* Retrieves an option value based on an option name.
[9] Fix | Delete
*
[10] Fix | Delete
* If the option does not exist or does not have a value, then the return value
[11] Fix | Delete
* will be false. This is useful to check whether you need to install an option
[12] Fix | Delete
* and is commonly used during installation of plugin options and to test
[13] Fix | Delete
* whether upgrading is required.
[14] Fix | Delete
*
[15] Fix | Delete
* If the option was serialized then it will be unserialized when it is returned.
[16] Fix | Delete
*
[17] Fix | Delete
* Any scalar values will be returned as strings. You may coerce the return type of
[18] Fix | Delete
* a given option by registering an {@see 'option_$option'} filter callback.
[19] Fix | Delete
*
[20] Fix | Delete
* @since 1.5.0
[21] Fix | Delete
*
[22] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[23] Fix | Delete
*
[24] Fix | Delete
* @param string $option Name of the option to retrieve. Expected to not be SQL-escaped.
[25] Fix | Delete
* @param mixed $default Optional. Default value to return if the option does not exist.
[26] Fix | Delete
* @return mixed Value set for the option. A value of any type may be returned, including
[27] Fix | Delete
* array, boolean, float, integer, null, object, and string.
[28] Fix | Delete
*/
[29] Fix | Delete
function get_option( $option, $default = false ) {
[30] Fix | Delete
global $wpdb;
[31] Fix | Delete
[32] Fix | Delete
$option = trim( $option );
[33] Fix | Delete
if ( empty( $option ) ) {
[34] Fix | Delete
return false;
[35] Fix | Delete
}
[36] Fix | Delete
[37] Fix | Delete
/*
[38] Fix | Delete
* Until a proper _deprecated_option() function can be introduced,
[39] Fix | Delete
* redirect requests to deprecated keys to the new, correct ones.
[40] Fix | Delete
*/
[41] Fix | Delete
$deprecated_keys = array(
[42] Fix | Delete
'blacklist_keys' => 'disallowed_keys',
[43] Fix | Delete
'comment_whitelist' => 'comment_previously_approved',
[44] Fix | Delete
);
[45] Fix | Delete
[46] Fix | Delete
if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
[47] Fix | Delete
_deprecated_argument(
[48] Fix | Delete
__FUNCTION__,
[49] Fix | Delete
'5.5.0',
[50] Fix | Delete
sprintf(
[51] Fix | Delete
/* translators: 1: Deprecated option key, 2: New option key. */
[52] Fix | Delete
__( 'The "%1$s" option key has been renamed to "%2$s".' ),
[53] Fix | Delete
$option,
[54] Fix | Delete
$deprecated_keys[ $option ]
[55] Fix | Delete
)
[56] Fix | Delete
);
[57] Fix | Delete
return get_option( $deprecated_keys[ $option ], $default );
[58] Fix | Delete
}
[59] Fix | Delete
[60] Fix | Delete
/**
[61] Fix | Delete
* Filters the value of an existing option before it is retrieved.
[62] Fix | Delete
*
[63] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[64] Fix | Delete
*
[65] Fix | Delete
* Returning a truthy value from the filter will effectively short-circuit retrieval
[66] Fix | Delete
* and return the passed value instead.
[67] Fix | Delete
*
[68] Fix | Delete
* @since 1.5.0
[69] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[70] Fix | Delete
* @since 4.9.0 The `$default` parameter was added.
[71] Fix | Delete
*
[72] Fix | Delete
* @param mixed $pre_option The value to return instead of the option value. This differs
[73] Fix | Delete
* from `$default`, which is used as the fallback value in the event
[74] Fix | Delete
* the option doesn't exist elsewhere in get_option().
[75] Fix | Delete
* Default false (to skip past the short-circuit).
[76] Fix | Delete
* @param string $option Option name.
[77] Fix | Delete
* @param mixed $default The fallback value to return if the option does not exist.
[78] Fix | Delete
* Default false.
[79] Fix | Delete
*/
[80] Fix | Delete
$pre = apply_filters( "pre_option_{$option}", false, $option, $default );
[81] Fix | Delete
[82] Fix | Delete
if ( false !== $pre ) {
[83] Fix | Delete
return $pre;
[84] Fix | Delete
}
[85] Fix | Delete
[86] Fix | Delete
if ( defined( 'WP_SETUP_CONFIG' ) ) {
[87] Fix | Delete
return false;
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
// Distinguish between `false` as a default, and not passing one.
[91] Fix | Delete
$passed_default = func_num_args() > 1;
[92] Fix | Delete
[93] Fix | Delete
if ( ! wp_installing() ) {
[94] Fix | Delete
// Prevent non-existent options from triggering multiple queries.
[95] Fix | Delete
$notoptions = wp_cache_get( 'notoptions', 'options' );
[96] Fix | Delete
[97] Fix | Delete
if ( isset( $notoptions[ $option ] ) ) {
[98] Fix | Delete
/**
[99] Fix | Delete
* Filters the default value for an option.
[100] Fix | Delete
*
[101] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[102] Fix | Delete
*
[103] Fix | Delete
* @since 3.4.0
[104] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[105] Fix | Delete
* @since 4.7.0 The `$passed_default` parameter was added to distinguish between a `false` value and the default parameter value.
[106] Fix | Delete
*
[107] Fix | Delete
* @param mixed $default The default value to return if the option does not exist
[108] Fix | Delete
* in the database.
[109] Fix | Delete
* @param string $option Option name.
[110] Fix | Delete
* @param bool $passed_default Was `get_option()` passed a default value?
[111] Fix | Delete
*/
[112] Fix | Delete
return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
[113] Fix | Delete
}
[114] Fix | Delete
[115] Fix | Delete
$alloptions = wp_load_alloptions();
[116] Fix | Delete
[117] Fix | Delete
if ( isset( $alloptions[ $option ] ) ) {
[118] Fix | Delete
$value = $alloptions[ $option ];
[119] Fix | Delete
} else {
[120] Fix | Delete
$value = wp_cache_get( $option, 'options' );
[121] Fix | Delete
[122] Fix | Delete
if ( false === $value ) {
[123] Fix | Delete
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
[124] Fix | Delete
[125] Fix | Delete
// Has to be get_row() instead of get_var() because of funkiness with 0, false, null values.
[126] Fix | Delete
if ( is_object( $row ) ) {
[127] Fix | Delete
$value = $row->option_value;
[128] Fix | Delete
wp_cache_add( $option, $value, 'options' );
[129] Fix | Delete
} else { // Option does not exist, so we must cache its non-existence.
[130] Fix | Delete
if ( ! is_array( $notoptions ) ) {
[131] Fix | Delete
$notoptions = array();
[132] Fix | Delete
}
[133] Fix | Delete
[134] Fix | Delete
$notoptions[ $option ] = true;
[135] Fix | Delete
wp_cache_set( 'notoptions', $notoptions, 'options' );
[136] Fix | Delete
[137] Fix | Delete
/** This filter is documented in wp-includes/option.php */
[138] Fix | Delete
return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
[139] Fix | Delete
}
[140] Fix | Delete
}
[141] Fix | Delete
}
[142] Fix | Delete
} else {
[143] Fix | Delete
$suppress = $wpdb->suppress_errors();
[144] Fix | Delete
$row = $wpdb->get_row( $wpdb->prepare( "SELECT option_value FROM $wpdb->options WHERE option_name = %s LIMIT 1", $option ) );
[145] Fix | Delete
$wpdb->suppress_errors( $suppress );
[146] Fix | Delete
[147] Fix | Delete
if ( is_object( $row ) ) {
[148] Fix | Delete
$value = $row->option_value;
[149] Fix | Delete
} else {
[150] Fix | Delete
/** This filter is documented in wp-includes/option.php */
[151] Fix | Delete
return apply_filters( "default_option_{$option}", $default, $option, $passed_default );
[152] Fix | Delete
}
[153] Fix | Delete
}
[154] Fix | Delete
[155] Fix | Delete
// If home is not set, use siteurl.
[156] Fix | Delete
if ( 'home' === $option && '' === $value ) {
[157] Fix | Delete
return get_option( 'siteurl' );
[158] Fix | Delete
}
[159] Fix | Delete
[160] Fix | Delete
if ( in_array( $option, array( 'siteurl', 'home', 'category_base', 'tag_base' ), true ) ) {
[161] Fix | Delete
$value = untrailingslashit( $value );
[162] Fix | Delete
}
[163] Fix | Delete
[164] Fix | Delete
/**
[165] Fix | Delete
* Filters the value of an existing option.
[166] Fix | Delete
*
[167] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[168] Fix | Delete
*
[169] Fix | Delete
* @since 1.5.0 As 'option_' . $setting
[170] Fix | Delete
* @since 3.0.0
[171] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[172] Fix | Delete
*
[173] Fix | Delete
* @param mixed $value Value of the option. If stored serialized, it will be
[174] Fix | Delete
* unserialized prior to being returned.
[175] Fix | Delete
* @param string $option Option name.
[176] Fix | Delete
*/
[177] Fix | Delete
return apply_filters( "option_{$option}", maybe_unserialize( $value ), $option );
[178] Fix | Delete
}
[179] Fix | Delete
[180] Fix | Delete
/**
[181] Fix | Delete
* Protects WordPress special option from being modified.
[182] Fix | Delete
*
[183] Fix | Delete
* Will die if $option is in protected list. Protected options are 'alloptions'
[184] Fix | Delete
* and 'notoptions' options.
[185] Fix | Delete
*
[186] Fix | Delete
* @since 2.2.0
[187] Fix | Delete
*
[188] Fix | Delete
* @param string $option Option name.
[189] Fix | Delete
*/
[190] Fix | Delete
function wp_protect_special_option( $option ) {
[191] Fix | Delete
if ( 'alloptions' === $option || 'notoptions' === $option ) {
[192] Fix | Delete
wp_die(
[193] Fix | Delete
sprintf(
[194] Fix | Delete
/* translators: %s: Option name. */
[195] Fix | Delete
__( '%s is a protected WP option and may not be modified' ),
[196] Fix | Delete
esc_html( $option )
[197] Fix | Delete
)
[198] Fix | Delete
);
[199] Fix | Delete
}
[200] Fix | Delete
}
[201] Fix | Delete
[202] Fix | Delete
/**
[203] Fix | Delete
* Prints option value after sanitizing for forms.
[204] Fix | Delete
*
[205] Fix | Delete
* @since 1.5.0
[206] Fix | Delete
*
[207] Fix | Delete
* @param string $option Option name.
[208] Fix | Delete
*/
[209] Fix | Delete
function form_option( $option ) {
[210] Fix | Delete
echo esc_attr( get_option( $option ) );
[211] Fix | Delete
}
[212] Fix | Delete
[213] Fix | Delete
/**
[214] Fix | Delete
* Loads and caches all autoloaded options, if available or all options.
[215] Fix | Delete
*
[216] Fix | Delete
* @since 2.2.0
[217] Fix | Delete
* @since 5.3.1 The `$force_cache` parameter was added.
[218] Fix | Delete
*
[219] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[220] Fix | Delete
*
[221] Fix | Delete
* @param bool $force_cache Optional. Whether to force an update of the local cache
[222] Fix | Delete
* from the persistent cache. Default false.
[223] Fix | Delete
* @return array List of all options.
[224] Fix | Delete
*/
[225] Fix | Delete
function wp_load_alloptions( $force_cache = false ) {
[226] Fix | Delete
global $wpdb;
[227] Fix | Delete
[228] Fix | Delete
if ( ! wp_installing() || ! is_multisite() ) {
[229] Fix | Delete
$alloptions = wp_cache_get( 'alloptions', 'options', $force_cache );
[230] Fix | Delete
} else {
[231] Fix | Delete
$alloptions = false;
[232] Fix | Delete
}
[233] Fix | Delete
[234] Fix | Delete
if ( ! $alloptions ) {
[235] Fix | Delete
$suppress = $wpdb->suppress_errors();
[236] Fix | Delete
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options WHERE autoload = 'yes'" );
[237] Fix | Delete
if ( ! $alloptions_db ) {
[238] Fix | Delete
$alloptions_db = $wpdb->get_results( "SELECT option_name, option_value FROM $wpdb->options" );
[239] Fix | Delete
}
[240] Fix | Delete
$wpdb->suppress_errors( $suppress );
[241] Fix | Delete
[242] Fix | Delete
$alloptions = array();
[243] Fix | Delete
foreach ( (array) $alloptions_db as $o ) {
[244] Fix | Delete
$alloptions[ $o->option_name ] = $o->option_value;
[245] Fix | Delete
}
[246] Fix | Delete
[247] Fix | Delete
if ( ! wp_installing() || ! is_multisite() ) {
[248] Fix | Delete
/**
[249] Fix | Delete
* Filters all options before caching them.
[250] Fix | Delete
*
[251] Fix | Delete
* @since 4.9.0
[252] Fix | Delete
*
[253] Fix | Delete
* @param array $alloptions Array with all options.
[254] Fix | Delete
*/
[255] Fix | Delete
$alloptions = apply_filters( 'pre_cache_alloptions', $alloptions );
[256] Fix | Delete
[257] Fix | Delete
wp_cache_add( 'alloptions', $alloptions, 'options' );
[258] Fix | Delete
}
[259] Fix | Delete
}
[260] Fix | Delete
[261] Fix | Delete
/**
[262] Fix | Delete
* Filters all options after retrieving them.
[263] Fix | Delete
*
[264] Fix | Delete
* @since 4.9.0
[265] Fix | Delete
*
[266] Fix | Delete
* @param array $alloptions Array with all options.
[267] Fix | Delete
*/
[268] Fix | Delete
return apply_filters( 'alloptions', $alloptions );
[269] Fix | Delete
}
[270] Fix | Delete
[271] Fix | Delete
/**
[272] Fix | Delete
* Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.
[273] Fix | Delete
*
[274] Fix | Delete
* @since 3.0.0
[275] Fix | Delete
*
[276] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[277] Fix | Delete
*
[278] Fix | Delete
* @param int $network_id Optional site ID for which to query the options. Defaults to the current site.
[279] Fix | Delete
*/
[280] Fix | Delete
function wp_load_core_site_options( $network_id = null ) {
[281] Fix | Delete
global $wpdb;
[282] Fix | Delete
[283] Fix | Delete
if ( ! is_multisite() || wp_using_ext_object_cache() || wp_installing() ) {
[284] Fix | Delete
return;
[285] Fix | Delete
}
[286] Fix | Delete
[287] Fix | Delete
if ( empty( $network_id ) ) {
[288] Fix | Delete
$network_id = get_current_network_id();
[289] Fix | Delete
}
[290] Fix | Delete
[291] 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' );
[292] Fix | Delete
[293] Fix | Delete
$core_options_in = "'" . implode( "', '", $core_options ) . "'";
[294] Fix | Delete
$options = $wpdb->get_results( $wpdb->prepare( "SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $network_id ) );
[295] Fix | Delete
[296] Fix | Delete
foreach ( $options as $option ) {
[297] Fix | Delete
$key = $option->meta_key;
[298] Fix | Delete
$cache_key = "{$network_id}:$key";
[299] Fix | Delete
$option->meta_value = maybe_unserialize( $option->meta_value );
[300] Fix | Delete
[301] Fix | Delete
wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
[302] Fix | Delete
}
[303] Fix | Delete
}
[304] Fix | Delete
[305] Fix | Delete
/**
[306] Fix | Delete
* Updates the value of an option that was already added.
[307] Fix | Delete
*
[308] Fix | Delete
* You do not need to serialize values. If the value needs to be serialized,
[309] Fix | Delete
* then it will be serialized before it is inserted into the database.
[310] Fix | Delete
* Remember, resources cannot be serialized or added as an option.
[311] Fix | Delete
*
[312] Fix | Delete
* If the option does not exist, it will be created.
[313] Fix | Delete
[314] Fix | Delete
* This function is designed to work with or without a logged-in user. In terms of security,
[315] Fix | Delete
* plugin developers should check the current user's capabilities before updating any options.
[316] Fix | Delete
*
[317] Fix | Delete
* @since 1.0.0
[318] Fix | Delete
* @since 4.2.0 The `$autoload` parameter was added.
[319] Fix | Delete
*
[320] Fix | Delete
* @global wpdb $wpdb WordPress database abstraction object.
[321] Fix | Delete
*
[322] Fix | Delete
* @param string $option Name of the option to update. Expected to not be SQL-escaped.
[323] Fix | Delete
* @param mixed $value Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
[324] Fix | Delete
* @param string|bool $autoload Optional. Whether to load the option when WordPress starts up. For existing options,
[325] Fix | Delete
* `$autoload` can only be updated using `update_option()` if `$value` is also changed.
[326] Fix | Delete
* Accepts 'yes'|true to enable or 'no'|false to disable. For non-existent options,
[327] Fix | Delete
* the default value is 'yes'. Default null.
[328] Fix | Delete
* @return bool True if the value was updated, false otherwise.
[329] Fix | Delete
*/
[330] Fix | Delete
function update_option( $option, $value, $autoload = null ) {
[331] Fix | Delete
global $wpdb;
[332] Fix | Delete
[333] Fix | Delete
$option = trim( $option );
[334] Fix | Delete
if ( empty( $option ) ) {
[335] Fix | Delete
return false;
[336] Fix | Delete
}
[337] Fix | Delete
[338] Fix | Delete
/*
[339] Fix | Delete
* Until a proper _deprecated_option() function can be introduced,
[340] Fix | Delete
* redirect requests to deprecated keys to the new, correct ones.
[341] Fix | Delete
*/
[342] Fix | Delete
$deprecated_keys = array(
[343] Fix | Delete
'blacklist_keys' => 'disallowed_keys',
[344] Fix | Delete
'comment_whitelist' => 'comment_previously_approved',
[345] Fix | Delete
);
[346] Fix | Delete
[347] Fix | Delete
if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
[348] Fix | Delete
_deprecated_argument(
[349] Fix | Delete
__FUNCTION__,
[350] Fix | Delete
'5.5.0',
[351] Fix | Delete
sprintf(
[352] Fix | Delete
/* translators: 1: Deprecated option key, 2: New option key. */
[353] Fix | Delete
__( 'The "%1$s" option key has been renamed to "%2$s".' ),
[354] Fix | Delete
$option,
[355] Fix | Delete
$deprecated_keys[ $option ]
[356] Fix | Delete
)
[357] Fix | Delete
);
[358] Fix | Delete
return update_option( $deprecated_keys[ $option ], $value, $autoload );
[359] Fix | Delete
}
[360] Fix | Delete
[361] Fix | Delete
wp_protect_special_option( $option );
[362] Fix | Delete
[363] Fix | Delete
if ( is_object( $value ) ) {
[364] Fix | Delete
$value = clone $value;
[365] Fix | Delete
}
[366] Fix | Delete
[367] Fix | Delete
$value = sanitize_option( $option, $value );
[368] Fix | Delete
$old_value = get_option( $option );
[369] Fix | Delete
[370] Fix | Delete
/**
[371] Fix | Delete
* Filters a specific option before its value is (maybe) serialized and updated.
[372] Fix | Delete
*
[373] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[374] Fix | Delete
*
[375] Fix | Delete
* @since 2.6.0
[376] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[377] Fix | Delete
*
[378] Fix | Delete
* @param mixed $value The new, unserialized option value.
[379] Fix | Delete
* @param mixed $old_value The old option value.
[380] Fix | Delete
* @param string $option Option name.
[381] Fix | Delete
*/
[382] Fix | Delete
$value = apply_filters( "pre_update_option_{$option}", $value, $old_value, $option );
[383] Fix | Delete
[384] Fix | Delete
/**
[385] Fix | Delete
* Filters an option before its value is (maybe) serialized and updated.
[386] Fix | Delete
*
[387] Fix | Delete
* @since 3.9.0
[388] Fix | Delete
*
[389] Fix | Delete
* @param mixed $value The new, unserialized option value.
[390] Fix | Delete
* @param string $option Name of the option.
[391] Fix | Delete
* @param mixed $old_value The old option value.
[392] Fix | Delete
*/
[393] Fix | Delete
$value = apply_filters( 'pre_update_option', $value, $option, $old_value );
[394] Fix | Delete
[395] Fix | Delete
/*
[396] Fix | Delete
* If the new and old values are the same, no need to update.
[397] Fix | Delete
*
[398] Fix | Delete
* Unserialized values will be adequate in most cases. If the unserialized
[399] Fix | Delete
* data differs, the (maybe) serialized data is checked to avoid
[400] Fix | Delete
* unnecessary database calls for otherwise identical object instances.
[401] Fix | Delete
*
[402] Fix | Delete
* See https://core.trac.wordpress.org/ticket/38903
[403] Fix | Delete
*/
[404] Fix | Delete
if ( $value === $old_value || maybe_serialize( $value ) === maybe_serialize( $old_value ) ) {
[405] Fix | Delete
return false;
[406] Fix | Delete
}
[407] Fix | Delete
[408] Fix | Delete
/** This filter is documented in wp-includes/option.php */
[409] Fix | Delete
if ( apply_filters( "default_option_{$option}", false, $option, false ) === $old_value ) {
[410] Fix | Delete
// Default setting for new options is 'yes'.
[411] Fix | Delete
if ( null === $autoload ) {
[412] Fix | Delete
$autoload = 'yes';
[413] Fix | Delete
}
[414] Fix | Delete
[415] Fix | Delete
return add_option( $option, $value, '', $autoload );
[416] Fix | Delete
}
[417] Fix | Delete
[418] Fix | Delete
$serialized_value = maybe_serialize( $value );
[419] Fix | Delete
[420] Fix | Delete
/**
[421] Fix | Delete
* Fires immediately before an option value is updated.
[422] Fix | Delete
*
[423] Fix | Delete
* @since 2.9.0
[424] Fix | Delete
*
[425] Fix | Delete
* @param string $option Name of the option to update.
[426] Fix | Delete
* @param mixed $old_value The old option value.
[427] Fix | Delete
* @param mixed $value The new option value.
[428] Fix | Delete
*/
[429] Fix | Delete
do_action( 'update_option', $option, $old_value, $value );
[430] Fix | Delete
[431] Fix | Delete
$update_args = array(
[432] Fix | Delete
'option_value' => $serialized_value,
[433] Fix | Delete
);
[434] Fix | Delete
[435] Fix | Delete
if ( null !== $autoload ) {
[436] Fix | Delete
$update_args['autoload'] = ( 'no' === $autoload || false === $autoload ) ? 'no' : 'yes';
[437] Fix | Delete
}
[438] Fix | Delete
[439] Fix | Delete
$result = $wpdb->update( $wpdb->options, $update_args, array( 'option_name' => $option ) );
[440] Fix | Delete
if ( ! $result ) {
[441] Fix | Delete
return false;
[442] Fix | Delete
}
[443] Fix | Delete
[444] Fix | Delete
$notoptions = wp_cache_get( 'notoptions', 'options' );
[445] Fix | Delete
[446] Fix | Delete
if ( is_array( $notoptions ) && isset( $notoptions[ $option ] ) ) {
[447] Fix | Delete
unset( $notoptions[ $option ] );
[448] Fix | Delete
wp_cache_set( 'notoptions', $notoptions, 'options' );
[449] Fix | Delete
}
[450] Fix | Delete
[451] Fix | Delete
if ( ! wp_installing() ) {
[452] Fix | Delete
$alloptions = wp_load_alloptions( true );
[453] Fix | Delete
if ( isset( $alloptions[ $option ] ) ) {
[454] Fix | Delete
$alloptions[ $option ] = $serialized_value;
[455] Fix | Delete
wp_cache_set( 'alloptions', $alloptions, 'options' );
[456] Fix | Delete
} else {
[457] Fix | Delete
wp_cache_set( $option, $serialized_value, 'options' );
[458] Fix | Delete
}
[459] Fix | Delete
}
[460] Fix | Delete
[461] Fix | Delete
/**
[462] Fix | Delete
* Fires after the value of a specific option has been successfully updated.
[463] Fix | Delete
*
[464] Fix | Delete
* The dynamic portion of the hook name, `$option`, refers to the option name.
[465] Fix | Delete
*
[466] Fix | Delete
* @since 2.0.1
[467] Fix | Delete
* @since 4.4.0 The `$option` parameter was added.
[468] Fix | Delete
*
[469] Fix | Delete
* @param mixed $old_value The old option value.
[470] Fix | Delete
* @param mixed $value The new option value.
[471] Fix | Delete
* @param string $option Option name.
[472] Fix | Delete
*/
[473] Fix | Delete
do_action( "update_option_{$option}", $old_value, $value, $option );
[474] Fix | Delete
[475] Fix | Delete
/**
[476] Fix | Delete
* Fires after the value of an option has been successfully updated.
[477] Fix | Delete
*
[478] Fix | Delete
* @since 2.9.0
[479] Fix | Delete
*
[480] Fix | Delete
* @param string $option Name of the updated option.
[481] Fix | Delete
* @param mixed $old_value The old option value.
[482] Fix | Delete
* @param mixed $value The new option value.
[483] Fix | Delete
*/
[484] Fix | Delete
do_action( 'updated_option', $option, $old_value, $value );
[485] Fix | Delete
[486] Fix | Delete
return true;
[487] Fix | Delete
}
[488] Fix | Delete
[489] Fix | Delete
/**
[490] Fix | Delete
* Adds a new option.
[491] Fix | Delete
*
[492] Fix | Delete
* You do not need to serialize values. If the value needs to be serialized,
[493] Fix | Delete
* then it will be serialized before it is inserted into the database.
[494] Fix | Delete
* Remember, resources cannot be serialized or added as an option.
[495] Fix | Delete
*
[496] Fix | Delete
* You can create options without values and then update the values later.
[497] Fix | Delete
* Existing options will not be updated and checks are performed to ensure that you
[498] Fix | Delete
* aren't adding a protected WordPress option. Care should be taken to not name
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function