Skip to content

Apply typographic transformations (texturize) to DataForm field labels and descriptions #77056

Open

Description

@j111q

Summary

WordPress core applies wptexturize() to post titles, content, excerpts, and comments via built-in filters — converting straight quotes, apostrophes, dashes, and ellipses to their typographically correct equivalents. However, this transformation is not applied to DataForm field labels and descriptions, which means user-facing field text renders with straight apostrophes and other untreated punctuation.

The problem

Field definitions like this:
'description' => __( "Select any items this coupon can't be used for.", 'test-project' ),

Render with a straight apostrophe (') instead of a typographic one ('). WordPress already considers this worth fixing for post content — the same standard should apply to form field text that users see.

Context

This came up while working on typography improvements in a project built on DataForms. The feedback from @tyxla was that this should be solved at the DataForm/core level rather than in individual products, so that all consumers benefit.

The current gap is that wptexturize() is PHP-only and DataForm is a React component, so there's no clear path to apply these transformations today.

Possible approaches

Server-side: Apply wptexturize() to field labels and descriptions in the REST API layer before data reaches DataForm — consistent with how core handles the_title and the_content

Client-side: Create a JavaScript texturize() utility within @wordpress/dataviews that DataForm applies when rendering field text

Hybrid: Texturize on the server for PHP-registered fields, provide a JS utility for client-only fields

I'd love to hear from the maintainers which approach fits best with the DataForm architecture. cc @oandregal

Related

WordPress wptexturize() documentation

Activity

  1. j111q commented on Apr 7, 2026

    @j111q
    ContributorAuthor

    @aduth here's the issue :)

  2. added
    [Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond
    on Apr 7, 2026
  3. tyxla commented on Apr 7, 2026

    @tyxla
    Member

    @aduth I hear you'd like to tinker with this, so I'll drop it off my list for now. Do let me know if I can help with reviews and stuff though!

    My 0.02 euro cents: I'd love to be able to achieve this without having to create a JS port of wptexturize().

  4. oandregal commented on Apr 7, 2026

    @oandregal
    Member

    Server-side: Apply wptexturize() to field labels and descriptions in the REST API layer before data reaches DataForm — consistent with how core handles the_title and the_content

    For awareness, I'm working moving the DataViews/DataForm config (field definition, view/form config, etc.) to the server.

  5. aduth commented on Apr 7, 2026

    @aduth
    Member

    @oandregal Do you see that being something where it'd be reasonable for the server part of DataViews configuration take care of the wptexturize ?

    To me, this doesn't really feel like a DataViews-specific problem, and more a general problem of "how do we consistently ensure user-facing strings use typographically-correct characters".

    My instincts lead toward:

    • "Build-time": This should be solved at the source, and the example field definition in the original post's problem statement should use the correct quote rather than the straight quote. To support projects wanting to enforce this consistently, we could explore linting tools to scan translated strings in files, and even update them automatically (this is an approach I've used in other projects for this problem).
    • Runtime: Otherwise, some general-purpose texturize utility and/or React component (e.g. <Texturized>), though this definitely gets into the realm of reimplementing / porting wptexturize. I'd be curious what the concerns you have are, @tyxla . This is something we've done already with e.g. wpautop (@wordpress/autop), although maybe that one does serve as a cautionary tale with its many issues over the years 😄 I'd like to think texturizing is a bit simpler.

    I think if DataViews already plans to support some level of server registration capability, it makes sense that it could handle texturizing as part of its abstraction layer. Because I don't think it's appropriate to just texturize all strings returned by a REST API endpoint, but may be appropriate for a higher level of abstraction aware of how these strings are used for field labels, descriptions, etc.

  6. tyxla commented on Apr 8, 2026

    @tyxla
    Member

    Runtime: Otherwise, some general-purpose texturize utility and/or React component (e.g. ), though this definitely gets into the realm of reimplementing / porting wptexturize. I'd be curious what the concerns you have are, @tyxla . This is something we've done already with e.g. wpautop (@wordpress/autop), although maybe that one does serve as a cautionary tale with its many issues over the years 😄 I'd like to think texturizing is a bit simpler.

    Well, texturizing is one of those things that sounds simpler than it actually is. It's not a huge deal, of course. My biggest issue with having a JS port is that we have to maintain all the changes in both places, and it's something that is very easy to go off track.

    I do agree with you that, ideally, this is something that should be handled consistently across the board.

  7. oandregal commented on Apr 9, 2026

    @oandregal
    Member

    Do you see that being something where it'd be reasonable for the server part of DataViews configuration take care of the wptexturize ?

    The plan is for fields to be defined in the server, so that's something it could take care of. Though, I reckon some fields (those wanting to define any special behaviour via JavaScript) may still be defined client-side. It's going to depend on specifics, but perhaps those cases do still need texturizing in the client (or at build time).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    [Feature] DataViewsWork surrounding upgrading and evolving views in the site editor and beyond[Type] EnhancementA suggestion for improvement.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions