/** * Get the name for a font face to be used within the CSS. * * @since 2.0.0 * * @param array $option Current option set by user for the font * @return string $stack CSS value for font-name property */ function themeblvd_get_font_face($option) { $stack = ''; $stacks = themeblvd_font_stacks(); if ($option['face'] == 'google') { // Grab font face, making sure they didn't do the // super, sneaky trick of including font weight or type. $name = explode(':', $option['google']); // And also check for accidental space at end $name = themeblvd_remove_trailing_char($name[0]); // Add the deafult font stack to the end of the // google font. $stack = $name . ', ' . $stacks['default']; } else { $stack = $stacks[$option['face']]; } return apply_filters('themeblvd_font_face', $stack, $option, $stacks); }
/** * Font Prep for customizer preview * * Since the Javascript for fonts will get repeated in * many themes, its being placed here so it can be easily * placed in each theme that requires it. * * This function sets up some objects we can use throughout * all of our font options. * * @since 2.1.0 */ function themeblvd_customizer_preview_font_prep() { // Global option name $option_name = themeblvd_get_option_name(); // Setup font stacks $font_stacks = themeblvd_font_stacks(); unset($font_stacks['google']); // Determine current google fonts with fake // booleans to be used in printed JS object. $types = array('body', 'header', 'special'); $google_fonts = array(); foreach ($types as $type) { $font = themeblvd_get_option('typography_' . $type); $google_fonts[$type . 'Name'] = !empty($font['google']) && $font['google'] ? $font['google'] : ''; $google_fonts[$type . 'Toggle'] = !empty($font['face']) && $font['face'] == 'google' ? 'true' : 'false'; } ?> // Font stacks fontStacks = <?php echo json_encode($font_stacks); ?> ; // Google font toggles googleFonts = <?php echo json_encode($google_fonts); ?> ; <?php }