Esempio n. 1
0
// 2. Remove 'italic' from setting output if it exists to provide us with just
//    the weight to work with.
// 3. Get the font stack.
//
$x_body_font_is_italic = x_is_font_italic($x_body_font_weight_and_style);
$x_headings_font_is_italic = x_is_font_italic($x_headings_font_weight_and_style);
$x_logo_font_is_italic = x_is_font_italic($x_logo_font_weight_and_style);
$x_navbar_font_is_italic = x_is_font_italic($x_navbar_font_weight_and_style);
$x_body_font_weight = x_get_font_weight($x_body_font_weight_and_style);
$x_headings_font_weight = x_get_font_weight($x_headings_font_weight_and_style);
$x_logo_font_weight = x_get_font_weight($x_logo_font_weight_and_style);
$x_navbar_font_weight = x_get_font_weight($x_navbar_font_weight_and_style);
$x_body_font_stack = x_get_font_data($x_body_font_family, 'stack');
$x_headings_font_stack = x_get_font_data($x_headings_font_family, 'stack');
$x_logo_font_stack = x_get_font_data($x_logo_font_family, 'stack');
$x_navbar_font_stack = x_get_font_data($x_navbar_font_family, 'stack');
// Header
// =============================================================================
$x_navbar_positioning = x_get_navbar_positioning();
$x_logo_adjust_navbar_top = x_get_option('x_logo_adjust_navbar_top');
$x_logo_adjust_navbar_side = x_get_option('x_logo_adjust_navbar_side');
$x_logo_navigation_layout = x_get_option('x_logo_navigation_layout');
$x_logobar_adjust_spacing_top = x_get_option('x_logobar_adjust_spacing_top');
$x_logobar_adjust_spacing_bottom = x_get_option('x_logobar_adjust_spacing_bottom');
$x_navbar_width = x_get_option('x_navbar_width');
$x_navbar_height = x_get_option('x_navbar_height');
$x_navbar_adjust_links_top = x_get_option('x_navbar_adjust_links_top');
$x_navbar_adjust_links_top_spacing = x_get_option('x_navbar_adjust_links_top_spacing');
$x_navbar_adjust_links_side = x_get_option('x_navbar_adjust_links_side');
$x_navbar_adjust_button = x_get_option('x_navbar_adjust_button');
$x_navbar_adjust_button_size = x_get_option('x_navbar_adjust_button_size');
Esempio n. 2
0
function x_get_google_fonts_request()
{
    //
    // Raw data.
    //
    $body_family = x_get_google_fonts_family_query(x_get_option('x_body_font_family'));
    $body_weight_style = x_get_option('x_body_font_weight');
    $body_weight = x_get_font_weight($body_weight_style);
    $body_key = sanitize_key($body_family);
    $headings_family = x_get_google_fonts_family_query(x_get_option('x_headings_font_family'));
    $headings_weight_style = x_get_option('x_headings_font_weight');
    $headings_weight = x_get_font_weight($headings_weight_style);
    $headings_key = sanitize_key($headings_family);
    $logo_family = x_get_google_fonts_family_query(x_get_option('x_logo_font_family'));
    $logo_weight_style = x_get_option('x_logo_font_weight');
    $logo_weight = x_get_font_weight($logo_weight_style);
    $logo_key = sanitize_key($logo_family);
    $navbar_family = x_get_google_fonts_family_query(x_get_option('x_navbar_font_family'));
    $navbar_weight_style = x_get_option('x_navbar_font_weight');
    $navbar_weight = x_get_font_weight($navbar_weight_style);
    $navbar_key = sanitize_key($navbar_family);
    //
    // Refined data.
    //
    $fonts = array();
    $fonts[$body_key] = array('name' => $body_family, 'weights' => array(), 'source' => x_get_font_data($body_family, 'source'));
    $fonts[$headings_key] = array('name' => $headings_family, 'weights' => array(), 'source' => x_get_font_data($headings_family, 'source'));
    $fonts[$logo_key] = array('name' => $logo_family, 'weights' => array(), 'source' => x_get_font_data($logo_family, 'source'));
    $fonts[$navbar_key] = array('name' => $navbar_family, 'weights' => array(), 'source' => x_get_font_data($navbar_family, 'source'));
    array_push($fonts[$body_key]['weights'], $body_weight, $body_weight . 'italic', '700', '700italic');
    array_push($fonts[$headings_key]['weights'], $headings_weight_style);
    array_push($fonts[$logo_key]['weights'], $logo_weight_style);
    array_push($fonts[$navbar_key]['weights'], $navbar_weight_style);
    $fonts[$body_key]['weights'] = array_unique($fonts[$body_key]['weights']);
    $fonts[$headings_key]['weights'] = array_unique($fonts[$headings_key]['weights']);
    $fonts[$logo_key]['weights'] = array_unique($fonts[$logo_key]['weights']);
    $fonts[$navbar_key]['weights'] = array_unique($fonts[$navbar_key]['weights']);
    //
    // Families.
    //
    $families = '';
    foreach ($fonts as $slug => $data) {
        if ($data['source'] != 'google') {
            continue;
        }
        $families .= $data['name'] . ':';
        foreach ($data['weights'] as $weight) {
            $families .= $weight . ',';
        }
        $families = rtrim($families, ',') . '|';
    }
    $families = rtrim($families, '|');
    //
    // Subsets.
    //
    $subsets = 'latin,latin-ext';
    if (x_get_option('x_google_fonts_subsets') == '1') {
        if (x_get_option('x_google_fonts_subset_cyrillic') == '1') {
            $subsets .= ',cyrillic,cyrillic-ext';
        }
        if (x_get_option('x_google_fonts_subset_greek') == '1') {
            $subsets .= ',greek,greek-ext';
        }
        if (x_get_option('x_google_fonts_subset_vietnamese') == '1') {
            $subsets .= ',vietnamese';
        }
    }
    //
    // Request (returns and empty string if Google Fonts are not used).
    //
    $args = array('family' => $families, 'subset' => $subsets);
    $request = x_is_google_fonts_used() ? add_query_arg($args, '//fonts.googleapis.com/css') : '';
    return $request;
}