[in progress] Abilities API: Add a core/settings ability#12141
[in progress] Abilities API: Add a core/settings ability#12141jorgefilipecosta wants to merge 1 commit into
Conversation
Add a read-only core/settings ability that returns WordPress settings as a flat name => value map. Only settings flagged with the new show_in_abilities registration arg are exposed; callers can filter by settings group or by name (mutually exclusive). Requires the manage_options capability. The logic lives in a new internal WP_Settings_Abilities class, structured so a future core/manage-settings write ability can reuse its helpers.
|
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. |
|
@jorgefilipecosta can you link this to the trac ticket please? I don't have edit perms in this repo. |
Part of: WordPress/ai#40
Summary
Adds a read-only
core/settingsability to the Abilities API. It returns WordPress settings — those flagged with a newshow_in_abilitiesregistration arg — as a flatname => valuemap, with per-setting metadata (type, title, description, default) carried in the output schema. Callers can filter by settingsgroupor byslugs(mutually exclusive). Requiresmanage_options.This is a flat-output alternative to #10747. The logic lives in a new internal
WP_Settings_Abilitiesclass (src/wp-includes/abilities/class-wp-settings-abilities.php), structured so a futurecore/manage-settingswrite ability can reuse its helpers (get_exposed_settings(),value_schema(),cast_value()).Test plan
In wp-admin, open the browser console:
name => valuemap with typed values (e.g.posts_per_pageis an int,use_smiliesa bool)groupandslugsfilters narrow the result; supplying both at once is rejectedmanage_options) is deniedPHPUnit coverage added in
tests/phpunit/tests/abilities-api/wpRegisterCoreSettingsAbility.php.