public function get_css_font_family($value = false)
 {
     if (!$value) {
         return '';
     }
     if (is_array($value)) {
         $value = $value['font_family'];
     }
     // Todo: Validate this!!!
     $font = json_decode($value);
     if (!empty($font->family)) {
         $value = $font->family;
     }
     if (isset($font->import_family)) {
         $styles = Styles_Plugin::get_instance();
         $styles->css->google_fonts[$value] = "@import url(//fonts.googleapis.com/css?family={$font->import_family});\r";
     }
     $css = '';
     if ($value) {
         $args = array('template' => $this->template_font_family, 'value' => $value);
         $css = $this->apply_template($args);
     }
     // Filter effects final CSS output, but not postMessage updates
     return apply_filters('styles_css_font_family', $css);
 }
 /**
  * Maybe instantiate, then return instance of this class.
  * @return Styles_Plugin Controller instance.
  */
 public static function get_instance()
 {
     if (!is_a(self::$instance, __CLASS__)) {
         self::$instance = true;
         self::$instance = new self();
         self::$instance->init();
     }
     return self::$instance;
 }
Exemplo n.º 3
0
 /**
  * Rebuild CSS
  *
  * Cache check called in Styles_Plugin::get_css to avoid initializing this class
  */
 public function get_css()
 {
     global $wp_customize;
     $css = '';
     $this->plugin->customize_register($wp_customize);
     foreach ($this->plugin->customize->get_settings() as $group => $elements) {
         foreach ($elements as $element) {
             if ($class = Styles_Helpers::get_element_class($element)) {
                 $element = apply_filters('styles_pre_get_css', $element);
                 $control = new $class($group, $element);
                 $css .= $control->get_css();
             }
         }
     }
     $css = apply_filters('styles_css_output', $css);
     $css = implode('', $this->google_fonts) . $css;
     $css = $this->minify($css);
     update_option(Styles_Helpers::get_option_key('css'), $css);
     return $css;
 }
Exemplo n.º 4
0
 /**
  * Load view for setting, passing arguments
  */
 public function display_setting($args = array())
 {
     $id = $type = $default = false;
     extract($args, EXTR_IF_EXISTS);
     $options = get_option('storm-styles');
     if (!isset($options[$id])) {
         $options[$id] = $default;
     }
     $args['option_value'] = $options[$id];
     $args['option_name'] = 'storm-styles' . '[' . $id . ']';
     $template = 'setting-' . $type;
     $this->plugin->get_view($template, $args);
 }
Exemplo n.º 5
0
 /**
  * Find all theme options in this site and run updates
  * @return void
  */
 public function upgrade_site()
 {
     global $wpdb;
     $plugin = Styles_Plugin::get_instance();
     // Get option keys for all Styles theme settings
     $query = "SELECT option_name\n\t\t\tFROM {$wpdb->options}\n\t\t\tWHERE option_name LIKE 'storm-styles-%'\n\t\t\tAND option_name NOT LIKE 'storm-styles-%-css'\n\t\t";
     $option_keys = $wpdb->get_col($query);
     foreach ((array) $option_keys as $option_key) {
         $this->old_options = $this->backup_before_upgrade($option_key, '1.1.0');
         $this->upgrade_font_families($option_key);
     }
     // This must be updated to avoid the updater running in an infinite loop
     $plugin->set_option('db_version', self::NEW_DB_VERSION);
 }
 public function __construct()
 {
     $this->plugin = Styles_Plugin::get_instance();
 }