コード例 #1
0
 /**
  * Register item with $wp_customize
  */
 public function add_item()
 {
     global $wp_customize;
     $wp_customize->add_setting($this->setting, $this->get_setting_args());
     $control = new WP_Customize_Color_Control($wp_customize, Styles_Helpers::get_control_id($this->id), $this->get_control_args());
     $wp_customize->add_control($control);
 }
コード例 #2
0
 /**
  * Register item with $wp_customize
  */
 public function add_item()
 {
     global $wp_customize;
     $args_size = $this->get_setting_args('font_size');
     $setting_size = $this->setting . '[font_size]';
     $args_family = $this->get_setting_args('font_family');
     // unset( $args_family['transport'] );
     $setting_family = $this->setting . '[font_family]';
     $wp_customize->add_setting($setting_size, $args_size);
     $wp_customize->add_setting($setting_family, $args_family);
     $control_args = $this->get_control_args();
     $control_args['settings'] = array('font_size' => $setting_size, 'font_family' => $setting_family);
     $control = new Styles_Customize_Text_Control($wp_customize, Styles_Helpers::get_control_id($this->id), $control_args);
     $wp_customize->add_control($control);
 }
コード例 #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;
 }
コード例 #4
0
 public function load_settings_from_json_file($json_file, $default_settings = array())
 {
     $settings = array();
     if (file_exists($json_file)) {
         $json = preg_replace('!/\\*.*?\\*/!s', '', file_get_contents($json_file));
         // strip comments before decoding
         $settings = json_decode($json, true);
         if ($json_error = Styles_Helpers::get_json_error($json_file, $settings)) {
             wp_die($json_error);
         }
     }
     return wp_parse_args($settings, $default_settings);
 }
コード例 #5
0
 public static function get_template()
 {
     if (isset(self::$template)) {
         return self::$template;
     }
     global $wp_customize;
     if (isset($_GET['theme'])) {
         self::$template = $_GET['theme'];
     } else {
         if (is_a($wp_customize, 'WP_Customize_Manager')) {
             self::$template = $wp_customize->theme()->template;
         } else {
             self::$template = get_template();
         }
     }
     return self::$template;
 }
コード例 #6
0
 public function get_css()
 {
     global $wp_customize;
     $css = false;
     if (empty($wp_customize)) {
         $css = get_option(Styles_Helpers::get_option_key('css'));
     }
     if (!empty($wp_customize) || empty($css) || apply_filters('styles_force_rebuild', false)) {
         // Rebuild
         $this->init_css();
         return $this->css->get_css();
     } else {
         return $css;
     }
 }
コード例 #7
0
 public function get_element_setting_value()
 {
     $settings = get_option(Styles_Helpers::get_option_key());
     $group_id = Styles_Helpers::get_group_id($this->group);
     $value = false;
     if (isset($settings[$group_id][$this->id])) {
         $value = $settings[$group_id][$this->id];
     }
     if (!empty($value)) {
         return $value;
     } else {
         return false;
     }
 }