Adding a way to include Javascript or PHP snippets to Block Themes #47151
Replies: 4 comments 8 replies
-
Here is a specific use case I ran into, smooth scrolling. A "presentation layer" popular theme feature where you need both modern CSS and Javascript snippet to do right. |
Beta Was this translation helpful? Give feedback.
-
There does not need to be anything new in order to accomplish this. Block Themes have access to the same tools that classic does in this regard. A functions.php file with script/styles enqueuing would be the approach in both cases. |
Beta Was this translation helpful? Give feedback.
-
I may not understand exactly, but I don't understand why such a file is needed to customize a block theme with PHP/JS/CSS. Instead of the block theme having a file called As I understand it, one of the goals of Gutenberg Phase 2 customization is to make it possible to customize the entire site without having to write HTML/PHP/CSS/JS code, not to make it possible to customize it with code. If you encounter a case that cannot be achieved without writing code, and it is desirable to be able to achieve this without writing code, or if you consider that to be the presentation layer, then I think it is a good idea to propose this as an issue. If not, or if the current Gutenberg cannot handle the case, we may have no choice but to use the old method, as mentioned in the previous comment. |
Beta Was this translation helpful? Give feedback.
-
I'm having trouble understanding what the issue is exactly here.
Adding plugin-territory features in themes is strictly forbidden and themes that do that are not allowed in the w.org themes repository. However, we have no control over what developers do in their custom themes... Nor should we. If someone builds a one-off theme for a client and they want to add site-specific functionality to that theme instead of a plugin, WordPress has no business forbidding that. |
Beta Was this translation helpful? Give feedback.
-
A broader conversation broke out in the nineteenth call for testing with the FSE Outreach Program that I wanted to bring here for a wider discussion and for awareness.
The comment continues here with more context (trying to capture the gist right now).
On the flip side, @scruffian shared:
In my mind this is plugin territory too but I wanted to open the conversation here in case I was missing something. I'd love to hear what @tadlock @DaisyOlsen think here as well as any @WordPress/block-themers. Either way, I imagine Rob isn't the only one wondering this and it seems wise to have the conversation now.
Beta Was this translation helpful? Give feedback.
All reactions