-
Notifications
You must be signed in to change notification settings - Fork 82
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 a block binding and pattern for the copyright date #21
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
…twentytwentyfive into add/copyright-binding
Remove the site title from the pattern title, since the site title is not used. Updates the package information to include both package and subpackage. Adds a blank line after the file comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this @carolinan 🏅
It's super exciting to be showcasing how to use bindings in the default theme. I left a few comments we may want to look at.
- Move the action after the functions, to improve the consistency - Wrap both functions in separate "if function exist" conditions, in case an extender only wants to override one of them. - Remove the variable and the translation function for the date format - Add escaping.
…ion function It is not documented why the priority on the init hook is needed, and removing it does not break anything, so, it should be removed. The translation function for the copyright text was accidently added as only an escaping function. By changing esc_html() to esc_html()__ the text is both translated and escaped, which is the desired outcome.
I think the placeholder text that shows in the editor can be improved, but I am reluctant to include the year since the date will not update in the editor once the block is placed. The current text in the editor is Because the block is synced, it is purple in the editor, and there is a block binding specific panel in the block settings sidebar for the attribute: Other than that it is difficult to see that this block is a placeholder and not just any other editable block. Perhaps the editor text should be |
I think the |
This PR registers a block binding source with a custom function as a callback.
The callback returns a text with the copyright symbol and the year. The purpose is for the year to update automatically without the user needing to edit the pattern.
The binding is then used in a block pattern with a paragraph block.
Closes #7
Note that the development version of the Gutenberg plugin was active when these screenshots were taken:
Editor:
Front:
And here it is in the Portfolio pattern, above the footer.