- This topic has 11 replies, 3 voices, and was last updated 3 months, 4 weeks ago by Thiago Senna.
May 24, 2020 at 3:10 pm #1299737Lukas
first I have to say: you did some great work on that theme and the Premium plugin. I’ve been working with WordPress for years and created dozens of websites for customers, but never heard of this theme. Now that I found it, that’s really an amazing base for a lot of great pages!
Right now, I would love to use it on a new multisite network I’m working on and I want my users to pick themes from the site library. But it would be great if I could build a site library myself, so that they can import settings into the customizer, some default “Elements” etc., but from settings that I created.
I found a topic that drew my attention but unfortunately Tom’s last post took away some hopes on being able to build something like that: https://generatepress.com/forums/topic/using-custom-sites-in-the-site-library/
It would be great to get some info on if building an own site library is possible and if yes, some rough idea of how to build it.
Thanks so much and keep it up!
Regards from Germany,
LukasMay 24, 2020 at 3:16 pm #1299740Lukas
Just to add something to that, what would also be fine:
Is it possible to use exported settings from customizer etc. and have different child themes, that load those settings on theme activation?May 24, 2020 at 7:45 pm #1299917TomLead DeveloperLead Developer
Glad you’re enjoying GP!
I originally built the library to do this but realized it could go wrong if people started selling/providing buggy/dangerous sites.
One thing I’ve thought of is displaying a warning/notice when a site isn’t from the GP servers themselves, explaining that you should only install the site if you trust the source.
As of right now, the library will only display sites that live on our server.
You could export the Customizer settings and then run a function on child theme activation, but the code would be quite complex. You’d basically need to add an option to the database so the function only runs once. Once it runs, add the option and check for the option in the function itself. That way it wouldn’t run every time the user went to their site/Dashboard.May 25, 2020 at 10:20 am #1300890Lukas
I’ve been researching and testing a lot today…
I’ll keep you posted and might come back for some more info and help 🙂
But I wanted to thank you for your quick and helpful response already!May 25, 2020 at 3:51 pm #1301248TomLead DeveloperLead DeveloperMay 25, 2020 at 5:17 pm #1301306Lukas
So, I’m as far as that: I use the action hook after_switch_theme combined with a check, which theme gets activated, in the child theme’s functions.php to import a .dat-file for changing the customizer settings on activation. This is kind of working.
But now the questions are:
1. How to put all the information needed into one JSON file and create
- Dummy-Content (maybe)
- Activate/Deactivate GP-Modules
- Activate/Deactivate Plugins
- Adding all the Customizer Settings/Theme Mods
- Adding all the GP Elements used
2. which function to use to import the data into the activated theme.
I tried to read myself into the import-export/functions/functions.php but as far as I get it, it’s only importing GP modules, customizer mods and options. So no content, no plugins.
That’s why I switched over to the site-library files, because that’s giving all the options needed.
Now in sites/sites.php from line 474 it’s getting interesting, because the Export Setting “GeneratePress Site” is declared here. So when ticking GeneratePress Site before exporting, it’ll also include some information about the plugins needed. In my case, for example, it was a bit weird, because it only showed happyforms.php, although other plugins were also activated. This might be, because I loaded a site from the site-library earlier without deleting the content. So it seems to be only getting the dependency from the information of the site-library-activated theme.
But this was good information on how/where to put the information about necessary plugins into the JSON-file.
What I haven’t figured out still: How to add a dummy content and how to add the GP Elements, as those don’t seem to get exported.
Do you have a hint for me on how to proceed, what might be the next step? I really want to try to work it out as much as I can on my own without bothering you… so sorry for that.
If you think this is too much for the support forum, you can also just email me, whatever you find easier and what you prefer.
Thank you so much for your help! 🙂May 26, 2020 at 10:47 am #1302431TomLead DeveloperLead Developer
When it comes to importing content, plugins, Elements etc.. it’s not easy. It took me months of developing when building the Site Library to do this stuff.
The Site Library has all of the answers, but it’s complex stuff, so it might be difficult to pick out the parts you need depending on your coding experience.
Content and Elements (which are content), are exported in “Tools > Export”. Importing them is the hardest part of the Site Library – it involved forking the core WP importer and tweaking it to work with the sites.
Unfortunately it’s not really something I have the time/resources to go through step by step – it would take weeks to get something custom working (if not months).
It might be worth doing the most you can, then using a service like Codeable to finish up.May 26, 2020 at 11:08 am #1302459Thiago Senna
I was about to ask almost the same question – how much is site-library extensible to allow hosting my own sites for easy importing for custom client projects? What I have already did and worked fine is just to export the site library and WordPress content (tools) manually and import in a new website. Like Lukas probably I will check your code from inside too 🙂May 26, 2020 at 4:04 pm #1302740TomLead DeveloperLead Developer
There’s just a check right now to make sure the sites come from our gpsites.co server.
What I might do is remove that check, but display a disclaimer for the user if the site is coming from another location. That way it will be easy to build your own sites and provide them.May 26, 2020 at 6:06 pm #1302806Lukas
Thank you so much for your honest words on that, Tom.
I see that the whole site library must have been a challenging thing to build. It’s really great!
And I totally understand your concerns about harmful or just bad code that could be delivered allowing people to put up their sites into the library.
Removing the check, if the author/server is gpsites.co and showing a disclaimer would be one thing that has to be done if you want to open it. For me, the other thing though would be the possibility to connect an own library/json in the generatepress_sites_init function on line 653 where $data is declared.
Just for your info: In my case, the multisite network I’m building will be maintained by myself and I want to distribute own “themes” only for my users in this network free of charge. I don’t want anyone else to be able to get/download the sites (so I don’t want to be part of the official site-library for the fame or anything, hehe). This multisite network should function as a kind of page building tool for a certain group of people with some pre defined designs.
I would not need the regular GP site-library then. But still, I want to credit your work for GP itself and also the disclaimer about “Do you trust the source of this template” would be totally fine for me!
So – it would be great to get a possibility to use the site-library for this kind of thing, BUT you need to feel comfortable, with whatever that kind of solution could be. Because GP is your digital baby 🙂
Thank you for your great support!May 27, 2020 at 10:09 am #1303836TomLead DeveloperLead Developer
There is a way to filter into the current library with a PHP filter as of right now. That allows you to have a MU plugin that adds your custom sites to the library but only for your users. The problem is that gpsites.co block I mentioned earlier.
Once I remove that block and include a disclaimer, it will be possible to serve your own sites only to users on your multi-site network 🙂May 27, 2020 at 10:31 am #1303859Thiago Senna
maybe I’d move to a different direction beside hosting my own sites – I usually prefer child-themes so decided to save blocks as block patterns within the theme. But I will keep my eyes on your Site Library anyway 🙂
- You must be logged in to reply to this topic.