/** * Get Font Family Control * * Gets the font family select control. Will only show * the fonts from the applicable subset if it has been * selected. * * @uses EGF_Font_Utilities::get_google_fonts() defined in includes\class-egf-font-utilities * @uses EGF_Font_Utilities::get_default_fonts() defined in includes\class-egf-font-utilities * * @since 1.2 * @version 1.3.1 * */ public function get_font_family_control() { // Get defaults and current value $this_value = $this->value('font_id'); $default_value = $this->default['font_id']; $current_value = empty($this_value) ? '' : $this_value; // Get all font families $all_fonts = PootlePage_Font_Utility::get_all_fonts(); // Get control view ?> <label><?php _e('Font Family', 'scratch'); ?> <select class='sc-font-family-list' <?php $this->link('font_id'); ?> data-default-value="<?php echo $default_value; ?> " autocomplete="off"> <option value="" <?php selected($current_value, ''); ?> ><?php _e('— Default —', 'scratch'); ?> </option> <?php if (function_exists('wf_get_system_fonts_test_cases')) { $test_cases = wf_get_system_fonts_test_cases(); } else { $test_cases = array(); } //Font Options for select echo output_font_select_options($all_fonts, $test_cases, $current_value); ?> </select> </label> <?php }
function eighteen_tags_pro_google_fonts($value) { global $pootlepb_font; $font_faces = $pootlepb_font; $test_cases = array(); if (function_exists('wf_get_system_fonts_test_cases')) { $test_cases = wf_get_system_fonts_test_cases(); } $html = ''; foreach ($font_faces as $k => $v) { $selected = ''; // If one of the fonts requires a test case, use that value. Otherwise, use the key as the test case. if (in_array($k, array_keys($test_cases))) { $value_to_test = $test_cases[$k]; } else { $value_to_test = $k; } if (pootlepb_test_typeface_against_test_case($value, $value_to_test)) { $selected = ' selected="selected"'; } $html .= '<option value="' . esc_attr($k) . '" ' . $selected . '>' . esc_html($v) . '</option>' . "\n"; } return $html; }
/** * Render HTML markup for the "typography" field type. * @access protected * @since 6.0.0 * @param string $key The unique ID of this field. * @param array $args Arguments used to construct this field. * @return string HTML markup for the field. */ protected function render_field_typography($key, $args) { $this->_has_colourpicker = true; $this->_has_typography = true; $this->_has_select = true; $html = ''; $defaults = array('size' => get_option($key . '_size', ''), 'unit' => get_option($key . '_unit', ''), 'face' => get_option($key . '_face', ''), 'style' => get_option($key . '_style', ''), 'color' => get_option($key . '_color', '')); if (0 < count($defaults) && isset($args['std']) && is_array($args['std'])) { foreach ($defaults as $k => $v) { if ('' == $v && isset($args['std'][$k])) { $defaults[$k] = $args['std'][$k]; } } } $value = $this->get_value($key, $defaults); // Make sure we place our default values in if the key is empty. wp_parse_args() didn't seem to work for this. foreach ($defaults as $k => $v) { if (!isset($value[$k])) { $value[$k] = $defaults[$k]; } else { if ('' == $value[$k]) { $value[$k] = $defaults[$k]; } } } // Make sure the size fields are set correctly. if (!isset($value['size'])) { $value['size'] = $value['size_' . $value['unit']]; } $unit = $value['unit']; $html .= '<span class="unit-container ' . esc_attr('unit-' . sanitize_title_with_dashes($unit)) . '">' . "\n"; /* Size in Pixels */ $html .= '<select class="woo-typography woo-typography-size woo-typography-size-px hide-if-em" name="' . esc_attr($key . '[size_px]') . '" id="' . esc_attr($key . '_size') . '">' . "\n"; for ($i = 9; $i < floatval(apply_filters('wf_fields_typography_font_size_px_upper_limit', 71)); $i++) { $html .= '<option value="' . esc_attr($i) . '" ' . selected(floatval($value['size']), $i, false) . '>' . esc_html($i) . '</option>' . "\n"; } $html .= '</select>' . "\n"; /* Size in EMs */ $html .= '<select class="woo-typography woo-typography-size woo-typography-size-em hide-if-px" name="' . esc_attr($key . '[size_em]') . '" id="' . esc_attr($key . '_size') . '">' . "\n"; $em = 0; for ($i = 0; $i < 39; $i++) { if ($i <= 24) { // up to 2.0em in 0.1 increments $em = $em + 0.1; } elseif ($i >= 14 && $i <= 24) { // Above 2.0em to 3.0em in 0.2 increments $em = $em + 0.2; } elseif ($i >= 24) { // Above 3.0em in 0.5 increments $em = $em + 0.5; } $active = ''; if (strval($em) == $value['size']) { $active = 'selected="selected"'; } $html .= '<option value="' . esc_attr(floatval($em)) . '" ' . $active . '>' . esc_html($em) . '</option>'; } $html .= '</select>' . "\n"; /* Font Unit */ $unit = $value['unit']; $em = ''; $px = ''; if ('em' == $unit) { $em = 'selected="selected"'; } if ('px' == $unit) { $px = 'selected="selected"'; } $html .= '<select class="woo-typography woo-typography-unit" name="' . esc_attr($key . '[unit]') . '" id="' . esc_attr($key . '_unit') . '">' . "\n"; $html .= '<option value="px" ' . $px . '">px</option>' . "\n"; $html .= '<option value="em" ' . $em . '>em</option>' . "\n"; $html .= '</select>' . "\n"; /* Weights */ $font_weights = (array) apply_filters('wf_fields_typography_font_weights', array('300' => __('Thin', 'woothemes'), '300 italic' => __('Thin Italic', 'woothemes'), 'normal' => __('Normal', 'woothemes'), 'italic' => __('Italic', 'woothemes'), 'bold' => __('Bold', 'woothemes'), 'bold italic' => __('Bold/Italic', 'woothemes'))); if (0 < count($font_weights)) { $html .= '<select class="woo-typography woo-typography-font-weight woo-typography-style" name="' . esc_attr($key . '[style]') . '" id="' . esc_attr($key . '_style') . '">' . "\n"; foreach ($font_weights as $k => $v) { $html .= '<option value="' . esc_attr($k) . '" ' . selected($value['style'], $k, false) . '>' . esc_html($v) . '</option>' . "\n"; } $html .= '</select>' . "\n"; } /* Font Face */ $font_faces = wf_get_system_fonts(); $google_fonts = wf_get_google_fonts(); if (0 < count($google_fonts)) { $font_faces[''] = __('-- Google WebFonts --', 'woothemes'); $google_fonts_array = array(); foreach ($google_fonts as $k => $v) { $google_fonts_array[$v['name']] = $v['name']; } asort($google_fonts_array); $font_faces = array_merge($font_faces, $google_fonts_array); } if (0 < count($font_faces)) { $test_cases = wf_get_system_fonts_test_cases(); $html .= '<select class="woo-typography woo-typography-font-face woo-typography-face" name="' . esc_attr($key . '[face]') . '" id="' . esc_attr($key . '_face') . '">' . "\n"; foreach ($font_faces as $k => $v) { $selected = ''; // If one of the fonts requires a test case, use that value. Otherwise, use the key as the test case. if (in_array($k, array_keys($test_cases))) { $value_to_test = $test_cases[$k]; } else { $value_to_test = $k; } if ($this->_test_typeface_against_test_case($value['face'], $value_to_test)) { $selected = ' selected="selected"'; } $html .= '<option value="' . esc_attr($k) . '" ' . $selected . '>' . esc_html($v) . '</option>' . "\n"; } $html .= '</select>' . "\n"; } /* Border Color */ $html .= '<input id="' . esc_attr($key . '_color') . '" name="' . esc_attr($key . '[color]') . '" size="40" type="text" class="woo-typography-color colour" value="' . esc_attr($value['color']) . '" />' . "\n"; $html .= '</span>' . "\n"; return $html; }
/** * Outputs typography font face fields * * @param $key * @param $value * @return string */ public function typography_font_face($key, $value) { $html = ''; $font_faces = wf_get_system_fonts(); $google_fonts = wf_get_google_fonts(); if (0 < count($google_fonts)) { $font_faces[''] = __('-- Google WebFonts --', 'woothemes'); $google_fonts_array = array(); foreach ($google_fonts as $k => $v) { $google_fonts_array[$v['name']] = $v['name']; } asort($google_fonts_array); $font_faces = array_merge($font_faces, $google_fonts_array); } if (0 < count($font_faces)) { $test_cases = wf_get_system_fonts_test_cases(); $html .= '<select class="woo-typography woo-typography-font-face woo-typography-face" name="' . esc_attr($key . '[face]') . '" id="' . esc_attr($key . '_face') . '">' . "\n"; //Font Options for select $html .= output_font_select_options($font_faces, $test_cases, $value['face']); $html .= '</select>' . "\n"; } return $html; }