: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* of the transient, and return that value.
* @param string $transient Transient name.
$pre = apply_filters( "pre_site_transient_{$transient}", false, $transient );
if ( wp_using_ext_object_cache() || wp_installing() ) {
$value = wp_cache_get( $transient, 'site-transient' );
// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
$no_timeout = array( 'update_core', 'update_plugins', 'update_themes' );
$transient_option = '_site_transient_' . $transient;
if ( ! in_array( $transient, $no_timeout, true ) ) {
$transient_timeout = '_site_transient_timeout_' . $transient;
wp_prime_site_option_caches( array( $transient_option, $transient_timeout ) );
$timeout = get_site_option( $transient_timeout );
if ( false !== $timeout && $timeout < time() ) {
delete_site_option( $transient_option );
delete_site_option( $transient_timeout );
if ( ! isset( $value ) ) {
$value = get_site_option( $transient_option );
* Filters the value of an existing site transient.
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
* @since 4.4.0 The `$transient` parameter was added.
* @param mixed $value Value of site transient.
* @param string $transient Transient name.
return apply_filters( "site_transient_{$transient}", $value, $transient );
* Sets/updates the value of a site 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
* 167 characters or fewer in length.
* @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 True if the value was set, false otherwise.
function set_site_transient( $transient, $value, $expiration = 0 ) {
* 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.
* @since 4.4.0 The `$transient` parameter was added.
* @param mixed $value New value of site transient.
* @param string $transient Transient name.
$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );
$expiration = (int) $expiration;
* 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.
* @param int $expiration Time until expiration in seconds. Use 0 for no expiration.
* @param mixed $value New value of site transient.
* @param string $transient Transient name.
$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
if ( wp_using_ext_object_cache() || wp_installing() ) {
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
$transient_timeout = '_site_transient_timeout_' . $transient;
$option = '_site_transient_' . $transient;
wp_prime_site_option_caches( array( $option, $transient_timeout ) );
if ( false === get_site_option( $option ) ) {
add_site_option( $transient_timeout, time() + $expiration );
$result = add_site_option( $option, $value );
update_site_option( $transient_timeout, time() + $expiration );
$result = update_site_option( $option, $value );
* Fires after the value for a specific site transient has been set.
* The dynamic portion of the hook name, `$transient`, refers to the transient name.
* @since 4.4.0 The `$transient` parameter was added
* @param mixed $value Site transient value.
* @param int $expiration Time until expiration in seconds.
* @param string $transient Transient name.
do_action( "set_site_transient_{$transient}", $value, $expiration, $transient );
* Fires after the value for a site transient has been set.
* @param string $transient The name of the site transient.
* @param mixed $value Site transient value.
* @param int $expiration Time until expiration in seconds.
do_action( 'setted_site_transient', $transient, $value, $expiration );
* Registers 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.
* @since 6.0.1 The `show_on_front`, `page_on_front`, and `page_for_posts` options were added.
function register_initial_settings() {
'label' => __( 'Title' ),
'description' => __( 'Site title.' ),
'label' => __( 'Tagline' ),
'description' => __( 'Site tagline.' ),
if ( ! is_multisite() ) {
'description' => __( 'Site URL.' ),
if ( ! is_multisite() ) {
'description' => __( 'This address is used for admin purposes, like new user notification.' ),
'description' => __( 'A city in the same timezone as you.' ),
'description' => __( 'A date format for all date strings.' ),
'description' => __( 'A time format for all time strings.' ),
'description' => __( 'A day number of the week that the week should start on.' ),
'description' => __( 'WordPress locale code.' ),
'description' => __( 'Convert emoticons like :-) and :-P to graphics on display.' ),
'description' => __( 'Default post category.' ),
'description' => __( 'Default post format.' ),
'label' => __( 'Maximum posts per page' ),
'description' => __( 'Blog pages show at most.' ),
'label' => __( 'Show on front' ),
'description' => __( 'What to show on the front page' ),
'label' => __( 'Page on front' ),
'description' => __( 'The ID of the page that should be displayed on the front page' ),
'description' => __( 'The ID of the page that should display the latest posts' ),
'enum' => array( 'open', 'closed' ),
'description' => __( 'Allow link notifications from other blogs (pingbacks and trackbacks) on new articles.' ),
'default_comment_status',
'enum' => array( 'open', 'closed' ),
'label' => __( 'Allow comments on new posts' ),
'description' => __( 'Allow people to submit comments on new posts.' ),
* Registers a setting and its data.
* @since 3.0.0 The `misc` option group was deprecated.
* @since 3.5.0 The `privacy` option group was deprecated.
* @since 4.7.0 `$args` can be passed to set flags on the setting, similar to `register_meta()`.
* @since 5.5.0 `$new_whitelist_options` was renamed to `$new_allowed_options`.
* Please consider writing more inclusive code.
* @since 6.6.0 Added the `label` argument.
* @global array $new_allowed_options
* @global array $wp_registered_settings
* @param string $option_group A settings group name. Should correspond to an allowed option key name.
* Default allowed option key names include 'general', 'discussion', 'media',
* 'reading', 'writing', and 'options'.
* @param string $option_name The name of an option to sanitize and save.
* Data used to describe the setting when registered.
* @type string $type The type of data associated with this setting.
* Valid values are 'string', 'boolean', 'integer', 'number', 'array', and 'object'.
* @type string $label A label of the data attached to this setting.
* @type string $description A description of the data attached to this setting.
* @type callable $sanitize_callback A callback function that sanitizes the option's value.
* @type bool|array $show_in_rest Whether data associated with this setting should be included in the REST API.
* When registering complex settings, this argument may optionally be an
* array with a 'schema' key.
* @type mixed $default Default value when calling `get_option()`.
function register_setting( $option_group, $option_name, $args = array() ) {
global $new_allowed_options, $wp_registered_settings;
* In 5.5.0, the `$new_whitelist_options` global variable was renamed to `$new_allowed_options`.
* Please consider writing more inclusive code.
$GLOBALS['new_whitelist_options'] = &$new_allowed_options;
'group' => $option_group,
'sanitize_callback' => null,
// Back-compat: old sanitize callback is added.
if ( is_callable( $args ) ) {
'sanitize_callback' => $args,
* Filters the registration arguments when registering a setting.
* @param array $args Array of setting registration arguments.
* @param array $defaults Array of default arguments.
* @param string $option_group Setting group.
* @param string $option_name Setting name.
$args = apply_filters( 'register_setting_args', $args, $defaults, $option_group, $option_name );
$args = wp_parse_args( $args, $defaults );
// Require an item schema when registering settings with an array type.
if ( false !== $args['show_in_rest'] && 'array' === $args['type'] && ( ! is_array( $args['show_in_rest'] ) || ! isset( $args['show_in_rest']['schema']['items'] ) ) ) {
_doing_it_wrong( __FUNCTION__, __( 'When registering an "array" setting to show in the REST API, you must specify the schema for each array item in "show_in_rest.schema.items".' ), '5.4.0' );
if ( ! is_array( $wp_registered_settings ) ) {
$wp_registered_settings = array();
if ( 'misc' === $option_group ) {
/* translators: %s: misc */
__( 'The "%s" options group has been removed. Use another settings group.' ),
$option_group = 'general';
if ( 'privacy' === $option_group ) {
/* translators: %s: privacy */
__( 'The "%s" options group has been removed. Use another settings group.' ),
$option_group = 'reading';
$new_allowed_options[ $option_group ][] = $option_name;
if ( ! empty( $args['sanitize_callback'] ) ) {
add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] );
if ( array_key_exists( 'default', $args ) ) {
add_filter( "default_option_{$option_name}", 'filter_default_option', 10, 3 );
* Fires immediately before the setting is registered but after its filters are in place.
* @param string $option_group Setting group.
* @param string $option_name Setting name.
* @param array $args Array of setting registration arguments.
do_action( 'register_setting', $option_group, $option_name, $args );
$wp_registered_settings[ $option_name ] = $args;