function jeg_get_font_string()
{
    $fontname = $_REQUEST['fontname'];
    $styles = jeg_extract_value(vp_get_gwf_style($fontname));
    $weight = jeg_extract_value(vp_get_gwf_weight($fontname));
    $fonturl = "https://fonts.googleapis.com/css?family=";
    $farray = array();
    foreach ($styles as $fontstyle) {
        foreach ($weight as $fontweight) {
            if ($fontweight == 'normal') {
                $fontweight = 400;
            }
            $farray[] = $fontweight . $fontstyle;
        }
    }
    if (empty($farray)) {
        $fullfonturl = $fonturl . $fontname;
    } else {
        $fullfonturl = $fonturl . $fontname . ":" . implode(',', $farray);
    }
    echo $fullfonturl;
    exit;
}
Beispiel #2
0
function jeg_font_setup()
{
    $fontarray = array();
    // style schema
    $style = get_theme_mod('switch_style');
    switch ($style) {
        case 'flat':
            // flat
            $fontarray[0] = array('fontname' => 'Open Sans', 'fontstyle' => array('normal'), 'fontweight' => array('300', '400', '700'));
            $fontarray[1] = array('fontname' => 'Raleway', 'fontstyle' => array('normal', 'italic'), 'fontweight' => array('300', '400', '700'));
            break;
        case 'dark':
            // dark
            break;
        case 'hotel':
        case 'normal':
        default:
            $fontarray[0] = array('fontname' => 'Open Sans', 'fontstyle' => array('normal'), 'fontweight' => array('300', '400', '700'));
            $fontarray[1] = array('fontname' => 'Lato', 'fontstyle' => array('normal'), 'fontweight' => array('400', '700'));
            $fontarray[2] = array('fontname' => 'Playfair Display', 'fontstyle' => array('normal, italic'), 'fontweight' => array('400'));
            break;
    }
    if (!jeg_check_use_font_uploader('additional_font_1')) {
        $firstfont = get_theme_mod('first_font');
        if (!empty($firstfont)) {
            $fontarray[0] = array('fontname' => $firstfont, 'fontstyle' => jeg_extract_value(vp_get_gwf_style($firstfont)), 'fontweight' => jeg_extract_value(vp_get_gwf_weight($firstfont)));
        }
    }
    if (!jeg_check_use_font_uploader('additional_font_2')) {
        $secondfont = get_theme_mod('second_font');
        if (!empty($secondfont)) {
            $fontarray[1] = array('fontname' => $secondfont, 'fontstyle' => jeg_extract_value(vp_get_gwf_style($secondfont)), 'fontweight' => jeg_extract_value(vp_get_gwf_weight($secondfont)));
        }
    }
    if (!jeg_check_use_font_uploader('additional_font_3')) {
        $thirdfont = get_theme_mod('third_font');
        if (!empty($thirdfont)) {
            $fontarray[2] = array('fontname' => $thirdfont, 'fontstyle' => jeg_extract_value(vp_get_gwf_style($thirdfont)), 'fontweight' => jeg_extract_value(vp_get_gwf_weight($thirdfont)));
        }
    }
    jeg_build_font($fontarray);
}