Adding MyFontsWebKit JS file into Pro Child Theme PHP file

Hi there,

Asked this question like way before APEX forums came along (should have saved the answer). How should I correctly add this code to the head section of your website’s HTML code? I realise it needs to go into the child theme functions.php file and would like to know the correct code to use. Am using the latest version of Pro.

<!--
/**
 * @license
 * MyFonts Webfont Build ID xxxxxxxx, 2017-12-07T18:25:22-0500
 * 
 * The fonts listed in this notice are subject to the End User License
 * Agreement(s) entered into by the website owner. All other parties are 
 * explicitly restricted from using the Licensed Webfonts(s).
 * 
 * You may obtain a valid license at the URLs below.
 * 
 * Webfont: ArialRoundedMTPro-Bold by Monotype 
 * URL: https://www.myfonts.com/fonts/mti/arial-rounded/pro-rounded-bold/
 * Copyright: Font software Copyright 1991 Adobe Systems Incorporated. Typeface designs
 * Copyright 1991 The Monotype Corporation. All rights reserved.
 * Licensed pageviews: 250,000
 * 
 * 
 * License: https://www.myfonts.com/viewlicense?type=web&buildid=xxxxxxx
 * 
 * © 2017 MyFonts Inc
*/

-->

<script type="text/javascript">
//uncomment and change this to false if you're having trouble with WOFFs
//var woffEnabled = true;
//to place your webfonts in a custom directory 
//uncomment this and set it to where your webfonts are.
//var customPath = "/themes/fonts";
</script>
<script type="text/javascript" src="MyFontsWebfontsKit.js"></script>

I have searched back and read through https://theme.co/apex/forum/t/problem-with-myfontswebfontskit/436 I know I am daft and just cannot get it…

Help would be much appreciated

RickM
NZ

Hello @Bell_Lodge,

Thanks for writing in! :slight_smile:

I’ll provide you the complete code below. All you need to do is add this into functions.php of your child theme.

function third_party_tracking_code() { ?>
<script type="text/javascript">
//uncomment and change this to false if you're having trouble with WOFFs
//var woffEnabled = true;
//to place your webfonts in a custom directory 
//uncomment this and set it to where your webfonts are.
//var customPath = "/themes/fonts";
</script>
<script type="text/javascript" src="MyFontsWebfontsKit.js"></script>
} 

add_action( 'wp_head', 'third_party_tracking_code' );

Hope that helps.

1 Like

Fabulous @jumar, Can never see how this php & js stuff works…

That did the job…

Cheers

RickM
NZ

If you need anything else please let us know.

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