Automattic / Automattic/wordpress-rs

Support registered settings

Open
#228 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
36
Forks
5
Avg merge
17h 30m
Merged PRs (30d)
43

Description

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
'boolean',
'label' => "Should it do the thing?",
'description' => "",
'show_in_rest' => true,
'default' => false
]);
}

add_action( 'init', 'register_settings_for_test_plugin' );
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start by inspecting the Rust implementation of the `/wp/v2/settings` endpoint and use `rg register_setting` in WordPress Core to enumerate settings with `show_in_rest => true`. Compare `curl localhost/wp-json | jq '.routes["/wp/v2/settings"].endpoints[1].args'` with and without the sample mu-plugin. Done means registered arbitrary settings, including defaults and schema-compatible values, appear in the response.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
api, backend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.