Repository navigation
Let custom field types declare text for the WPML configuration - #187
Merged
dnnsjsk merged 2 commits intoOct 26, 2026
Merged
Conversation
Contributor
|
Released in Blockstudio 7.7.9. Thanks for the contribution. |
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.
Builds on #180 (the
translatefield property). Until #180 is merged, this branch contains its commit as well; the change of this PR is the second commit, "Let custom field types declare text for the WPML configuration". I am happy to rebase ontomainonce #180 is in.wp bs wpml configskips fields of custom field types and prints a warning, because only the field type knows whether its value is text. This adds a registration option: a type registered with'translate' => truestores plain text, and the command declares its fields liketextfields.Field_Type_Registryvalidates the option like the other options:translatemust be a boolean, andtruerequiresattributestring(or['string']). Any other combination makes the registration invalid, sobs_register_field_type()returnsfalseand the filter ignores the entry, as it does for an invalidstorageorattributetoday.Wpml_Config::kind()classifies fields of such types as text. A field's own"translate": falsestill leaves it out, and without the option nothing changes: the fields are skipped and reported.Tests:
WpmlConfigTestregisters a text type, a string type without the option and an object type (declared, also inside a repeater;"translate": falsewins; the others reported), andFieldTypeRegistryTestcovers valid and invalid combinations. The positive cases fail without the change. Run in WordPress Playground (PHP 8.4) with thewpml,field,attribute-builderandvalidationunit directories: 327 tests pass. PHPCS and PHPStan are clean on the changed files,docs:check,schemas:checkand the non-Docker parts ofnpm run checkpass.