public static function get_all_fonts()
 {
     if (function_exists('wf_get_system_fonts') && function_exists('wf_get_google_fonts') && function_exists('wf_get_system_fonts_test_cases')) {
         $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);
         }
         return $font_faces;
     } else {
         // Declare default font list
         $font_list = array('Arial' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Century Gothic' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Courier New' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Georgia' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Helvetica' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Impact' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Lucida Console' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Lucida Sans Unicode' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Palatino Linotype' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'sans-serif' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'serif' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Tahoma' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Trebuchet MS' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')), 'Verdana' => array('weights' => array('100', '100italic', '400', '400italic', '700', '700italic')));
         $font_faces = array();
         foreach ($font_list as $k => $v) {
             $font_faces[$k] = $k;
         }
         return $font_faces;
     }
     //			//Build font list to return
     //			$fonts = array();
     //			foreach ( $font_list as $font => $attributes ) {
     //
     //				$urls = array();
     //
     //				// Get font properties from json array.
     //				foreach ( $attributes['weights'] as $variant ) {
     //					$urls[ $variant ] = "";
     //				}
     //
     //				// Create a font array containing it's properties and add it to the $fonts array
     //				$atts = array(
     //						'name'		 => $font,
     //						'font_type'	=> 'default',
     //						'font_weights' => $attributes['weights'],
     //						'subsets'	  => array(),
     //						'files'		=> array(),
     //						'urls'		 => $urls,
     //				);
     //
     //				// Add this font to all of the fonts
     //				$id		   = $font; //strtolower( str_replace( ' ', '_', $font ) );
     //				$fonts[ $id ] = $atts;
     //			}
     //
     //			// Filter to allow us to modify the fonts array before saving the transient
     //			$fonts = apply_filters( 'tt_font_default_fonts_array', $fonts );
     //
     //			// Return the font list
     //			return apply_filters( 'tt_font_get_default_fonts', $fonts );
 }
Ejemplo n.º 2
0
 public function google_webfonts()
 {
     if (!function_exists('wf_get_google_fonts')) {
         return;
     }
     $google_fonts = wf_get_google_fonts();
     $fonts_to_load = array();
     $output = '';
     // Go through the options
     if (!empty($this->options) && !empty($google_fonts)) {
         foreach ($this->options as $key => $option) {
             if (is_array($option) && $option['type'] == 'font') {
                 $fontFamilySettingId = $option['settings']['font_id'];
                 $fontFamilyDefault = $option['defaults']['font_id'];
                 $fontFamily = get_option($fontFamilySettingId, $fontFamilyDefault);
                 // Go through the google font array
                 foreach ($google_fonts as $font) {
                     // Check if the google font name exists in the current "face" option
                     if ($fontFamily == $font['name'] && !in_array($font['name'], array_keys($fonts_to_load))) {
                         // Add google font to output
                         $variant = '';
                         if (isset($font['variant'])) {
                             $variant = $font['variant'];
                         }
                         $fonts_to_load[$font['name']] = $variant;
                     }
                 }
             }
         }
         // Output google font css in header
         if (0 < count($fonts_to_load)) {
             $fonts_and_variants = array();
             foreach ($fonts_to_load as $k => $v) {
                 $fonts_and_variants[] = $k . $v;
             }
             $fonts_and_variants = array_map('urlencode', $fonts_and_variants);
             $fonts = join('|', $fonts_and_variants);
             $output .= "\n<!-- Google Webfonts -->\n";
             $output .= '<link href="http' . (is_ssl() ? 's' : '') . '://fonts.googleapis.com/css?family=' . $fonts . '" rel="stylesheet" type="text/css" />' . "\n";
             echo $output;
         }
     }
 }
Ejemplo n.º 3
0
 /**
  * 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;
 }
Ejemplo n.º 4
0
            unset($matches[$sz - 1]);
            return implode(' ', $matches) . " ...";
        }
        return $text;
    }
    // End woo_text_trim()
}
/*-----------------------------------------------------------------------------------*/
/* Google Webfonts Array */
/* Documentation:
/*
/* name: The name of the Google Font.
/* variant: The Google Font API variants available for the font.
/*-----------------------------------------------------------------------------------*/
// Available Google webfont names
$GLOBALS['google_fonts'] = wf_get_google_fonts();
/**
 * Return a filtered array of possible system fonts.
 * @since  6.0.0
 * @return array Possible system fonts.
 */
function wf_get_system_fonts()
{
    return (array) apply_filters('wf_get_system_fonts', array('Arial, sans-serif' => __('Arial', 'woothemes'), 'Verdana, Geneva, sans-serif' => __('Verdana', 'woothemes'), '&quot;Trebuchet MS&quot;, Tahoma, sans-serif' => __('Trebuchet', 'woothemes'), 'Georgia, serif' => __('Georgia', 'woothemes'), '&quot;Times New Roman&quot;, serif' => __('Times New Roman', 'woothemes'), 'Tahoma, Geneva, Verdana, sans-serif' => __('Tahoma', 'woothemes'), 'Palatino, &quot;Palatino Linotype&quot;, serif' => __('Palatino', 'woothemes'), '&quot;Helvetica Neue&quot;, Helvetica, sans-serif' => __('Helvetica *', 'woothemes'), 'Calibri, Candara, Segoe, Optima, sans-serif' => __('Calibri *', 'woothemes'), '&quot;Myriad Pro&quot;, Myriad, sans-serif' => __('Myriad Pro *', 'woothemes'), '&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, &quot;Lucida Sans&quot;, sans-serif' => __('Lucida', 'woothemes'), '&quot;Arial Black&quot;, sans-serif' => __('Arial Black', 'woothemes'), '&quot;Gill Sans&quot;, &quot;Gill Sans MT&quot;, Calibri, sans-serif' => __('Gill Sans *', 'woothemes'), 'Geneva, Tahoma, Verdana, sans-serif' => __('Geneva *', 'woothemes'), 'Impact, Charcoal, sans-serif' => __('Impact', 'woothemes'), 'Courier, &quot;Courier New&quot;, monospace' => __('Courier', 'woothemes'), '&quot;Century Gothic&quot;, sans-serif' => __('Century Gothic', 'woothemes')));
}
// End wf_get_system_fonts()
/**
 * Return a filtered array of possible system fonts test cases.
 * @since  6.0.0
 * @return array Possible system fonts test cases.
 */
 /**
  * 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;
 }