Skip to content

Conversation

@jorgefilipecosta
Copy link
Member

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-settings ability to the WordPress Abilities API. This ability dynamically discovers and exposes all WordPress settings. For now all abilities that are register show_in_rest = true are 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_Abilities in src/wp-includes/abilities/class-wp-settings-abilities.php. The class is organized into:

  • Initialization: init() method that collects available groups and builds the output schema
  • Schema Building: build_output_schema() creates a rich JSON Schema from registered settings metadata
  • Ability Registration: register_get_settings() registers the ability with dynamic schemas
  • Execution: execute_get_settings() retrieves and returns settings grouped by their registration group
  • Utilities: Helper methods for permission checking and value type casting

Test plan

  • Open http://localhost:6888/site-wp-dev-1/wp-admin/post-new.php
  • Open the browser console and run the following examples:
// Get all settings
await wp.apiFetch({
  path: '/wp-abilities/v1/abilities/core/get-settings/run',
  method: 'POST',
  data: { input: {} }
});
  • Verify all settings are returned grouped by their registration group (general, reading, writing, discussion)
// Get only general settings
await wp.apiFetch({
  path: '/wp-abilities/v1/abilities/core/get-settings/run',
  method: 'POST',
  data: { input: { group: 'general' } }
});
  • Verify only general settings are returned when filtering by group
// Check the ability schema
await wp.apiFetch({
  path: '/wp-abilities/v1/abilities/core/get-settings',
  method: 'GET'
});
  • Verify the input schema includes a dynamic enum of available groups

  • Verify 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_options capability)

@github-actions
Copy link

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props jorgefilipecosta.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@jorgefilipecosta jorgefilipecosta changed the title Initial implementation Add: WordPress Core get settings ability Jan 16, 2026
@github-actions
Copy link

Test using WordPress Playground

The 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

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

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

Successfully merging this pull request may close these issues.

1 participant