Archived topic
Syncing settings
5 replies · Started by Mike on August 16, 2019
Hi - apologies if this is obvious, have only just started using GP but couldn't find an answer...
So - I see there's a way of exporting and importing settings.
We're looking at using GP in a multisite environment - so my question is, is there any way of these settings being in place by default when a new site is launched?
I guess the analogous example would be the way Advanced Custom Fields has an acf-sync folder which contains options that the plugin looks at - means we can not only set defaults but also push these into source control.
Thanks!
Mike
Hi Mike,
All of our defaults are filterable, so you can create a network-active plugin which adds your defaults to new sites.
This file has a lot of the defaults: https://github.com/tomusborne/generatepress/blob/2.3.2/inc/defaults.php
So for example, if we wanted to target generate_option_defaults, we could do this:
add_filter( 'generate_option_defaults', function( $defaults ) {
$defaults['container_width'] = '1500';
$defaults['layout_setting'] = 'left-sidebar';
return $defaults;
} );
Unfortunately, we haven't documented all of the available for each option as of right now. I'll see if we can get that done ASAP.
Let me know if you need more info :)
Thanks Tom, useful.
So is it a case of setting up a site, exporting the settings and then manually writing the filters into a plugin? Or is there a way of going from the export file to code in some way?
Right now it's a manual process, which sucks. I've made a note to play with a method to do it automatically, as that would be awesome.
Thanks Tom, much appreciate your quick and candid answers :-)
The way that ACF does it is really cool - you may want to take a look there for reference:
https://www.advancedcustomfields.com/resources/synchronized-json/
In particular what we like about it is being able to bring ACF settings into source control - but it also means that in scenarios like the multisite one I outline above you can easily edit / set defaults.
cheers
Mike
Awesome, thanks for sharing that! Super useful :)