Тёмный

Registering Block Settings in PHP? Build in Public Ep 6 

Brian Coords - WP Dev
Подписаться 2,5 тыс.
Просмотров 1,1 тыс.
50% 1

Опубликовано:

 

30 сен 2024

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 35   
@Rbog17
@Rbog17 3 месяца назад
Thats awesome. Well done and much needed. Could definitely come in handy.
@JM7Blocks
@JM7Blocks 3 месяца назад
Amazing. I need this. Just for adding classes to blocks for styling, that's all I need.
@BrianCoords
@BrianCoords 3 месяца назад
Yep, that's how I feel.
@SiteStudio
@SiteStudio 3 месяца назад
Would be nice if something like this existed as a library (not plugin) that could be included in any WordPress block theme or plugin.
@BrianCoords
@BrianCoords 3 месяца назад
Yeah I'm thinking I'll have instructions for that in the documentation, though I'm not sure I'll go so far as making a Composer package for it.
@BrendanOConnellWP
@BrendanOConnellWP 3 месяца назад
This is really cool, thanks for sharing as always!
@BrianCoords
@BrianCoords 3 месяца назад
Thanks!
@Whatreally123
@Whatreally123 Месяц назад
Hi Brian, Off topic question. I am building a simple site using 2024 theme and core blocks. I am trying to find information on how to add Google AdSense code to websites built on Block themes. All the tutorials and videos are for Classic themes where they update the header file or body file. Not sure that's how to do it on sites built on Block themes. Can you shed some light on how can one add AdSense code to block websites? Thanks.
@BrianCoords
@BrianCoords Месяц назад
If you're comfortable with code, then you'd use a hook like wp_head to add it. Otherwise, I'd recommend using the Google Site Kit plugin: wordpress.org/plugins/google-site-kit/
@AlexOliverwd
@AlexOliverwd 3 месяца назад
100% would use this. Thanks for the great content.
@lovor01
@lovor01 3 месяца назад
One remark: perhaps rename this to something other than block settings? Block settings is already a term for a block configuration object, in essence constructed from block.json in javascript.
@BrianCoords
@BrianCoords 3 месяца назад
Saw your issue and responded. Definitely an opportunity for better naming there.
@lovor01
@lovor01 3 месяца назад
Great idea! Although I am totally familiar with React and block editor, I know this will help a lot of people who aren't. If you opened this as a public project (I will check) I can contribute. Cheers!
@BrianCoords
@BrianCoords 3 месяца назад
Yes it's public! Share your thoughts and ideas, please.
@Xenio2007
@Xenio2007 3 месяца назад
Thanks you very useful for custom field in blocks, I also love to use CMB2, maybe a tutorial will be great.
@BrianCoords
@BrianCoords 3 месяца назад
Thanks! Yeah maybe I can do a CMB2 vs ACF explainer.
@alexlove2012
@alexlove2012 3 месяца назад
I dont like the idea of altering the html output. Every component you filter with it will execute that extra logic on every page reqest. For me i think it's a performance issue and aint a good approach.
@BrianCoords
@BrianCoords 3 месяца назад
For sure performance is a legitimate concern, but these filters exist and are already executing on page load regardless. Core uses them pretty regularly, and that's not even considering the number of blocks that are dynamic, meaning built entirely from PHP, not stored statically inside the content. This is pretty normal in WordPress and the alternative (altering them before they're saved in the database) is much more likely to cause problems.
@jameshofton
@jameshofton 2 месяца назад
Thanks for sharing, this is so useful and exactly what i am wrestling with at the moment. I really appreciate all the effort your going to
@BrianCoords
@BrianCoords 2 месяца назад
Good to know that many of us are in the same place trying to figure out the same workflow issues.
@RomanGamanov
@RomanGamanov 3 месяца назад
For sure way to go, but acf has something like this with posibility of building fields via ui or via php code.
@BrianCoords
@BrianCoords 3 месяца назад
Yeah but the PHP code method in ACF is not my favorite. And they also don't offer adding custom fields to core blocks, just to ACF Blocks.
@roseseto1358
@roseseto1358 2 месяца назад
Great tutorial! thank you for sharing! Quick question. The core/group has different variations: group, row, stack, grid , so under the 'blockTypes' option, is there a way to target only 'group'? If 'row' , 'stack' or 'grid' is selected it will not show the custom block settings fields. thank you!
@BrianCoords
@BrianCoords 2 месяца назад
That's definitely something you could do if you were building out your custom settings panel by hand in JavaScript/React. You can sort of see how they're figuring out which variation is active in this code here, though it's a big messy: github.com/WordPress/gutenberg/blob/trunk/packages/block-library/src/group/variations.js
@roseseto1358
@roseseto1358 2 месяца назад
@@BrianCoords thank you!
@carltongordon
@carltongordon 3 месяца назад
Been waiting on a update lol
@BrianCoords
@BrianCoords 3 месяца назад
Haha I know! I've been holding off since the new block styles features coming in 6.6 really cover much of the same territory and I'm trying to see where they're going with it.
@CreativeLogic
@CreativeLogic 3 месяца назад
Best idea I've seen for the Block Editor in a long while. Virtual high five because I'm pretty excited to try this out! As it stands now, it already has a lot of potential. I also liked all the ideas you mentioned, so it can only get better. Thank you for this!
@wpmarkuk
@wpmarkuk 3 месяца назад
This looks super useful Brian, thanks for sharing and I will certainly try this out.
@BrianCoords
@BrianCoords 3 месяца назад
Thanks Mark - I would love to discuss some use-cases for block custom fields with other developers testing the FSE waters if you have any.
@wpmarkuk
@wpmarkuk 3 месяца назад
@@BrianCoords We currently have a build taking place and therefore I may well be able to contribute to this discussion on use cases. Having thought about this again though, it seems as though this could be functionality something like ACF should add to their plugin - add fields to any block.
@BrianCoords
@BrianCoords 3 месяца назад
Yeah definitely. The one downside of ACF is that you're split between setting things up in their UI and then also writing code. I've been enjoying just sticking to code only.
@wpmarkuk
@wpmarkuk 3 месяца назад
@@BrianCoords I always use PHP to register fields and groups in ACF anyway so no change for me
@zensukai
@zensukai 3 месяца назад
Great tutorial -- thanks for the share! =]
Далее
Using Block Variations with the Block Bindings API
15:42
I learned to code from scratch in 1 year. Here's how.
41:55
Avoid Async Void
23:17
Просмотров 121
These Coding Projects Give You An Unfair Advantage
14:39
WordPress 6.6 is changing the game for Custom Fields
11:12
Bricks vs Block Themes: My Followup to Bridge Builders
24:21