Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add filter to site edit titles #45918

Conversation

KevinBatdorf
Copy link
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
Copy link

codesandbox bot commented Nov 19, 2022

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
Member

Hey, @KevinBatdorf

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

@KevinBatdorf
Copy link
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
Member

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

@KevinBatdorf
Copy link
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