/** * Generates CSS to preview Typography Fonts families * * @return void */ public static function fonts_families_preview() { if (!option::is_on('framework_fonts_preview')) { return; } $css = ''; $fonts = ''; $font_families = ui::recognized_font_families(); $google_font_families = ui::recognized_google_webfonts_families(); foreach ($font_families as $slug => $font) { $css .= '.selectBox-dropdown-menu a[rel=' . $slug . ']{font-family:' . $font . ';}'; } foreach ($google_font_families as $font) { if (isset($font['separator'])) { continue; } $slug = str_replace(' ', '-', strtolower($font['name'])); $css .= '.selectBox-dropdown-menu a[rel=' . $slug . ']{font-family:' . $font['name'] . ';}'; $fonts .= $font['name'] . '|'; } $fonts = str_replace(" ", "+", $fonts); $google_css = '@import url("http' . (is_ssl() ? 's' : '') . '://fonts.googleapis.com/css?family=' . $fonts . "\");\n"; $google_css = str_replace('|"', '"', $google_css); echo '<style type="text/css">'; echo $google_css; echo $css; echo '</style>'; }
public function typography($args) { extract($args); $selected_value = is_array(option::get($id)) ? option::get($id) : array(); $out .= '<div class="zoom-typography">'; $out .= "<label>{$name}</label>"; /* fonts */ $font_families = ui::recognized_font_families($id); $google_font_families = ui::recognized_google_webfonts_families($id); $font_family = isset($selected_value['font-family']) ? $selected_value['font-family'] : ''; $out .= '<select name="' . $id . '[font-family]" id="' . $id . '-family" class="zoom-typography-family">'; $out .= '<optgroup label="Web Safe Fonts">'; $out .= '<option value="">font-family</option>'; foreach ($font_families as $key => $value) { $out .= '<option value="' . esc_attr($key) . '" ' . selected($font_family, $key, false) . '>' . esc_attr($value) . '</option>'; } $out .= '</optgroup>'; $out .= '<optgroup label="Google Web Fonts">'; foreach ($google_font_families as $value) { if (isset($value['separator'])) { $out .= '<option value="" disabled="disabled">' . $value['separator'] . '</option>'; continue; } $key = str_replace(' ', '-', strtolower($value['name'])); $out .= '<option value="' . esc_attr($key) . '" ' . selected($font_family, $key, false) . '>' . esc_attr($value['name']) . '</option>'; } $out .= '</optgroup>'; $out .= '</select>'; /* style */ $font_styles = ui::recognized_font_styles($id); $font_style = isset($selected_value['font-style']) ? $selected_value['font-style'] : ''; $out .= '<select name="' . $id . '[font-style]" id="' . $id . '-style" class="zoom-typography-style">'; $out .= '<option value="">font-style</option>'; foreach ($font_styles as $key => $value) { $out .= '<option value="' . esc_attr($key) . '" ' . selected($font_style, $key, false) . '>' . esc_attr($value) . '</option>'; } $out .= '</select>'; /* sizing */ $font_size = isset($selected_value['font-size']) ? $selected_value['font-size'] : ''; $out .= '<select name="' . $id . '[font-size]" id="' . $id . '-size" class="zoom-typography-size">'; $out .= '<option value="">size</option>'; for ($i = 8; $i <= 72; $i++) { $size = $i . 'px'; $out .= '<option value="' . esc_attr($size) . '" ' . selected($font_size, $size, false) . '>' . esc_attr($size) . '</option>'; } $out .= '</select>'; /* color */ $font_color = isset($selected_value['font-color']) ? $selected_value['font-color'] : ''; $out .= '<div class="colorSelector"><div></div></div><input name="' . $id . '[font-color]" id="' . $id . '-color" class="txt input-text input-colourpicker zoom-typography-color" type="text" value="' . $font_color . '"></input>'; $out .= "<p>{$desc}</p>"; $out .= '</div><!-- /div.zoom-typography -->'; return $out; }
/** * Generates CSS for typography options from ZOOM Admin * * @param array $option * @return string The CSS */ public static function dynamic_typography_css($option) { $value = option::get($option['id']); if (!is_array($value)) { return ''; } $font = array(); if (isset($value['font-color']) && trim($value['font-color'])) { $font[] = "color: " . $value['font-color'] . ";"; } if (isset($value['font-family']) && trim($value['font-family'])) { $font_families = ui::recognized_font_families($option['id']); $google_font_families = ui::recognized_google_webfonts_families($option['id']); if (array_key_exists($value['font-family'], $font_families)) { $font[] = "font-family: " . $font_families[$value['font-family']] . ";"; } foreach ($google_font_families as $google_font_v) { if (isset($google_font_v['separator'])) { continue; } $key = str_replace(' ', '-', strtolower($google_font_v['name'])); if ($value['font-family'] == $key) { $font[] = "font-family: '" . $google_font_v['name'] . "';"; self::dynamic_google_webfonts_register($google_font_v); break; } } } if (isset($value['font-size']) && trim($value['font-size'])) { $font[] = "font-size: " . $value['font-size'] . ";"; } if (isset($value['font-style']) && trim($value['font-style'])) { if ($value['font-style'] == 'bold-italic') { $font[] = "font-style: italic;"; $font[] = "font-weight: bold;"; } elseif ($value['font-style'] == 'bold') { $font[] = "font-weight: bold;"; } else { $font[] = "font-style: " . $value['font-style'] . ";"; } } if (empty($font)) { return ''; } return $option['selector'] . '{' . implode('', $font) . '}'; }