Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Load Typekit JS from child theme so that it can be modified - https://wordpress.org/plugins/custom-typekit-fonts/
<?php // don't copy this line your code
if ( is_callable( 'Custom_Typekit_Fonts_Render::get_instance' ) ) {
remove_action( 'wp_head', array( Custom_Typekit_Fonts_Render::get_instance(), 'typekit_embed_head' ) );
add_action( 'wp_head', 'your_prefix_typekit_embed_head' );
}
function your_prefix_typekit_embed_head() {
$kit_info = get_option( 'custom-typekit-fonts' );
if ( empty( $kit_info['custom-typekit-font-details'] ) ) {
return;
}
?>
<script type="text/javascript">
(function(d) {
var config = {
kitId : '<?php echo esc_js( $kit_info['custom-typekit-font-id'] ); ?>',
scriptTimeout : 3000,
async : true
},
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
})(document);
</script>
<?php
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.