Registering Block Settings in PHP? Build in Public Ep 6

Поділитися
Вставка
  • Опубліковано 22 лип 2024
  • Thoughts on adding custom fields to Gutenberg blocks- using PHP, no JavaScript or React. Should WordPress let us register custom fields on blocks?
    👉 10ups Gutenberg Best Practices - gutenberg.10up.com/
    👉 CMB2 - wordpress.org/plugins/cmb2/
    👉 Block Settings Repo - github.com/bacoords/block-set...
    🚨 Free Video Series: 7 Tools for Modern WordPress Development 🚨
    👉 briancoords.com/7tools
    00:00:00 Intro
    00:01:26 CMB2 - The OG ACF
    00:02:10 Code-based Custom Fields
    00:03:31 10ups Block Extensions
    00:05:35 Block Settings Demo
    00:07:47 Code-view of block settings
    00:12:27 Thoughts and Feedback
  • Розваги

КОМЕНТАРІ • 33

  • @JM7Blocks
    @JM7Blocks 24 дні тому +2

    Amazing. I need this. Just for adding classes to blocks for styling, that's all I need.

  • @BrendanOConnellWP
    @BrendanOConnellWP 25 днів тому +1

    This is really cool, thanks for sharing as always!

  • @jameshofton
    @jameshofton 19 днів тому

    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  14 днів тому

      Good to know that many of us are in the same place trying to figure out the same workflow issues.

  • @lovor01
    @lovor01 24 дні тому

    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  24 дні тому +1

      Yes it's public! Share your thoughts and ideas, please.

  • @AlexOliverwd
    @AlexOliverwd 26 днів тому +1

    100% would use this. Thanks for the great content.

  • @Xenio2007
    @Xenio2007 25 днів тому

    Thanks you very useful for custom field in blocks, I also love to use CMB2, maybe a tutorial will be great.

    • @BrianCoords
      @BrianCoords  25 днів тому +1

      Thanks! Yeah maybe I can do a CMB2 vs ACF explainer.

  • @wpmarkuk
    @wpmarkuk 25 днів тому

    This looks super useful Brian, thanks for sharing and I will certainly try this out.

    • @BrianCoords
      @BrianCoords  25 днів тому

      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 25 днів тому

      @@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  24 дні тому

      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 24 дні тому

      @@BrianCoords I always use PHP to register fields and groups in ACF anyway so no change for me

  • @SiteStudio
    @SiteStudio 25 днів тому +1

    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  25 днів тому +1

      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.

  • @Rbog17
    @Rbog17 26 днів тому

    Thats awesome. Well done and much needed. Could definitely come in handy.

  • @CreativeLogic
    @CreativeLogic 25 днів тому

    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!

  • @Andy-vh3ns
    @Andy-vh3ns 26 днів тому

    Great tutorial -- thanks for the share! =]

  • @RomanGamanov
    @RomanGamanov 26 днів тому +1

    For sure way to go, but acf has something like this with posibility of building fields via ui or via php code.

    • @BrianCoords
      @BrianCoords  26 днів тому +2

      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.

  • @carltongordon
    @carltongordon 26 днів тому

    Been waiting on a update lol

    • @BrianCoords
      @BrianCoords  25 днів тому

      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.

  • @roseseto1358
    @roseseto1358 18 днів тому

    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  14 днів тому

      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 14 днів тому

      @@BrianCoords thank you!

  • @lovor01
    @lovor01 24 дні тому

    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  24 дні тому +1

      Saw your issue and responded. Definitely an opportunity for better naming there.

  • @alexlove2012
    @alexlove2012 20 днів тому

    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  20 днів тому

      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.