Skip to content
This repository has been archived by the owner on Nov 18, 2024. It is now read-only.

Add block bindings for copyright date and privacy policy link #7

Closed
carolinan opened this issue Jul 3, 2024 · 8 comments · Fixed by #21
Closed

Add block bindings for copyright date and privacy policy link #7

carolinan opened this issue Jul 3, 2024 · 8 comments · Fixed by #21
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@carolinan
Copy link
Contributor

What

Add a block binding for a dynamic copyright date.
Add a block binding for a link to the privacy policy page. This link should only display if the privacy policy page is published.

Why

The purpose of this task is twofold: To solve two common problems and showcase how to use the block bindings api.

Resources

https://make.wordpress.org/core/2024/03/06/new-feature-the-block-bindings-api/
https://developer.wordpress.org/news/2024/02/20/introducing-block-bindings-part-1-connecting-custom-fields/
https://developer.wordpress.org/news/2024/03/06/introducing-block-bindings-part-2-working-with-custom-binding-sources/
https://developer.wordpress.org/news/2024/05/06/building-a-book-review-site-with-block-bindings-part-1-custom-fields-and-block-variations/
https://developer.wordpress.org/news/2024/06/06/building-a-book-review-site-with-block-bindings-part-2-queries-patterns-and-templates/

@carolinan carolinan added the [Type] Enhancement A suggestion for improvement. label Jul 3, 2024
@carolinan carolinan changed the title Add block bindings for copyright date and privacy policy links Add block bindings for copyright date and privacy policy link Jul 3, 2024
@justintadlock
Copy link
Contributor

I'd love to see this.

I'd say the one downside of the Privacy Policy is that you'll get an empty <p> on the front end if it's not published because there's no good way to do conditionals. I know there's some discussion around this here (not sure if there's a dedicated ticket, though): WordPress/gutenberg#59272 (comment)

@carolinan
Copy link
Contributor Author

Perhaps the paragraph could contain something more than the link, like the site title?

Let's start with the copyright info.

@dballari
Copy link
Contributor

dballari commented Jul 11, 2024

I think the empty p could be solved by using the empty css selector, something like this: .site-footer p:empty { display: none; }
This could be added in a css section of the theme.json file

@carstingaxion
Copy link

@carolinan @justintadlock I would create a block variation for the policy link. This variation can be addressed within a pre_render_block filter to be only visible if a policy is already published and preventing the empty paragraph as a side effect.

@justintadlock
Copy link
Contributor

@carstingaxion - Yep, that's a solution that I've employed in similar situations. Just not sure if that's something OK to go in a default theme or not, but I'll leave that up to folks to decide.

@richtabor
Copy link
Member

Let's at least do the copyright. Would be a good use case others can learn from as well (and easy as it doesn't rely on conditionals).

@carolinan
Copy link
Contributor Author

Part of it is choosing what the bound text should be, in the editor :)

@codersantosh
Copy link

codersantosh commented Sep 9, 2024

I would also recommend adding a separate pattern or block variation for the copyright section, utilizing block bindings properties. This would allow users to easily insert the copyright element wherever needed.
I just noticed that there's already a pull request for the copyright pattern (#21 ).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants