-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Add: WordPress Core get settings ability #10747
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
base: trunk
Are you sure you want to change the base?
Add: WordPress Core get settings ability #10747
Conversation
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
c7d29ed to
5881244
Compare
Co-authored-by: Mukesh Panchal <mukeshpanchal27@users.noreply.github.com>
Co-authored-by: Dovid Levine <justlevine@gmail.com>
Addresses review feedback to add support for filtering settings by specific setting slugs. The input schema now supports both `group` and `slugs` parameters with a oneOf relationship making them mutually exclusive. - Add $available_slugs static property - Add get_available_slugs() method to collect setting slugs - Update input_schema with slugs parameter and oneOf constraint - Update execute_get_settings() to filter by slugs when provided
Use explicit union type (string|bool|int|float|array) instead of mixed for better type safety and documentation.
f7bc83e to
00a6bbd
Compare
Trac Ticket MissingThis pull request is missing a link to a Trac ticket. For a contribution to be considered, there must be a corresponding ticket in Trac. To attach a pull request to a Trac ticket, please include the ticket's full URL in your pull request description. More information about contributing to WordPress on GitHub can be found in the Core Handbook. |
|
Hi @justlevine, @mukeshpanchal27, thank you both for the reviews, I tried to address or answerer them all. I think it is ready for another pass. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jorgefilipecosta Out of curiosity, why are we coupling this to the REST API? Why would this Ability limit itself to settings that are configured to work with REST? Or am I misunderstanding something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm inclined away from using a preexisting configuration in an unexpected way.
|
I guess I'm also not understanding the purpose of this Ability. Why would someone use this over the |
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)