Skip to content

Let custom field types declare text for the WPML configuration - #187

Merged
dnnsjsk merged 2 commits into
inline0:mainfrom
Contributolo:feat/wpml-field-type-translate
Oct 26, 2026
Merged

dnnsjsk merged 2 commits into
inline0:mainfrom
Contributolo:feat/wpml-field-type-translate

Conversation

@Contributolo

Copy link
Copy Markdown
Collaborator

Builds on #180 (the translate field 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 onto main once #180 is in.

wp bs wpml config skips 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' => true stores plain text, and the command declares its fields like text fields.

  • Field_Type_Registry validates the option like the other options: translate must be a boolean, and true requires attribute string (or ['string']). Any other combination makes the registration invalid, so bs_register_field_type() returns false and the filter ignores the entry, as it does for an invalid storage or attribute today.
  • Wpml_Config::kind() classifies fields of such types as text. A field's own "translate": false still leaves it out, and without the option nothing changes: the fields are skipped and reported.
  • Docs: the definition keys table and a short WPML section on the custom field types page, the declaration table and a section on the WPML page; LLM bundles regenerated.

Tests: WpmlConfigTest registers a text type, a string type without the option and an object type (declared, also inside a repeater; "translate": false wins; the others reported), and FieldTypeRegistryTest covers valid and invalid combinations. The positive cases fail without the change. Run in WordPress Playground (PHP 8.4) with the wpml, field, attribute-builder and validation unit directories: 327 tests pass. PHPCS and PHPStan are clean on the changed files, docs:check, schemas:check and the non-Docker parts of npm run check pass.

@dnnsjsk
dnnsjsk merged commit 9d25c8d into inline0:main Oct 26, 2026
@dnnsjsk

dnnsjsk commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Released in Blockstudio 7.7.9. Thanks for the contribution.

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.

2 participants