Example #1
0
 function thb_append_theme_customization()
 {
     thb_css_start('thb_theme_customization');
     thb_theme()->getCustomization()->render(true);
     // echo get_option(THB_CUSTOMIZATIONS);
     thb_custom_css();
     thb_css_end();
 }
 /**
  * Print a well formed CSS stylesheet based on the registered settings.
  *
  * @param boolean $hideTag True to hide the <style> tag.
  * @return void
  */
 public function render($hideTag = false)
 {
     if (!$hideTag) {
         thb_css_start('thb-style-customizer');
     }
     $this->importFonts();
     $style_rules = array();
     $style_mixins = array();
     foreach ($this->_sections as $section) {
         foreach ($section['settings'] as $setting) {
             $value = get_theme_mod($setting['key']);
             if (empty($value)) {
                 $value = $setting['default'];
             }
             foreach ($setting['selectors'] as $selector => $rules) {
                 if (!isset($style_rules[$selector])) {
                     $style_rules[$selector] = array();
                 }
                 foreach ($rules as $rule) {
                     if (thb_text_startsWith($rule, 'mixin-')) {
                         $mixin = str_replace('mixin-', '', $rule);
                         if (function_exists($mixin)) {
                             $style_mixins[] = call_user_func($mixin, $value, $selector);
                         }
                     } else {
                         list($prefix, $suffix) = thb_css_prefix_suffix($rule);
                         $style_rules[$selector][] = thb_get_css_rule($rule, $value, $prefix, $suffix);
                     }
                 }
             }
         }
     }
     foreach ($style_rules as $selector => $rules) {
         thb_css_selector($selector, $rules);
     }
     foreach ($style_mixins as $mixin) {
         echo $mixin;
     }
     ksort($this->additionalStyles);
     foreach ($this->additionalStyles as $style) {
         if (function_exists($style)) {
             echo ' ' . call_user_func($style);
         }
     }
     if (!$hideTag) {
         thb_css_end();
     }
 }