Easy Google Fonts Plugin not copying over settings

Attempting to set up a blog template for new signups. In this blog template I have the easy google fonts plugin (http://wordpress.org/plugins/easy-google-fonts/) installed and set up to manipulate 4 items.

For some reason the settings I have created with this plugin are not being carried over to the sign ups that are using this blog template when signing up...any ideas why this plugin might not be working...great plugin.

    Ben

    @Mac

    Thanks for the quick reply. I've been doing lots of tests...and I can come to no conclusion as to why the settings for this plugin are not being copied over. Also please note I am using the multi-db plugin.

    I have tried removing > deleting > re-installing the plugin. (i also noticed that after doing that, the settings for the blogs that had been using that plugin remained in place after the re-install)

    I then created a brand new blog from scratch, adding the settings you see in the images, and then made a blog template from that new blog. I then created another blog based on that template, however the easy google font plugin settings were not carried over to the new blog created from the new template.

    Could there be a bug in the new template plugin?

    Thanks!

    PC

    Hey there,

    Thanks for posting back.

    I did a quick test. Creted a template blog and selected the fonts on the customizer and then created a blog using that template.

    I notice that the settings via Settings >> Google Fonts are being copied successfully

    Coming to the customizer, the fonts which I have selected on the template blog, are working on the newly created site. Its just that its not showing in the dropdown in the customizer >> typography.

    I am sure that our lead developer would be able to explain why that is happening. Perhaps its just setup like that so that it can present the new blog created using template with the fonts as default and simply allowing the users to choose their own fonts.

    He should be around soon.

    Cheers, PC

    Ben

    @Mac, thanks for playing with it.

    Just to be clear...u are saying that you are creating font controls in the template with the google font plugin, and those settings are being set and saved and showed in the font controls of the new site you created, but for some reason even though there are in the font controls that have been set up, they are not showing in the customize section...?

    Anyways the main goal I would like to see is for me to set up font controls with this plugin and put them in the template and then every site that is created with this template already has the font controls pre-set up and the user can make changes to the fonts very easily. It seems that should be the expected use.

    Keep me updated on what the dev says, this is a very important feature for me to be working,,,thanks!

    PC

    Hey there,

    Thanks for posting back.

    Just to be clear...u are saying that you are creating font controls in the template with the google font plugin, and those settings are being set and saved and showed in the font controls of the new site you created, but for some reason even though there are in the font controls that have been set up, they are not showing in the customize section...?

    Yeah, the font control template which I have created gets carried over to the new site created using template. The fonts I have selected on the template site are also copied over on the new site. Its just that the new site customize section does not display the font name which is carried over. It just thinks of that as a default font as its saved its value in the db.

    Is the template not getting saved on your site ?

    Our dev should be around and he will post on the same thread

    Cheers, PC

    Ignacio

    Hi @Ben.

    Apparently, Easy Google Fonts saves its data into posts table. If you don't copy posts, then settings won't be copied but there's an easy fix for that and I'll add it into the next version. Just open blogtemplates/blogtemplatesfiles/integration.php file and put this code at the end of the file:

    /** EASY GOOGLE FONTS **/
    add_action( 'blog_templates-copy-after_copying', 'nbt_copy_easy_google_fonts_controls', 10, 2 );
    function nbt_copy_easy_google_fonts_controls( $template, $destination_blog_id ) {
    	global $wpdb;
    
    	if ( ! is_plugin_active( 'easy-google-fonts/easy-google-fonts.php' ) )
    		return;
    
    	$source_blog_id = $template['blog_id'];
    
    	if ( ! isset( $template['to_copy']['posts'] ) && get_blog_details( $source_blog_id ) && get_blog_details( $destination_blog_id ) ) {
    		switch_to_blog( $source_blog_id );
    
    		$post_query = "SELECT t1.* FROM {$wpdb->posts} t1 ";
    		$post_query .= "WHERE t1.post_type = 'tt_font_control'";
    		$posts_results = $wpdb->get_results( $post_query );
    
    		$postmeta_query = "SELECT t1.* FROM {$wpdb->postmeta} t1 ";
    		$postmeta_query .= "INNER JOIN $wpdb->posts t2 ON t1.post_id = t2.ID WHERE t2.post_type = 'tt_font_control'";
    		$postmeta_results = $wpdb->get_results( $postmeta_query );
    
    		restore_current_blog();
    
    		switch_to_blog( $destination_blog_id );
    		foreach ( $posts_results as $row ) {
                $row = (array)$row;
                var_dump($row);
                $wpdb->insert( $wpdb->posts, $row );
            }
    
            foreach ( $postmeta_results as $row ) {
                $row = (array)$row;
                $wpdb->insert( $wpdb->postmeta, $row );
            }
    
            restore_current_blog();
    
    	}
    }

    That shoud copy the data.

    Could you try and tell us if it worked?

    Regards.
    Ignacio.

    Ben

    @Ignacio great work, thanks for working through this bug, this was a very important feature for me, thank you.

    I have tested it and can now confirm that this plugin is now working as expected with this fix.

    (also in case you forget there is an accidental "var_dump($row);" you left in the code)

    Happy that it is working now and yes please don't forget to include this fix in the next release!

    Thanks!

    -Ben