*/
/**
- * Retrieve option value based on name of option.
+ * Retrieves an option value based on an option name.
*
* If the option does not exist or does not have a value, then the return value
* will be false. This is useful to check whether you need to install an option
*
* If the option was serialized then it will be unserialized when it is returned.
*
+ * Any scalar values will be returned as strings. You may coerce the return type of
+ * a given option by registering an {@see 'option_$option'} filter callback.
+ *
* @since 1.5.0
*
* @global wpdb $wpdb WordPress database abstraction object.
return false;
/**
- * Filter the value of an existing option before it is retrieved.
+ * Filters the value of an existing option before it is retrieved.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
$notoptions = wp_cache_get( 'notoptions', 'options' );
if ( isset( $notoptions[ $option ] ) ) {
/**
- * Filter the default value for an option.
+ * Filters the default value for an option.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
$value = untrailingslashit( $value );
/**
- * Filter the value of an existing option.
+ * Filters the value of an existing option.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
$old_value = get_option( $option );
/**
- * Filter a specific option before its value is (maybe) serialized and updated.
+ * 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.
*
$value = apply_filters( 'pre_update_option_' . $option, $value, $old_value, $option );
/**
- * Filter an option before its value is (maybe) serialized and updated.
+ * Filters an option before its value is (maybe) serialized and updated.
*
* @since 3.9.0
*
return false;
/** This filter is documented in wp-includes/option.php */
- if ( apply_filters( 'default_option_' . $option, false ) === $old_value ) {
+ if ( apply_filters( 'default_option_' . $option, false, $option ) === $old_value ) {
// Default setting for new options is 'yes'.
if ( null === $autoload ) {
$autoload = 'yes';
global $wpdb;
if ( !empty( $deprecated ) )
- _deprecated_argument( __FUNCTION__, '2.3' );
+ _deprecated_argument( __FUNCTION__, '2.3.0' );
$option = trim($option);
if ( empty($option) )
$notoptions = wp_cache_get( 'notoptions', 'options' );
if ( !is_array( $notoptions ) || !isset( $notoptions[$option] ) )
/** This filter is documented in wp-includes/option.php */
- if ( apply_filters( 'default_option_' . $option, false ) !== get_option( $option ) )
+ if ( apply_filters( 'default_option_' . $option, false, $option ) !== get_option( $option ) )
return false;
$serialized_value = maybe_serialize( $value );
function get_transient( $transient ) {
/**
- * Filter the value of an existing transient.
+ * Filters the value of an existing transient.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
}
/**
- * Filter an existing transient's value.
+ * Filters an existing transient's value.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
$expiration = (int) $expiration;
/**
- * Filter a specific transient before its value is set.
+ * Filters a specific transient before its value is set.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
$value = apply_filters( 'pre_set_transient_' . $transient, $value, $expiration, $transient );
/**
- * Filter the expiration for a transient before its value is set.
+ * Filters the expiration for a transient before its value is set.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
* Add or update user interface setting.
*
* Both $name and $value can contain only ASCII letters, numbers and underscores.
+ *
* This function has to be used before any output has started as it calls setcookie().
*
* @since 2.8.0
*
* @param string $name The name of the setting.
* @param string $value The value for the setting.
- * @return bool|void true if set successfully/false if not.
+ * @return bool|null True if set successfully, false if not. Null if the current user can't be established.
*/
function set_user_setting( $name, $value ) {
if ( headers_sent() ) {
* Delete user interface settings.
*
* Deleting settings would reset them to the defaults.
+ *
* This function has to be used before any output has started as it calls setcookie().
*
* @since 2.7.0
*
* @param string $names The name or array of names of the setting to be deleted.
- * @return bool|void true if deleted successfully/false if not.
+ * @return bool|null True if deleted successfully, false if not. Null if the current user can't be established.
*/
function delete_user_setting( $names ) {
if ( headers_sent() ) {
* Private. Set all user interface settings.
*
* @since 2.8.0
+ * @access private
*
* @global array $_updated_user_settings
*
- * @param array $user_settings
- * @return bool|void
+ * @param array $user_settings User settings.
+ * @return bool|null False if the current user can't be found, null if the current
+ * user is not a super admin or a member of the site, otherwise true.
*/
function wp_set_all_user_settings( $user_settings ) {
global $_updated_user_settings;
}
/**
- * Filter an existing network option before it is retrieved.
+ * Filters an existing network option before it is retrieved.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
if ( isset( $notoptions[ $option ] ) ) {
/**
- * Filter a specific default network option.
+ * Filters a specific default network option.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
}
/**
- * Filter the value of an existing network option.
+ * Filters the value of an existing network option.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
wp_protect_special_option( $option );
/**
- * Filter the value of a specific network option before it is added.
+ * Filters the value of a specific network option before it is added.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
$notoptions_key = "$network_id:notoptions";
if ( ! is_multisite() ) {
- $result = add_option( $option, $value );
+ $result = add_option( $option, $value, '', 'no' );
} else {
$cache_key = "$network_id:$option";
$old_value = get_network_option( $network_id, $option, false );
/**
- * Filter a specific network option before its value is updated.
+ * Filters a specific network option before its value is updated.
*
* The dynamic portion of the hook name, `$option`, refers to the option name.
*
}
if ( ! is_multisite() ) {
- $result = update_option( $option, $value );
+ $result = update_option( $option, $value, 'no' );
} else {
$value = sanitize_option( $option, $value );
function get_site_transient( $transient ) {
/**
- * Filter the value of an existing site transient.
+ * Filters the value of an existing site transient.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
}
/**
- * Filter the value of an existing site transient.
+ * Filters the value of an existing site transient.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
function set_site_transient( $transient, $value, $expiration = 0 ) {
/**
- * Filter the value of a specific site transient before it is set.
+ * Filters the value of a specific site transient before it is set.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*
$expiration = (int) $expiration;
/**
- * Filter the expiration for a site transient before its value is set.
+ * Filters the expiration for a site transient before its value is set.
*
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
*