Pro 5.1.x bug: JS snippet for importing Typekit fonts missing semicolons

Bringing this to attention again as this has not been fixed in the latest release cycle of 5.1.x:

The fix should be really straightforward, and currently I am having to re-do the fix every time I update Pro.

The file in question can be found here: /wp-content/themes/pro/cornerstone/includes/classes/styling/class-font-manager.php

And the section is from lines 412–437 in the cs-typekit-loader script.

Semicolons need to be added to line endings as follows:

<script id="cs-typekit-loader">
  (function(doc){
    var config = { kitId:'<?php echo $config['typekitKitID'];?>', async:true };

    var timer = setTimeout(function(){
      doc.documentElement.className = doc.documentElement.className.replace(/\bwf-loading\b/g,"") + " wf-inactive";
    }, 3000);

    var tk = doc.createElement("script");
    var loaded = false;
    var firstScript = doc.getElementsByTagName("script")[0];

    doc.documentElement.className += " wf-loading";

    tk.src = 'https://use.typekit.net/' + config.kitId + '.js';
    tk.async = true;
    tk.onload = tk.onreadystatechange = function(){
      if (loaded || this.readyState && this.readyState != "complete" && this.readyState != "loaded") return;
      loaded = true;
      clearTimeout(timer);
      try { Typekit.load(config) } catch(e){}
    };

    firstScript.parentNode.insertBefore(tk, firstScript);
  })(window.document);
</script>

I hope that this bug can be sorted in a minor release or in the next cycle.

Hi @arthurodb,

The issue has been already reported to our issue tracker by my colleague but it is great that you shared the solution here.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.