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 block pattern management #287

Open
2 tasks
justintadlock opened this issue Mar 23, 2023 · 22 comments
Open
2 tasks

Add block pattern management #287

justintadlock opened this issue Mar 23, 2023 · 22 comments

Comments

@justintadlock
Copy link

justintadlock commented Mar 23, 2023

@annezazu reached out to see what I thought of integrating my Block Pattern Builder plugin into Create Block Theme. One of the pain points being that the pattern creation process was a bit too manual for non-technical users.

BPB was originally built as a proof of concept of a pattern manager that I'd envisioned core WP eventually handling. The current release is not 100% up to date with the current Patterns API features, but I've been working locally to update it.

I'm happy to start on the process of a PR if this is desirable for the plugin.

If so, I imagine one thing that would need to change is prefixes. Names/prefixes:

  • Patterns: bpb/pattern-name
  • CPT: bpb_pattern
  • Taxonomy: bpb_pattern_category
  • Role capabilities: bpb_cap_name

Any thoughts on naming/prefixing for those things?


Potential features:

  • Allow user-created patterns to be exported with a theme
  • Allow deleting theme patterns via the Editor; or allow theme patterns to be excluded from the theme export
@matiasbenedetto
Copy link
Contributor

I haven't used this plugin before, and I'm curious about the differences with this recently launched plugin for managing patterns.

Will integrating your plugin add any new features different from the other plugin?

@justintadlock
Copy link
Author

Block Pattern Builder was primarily built for users and hasn't been updated in a bit for newer Pattern API features. In and of itself, it wouldn't add any new features.

Pattern Manager was built primarily for developers as part of their workflow. It'd be an obvious choice to integrate into Create Block Theme.

@annezazu
Copy link

I'll ask the folks behind the other plugin too about possible integration in case there are a few ways forward here. Ultimately, just want to see what we can do in the short term to make patterns easier and easier to create and manage.

@ndiego
Copy link
Member

ndiego commented Aug 29, 2023

Now that 6.3 includes the ability for users to create both synced and standard patterns from within the Editor, it would be great to revisit this issue. Creating standard patterns in the Editor and then exporting them directly to the theme, much like templates and template parts, would be amazing.

cc @mikachan 😉

@annezazu
Copy link

Bringing in feedback from the FSE Hallway Hangout last week as this continues to come up as as a pain point and borderline deterrent currently. Specifically, here are the notes:

We discussed the potential and power of patterns alongside the overall pain points in managing/maintaining them. Mike talked about the early days before you could create them in the interface and how cumbersome the process was (had to create in the page, export the content, put it into a file, figure out the image, etc). Maintaining patterns is immense still: have to manually put in a file, translate the strings again, change the image tags, etc.

We talked about incorporating this more into the Create block theme plugin folks, some of whom were on the call, and they haven’t had the bandwidth to add it in yet. However, it’s clear that this is a part of the UI that isn’t covered well anywhere right now and definitely needs attention.

“If you were to tell this to a new user for distribution, they would say no way.” - Mike McAllister.

As work is underway to consider what to tackle next, I hope this can be taken into consideration!

@justintadlock
Copy link
Author

justintadlock commented Oct 18, 2023

Just some other thoughts, which I also shared in the above-linked Hallway Hangout:

My Block Pattern Builder plugin wouldn't be ideal for what theme authors would need. It was built specifically for pattern management for end-users and saves patterns in the database. Of course, this feature is now a part of core WP.

What's needed is a way to write patterns to disk---files in the theme's /patterns folder---since the ultimate goal would be to make a distributable theme.

@carolinan
Copy link

I am not sure I understand the goal, let me try to summarize

  1. We want to be able to create patterns via the pattern creation interface:
  • Whether that is in the Site Editor or the "classic" admin screen
  1. When exporting the theme, the pattern that is saved in the database should create files inside the themes patterns folder
  • Text strings should be translation ready
  • Media file path should be updated and media saved inside the theme folder

Wouldn't this be doable in a similar way as when template changes are exported from the database?
Without looking at the code in the plugin, media files are already moved and the code that includes the media path is already turned into a pattern file, correct?

@carolinan
Copy link

I think we must consider the long term. I believe the plan is to make template parts synced patterns.
Right now template parts are in a strange "limbo" as they often only contain a single pattern. In those cases, the template part is only used because it is synced, because there is no easy way for themes to register synced patterns.

@mikachan
Copy link
Member

@aaronrobertshaw @glendaviesnz 👋 I know you've been working a lot with patterns in Gutenberg and for WP 6.4. Are there any existing plans around exporting patterns as part of the theme export? We want to explore this as part of Create Block Theme, but it would be good to know if there are any other plans within Gutenberg before we start. Thanks!

@georgestephanis
Copy link

Also acknowledging parallels with a discussion I was having with @scruffian yesterday about the importance of importing block patterns (possibly from a directory) to enable composite themes where folks can have a block theme and ad-hoc import home page (or other) templates (as block patterns) or the like from a directory -- enabling export as well would be the flip side of enabling migrations from staging to production sites -- and then the export could enable packaging it up to upload to a directory.

The other thing I was discussing was that it would likely require the block that embeds patterns may need to start referring to the pattern by slug instead of by post_id -- as slug can be consistent cross-site, but if exported/imported, post_id wouldn't be. That feels like an important shift as well.

Finally, if it's useful and semi-related to this area, something we cobbled together a bit ago as fork of another plugin to track usage of reusable block patterns: https://github.com/a8cteam51/Reusable-Block-Count -- which is a very basic ~100 line plugin.

@glendaviesnz
Copy link

@aaronrobertshaw @glendaviesnz 👋 I know you've been working a lot with patterns in Gutenberg and for WP 6.4. Are there any existing plans around exporting patterns as part of the theme export?

There is an open issue here about patterns breaking theme export, but we currently have no plans to pick this up as we will be focused on partial syncing for 6.5, so feel free to pick this up.

This issue here will probably be related, as this work will most likely involve adding a slug to the synced patterns, as the current id can't be reused between themes.

@mikemcalister
Copy link

Hey folks, curious if there has been any movement on this yet? In a quick test, it looks like we're still not exporting patterns with the export zip?

With a huge focus being placed on patterns as a key component of modern WordPress, builders need to be able to export them with their theme. Otherwise, what is the current proposed workflow for builders to move patterns from a local site to a live site? I know there is a json pattern export but surely we can do better than that for builders.

I have lots of curious block theme adopters writing in asking me about this and I don't have a great answer.

@justintadlock @richtabor @annezazu

@annezazu
Copy link

annezazu commented Jun 18, 2024

As you stated, the latest is that 6.6 will include the ability to bulk export patterns (58897). In terms of the work on this issue itself, none of the folks you tagged are working directly on the create block theme plugin itself. @mikachan perhaps you can speak more to this and where this might exist in terms of priorities?

Of note, for anyone following, this is also a great area to contribute back :)

@mikemcalister
Copy link

Thanks, @annezazu! If I had the technical prowess, I'd be on it in a heartbeat. It would be such a huge win for block theme builders, agencies, and freelancers!

@mikachan
Copy link
Member

mikachan commented Jun 18, 2024

Thanks for the question @mikemcalister and for the ping @annezazu!

Currently, the plugin does not include newly created patterns in the theme export. We do still have plans to explore this, but recently we have prioritised refactoring the plugin UI and moving all functionality from the wp-admin page to the editor.

It is the next thing we plan to look into, although we're considering whether it should happen in the plugin or directly in the Editor (and eventually be included in Core). One of the things we're considering is that this Gutenberg issue includes plans for addressing exported patterns, which would sit alongside the synced patterns work in the Editor. We'd appreciate any opinions either way on this: whether the ability to export patterns should sit in Gutenberg or in Create Block Theme. To confirm, from my perspective this doesn't affect the prioritisation, although it's worth noting that we can probably work more quickly in this plugin as it's a smaller codebase.

Otherwise, what is the current proposed workflow for builders to move patterns from a local site to a live site?

Unfortunately, at the moment there isn't a great workflow that doesn't involve copying files outside of the Editor, e.g. in a code editor.

@annezazu
Copy link

annezazu commented Jun 18, 2024

We'd appreciate any opinions either way on this: whether the ability to export patterns should sit in Gutenberg or in Create Block Theme. To confirm, from my perspective this doesn't affect the prioritisation, although it's probably worth noting that we can probably work more quickly in this plugin as it's a smaller codebase.

To me, similar to the font library, I think it would be neat to build it out first here then see about bringing it into Core proper. It seems like a way to move faster and still get features to block themers without needing to wait for Core for something we may or may not do.

@bacoords
Copy link

Since this thread is popping, I'd be happy to add my ideal as one perspective-

Ideally, theme patterns could be overridden, with the same ability to see and 'clear' customizations that templates and template parts have. And then the ability to save those customizations via CBT back to the theme files.

Similarly, it'd be great to include theme.json support for defining pattern meta, similar to templates/parts. Imagine that themes could 'lock' patterns and templates/templates parts from being edited in certain environments, perhaps by filtering theme.json or similar).

So essentially, how close can we keep the pattern experience to the template experience where core handles customizations and CBT handles exporting to disk. And I agree with the idea of iterating in CBT first before worrying about core whenever possible

@mikemcalister
Copy link

mikemcalister commented Jun 20, 2024

Ten thumbs up to what Brian and Anne said, especially this:

And I agree with the idea of iterating in CBT first before worrying about core whenever possible

If CBT is going to be the defacto theme dev tool for the time being, let's just focus there. I fear we're losing block theme devs due to the lack of a robust and reliable workflow, so getting something iterative to them sooner would be really beneficial to adoption.

@markhowellsmead
Copy link

After the Hallway Hangout yesterday, I’m itching for someone to get the GitHub connectivity (as seen in Playground) into the plugin. Pretty please! 🥺

@mikachan
Copy link
Member

mikachan commented Jun 27, 2024

Thanks all for the feedback. I agree with the reasons for iterating in this plugin first. However, I think this work needs scoping out first to investigate any foundational steps that may need to happen upstream in Gutenberg. I'm mainly thinking of the upcoming changes to synced patterns in 6.7, especially WordPress/gutenberg#59272. This work would be much quicker to iterate on if patterns could be referenced via slugs rather than ids.

Here are some ideas for the next steps in the plugin, which I think can happen before and during the 6.7 cycle (i.e. now!), and we can update functionality as necessary based on changes in GB for 6.7:

  1. Explore allowing user-created patterns to be exported with a theme via Create Block Theme.
    We could start by including another checkbox option on the save panel that allows all user-created patterns to be exported with the theme. A potential blocker here is that patterns are currently referenced using ids, which doesn't work in the context of exports (as the id won't exist in a different site). Hopefully this is unblocked soon in GB, and we can be working on the export functionality in the meantime.

  2. Explore how Create Block Theme could remove theme patterns from the theme export.
    The plugin could include a specific page listing all these patterns and allow users to mark which ones to keep and which ones to remove during export. Or, we could add an option that removes the theme pattern files and uploads them as regular synced or unsynced patterns instead. Once they are synced or unsynced patterns, it becomes easier to remove them like regular patterns.

@mikachan
Copy link
Member

Started some initial exploration in this PR: #675

@paaljoachim
Copy link

paaljoachim commented Aug 3, 2024

I added this comment: WordPress/gutenberg#62566 (comment) to Synced Patterns iteration for WordPress 6.7

I am looking at patterns from the general user kind of view. As in how do I want to customize the content I have available for my own site.

  • Customisations. As in being able to modify existing categories. Renaming/trashing categories and patterns. (Lets include templates and template parts in this as well.)
  • Adding a trash folder(?) to where I would trash category folders and patterns (templates and template parts) I do not plan on using.
  • Switching a pattern that is being used through the site with another pattern.
  • Being able to see where a pattern is being used.
  • Easily being able to go to the online pattern directly to lookup patterns I want to use and add these to any of the folders/categories.

I went ahead and made a video: https://youtu.be/Y8qi7LIgZic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests