Example #1
0
 static function generate_fonts()
 {
     if (is_array(self::$fonts)) {
         $protocol = is_ssl() ? 'https' : 'http';
         $generate_font_req = '';
         $generate_font_css = '';
         foreach (self::$fonts as $name => $font) {
             $custom = false;
             # check for ot default google fonts
             $ot_font = Bw::get_option($name . '_font');
             if (!empty($ot_font)) {
                 $font['font'] = $ot_font;
             }
             # check for ot declared fonts
             $ot_font_declaration = Bw::get_option($name . '_font_declaration');
             if (!empty($ot_font_declaration)) {
                 $font['font'] = $ot_font_declaration;
                 $custom = true;
             }
             if ($font['font']) {
                 $generate_font_req[] = str_replace(" ", "+", $font['font']);
                 $rule = join(',', $font['selectors']);
                 $generate_font_css .= $custom ? "{$rule}{font:{$font['font']}}" : "{$rule}{font-family:'{$font['font']}'}";
             }
         }
         $output_css = join('|', $generate_font_req);
         wp_enqueue_style('google-fonts', "{$protocol}://fonts.googleapis.com/css?family={$output_css}");
         Bw::add_css($generate_font_css);
     }
 }