function foundation_google_fonts_init()
{
    $settings = wptouch_get_settings('foundation');
    if ($settings->typography_sets != 'default') {
        wp_enqueue_script('foundation_google_fonts', foundation_get_base_module_url() . '/google-fonts/google-fonts.js', false, md5(FOUNDATION_VERSION), true);
        add_filter('wptouch_body_classes', 'foundation_add_google_font_classes');
    }
    $selected_font_info = foundation_google_fonts_get_selected_info();
    if ($selected_font_info) {
        $family_string = '';
        $inline_style_data = '';
        if (is_array($selected_font_info) && count($selected_font_info)) {
            $new_families = array();
            foreach ($selected_font_info as $font_info) {
                $font_string = htmlentities($font_info->name);
                if (isset($font_info->variants) && is_array($font_info->variants)) {
                    $font_string .= ':' . implode(',', $font_info->variants);
                }
                $new_families[] = $font_string;
                $inline_style_data .= "." . $font_info->selector . "-font" . " {\n";
                $inline_style_data .= "\tfont-family: '" . $font_info->name . "', " . $font_info->fallback . ";\n";
                $inline_style_data .= "}\n";
            }
            $family_string = implode('|', $new_families);
        }
        if ($family_string) {
            wp_enqueue_style('foundation_google_fonts', 'http://fonts.googleapis.com/css?family=' . $family_string, false, FOUNDATION_VERSION, false);
            if ($inline_style_data) {
                wp_add_inline_style('foundation_google_fonts', $inline_style_data);
            }
        }
    }
}
function foundation_build_google_fonts($fonts = array())
{
    $selected_font_info = foundation_google_fonts_get_selected_info();
    if (is_array($selected_font_info)) {
        foreach ($selected_font_info as $font_info) {
            $font_string = htmlentities($font_info->name);
            if (isset($font_info->variants) && is_array($font_info->variants)) {
                $font_string .= ':' . implode(',', $font_info->variants);
            }
            $fonts[$font_info->selector] = $font_string;
        }
    }
    return $fonts;
}
Exemple #3
0
function foundation_google_fonts_init()
{
    global $google_fonts_enabled;
    if ($google_fonts_enabled) {
        $settings = wptouch_get_settings('foundation');
        if ($settings->typography_sets != 'default') {
            wp_enqueue_script('foundation_google_fonts', foundation_get_base_module_url() . '/google-fonts/google-fonts.js', false, md5(FOUNDATION_VERSION), true);
            add_filter('wptouch_body_classes', 'foundation_add_google_font_classes');
        }
        $selected_font_info = foundation_google_fonts_get_selected_info();
        if ($selected_font_info) {
            $family_string = '';
            $inline_style_data = '';
            if (is_array($selected_font_info) && count($selected_font_info)) {
                $new_families = array();
                // Maintain the module's max of 2 fonts when rendering; we'll let ourselves register more font placements for selection in the advanced type module.
                if (count($selected_font_info) > 2) {
                    $selected_font_info = array_slice($selected_font_info, 0, 2);
                }
                foreach ($selected_font_info as $font_info) {
                    $font_string = htmlentities($font_info->name);
                    if (isset($font_info->variants) && is_array($font_info->variants)) {
                        $font_string .= ':' . implode(',', $font_info->variants);
                    }
                    $new_families[] = $font_string;
                    $inline_style_data .= "." . $font_info->selector . "-font" . " {\n";
                    $inline_style_data .= "\tfont-family: '" . $font_info->name . "', " . $font_info->fallback . ";\n";
                    $inline_style_data .= "}\n";
                }
                $family_string = implode('|', $new_families);
            }
            if ($family_string) {
                wp_enqueue_style('foundation_google_fonts', '//fonts.googleapis.com/css?family=' . $family_string, false, FOUNDATION_VERSION, false);
                if ($inline_style_data) {
                    wp_add_inline_style('foundation_google_fonts', $inline_style_data);
                }
            }
        }
    }
}