Add: WordPress Core get settings ability #10747
Open
+303
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of: WordPress/ai#40
Inspired by the work on https://github.com/galatanovidiu/mcp-adapter-implementation-example/tree/experiment/layerd-mcp-tools/includes/Abilities by @galatanovidiu.
Summary
This PR adds a
core/get-settingsability to the WordPress Abilities API. This ability dynamically discovers and exposes all WordPress settings. For now all abilities that are registershow_in_rest = trueare exposed. We should probably have a setting related to the ability exposition but can be a follow.Organization
Following the pattern established in #10665, this PR adds a new class
WP_Settings_Abilitiesinsrc/wp-includes/abilities/class-wp-settings-abilities.php. The class is organized into:init()method that collects available groups and builds the output schemabuild_output_schema()creates a rich JSON Schema from registered settings metadataregister_get_settings()registers the ability with dynamic schemasexecute_get_settings()retrieves and returns settings grouped by their registration groupTest plan
http://localhost:6888/site-wp-dev-1/wp-admin/post-new.phpVerify the input schema includes a dynamic
enumof available groupsVerify the output schema documents each group and its settings with types, descriptions, and defaults
Test permission check: Verify non-admin users cannot access the ability (requires
manage_optionscapability)