Esempio n. 1
0
/**
 * Get Base Font (Google Font)
 */
function tamatebako_fonts_mce_google_fonts_url()
{
    /* var */
    $google_fonts = array();
    $fonts_subsets = array();
    $fonts = tamatebako_fonts_mce_fonts();
    /* Foreach fonts get data. */
    foreach ($fonts as $font_name => $font_data) {
        $font = tamatebako_fonts_remove_websafe($font_name);
        if (!empty($font)) {
            $google_fonts[$font_name] = $font_data;
            /* subsets. */
            $get_font_subsets = tamatebako_get_font_subsets($font_name);
            if (!empty($get_font_subsets)) {
                foreach ($get_font_subsets as $subset) {
                    $fonts_subsets[] = $subset;
                }
            }
        }
    }
    /* get available subset. */
    $subsets_settings = tamatebako_fonts_subsets();
    $subsets = array_intersect($subsets_settings, $fonts_subsets);
    $url = tamatebako_google_fonts_url($google_fonts, $subsets);
    return $url;
}
Esempio n. 2
0
/**
 * Enqueue Google Font In Customizer
 */
function tametebako_fonts_customize_styles()
{
    /* default var. */
    $google_fonts = array();
    /* get all google fonts */
    $fonts = tamatebako_fonts_google();
    /* Foreach google fonts add it, */
    foreach ($fonts as $fonts_name => $fonts_data) {
        /* Do not add weight/style. just need the normal font. */
        $google_fonts[$fonts_name] = '';
    }
    wp_enqueue_style('tamatebako-fonts-customizer', tamatebako_google_fonts_url($google_fonts));
}
Esempio n. 3
0
/**
 * Return Google Font URL containing all fonts used.
 */
function tamatebako_fonts_all_google_url()
{
    /* Get fonts config */
    $config = tamatebako_fonts_config();
    /* Vars: List of all fonts used */
    $fonts = array();
    $fonts_subsets = array();
    /* Foreach setting */
    foreach ($config as $section => $section_data) {
        /* Get font saved. */
        $font = tamatebako_fonts_remove_websafe(get_theme_mod($section, $section_data['default']));
        if (!empty($font)) {
            $fonts[$font] = tamatebako_get_font_weight($font);
            /* subsets. */
            $get_font_subsets = tamatebako_get_font_subsets($font);
            if (!empty($get_font_subsets)) {
                foreach ($get_font_subsets as $subset) {
                    $fonts_subsets[] = $subset;
                }
            }
        }
    }
    if (!empty($fonts)) {
        /* get available subset. */
        $subsets_settings = tamatebako_fonts_subsets();
        $subsets = array_intersect($subsets_settings, $fonts_subsets);
        /* return url */
        return tamatebako_google_fonts_url($fonts, $subsets);
    }
    return '';
}