--- a/wp/wp-includes/option.php Wed Sep 21 18:19:35 2022 +0200
+++ b/wp/wp-includes/option.php Tue Sep 27 16:37:53 2022 +0200
@@ -28,10 +28,11 @@
* as string equivalents.
*
* Exceptions:
+ *
* 1. When the option has not been saved in the database, the `$default` value
* is returned if provided. If not, boolean `false` is returned.
- * 2. When one of the Options API filters is used: {@see 'pre_option_{$option}'},
- * {@see 'default_option_{$option}'}, or {@see 'option_{$option}'}, the returned
+ * 2. When one of the Options API filters is used: {@see 'pre_option_$option'},
+ * {@see 'default_option_$option'}, or {@see 'option_$option'}, the returned
* value may not match the expected type.
* 3. When the option has just been saved in the database, and get_option()
* is used right after, non-string scalar and null values are not converted to
@@ -39,28 +40,28 @@
*
* Examples:
*
- * When adding options like this: `add_option( 'my_option_name', 'value' );`
- * and then retrieving them with `get_option( 'my_option_name' );`, the returned
+ * When adding options like this: `add_option( 'my_option_name', 'value' )`
+ * and then retrieving them with `get_option( 'my_option_name' )`, the returned
* values will be:
*
- * `false` returns `string(0) ""`
- * `true` returns `string(1) "1"`
- * `0` returns `string(1) "0"`
- * `1` returns `string(1) "1"`
- * `'0'` returns `string(1) "0"`
- * `'1'` returns `string(1) "1"`
- * `null` returns `string(0) ""`
+ * - `false` returns `string(0) ""`
+ * - `true` returns `string(1) "1"`
+ * - `0` returns `string(1) "0"`
+ * - `1` returns `string(1) "1"`
+ * - `'0'` returns `string(1) "0"`
+ * - `'1'` returns `string(1) "1"`
+ * - `null` returns `string(0) ""`
*
* When adding options with non-scalar values like
- * `add_option( 'my_array', array( false, 'str', null ) );`, the returned value
+ * `add_option( 'my_array', array( false, 'str', null ) )`, the returned value
* will be identical to the original as it is serialized before saving
* it in the database:
*
- * array(3) {
- * [0] => bool(false)
- * [1] => string(3) "str"
- * [2] => NULL
- * }
+ * array(3) {
+ * [0] => bool(false)
+ * [1] => string(3) "str"
+ * [2] => NULL
+ * }
*
* @since 1.5.0
*
@@ -77,7 +78,10 @@
function get_option( $option, $default = false ) {
global $wpdb;
- $option = trim( $option );
+ if ( is_scalar( $option ) ) {
+ $option = trim( $option );
+ }
+
if ( empty( $option ) ) {
return false;
}
@@ -341,13 +345,15 @@
$core_options_in = "'" . implode( "', '", $core_options ) . "'";
$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 ) );
+ $data = array();
foreach ( $options as $option ) {
$key = $option->meta_key;
$cache_key = "{$network_id}:$key";
$option->meta_value = maybe_unserialize( $option->meta_value );
- wp_cache_set( $cache_key, $option->meta_value, 'site-options' );
+ $data[ $cache_key ] = $option->meta_value;
}
+ wp_cache_set_multiple( $data, 'site-options' );
}
/**
@@ -378,7 +384,10 @@
function update_option( $option, $value, $autoload = null ) {
global $wpdb;
- $option = trim( $option );
+ if ( is_scalar( $option ) ) {
+ $option = trim( $option );
+ }
+
if ( empty( $option ) ) {
return false;
}
@@ -565,7 +574,10 @@
_deprecated_argument( __FUNCTION__, '2.3.0' );
}
- $option = trim( $option );
+ if ( is_scalar( $option ) ) {
+ $option = trim( $option );
+ }
+
if ( empty( $option ) ) {
return false;
}
@@ -687,7 +699,10 @@
function delete_option( $option ) {
global $wpdb;
- $option = trim( $option );
+ if ( is_scalar( $option ) ) {
+ $option = trim( $option );
+ }
+
if ( empty( $option ) ) {
return false;
}
@@ -772,7 +787,7 @@
*/
do_action( "delete_transient_{$transient}", $transient );
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$result = wp_cache_delete( $transient, 'transient' );
} else {
$option_timeout = '_transient_timeout_' . $transient;
@@ -834,7 +849,7 @@
return $pre;
}
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$value = wp_cache_get( $transient, 'transient' );
} else {
$transient_option = '_transient_' . $transient;
@@ -918,7 +933,7 @@
*/
$expiration = apply_filters( "expiration_of_transient_{$transient}", $expiration, $value, $transient );
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$result = wp_cache_set( $transient, $value, 'transient', $expiration );
} else {
$transient_timeout = '_transient_timeout_' . $transient;
@@ -1846,7 +1861,7 @@
*/
do_action( "delete_site_transient_{$transient}", $transient );
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$result = wp_cache_delete( $transient, 'site-transient' );
} else {
$option_timeout = '_site_transient_timeout_' . $transient;
@@ -1910,7 +1925,7 @@
return $pre;
}
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$value = wp_cache_get( $transient, 'site-transient' );
} else {
// Core transients that do not have a timeout. Listed here so querying timeouts can be avoided.
@@ -1991,7 +2006,7 @@
*/
$expiration = apply_filters( "expiration_of_site_transient_{$transient}", $expiration, $value, $transient );
- if ( wp_using_ext_object_cache() ) {
+ if ( wp_using_ext_object_cache() || wp_installing() ) {
$result = wp_cache_set( $transient, $value, 'site-transient', $expiration );
} else {
$transient_timeout = '_site_transient_timeout_' . $transient;
@@ -2048,6 +2063,7 @@
* does not encompass all settings available in WordPress.
*
* @since 4.7.0
+ * @since 6.0.1 The `show_on_front`, `page_on_front`, and `page_for_posts` options were added.
*/
function register_initial_settings() {
register_setting(
@@ -2206,6 +2222,36 @@
);
register_setting(
+ 'reading',
+ 'show_on_front',
+ array(
+ 'show_in_rest' => true,
+ 'type' => 'string',
+ 'description' => __( 'What to show on the front page' ),
+ )
+ );
+
+ register_setting(
+ 'reading',
+ 'page_on_front',
+ array(
+ 'show_in_rest' => true,
+ 'type' => 'integer',
+ 'description' => __( 'The ID of the page that should be displayed on the front page' ),
+ )
+ );
+
+ register_setting(
+ 'reading',
+ 'page_for_posts',
+ array(
+ 'show_in_rest' => true,
+ 'type' => 'integer',
+ 'description' => __( 'The ID of the page that should display the latest posts' ),
+ )
+ );
+
+ register_setting(
'discussion',
'default_ping_status',
array(
@@ -2238,6 +2284,8 @@
* Registers a setting and its data.
*
* @since 2.7.0
+ * @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.
@@ -2247,7 +2295,7 @@
*
* @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', 'misc', 'options', and 'privacy'.
+ * 'reading', 'writing', and 'options'.
* @param string $option_name The name of an option to sanitize and save.
* @param array $args {
* Data used to describe the setting when registered.
@@ -2369,9 +2417,9 @@
* @global array $new_allowed_options
* @global array $wp_registered_settings
*
- * @param string $option_group The settings group name used during registration.
- * @param string $option_name The name of the option to unregister.
- * @param callable|string $deprecated Deprecated.
+ * @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 Optional. Deprecated.
*/
function unregister_setting( $option_group, $option_name, $deprecated = '' ) {
global $new_allowed_options, $wp_registered_settings;