Skip to content

Add a core/manage-settings ability#764

Open
jorgefilipecosta wants to merge 4 commits into
developfrom
add/core-manage-settings-ability
Open

Add a core/manage-settings ability#764
jorgefilipecosta wants to merge 4 commits into
developfrom
add/core-manage-settings-ability

Conversation

@jorgefilipecosta

@jorgefilipecosta jorgefilipecosta commented Jun 23, 2026

Copy link
Copy Markdown
Member

What

Adds a write-oriented core/manage-settings ability that updates WordPress settings, the write counterpart to the read-only core/settings ability added in #691.

Core's WP_Settings_Abilities already reserves a slot for this (register_manage_settings()) but does not yet implement it. The plugin implements it in the same Settings class, reusing the exposed-settings snapshot and the shared helpers (get_exposed_settings(), value_schema(), cast_value()).

  • Input: a map of setting name → new value (at least one). The input/output schemas reuse each setting's own value schema, with additionalProperties: false.
  • Output: a map of each updated setting name → its stored value.
  • Permission: manage_options (shared with core/settings).
  • Annotations: readonly: false, destructive: false, idempotent: true.

Atomic, all-or-nothing

The Abilities API validates the input against the registered input schema before execute_manage_settings() runs, so an invalid or unknown value aborts the whole call before any update_option() fires — matching WP_REST_Settings_Controller::update_item(), which rejects the entire request via has_valid_params() when any value is invalid. Accepted values are sanitized against their schema, stored, then read back and cast for the response.

Open WordPress Playground Preview

Implements the write-oriented core/manage-settings ability that core's
WP_Settings_Abilities reserves but does not yet ship. It reuses the
exposed-settings snapshot built for core/settings, so every setting flagged
with show_in_abilities is both readable (core/settings) and writable
(core/manage-settings), and the input/output schemas reuse the same
per-setting schemas.

The Abilities API validates the input against those schemas (with
additionalProperties disabled) before execution, so an invalid or unknown
value aborts the whole call before any option is written -- matching the
all-or-nothing behavior of the core REST settings controller. Each accepted
value is sanitized against its schema, stored, then read back and cast for
the response.
Extends the settings ability test suite with coverage for the write ability:
registration and writable annotations, an input schema that mirrors the
exposed settings with additionalProperties disabled, updating and returning
correctly typed values, all-or-nothing aborting on an invalid value (the
valid sibling must not persist), rejection of unknown keys and empty input,
the manage_options permission gate, and writing a setting registered by
another plugin.
Runs the write ability through the browser Abilities API, mirroring the
core/settings spec: updates blogname and posts_per_page and asserts the
echoed values, reads them back through core/settings to confirm they
persisted, rejects an unknown setting, and writes a setting registered by
another active plugin. Each test restores the original values when done.
@github-actions

Copy link
Copy Markdown

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.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>

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

@github-actions

Copy link
Copy Markdown

✅ WordPress Plugin Check Report

✅ Status: Passed

📊 Report

All checks passed! No errors or warnings found.


🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

@codecov

codecov Bot commented Jun 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.29630% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.55%. Comparing base (26ce3f0) to head (68d5383).

Files with missing lines Patch % Lines
includes/Abilities/Settings/Settings.php 96.29% 2 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##             develop     #764      +/-   ##
=============================================
+ Coverage      76.41%   76.55%   +0.13%     
- Complexity      1828     1839      +11     
=============================================
  Files             87       87              
  Lines           7764     7818      +54     
=============================================
+ Hits            5933     5985      +52     
- Misses          1831     1833       +2     
Flag Coverage Δ
unit 76.55% <96.29%> (+0.13%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jeffpaul jeffpaul added this to the 1.2.0 milestone Jun 23, 2026
@jeffpaul jeffpaul moved this from Triage to Needs review in WordPress AI Roadmap Jun 23, 2026
@jeffpaul jeffpaul requested review from dkotter and gziolo June 23, 2026 14:59
Drops three comments that restated information available elsewhere: the
class-docblock "Plugin:" note (duplicated by the method docblock), the
register_manage_settings() paragraph describing atomicity (already on
execute_manage_settings()), and an e2e comment restating its own assertion.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Needs review

Development

Successfully merging this pull request may close these issues.

2 participants