Example #1
0
 /**
  * Checks if a given mod is Font Family
  *
  * @return bool
  */
 function quest_is_font_family($mod)
 {
     return quest_string_ends_with($mod, 'font_family') || quest_string_ends_with($mod, 'font_variant');
 }
Example #2
0
 public function enqueue_fonts()
 {
     $fonts = array('typography_global_font_family' => quest_get_mod('typography_global_font_family'), 'typography_global_font_variant' => quest_get_mod('typography_global_font_variant'), 'typography_heading_h1_font_family' => quest_get_mod('typography_heading_h1_font_family'), 'typography_heading_h1_font_variant' => quest_get_mod('typography_heading_h1_font_variant'), 'typography_heading_h2_font_family' => quest_get_mod('typography_heading_h2_font_family'), 'typography_heading_h2_font_variant' => quest_get_mod('typography_heading_h2_font_variant'), 'typography_heading_h3_font_family' => quest_get_mod('typography_heading_h3_font_family'), 'typography_heading_h3_font_variant' => quest_get_mod('typography_heading_h3_font_variant'), 'typography_heading_h4_font_family' => quest_get_mod('typography_heading_h4_font_family'), 'typography_heading_h4_font_variant' => quest_get_mod('typography_heading_h4_font_variant'), 'typography_heading_h5_font_family' => quest_get_mod('typography_heading_h5_font_family'), 'typography_heading_h5_font_variant' => quest_get_mod('typography_heading_h5_font_variant'), 'typography_heading_h6_font_family' => quest_get_mod('typography_heading_h6_font_family'), 'typography_heading_h6_font_variant' => quest_get_mod('typography_heading_h6_font_variant'), 'typography_menu_font_family' => quest_get_mod('typography_menu_font_family'), 'typography_menu_font_variant' => quest_get_mod('typography_menu_font_variant'), 'typography_menu_sub_font_family' => quest_get_mod('typography_menu_sub_font_family'), 'typography_menu_sub_font_variant' => quest_get_mod('typography_menu_sub_font_variant'), 'typography_site_title_font_family' => quest_get_mod('typography_site_title_font_family'), 'typography_site_title_font_variant' => quest_get_mod('typography_site_title_font_variant'), 'typography_site_tagline_font_family' => quest_get_mod('typography_site_tagline_font_family'), 'typography_site_tagline_font_variant' => quest_get_mod('typography_site_tagline_font_variant'), 'typography_sidebar_title_font_family' => quest_get_mod('typography_sidebar_title_font_family'), 'typography_sidebar_title_font_variant' => quest_get_mod('typography_sidebar_title_font_variant'), 'typography_sidebar_body_font_family' => quest_get_mod('typography_sidebar_body_font_family'), 'typography_sidebar_body_font_variant' => quest_get_mod('typography_sidebar_body_font_variant'), 'typography_footer_title_font_family' => quest_get_mod('typography_footer_title_font_family'), 'typography_footer_title_font_variant' => quest_get_mod('typography_footer_title_font_variant'), 'typography_footer_body_font_family' => quest_get_mod('typography_footer_body_font_family'), 'typography_footer_body_font_variant' => quest_get_mod('typography_footer_body_font_variant'), 'typography_footer_text_font_family' => quest_get_mod('typography_footer_text_font_family'), 'typography_footer_text_font_variant' => quest_get_mod('typography_footer_text_font_variant'));
     $used_fonts = array();
     $defaults = array_keys(quest_get_standard_fonts());
     foreach ($fonts as $key => $value) {
         if (quest_string_ends_with($key, '_family') && trim($value) !== "" && !in_array($value, $defaults)) {
             $variant = quest_get_default_mod(str_replace('_family', '_variant', $key), $fonts);
             $used_fonts[$value] = array_key_exists($value, $used_fonts) ? strpos($used_fonts[$value], $variant) !== false ? $used_fonts[$value] : "{$used_fonts[$value]},{$variant}" : "{$value}:{$variant}";
         }
     }
     $protocol = is_ssl() ? 'https' : 'http';
     $query_args = array('family' => str_replace(" ", "+", implode('|', array_values($used_fonts))), 'subset' => implode(',', quest_get_mod('typography_options_subsets')));
     wp_enqueue_style('google-fonts', add_query_arg($query_args, "{$protocol}://fonts.googleapis.com/css"), array(), null);
 }
Example #3
0
 public function EnqueueFonts()
 {
     $mods = quest_get_mods();
     $fonts = array_intersect_key($mods, array_flip(array_filter(array_keys($mods), 'quest_is_font_family')));
     $used_fonts = array();
     $defaults = array_keys(quest_get_standard_fonts());
     foreach ($fonts as $key => $value) {
         if (quest_string_ends_with($key, '_family') && trim($value) !== "" && !in_array($value, $defaults)) {
             $variant = quest_get_default_mod(str_replace('_family', '_variant', $key), $fonts);
             $used_fonts[$value] = array_key_exists($value, $used_fonts) ? strpos($used_fonts[$value], $variant) !== false ? $used_fonts[$value] : "{$used_fonts[$value]},{$variant}" : "{$value}:{$variant}";
         }
     }
     $protocol = is_ssl() ? 'https' : 'http';
     wp_enqueue_style('google-fonts', "{$protocol}://fonts.googleapis.com/css?family=" . implode('|', array_values($used_fonts)), false, false);
 }