wp-theatre
wp-theatre copied to clipboard
POC: Transform [wpt_productions] into query-block variation
From all the Shortcodes, [wpt_productions]
seemed to be the best candidate to validate the idea of using block-transforms on the existing shortcodes to migrate into the new era of blocks.
https://github.com/slimndap/wp-theatre/assets/198883/55468ccc-71a9-4259-896d-a42bb6d290e1
Ressources
- Block Editor Handbook
- CSS-Tricks
- 10up - Gutenberg Best Practices
- What are Block Transforms and Why You Should Use Them
Steps I did
- [x] Update
register_post_type()
arguments ofwp_theatre_prod
with:'show_in_rest' => true,
- [ ] Write a dedicated filter on this
- [x] Create a block that transforms the shortcode(s) into one or more block
- [ ] Hide block from inserter, as it is only needed to register the transforms
- [x] Transform shortcode attributes like
order
into block-attributes is working for most, not all attributes out of the box - [ ] Transform template fields of an enclosing shortcode like
{{excerpt}}
into innerBlocks
working, so far
1.
- [x]
[wpt_productions]
- [x]
[wpt_productions limit=1]
- [x]
[wpt_productions cat=2]
- [x]
[wpt_productions post__not_in=11,12]
- [x]
[wpt_productions order=desc]
- [x]
[wpt_productions limit=8 cat=2 post__not_in=11,12 order=desc]
- [x]
[wpt_productions fields="thumbnail,title,summary"]
and some more fields
2.
- [x]
[wpt_event_ticket_button]
- [x]
[wpt_event_ticket_button id=123]
https://github.com/slimndap/wp-theatre/assets/198883/0d236850-50ce-4d55-8524-fef8c95e7180
Next steps
- I would go on creating dedicated issues for each shortcode. This should help while developing and documenting the necessary steps, parameters, fields and use-cases.
- Create transforms for all existing shortcodes and all its parameters to achieve best compatibility with existing installations
I think, that all of this, could be done independently from our decisions whether to carry out an own event-management solution or not.
Find the working code in figuren-theater/theater-production-blocks at feature/wpt-shortcode-to-query-block, if you want to give it a try @slimndap