public function __construct($name, $default, array $properties = array()) { parent::__construct($name, $default, $properties); self::$instances[] = $this; if (!self::$google_fonts && !(self::$google_fonts = get_transient(Theme::getInstance()->getTransientName('google_fonts')))) { self::$google_fonts = Func::googleGetFonts(Func::GOOGLE_API_KEY); if (self::$google_fonts === false) { self::$google_fonts = unserialize(@file_get_contents(get_template_directory() . '/' . \Drone\DIRECTORY . '/odd/google-fonts.dat')); } $expiration = Func::intRandJitter(self::GOOGLE_FONTS_UPDATE_INTERVAL, self::GOOGLE_FONTS_UPDATE_INTERVAL_JITTER) * 86400; set_transient(Theme::getInstance()->getTransientName('google_fonts'), self::$google_fonts, $expiration); } $this->family->on_sanitize = function ($option, $original_value, &$value) { $value = (string) $original_value; }; $this->family->on_html = function ($option, &$html) { $html->data('value', $option->value); $i = 0; foreach (array('web_safe', 'google_fonts', 'custom_fontface') as $type) { if ($option->parent->{'allow_' . $type}) { $html->child($i)->data('type', $type); $i++; } } }; if ($this->allow_web_safe) { $this->family->groups[__('Classic web fonts', $this->domain)] = array(); } if ($this->allow_google_fonts) { $this->family->groups[__('Google Fonts', $this->domain)] = array(); } if ($this->allow_custom_fontface) { $this->family->groups[__('Custom font-face', $this->domain)] = array(); } if (isset($this->color)) { $this->color->required = false; $this->color->placeholder = __('default', $this->domain); } if (isset($this->size)) { $this->size->unit = $this->size_unit; switch ($this->size_unit) { case 'px': case 'pt': $this->size->min = 0; $this->size->max = 100; break; case 'em': $this->size->float = true; $this->size->min = 0; $this->size->max = 10; break; case '%': $this->size->float = true; $this->size->min = 0; $this->size->max = 1000; break; } } if (isset($this->line_height)) { $this->line_height->unit = $this->line_height_unit; switch ($this->line_height_unit) { case 'px': case 'pt': $this->line_height->min = 0; $this->line_height->max = 100; break; case 'em': case '': $this->line_height->float = true; $this->line_height->min = 0; $this->line_height->max = 10; break; case '%': $this->line_height->float = true; $this->line_height->min = 0; $this->line_height->max = 1000; break; } } if (isset($this->styles)) { $this->styles->multiple = true; $this->styles->style = 'horizontal'; $this->styles->options = array('bold' => __('Bold', $this->domain), 'italic' => __('Italic', $this->domain), 'underline' => __('Underline', $this->domain)); } }