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 a block binding and pattern for the copyright date #21

Merged
merged 13 commits into from
Sep 16, 2024

Conversation

carolinan
Copy link
Contributor

@carolinan carolinan commented Aug 14, 2024

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:
image

Front:
image

And here it is in the Portfolio pattern, above the footer.
image

functions.php Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Aug 21, 2024

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 props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: carolinan <[email protected]>
Co-authored-by: g-elwell <[email protected]>
Co-authored-by: juanfra <[email protected]>
Co-authored-by: justintadlock <[email protected]>
Co-authored-by: dballari <[email protected]>
Co-authored-by: carstingaxion <[email protected]>
Co-authored-by: richtabor <[email protected]>
Co-authored-by: codersantosh <[email protected]>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@carolinan carolinan added the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Aug 28, 2024
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.
@carolinan carolinan removed the [Priority] Low Used to indicate that the issue at hand isn't a top priority to address and can be handled later label Sep 13, 2024
Copy link
Member

@juanfra juanfra left a 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.

functions.php Outdated Show resolved Hide resolved
functions.php Outdated Show resolved Hide resolved
functions.php Show resolved Hide resolved
functions.php Outdated Show resolved Hide resolved
- 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.
@carolinan
Copy link
Contributor Author

carolinan commented Sep 14, 2024

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 Copyright.
The current text on the front is © 2024

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.
The reason why I did not go with Copyright date placeholder was that the text is so much longer than what is intended in the design, so the editor and front does not match well.

Perhaps the editor text should be © YEAR ? Does anyone have any other ideas?

@juanfra
Copy link
Member

juanfra commented Sep 16, 2024

I think the © YEAR proposal is the one that better reflects the pattern's functionality.

@carolinan carolinan merged commit 0b16f7d into trunk Sep 16, 2024
3 checks passed
@juanfra juanfra deleted the add/copyright-binding branch September 16, 2024 11:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add block bindings for copyright date and privacy policy link
3 participants