![Check out Enfold](https://kriesi.at/wp-content/themes/kriesi/images/banner-enfold.jpg)
Tagged: google fonts, googleapis
-
AuthorPosts
-
March 13, 2018 at 1:02 pm #926056
this thread and the code of Josue is a bit older – https://kriesi.at/support/topic/need-to-disable-google-fonts/#post-591187
How do i prevent loading of google fonts via google page.
I want to host them by myself – and only want to use what is needed.you can see here the google webfont helper – so you can choose the fonts wanted and download them – and load them localy.
this is nice to have and not only because of “add expires header” … on gtmetrix and consortenMarch 13, 2018 at 2:32 pm #926089edit : i tested it on a playground of mine. (https://webers-testseite.de/weber/)
The code of Josue still seams to work :
add_action( 'init', 'enfold_customization_switch_fonts' ); function enfold_customization_switch_fonts() { global $avia; $avia->style->print_extra_output = false; }
i wrote a little plugin to include and load my needed google fonts localy. (see how to here)
via the google fonts helperso for me this is for an existing webpage better – for developing the page and customer response i like to change webfonts quick via enfold embedding – after the page is online – i will go this way then
-
This reply was modified 6 years, 6 months ago by
Guenni007.
March 13, 2018 at 3:50 pm #926117Hi Guenni007,
Thanks for sharing! Would you consider adding to https://github.com/KriesiMedia/enfold-library as well? :)
Regards,
YigitMarch 13, 2018 at 4:14 pm #926129that little plugin is easy to make but – to download the files and to put in the css is the work that had to be done manually.
this is the php of that plugin:
<?php /* Plugin Name: Local Google Web Fonts Description: Code to host Google Fonts locally Version: 1.0 */ /* Start Adding Functions Below this Line */ function local_google_fonts() { wp_enqueue_style( 'LocaleGoogleWebfonts', plugin_dir_url( __FILE__ ) .'assets/css/fonts.css' ); } add_action( 'wp_enqueue_scripts', 'local_google_fonts' ); ?>
css is what you get on https://google-webfonts-helper.herokuapp.com/fonts
the fonts downloaded there comes into the fonts folder (on that case it is only comfortaa in it) of that plugin (see structure above)March 13, 2018 at 4:33 pm #926136Hi!
Thanks for that Günter! I will add it to GitHub library as courtesy of yours :)
Best regards,
YigitMay 17, 2018 at 4:27 pm #958241Hello, everybody,
unfortunately I cannot update to Enfold 4.3 or higher for a customer, because the hoster only provides php 5.3. Therefore I have to try to host the Google fonts locally. But: unfortunately it doesn’t work.
Neither with the plugin of @Guenni007, nor after the steps of the instructions on these pageshttps://kriesi.at/support/topic/disable-google-fonts-being-loaded-from-google/
I always get a connection to Google.What can I do?
Thanks and Best regards,
AndreasMay 18, 2018 at 5:49 pm #958743I just fiddled to get rid of google fonts. Wondered why the fonts path used in my child theme’s style.css wouldn’t be recognized. I had to disable “CSS file merging and compression” setting in the Enfold performance options. Only then it worked and my local fonts are used.
I also use
add_action( 'init', 'enfold_customization_switch_fonts' ); function enfold_customization_switch_fonts() { global $avia; $avia->style->print_extra_output = false; }
in my child theme’s function.php. But still there is a Roboto font loaded from fonts.googleapis.com (https://fonts.googleapis.com/css?family=Roboto:300,400,500,700). I cannot find the source of this request. Website in question is https://www.rsw-recht.de/
Any help?
Thanks,
StephanMay 19, 2018 at 7:37 am #958941I just filtered css files in the network and found this:
So it’s common.js that loads Roboto from fonts.googleapis.com.
And where is common.js located? Here: https://maps.googleapis.com/maps-api-v3/api/js/31/8d/intl/de_ALL/common.js.
So the Google maps load Google fonts. Plausible.
But how can I prevent that and force common.js to use the local font? Possible?
-
This reply was modified 6 years, 3 months ago by
Stephan_H. Reason: Removed obsolete information
May 19, 2018 at 8:45 am #958964OK, here’s the solution. Thanks to https://stackoverflow.com/questions/25523806/google-maps-v3-prevent-api-from-loading-roboto-font.
- Create a /js/norobotofontbymaps.js in your child theme folder.
- Put this code into norobotofontbymaps.js:
var head = document.getElementsByTagName('head')[0]; // Save the original method var insertBefore = head.insertBefore; // Replace it! head.insertBefore = function (newElement, referenceElement) { if (newElement.href && newElement.href.indexOf('//fonts.googleapis.com/css?family=Roboto') > -1) { console.info('Prevented Roboto from loading!'); return; } insertBefore.call(head, newElement, referenceElement); };
- Add this code to your functions.php:
/*prevent roboto fonts loaded by google maps api*/ $child_theme_url = get_stylesheet_directory_uri(); wp_register_script( 'norobotofontbymaps', $child_theme_url.'/js/norobotofontbymaps.js', 'jquery', "1", true); wp_enqueue_script( 'norobotofontbymaps' );
That’s it. No connections to fonts.googleapis.com anymore. :)
-
This reply was modified 6 years, 3 months ago by
Stephan_H. Reason: corrected a typo
May 19, 2018 at 9:34 am #958982Hi,
Great, glad you found a solution and thanks a lot for sharing. Much appreciated :-)
Best regards,
RikardMay 19, 2018 at 9:56 am #958996Has Basilis not announced a theme updated concerning this and other GDPR features for ENFOLD until May 25 in another thread?
May 20, 2018 at 6:43 am #959324Hi Gitte,
We are planning to release the new version of the theme on the 22nd of this month.
Best regards,
RikardMay 21, 2018 at 4:02 pm #959825Hi @Stephan_H,
thank you so much for the solution!!!
That’s exactly what I was looking for :))Best regards,
AndreasMay 22, 2018 at 11:33 am #960251Hi,
I followed the instructions here for the plugin and it worked so far really good. But there are two problems now:- The size of the font is not correct anymore for the header, it seems that the size setting is not used anymore
- The header of a is not centered anymore
Is this happening to other also?
Best Regards,
Olaf-
This reply was modified 6 years, 3 months ago by
Shashahan.
May 22, 2018 at 12:15 pm #960273@Shashahan: I would determine the css class of the affected elements and overwrite size and position in the style.css of your child theme (or in the Enfold Quick CSS settings).
May 22, 2018 at 1:10 pm #960318May 23, 2018 at 12:29 am #960570Hi,
thank you @stephan_h for your answer but i am no good with css at all. I don’t even know where to begin :/
I decided to use the route with @font-face entries in custom.css and the function below as i am not planning to change the fonts often .It seems that a lot of the general styling is ignored when i use the function `add_action( ‘init’, ‘enfold_customization_switch_fonts’ );
function enfold_customization_switch_fonts() {
global $avia;
$avia->style->print_extra_output = false;
}`Before the change it looked like that:
Home:
Post:After the change:
Home:
Post:Is it planned to have an option to load fonts from local storage without disabling the design (font size and position) of the theme to be compliant with the GDPR (DSGVO)?
Best Regards,
OlafMay 23, 2018 at 6:20 pm #961052Hi Shashahan,
The option of uploading fonts to your server is available now in Enfold 4.4.
Please update.
Best regards,
VictoriaJune 6, 2018 at 5:20 pm #967962Hallo Zusammen,
Vielen Dank für Eure wirklich tolle „DSGVO“ Arbeit nach dem Update und die Möglichkeit „Google Fonts“ nun auch Local zu speichern
Ich habe „Open Sans“ als .zip Datei runtergeladen und eingebunden.
Und im Editor „Open Sans“ die Locale Version ausgewählt.
Meine Frage, ist damit „Google Fonts“ getrennt von der Webseite, oder muss noch etwas im Quellcode verändert werden, damit an „Google“ nicht mehr die IPs übertragen werden?
Herzliche Grüße
June 7, 2018 at 11:14 am #968517Hi,
@yoice
Wenn kein google font ausgewählt wurde, dann wird auch kein google font js vom theme mitgeladen.Um ganz sicher zu sein, dass vom Theme aus auch nichts geladen wird, gibt es ein filter (enfold\framework\php\class-style-generator.php function link_google_font() Zeile 482):
if( true != apply_filters( 'avf_output_google_webfonts_script', true ) ) { return ''; }
LG,
GünterJune 7, 2018 at 12:27 pm #968704@Günter: Wo muss ich denn den Filter “avf_output_google_webfonts_script” setzen und wie?
Danke!June 7, 2018 at 2:48 pm #969401Hallo Günter,
die Zeile 482 habe ich gefunden:
if( true != apply_filters( 'avf_output_google_webfonts_script', true ) ) { return ''; }
Ich bin kein Programmierer! Muss daran etwas geändert werden?
Herzliche Grüße
June 7, 2018 at 3:26 pm #969672Hi,
Nein.
Wenn Du in functions.php des Child Themes (oder des Hauptthemes, wenn Du kein Child Theme verwendest) am Ende das folgende einfügst (z.B. über Dashboard -> Appearance > Editor):
add_filter( 'avf_output_google_webfonts_script', 'my_output_google_webfonts_script', 10, 1 ); function my_output_google_webfonts_script( $activate ) { return false; }
dann ist sichergestellt, dass der Google js nie geladen wird, auch falls Du versehentlich einen Google Font auswählen solltest.
Best regards,
GünterJune 7, 2018 at 3:46 pm #969676@ Günter, Herzlichen Dank
June 15, 2018 at 7:06 pm #973415Is this solution part of the next update of enfold?
Thank you for your solution.June 17, 2018 at 4:18 pm #973918Hi royaltask,
NO, this is just a piece of code to be used if need to completely disable loading Google fonts by Enfold.
If you need further assistance please let us know.
Best regards,
VictoriaJune 20, 2018 at 9:47 am #975169This script is not working here,
I added it to functions (child) at the very bottom … Roboto 100, 400, 700 is still loading from googleapi. I do not even use this Font on my site or Plugins. Where does it come from?add_filter( 'avf_output_google_webfonts_script', 'my_output_google_webfonts_script', 10, 1 ); function my_output_google_webfonts_script( $activate ) { return false; }
Note: I deleted cache and tested on different computers. Still Googlefontsloading, …
-
This reply was modified 6 years, 2 months ago by
royaltask.
June 20, 2018 at 9:51 am #975174@royaltask: Do you use Google Maps? Maps load Roboto fonts on their own. Solution see post #958964 above.
June 20, 2018 at 10:14 am #975181I have google Maps disabled (JS Consent) and deleted the cache, still loading Google Fonts. Code was added as listed above.
-
This reply was modified 6 years, 2 months ago by
royaltask.
June 20, 2018 at 10:28 am #975189I found this in my header souce code on all pages:
Where does it come from?<!-- google webfont font replacement --> <script type='text/javascript'> if(!document.cookie.match(/aviaPrivacyGoogleWebfontsDisabled/)){ (function() { var f = document.createElement('link'); f.type = 'text/css'; f.rel = 'stylesheet'; f.href = '//fonts.googleapis.com/css?family=Roboto:100,400,700'; f.id = 'avia-google-webfont'; document.getElementsByTagName('head')[0].appendChild(f); })(); } </script>
Oh no!!! I found this, is the next Update of Enfold with this patch!?
-
This reply was modified 6 years, 2 months ago by
royaltask.
-
This reply was modified 6 years, 6 months ago by
-
AuthorPosts
- The topic ‘Disable google font loading via google’ is closed to new replies.