/test-plugin-webfonts.php Secret
Created
April 19, 2022 13:21
Test Plugin that programmatically registers a normal and italic Source Sans Pro with the Webfonts API
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 | |
/** | |
Plugin Name: Test Webfonts | |
Plugin URI: http://wordpress.org/plugins/test-plugin/ | |
Description: Testing programmatically register webfonts from a plugin. | |
Author: me | |
Version: 1.0 | |
*/ | |
add_action( | |
'after_setup_theme', | |
function() { | |
$webfonts = array( | |
array( | |
'font-family' => 'Source Sans Pro', | |
'font-style' => 'normal', | |
'font-stretch' => 'normal', | |
'font-weight' => '400', | |
'src' => 'http://localhost:8889/src/wp-content/plugins/test-plugin-webfonts/assets/fonts/SourceSansPro-Regular.ttf', | |
), | |
array( | |
'font-family' => 'Source Sans Pro', | |
'font-style' => 'normal', | |
'font-stretch' => 'italic', | |
'font-weight' => '400', | |
'src' => 'http://localhost:8889/src/wp-content/plugins/test-plugin-webfonts/assets/fonts/SourceSansPro-Italic.ttf', | |
) | |
); | |
wp_register_webfonts( $webfonts ); | |
}, | |
99 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment