Skip to content

Add filter to site edit titles#45918

Closed
KevinBatdorf wants to merge 2 commits into
WordPress:trunkfrom
KevinBatdorf:allow-naming-of-custom-entity-props
Closed

Add filter to site edit titles#45918
KevinBatdorf wants to merge 2 commits into
WordPress:trunkfrom
KevinBatdorf:allow-naming-of-custom-entity-props

Conversation

@KevinBatdorf

Copy link
Copy Markdown
Contributor

What?

This allows developers to override title property in siteEditsAsEntities

closes #41637

Why?

More flexibility to the developer who wants to avoid showing "computer language" to the user (e.g. custom_site_option)

How?

title: applyFilters(
    'entitiesSavedStates.siteEditsAsEntities.title',
    TRANSLATED_SITE_PROPERTIES[ property ] || property,
    property
),

Testing Instructions

  • Visit the site editor
  • Change the title
  • Save the post.

On the confirmation page you will see mention that the Title was changed. Add the following code to the console:

wp.hooks.addFilter('entitiesSavedStates.siteEditsAsEntities.title', 'kb', () => 'hey')
  • Close and re-open the confirmation panel (i.e. trigger a re render)
  • See 'hey'

Screenshots or screencast

Screen.Recording.2022-11-18.at.11.23.34.PM.mov

@codesandbox

codesandbox Bot commented Nov 19, 2022

Copy link
Copy Markdown

CodeSandbox logoCodeSandbox logo  Open in CodeSandbox Web Editor | VS Code | VS Code Insiders

@skorasaurus skorasaurus added [Feature] Block API API that allows to express the block paradigm. [Feature] Extensibility The ability to extend blocks or the editing experience labels Dec 6, 2022
@gziolo gziolo added [Package] Editor /packages/editor and removed [Feature] Block API API that allows to express the block paradigm. labels Apr 18, 2023
@Mamaduka

Copy link
Copy Markdown
Member

Hey, @KevinBatdorf

I wasted working on an alternative solution - #59243. I would love to hear your thoughts about it.

@KevinBatdorf

Copy link
Copy Markdown
Contributor Author

Yeah we can close this.

I see how you can filter it via php in your PR. Nice job 🙌

@KevinBatdorf KevinBatdorf deleted the allow-naming-of-custom-entity-props branch February 27, 2024 07:06
@Mamaduka

Copy link
Copy Markdown
Member

You'll able to define settings title/label via the register_setting function. I've included example in my PR.

@KevinBatdorf

Copy link
Copy Markdown
Contributor Author

Ah right. I was looking at the default labels. I actually forgot what this PR was solving for but yeah that makes sense now :)

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

Labels

[Feature] Extensibility The ability to extend blocks or the editing experience [Package] Editor /packages/editor

Projects

Development

Successfully merging this pull request may close these issues.

Add method to name custom entity props

4 participants