Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support registered settings #228

Open
jkmassel opened this issue Jul 31, 2024 · 0 comments
Open

Support registered settings #228

jkmassel opened this issue Jul 31, 2024 · 0 comments

Comments

@jkmassel
Copy link
Contributor

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:

<?php

function register_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' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant