-
-
Save robneu/6400399 to your computer and use it in GitHub Desktop.
Enqueue typekit fonts to WordPress using wp_enqueue_scripts.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Enqueue typekit fonts into WordPress using wp_enqueue_scripts. | |
* | |
* @author Robert Neu | |
* @author Eric Fernandez | |
* @copyright Copyright (c) 2014, Robert Neu | |
* @license GPL-2.0+ | |
* @link http://typekit.com | |
*/ | |
add_action( 'wp_enqueue_scripts', 'prefix_enqueue_scripts' ); | |
/** | |
* Loads the main typekit Javascript. Replace your-id-here with the script name | |
* provided in your Kit Editor. | |
* | |
* @todo Replace prefix with your theme or plugin prefix | |
*/ | |
function prefix_enqueue_scripts() { | |
wp_enqueue_script( 'typekit', '//use.typekit.net/your-id-here.js', array(), '1.0.0' ); | |
} | |
add_action( 'wp_head', 'prefix_typekit_inline' ); | |
/** | |
* Check to make sure the main script has been enqueued and then load the typekit | |
* inline script. | |
* | |
* @todo Replace prefix with your theme or plugin prefix | |
*/ | |
function prefix_typekit_inline() { | |
if ( wp_script_is( 'typekit', 'enqueued' ) ) { | |
echo '<script type="text/javascript">try{Typekit.load();}catch(e){}</script>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment