redux-framework icon indicating copy to clipboard operation
redux-framework copied to clipboard

Google fonts loaded twice in both header and footer

Open Goldenworks opened this issue 12 years ago • 14 comments

I updated the framework yesterday from 3.1.7 to latest version, all works fine and I am very happy with the new look but I have the issue described in title.

In header I have this loaded:

https://gist.github.com/Goldenworks/9431251#file-gistfile1-txt

And in footer this:

https://gist.github.com/Goldenworks/9431264#file-gistfile1-txt

I also reset options but no luck. Any idea why is this happening ?

Goldenworks avatar Mar 08 '14 14:03 Goldenworks

Hi. Please review this (https://github.com/ReduxFramework/redux-framework/blob/master/CONTRIBUTING.md) and include the necessary information. Thanks!

kprovance avatar Mar 08 '14 17:03 kprovance

I am using version v3.1.8.11 embedded directly in the theme. I am loading the framework using this code inside functions.php:

` // load the theme's framework if ( !class_exists( 'ReduxFramework' ) && file_exists( dirname( FILE ) . '/framework/ReduxCore/framework.php' ) ) { require_once( dirname( FILE ) . '/framework/ReduxCore/framework.php' ); }

// load the theme's options if ( !isset( $redux_demo ) && file_exists( dirname( FILE ) . '/framework/options/options-config.php' ) ) { require_once( dirname( FILE ) . '/framework/options/options-config.php' ); } `

I also made a separate test(I embedded the framework in an empty theme that contains only header.php, footer.php, index.php, functions.php and style.css) and it's the same. I used the default typography option example from sample-config.php and my api key to load the google fonts. The inclusion is loaded just the same, in both wp_head() and wp_footer().

Let me know if there's any other information that I can provide.

Goldenworks avatar Mar 09 '14 14:03 Goldenworks

I assume this is originating from a typography field you are using? If so, could you paste back the typography field code you are using? I'd like to try it out on my end in an effort to replicate this issue.

kprovance avatar Mar 09 '14 17:03 kprovance

Yes sure, here is the whole section that I am using inside options-config.php:

http://pastie.org/8902125

However like I initially stated, it also occurs with the default typography example that comes with redux, which is this one:

array( 'id' => 'typography6', 'type' => 'typography', 'title' => __('Typography', 'redux-framework-demo'), //'compiler'=>true, // Use if you want to hook in your own CSS compiler 'google' => true, // Disable google fonts. Won't work if you haven't defined your google api key 'font-backup' => true, // Select a backup non-google font in addition to a google font //'font-style'=>false, // Includes font-style and weight. Can use font-style or font-weight to declare //'subsets'=>false, // Only appears if google is true and subsets not set to false //'font-size'=>false, //'line-height'=>false, //'word-spacing'=>true, // Defaults to false //'letter-spacing'=>true, // Defaults to false //'color'=>false, //'preview'=>false, // Disable the previewer 'all_styles' => true, // Enable all Google Font style/weight variations to be added to the page 'output' => array('h2.site-description'), // An array of CSS selectors to apply this font style to dynamically 'compiler' => array('h2.site-description-compiler'), // An array of CSS selectors to apply this font style to dynamically 'units' => 'px', // Defaults to px 'subtitle' => __('Typography option with each property can be called individually.', 'redux-framework-demo'), 'default' => array( 'color' => "#333", 'font-style' => '700', 'font-family' => 'Abel', 'google' => true, 'font-size' => '33px', 'line-height' => '40px'), ),

Hope this information helps.

Goldenworks avatar Mar 10 '14 01:03 Goldenworks

Problem is, I can't reproduce it. Even with the sample config, I only get google font loads in the header. I'm hoping your code will make in happen on my side.

kprovance avatar Mar 10 '14 01:03 kprovance

Have you tried updating to the latest build? 3.1.8.15? I still can't duplicate this. I have to hope the latest build fixed it.

kprovance avatar Mar 10 '14 02:03 kprovance

I downloaded the latest build 3.1.8.15 but I can't use it at all. Inside wordpress admin backend I have this error:

Fatal error: Cannot use object of type WP_Error as array in C:\Server\Apache2\htdocs\wordpress_test\wp-content\themes\clean\framework\ReduxCore\framework.php on line 490

Goldenworks avatar Mar 10 '14 23:03 Goldenworks

Actually I managed to "fix" the above error. I set the parameter "update_notice" to false.(I saw it was introduced in the latest build). Maybe the issue is caused by the fact that I work on localhost ?

In regards with the fonts, unfortunately it still persists. Here is how my source code in the test environment looks like:

http://pastie.org/8905807

Searching the link ids in the framework I found this inside framework.php:

echo '<link rel="stylesheet" id="options-google-fonts" href="'.$typography->makeGoogleWebfontLink( $this->typography ).'&amp;v='.$version.'" type="text/css" media="all" />'; wp_register_style( 'redux-google-fonts', $typography->makeGoogleWebfontLink( $this->typography ), '', $version ); wp_enqueue_style( 'redux-google-fonts' );

It is obvious that the google font is added twice now. If I comment only the wp_register_style and wp_enqueue_style lines, the font inclusion disappears from the footer which is exactly what I wanted, but I don't know what other implications this modification might have( I would rather not touch any framework core files because I don't want to run in more unnecessary issues ).

Please let me know about this.

Goldenworks avatar Mar 11 '14 00:03 Goldenworks

Hmmm. Interesting now that I can see the output. I'll check into this some more.

kprovance avatar Mar 11 '14 03:03 kprovance

Okay, here is what I did. I removed the css line from the header and left the footer, because the footer line uses wordpress API. So, unless anyone strenuously objects (and can explain why the former is better), we'll leave it this way. Please download the latest repo, v.3.1.8.16 and see if it works out for you. I also fixed the update_check. It shouldn't fail on a local install, as that's what I use. A proper internet connection would be another matter. If it gives you another error, please let me know. Good luck! :)

kprovance avatar Mar 11 '14 03:03 kprovance

I still have that issue with "Cannot use object" on localhost unfortunately, but it's not a big deal for me at least, since I can turn it off.

In regards with the google font, now the only issue is that the code won't validate anymore as html5. I understand that wp_register_style is the best practice to embed css, but isn't there a way to use this method to add the google font in the header ?

Goldenworks avatar Mar 11 '14 10:03 Goldenworks

Not as it stands. I can just switch the code to put the header call back and comment out the footer code. As long as it works. :)

kprovance avatar Mar 11 '14 15:03 kprovance

Okay, I switched the google css back to the header, and finally fixed the error from the update check. Seriously, I promise. :)

kprovance avatar Mar 12 '14 02:03 kprovance

Yes I confirm that it's fixed. Thanks for support!

Goldenworks avatar Mar 13 '14 13:03 Goldenworks