[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> option.php (summary)

Option API

File Size: 2283 lines (69 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 35 functions

  get_option()
  wp_protect_special_option()
  form_option()
  wp_load_alloptions()
  wp_load_core_site_options()
  update_option()
  add_option()
  delete_option()
  delete_transient()
  get_transient()
  set_transient()
  delete_expired_transients()
  wp_user_settings()
  get_user_setting()
  set_user_setting()
  delete_user_setting()
  get_all_user_settings()
  wp_set_all_user_settings()
  delete_all_user_settings()
  get_site_option()
  add_site_option()
  delete_site_option()
  update_site_option()
  get_network_option()
  add_network_option()
  delete_network_option()
  update_network_option()
  delete_site_transient()
  get_site_transient()
  set_site_transient()
  register_initial_settings()
  register_setting()
  unregister_setting()
  get_registered_settings()
  filter_default_option()

Functions
Functions that are not part of a class:

get_option( $option, $default = false )   X-Ref
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
and is commonly used during installation of plugin options and to test
whether upgrading is required.

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.

param: string $option  Name of option to retrieve. Expected to not be SQL-escaped.
param: mixed  $default Optional. Default value to return if the option does not exist.
return: mixed Value set for the option.

wp_protect_special_option( $option )   X-Ref
Protect WordPress special option from being modified.

Will die if $option is in protected list. Protected options are 'alloptions'
and 'notoptions' options.

param: string $option Option name.

form_option( $option )   X-Ref
Print option value after sanitizing for forms.

param: string $option Option name.

wp_load_alloptions()   X-Ref
Loads and caches all autoloaded options, if available or all options.

return: array List of all options.

wp_load_core_site_options( $network_id = null )   X-Ref
Loads and caches certain often requested site options if is_multisite() and a persistent cache is not being used.

param: int $network_id Optional site ID for which to query the options. Defaults to the current site.

update_option( $option, $value, $autoload = null )   X-Ref
Update the value of an option that was already added.

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 can not be serialized or added as an option.

If the option does not exist, then the option will be added with the option value,
with an `$autoload` value of 'yes'.

param: string      $option   Option name. Expected to not be SQL-escaped.
param: mixed       $value    Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
param: string|bool $autoload Optional. Whether to load the option when WordPress starts up. For existing options,
return: bool False if value was not updated and true if value was updated.

add_option( $option, $value = '', $deprecated = '', $autoload = 'yes' )   X-Ref
Add a new option.

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 can not be serialized or added as an option.

You can create options without values and then update the values later.
Existing options will not be updated and checks are performed to ensure that you
aren't adding a protected WordPress option. Care should be taken to not name
options the same as the ones which are protected.

param: string         $option      Name of option to add. Expected to not be SQL-escaped.
param: mixed          $value       Optional. Option value. Must be serializable if non-scalar. Expected to not be SQL-escaped.
param: string         $deprecated  Optional. Description. Not used anymore.
param: string|bool    $autoload    Optional. Whether to load the option when WordPress starts up.
return: bool False if option was not added and true if option was added.

delete_option( $option )   X-Ref
Removes option by name. Prevents removal of protected WordPress options.

param: string $option Name of option to remove. Expected to not be SQL-escaped.
return: bool True, if option is successfully deleted. False on failure.

delete_transient( $transient )   X-Ref
Delete a transient.

param: string $transient Transient name. Expected to not be SQL-escaped.
return: bool true if successful, false otherwise

get_transient( $transient )   X-Ref
Get the value of a transient.

If the transient does not exist, does not have a value, or has expired,
then the return value will be false.

param: string $transient Transient name. Expected to not be SQL-escaped.
return: mixed Value of transient.

set_transient( $transient, $value, $expiration = 0 )   X-Ref
Set/update the value of a transient.

You do not need to serialize values. If the value needs to be serialized, then
it will be serialized before it is set.

param: string $transient  Transient name. Expected to not be SQL-escaped. Must be
param: mixed  $value      Transient value. Must be serializable if non-scalar.
param: int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
return: bool False if value was not set and true if value was set.

delete_expired_transients( $force_db = false )   X-Ref
Deletes all expired transients.

The multi-table delete syntax is used to delete the transient record
from table a, and the corresponding transient_timeout record from table b.

param: bool $force_db Optional. Force cleanup to run against the database even when an external object cache is used.

wp_user_settings()   X-Ref
Saves and restores user interface settings stored in a cookie.

Checks if the current user-settings cookie is updated and stores it. When no
cookie exists (different browser used), adds the last saved cookie restoring
the settings.


get_user_setting( $name, $default = false )   X-Ref
Retrieve user interface setting value based on setting name.

param: string $name    The name of the setting.
param: string $default Optional default value to return when $name is not set.
return: mixed the last saved user setting or the default value/false if it doesn't exist.

set_user_setting( $name, $value )   X-Ref
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().

param: string $name  The name of the setting.
param: string $value The value for the setting.
return: bool|null True if set successfully, false if not. Null if the current user can't be established.

delete_user_setting( $names )   X-Ref
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().

param: string $names The name or array of names of the setting to be deleted.
return: bool|null True if deleted successfully, false if not. Null if the current user can't be established.

get_all_user_settings()   X-Ref
Retrieve all user interface settings.

return: array the last saved user settings or empty array.

wp_set_all_user_settings( $user_settings )   X-Ref
Private. Set all user interface settings.

param: array $user_settings User settings.
return: bool|null False if the current user can't be found, null if the current

delete_all_user_settings()   X-Ref
Delete the user settings of the current user.


get_site_option( $option, $default = false, $deprecated = true )   X-Ref
Retrieve an option value for the current network based on name of option.

param: string $option     Name of option to retrieve. Expected to not be SQL-escaped.
param: mixed  $default    Optional value to return if option doesn't exist. Default false.
param: bool   $deprecated Whether to use cache. Multisite only. Always set to true.
return: mixed Value set for the option.

add_site_option( $option, $value )   X-Ref
Add a new option for the current network.

Existing options will not be updated. Note that prior to 3.3 this wasn't the case.

param: string $option Name of option to add. Expected to not be SQL-escaped.
param: mixed  $value  Option value, can be anything. Expected to not be SQL-escaped.
return: bool False if the option was not added. True if the option was added.

delete_site_option( $option )   X-Ref
Removes a option by name for the current network.

param: string $option Name of option to remove. Expected to not be SQL-escaped.
return: bool True, if succeed. False, if failure.

update_site_option( $option, $value )   X-Ref
Update the value of an option that was already added for the current network.

param: string $option Name of option. Expected to not be SQL-escaped.
param: mixed  $value  Option value. Expected to not be SQL-escaped.
return: bool False if value was not updated. True if value was updated.

get_network_option( $network_id, $option, $default = false )   X-Ref
Retrieve a network's option value based on the option name.

param: int      $network_id ID of the network. Can be null to default to the current network ID.
param: string   $option     Name of option to retrieve. Expected to not be SQL-escaped.
param: mixed    $default    Optional. Value to return if the option doesn't exist. Default false.
return: mixed Value set for the option.

add_network_option( $network_id, $option, $value )   X-Ref
Add a new network option.

Existing options will not be updated.

param: int    $network_id ID of the network. Can be null to default to the current network ID.
param: string $option     Name of option to add. Expected to not be SQL-escaped.
param: mixed  $value      Option value, can be anything. Expected to not be SQL-escaped.
return: bool False if option was not added and true if option was added.

delete_network_option( $network_id, $option )   X-Ref
Removes a network option by name.

param: int    $network_id ID of the network. Can be null to default to the current network ID.
param: string $option     Name of option to remove. Expected to not be SQL-escaped.
return: bool True, if succeed. False, if failure.

update_network_option( $network_id, $option, $value )   X-Ref
Update the value of a network option that was already added.

param: int      $network_id ID of the network. Can be null to default to the current network ID.
param: string   $option     Name of option. Expected to not be SQL-escaped.
param: mixed    $value      Option value. Expected to not be SQL-escaped.
return: bool False if value was not updated and true if value was updated.

delete_site_transient( $transient )   X-Ref
Delete a site transient.

param: string $transient Transient name. Expected to not be SQL-escaped.
return: bool True if successful, false otherwise

get_site_transient( $transient )   X-Ref
Get the value of a site transient.

If the transient does not exist, does not have a value, or has expired,
then the return value will be false.

param: string $transient Transient name. Expected to not be SQL-escaped.
return: mixed Value of transient.

set_site_transient( $transient, $value, $expiration = 0 )   X-Ref
Set/update the value of a site transient.

You do not need to serialize values, if the value needs to be serialize, then
it will be serialized before it is set.

param: string $transient  Transient name. Expected to not be SQL-escaped. Must be
param: mixed  $value      Transient value. Expected to not be SQL-escaped.
param: int    $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
return: bool False if value was not set and true if value was set.

register_initial_settings()   X-Ref
Register default settings available in WordPress.

The settings registered here are primarily useful for the REST API, so this
does not encompass all settings available in WordPress.


register_setting( $option_group, $option_name, $args = array()   X-Ref
Register a setting and its data.

param: string $option_group A settings group name. Should correspond to a whitelisted option key name.
param: string $option_name The name of an option to sanitize and save.
param: array  $args {

unregister_setting( $option_group, $option_name, $deprecated = '' )   X-Ref
Unregister a setting.

param: string   $option_group      The settings group name used during registration.
param: string   $option_name       The name of the option to unregister.
param: callable $deprecated        Deprecated.

get_registered_settings()   X-Ref
Retrieves an array of registered settings.

return: array List of registered settings, keyed by option name.

filter_default_option( $default, $option, $passed_default )   X-Ref
Filter the default value for the option.

For settings which register a default setting in `register_setting()`, this
function is added as a filter to `default_option_{$option}`.

param: mixed $default Existing default value to return.
param: string $option Option name.
param: bool $passed_default Was `get_option()` passed a default value?
return: mixed Filtered default value.



Generated: Sun Oct 21 08:20:01 2018 Cross-referenced by PHPXref 0.7