Add google fonts to theme options
<?php | |
// Defines the font stacks displayed in Theme Options | |
function st_custom_theme_fonts() { | |
$default = array( | |
'lato' => 'Lato', | |
'helvetica' => 'Helvetica', | |
'arial' => 'Arial', | |
'tahoma' => 'Tahoma', | |
'georgia' => 'Georgia', | |
'cambria' => 'Cambria', | |
'palatino' => 'Palatino', | |
'droidsans' => 'Droid Sans', | |
'droidserif' => 'Droid Serif' | |
); | |
return $default; | |
} | |
add_filter( 'of_recognized_font_faces', 'st_custom_theme_fonts' ); | |
// Defines the font stacks used in CSS | |
function st_custom_font_stacks() { | |
$default = array( | |
'lato' => '"Lato", sans-serif', | |
'helvetica' => '"HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif', | |
'arial' => 'Arial, Helvetica, sans-serif', | |
'georgia' => 'Constantia, "Lucida Bright", Lucidabright, "Lucida Serif", Lucida, "DejaVu Serif", "Bitstream Vera Serif", "Liberation Serif", Georgia, serif', | |
'cambria' => 'Cambria, "Hoefler Text", Utopia, "Liberation Serif", "Nimbus Roman No9 L Regular", Times, "Times New Roman", serif', | |
'tahoma' => 'Tahoma, Verdana, Segoe, sans-serif', | |
'palatino' => '"Palatino Linotype", Palatino, Baskerville, Georgia, serif', | |
'droidsans' => '"Droid Sans", sans-serif', | |
'droidserif' => '"Droid Serif", serif', | |
); | |
return $default; | |
} | |
add_filter( 'st_font_faces', 'st_custom_font_stacks' ); | |
// Load Google Fonts | |
// Add multiple fonts with the Pipe "|" character | |
// Example: family?family=Font+Name1:variants|Font+Name2:variants | |
function st_load_google_fonts() { | |
wp_register_style('googleFonts', 'http://fonts.googleapis.com/css?family=Lato:100,300,400'); | |
wp_enqueue_style( 'googleFonts'); | |
} | |
add_action('wp_print_styles', 'st_load_google_fonts'); | |
// Adds additional settings to use specific font weights | |
function st_font_weights() { | |
$default = array( | |
'normal' => 'Normal', | |
'italic' => 'Italic', | |
'bold' => 'Bold', | |
'bold italic' => 'Bold Italic', | |
'100' => '100', | |
'200' => '200', | |
'300' => '300', | |
'400' => '400', | |
'500' => '500', | |
'600' => '600', | |
'700' => '700', | |
'800' => '800' | |
); | |
return $default; | |
} | |
add_filter( 'of_recognized_font_styles', 'st_font_weights' ); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment