wp_set_options_autoload()
Enables or disables autoloading for several options without changing their values.
A wrapper for wp_set_option_autoload_values().
No Hooks.
Returns
Array.
array-option => resultpairs.truemeans autoloading was updated;falsemeans the option was not found, already had the requested value, or the request failed.
Usage
wp_set_options_autoload( $options, $autoload );
- $options(string[]) (required)
- Option names without SQL escaping.
- $autoload(bool) (required)
trueenables autoloading andfalsedisables it. The'yes'and'no'values are deprecated.
Examples
#1 Disabling option autoloading
$result = wp_set_options_autoload( [ 'my_plugin_settings', 'my_plugin_statistics', ], false );
Notes
Changelog
| Since 6.4.0 | Introduced. |
| Since 6.7.0 | The autoload values 'yes' and 'no' are deprecated. |
wp_set_options_autoload() wp set options autoload code WP 7.0.4
function wp_set_options_autoload( array $options, $autoload ) {
return wp_set_option_autoload_values(
array_fill_keys( $options, $autoload )
);
}