/** * 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; }
/** * 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 ''; }