Extract Settings schema, field HTML, and sanitization into collaborators. - #1994
Open
shadyvb wants to merge 2 commits into
Open
Extract Settings schema, field HTML, and sanitization into collaborators.#1994shadyvb wants to merge 2 commits into
shadyvb wants to merge 2 commits into
Conversation
…ors so field definitions and type rules can be unit-tested without booting WordPress.
shadyvb
marked this pull request as ready for review
September 6, 2026 20:27
Move the WP_Roles test stub into its own file to satisfy OneObjectStructurePerFile and apply PHPCBF alignment fixes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes XWPENG-51.
This PR continues the Settings decomposition started in the List Table split (XWPENG-50). The monolithic
Settingsclass mixed three concerns—field schema, admin HTML rendering, and posted-value sanitization—that were hard to unit test without booting WordPress. Those responsibilities are now extracted into dedicated collaborators whileSettingskeeps option persistence, registration, AJAX helpers, and TTL side effects.Approach
Settings_Registry— owns the settings schema: section/field definitions, defaults keyed by{section}_{name},has_field()/get_field()lookup, role choices, deletion-warning copy, and serialized-label translations. Applies the existingwp_stream_settings_option_fieldsfilter and sticky title sort.Settings_Renderer— renders field markup for all supported types (checkbox, multi-checkbox, number, rule list, link actions, etc.) and connector-driven term labels.Settings_Sanitizer— normalizes posted values by field type (number,checkbox, nested arrays, text). Exposes both theregister_setting()callback and a reusablesanitize_settings( $input, $fields )API.Settings— wires the three collaborators as public properties ($registry,$renderer,$sanitizer) and delegates rendering/sanitization while retaining hooks, option reads/writes, and purge/TTL behavior.Call sites that previously reached into
Settingsfor schema or sanitization now use the collaborators directly (Ability_Update_Settings,Network, admin purge/screen, connector settings). Existing integration tests were updated for the new entry points.Unit tests
Adds Brain Monkey unit coverage (no WordPress bootstrap):
Settings_Registry_Unit_Test— schema sections,{section}_{name}defaults/lookup, network filter injection, translation labels, deletion warnings, role resolution (with a dedicated WP_Roles stub file).Settings_Renderer_Unit_Test— representative field HTML output and connector label helpers.Settings_Sanitizer_Unit_Test— per-type sanitization and nested array handling.Checklist
contributing.md).Release Changelog
Release Checklist
masterbranch. (Stacked onticket/XWPENG-50-list-table-split.)readme.txt.stream.php.Stable taginreadme.txt.classes/class-plugin.php.