Viewing 30 posts - 1 through 30 (of 38 total)
  • Author
    Posts
  • #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 consorten

    #926089

    edit : 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 helper

    so 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, 9 months ago by Guenni007.
    #926117

    Hi Guenni007,

    Thanks for sharing! Would you consider adding to https://github.com/KriesiMedia/enfold-library as well? :)

    Regards,
    Yigit

    #926129

    that 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.

    that is the folder structure:

    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)

    #926136

    Hi!

    Thanks for that Günter! I will add it to GitHub library as courtesy of yours :)

    Best regards,
    Yigit

    #958241

    Hello, 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,
    Andreas

    #958743

    I 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,
    Stephan

    #958941

    I just filtered css files in the network and found this:
    Roboto loaded by common.js

    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, 7 months ago by Stephan_H. Reason: Removed obsolete information
    #958964

    OK, here’s the solution. Thanks to https://stackoverflow.com/questions/25523806/google-maps-v3-prevent-api-from-loading-roboto-font.

    1. Create a /js/norobotofontbymaps.js in your child theme folder.
    2. 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);
      };
    3. 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, 7 months ago by Stephan_H. Reason: corrected a typo
    #958982

    Hi,

    Great, glad you found a solution and thanks a lot for sharing. Much appreciated :-)

    Best regards,
    Rikard

    #958996

    Has Basilis not announced a theme updated concerning this and other GDPR features for ENFOLD until May 25 in another thread?

    #959324

    Hi Gitte,

    We are planning to release the new version of the theme on the 22nd of this month.

    Best regards,
    Rikard

    #959825

    Hi @Stephan_H,

    thank you so much for the solution!!!
    That’s exactly what I was looking for :))

    Best regards,
    Andreas

    #960251

    Hi,
    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, 7 months ago by Shashahan.
    #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).

    #960318

    Hi,

    Thanks for helping out @stephan_H, did you try that out @shashahan?

    Best regards,
    Rikard

    #960570

    Hi,
    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: Home before the change to local fonts
    Post: Post before the change to local fonts

    After the change:
    Home: Home after the change to local fonts
    Post: Post after the change to local fonts

    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,
    Olaf

    #961052

    Hi Shashahan,

    The option of uploading fonts to your server is available now in Enfold 4.4.

    Please update.

    Best regards,
    Victoria

    #967962

    Hallo 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

    #968517

    Hi,


    @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ünter

    #968704

    @Günter: Wo muss ich denn den Filter “avf_output_google_webfonts_script” setzen und wie?
    Danke!

    #969401

    Hallo 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

    #969672

    Hi,

    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ünter

    #969676

    @ Günter, Herzlichen Dank

    #973415

    Is this solution part of the next update of enfold?
    Thank you for your solution.

    #973918

    Hi 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,
    Victoria

    #975169

    This 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, 6 months ago by royaltask.
    #975174

    @royaltask: Do you use Google Maps? Maps load Roboto fonts on their own. Solution see post #958964 above.

    #975181

    I 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, 6 months ago by royaltask.
    #975189

    I 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, 6 months ago by royaltask.
Viewing 30 posts - 1 through 30 (of 38 total)
  • The topic ‘Disable google font loading via google’ is closed to new replies.