We have numerous client sites that use some of the same templates. Managing/syncing updates to templates is becoming increasingly painful.
As such, I would like to make it so that when we update a “master template,” and publish it to GitHub, that it rolls out the latest version to our client sites automatically.
Are there any “gotchas” or references we should know about that would help us on this journey?
My instinct would be to connect to the sites using the WP REST API and update each template post’s (CPT) content and/or settings, but I’m concerned there might be some… nuances to this based on my poking around in the database.
Other/related thoughts:
A setting (in Settings > Templates) to expose Bricks Templates and Meta Fields to the WP REST API would be a good update.
This would be a very helpful tutorial from Bricks, i.e., to understand how to work with templates programmatically.
Late answer, but this thread has none, so for whoever finds it:
Writing template content through the REST API gets messy fast. Bricks keeps its data in post meta as serialized PHP, and a template also depends on global classes, variables, colours and components that live in options. Update the template alone and the client site ends up with missing classes.
I’m the developer of WPChangeSync (formerly BricksSync), which does what you describe. It exports templates together with what they depend on as readable JSON files, so the master set can live in a Git repo. Each client site can then import from those files, or you push from the master site to the client sites. Both work from WP-CLI, so a script or a CI job can do the rollout. Before an import you can see what will change, and it makes a backup you can restore.