You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
WordPress Core has the register_setting API that allows developers to register custom settings that can be used throughout the WordPress UI.
These are strongly(ish) typed – the schema can be viewed with curl localhost/wp-json | jq '.routes["/wp/v2/settings"].endpoints[1].args'.
We should support the arbitrary key/value pairs that can be fetched here – the defaults will always be available (you can rg register_setting to see all the places in the codebase where settings are registered – any that have show_in_rest => true` will be part of the API response.
This trivial plugin shows an example of a custom setting – dropping it in wp-content/mu-plugins/index.php will add a custom element to the response:
<?phpfunctionregister_settings_for_test_plugin() {
register_setting('my_stuff', 'do_the_thing', [
'type' => 'boolean',
'label' => "Should it do the thing?",
'description' => "",
'show_in_rest' => true,
'default' => false
]);
}
add_action( 'init', 'register_settings_for_test_plugin' );
The text was updated successfully, but these errors were encountered:
WordPress Core has the
register_setting
API that allows developers to register custom settings that can be used throughout the WordPress UI.These are strongly(ish) typed – the schema can be viewed with
curl localhost/wp-json | jq '.routes["/wp/v2/settings"].endpoints[1].args'
.We should support the arbitrary key/value pairs that can be fetched here – the defaults will always be available (you can
rg register_setting
to see all the places in the codebase where settings are registered – any that haveshow_in_rest
=> true` will be part of the API response.This trivial plugin shows an example of a custom setting – dropping it in
wp-content/mu-plugins/index.php
will add a custom element to the response:The text was updated successfully, but these errors were encountered: