Exemplo n.º 1
0
 function create_css_file()
 {
     global $king;
     $datas = get_option($this->args['opt_name']);
     if (empty($datas)) {
         return;
     }
     $data = '/***' . "\n";
     $data .= '*' . "\n";
     $data .= '*	copyright (c) king-theme.com' . "\n";
     $data .= '* This file is generated automatically.' . "\n";
     $data .= '* Please change the value of options in the backend and do not edit here' . "\n";
     $data .= '*' . "\n";
     $data .= '***/' . "\n\n";
     $fonts = '';
     $default = array('Open Sans', 'Open Sans Condensed', 'Raleway', 'Roboto');
     global $king_option_css_value;
     foreach ($this->sections as $section) {
         if (isset($section['fields'])) {
             foreach ($section['fields'] as $field) {
                 if ($field['id'] == 'useBackgroundPattern') {
                     if (empty($datas[$field['id']])) {
                         unset($datas['backgroundImage']);
                     }
                 }
                 if (!empty($field['css'])) {
                     ob_start();
                     $king_option_css_value = $datas[$field['id']];
                     if (is_array($king_option_css_value)) {
                         if (isset($king_option_css_value['font'])) {
                             if ($king_option_css_value['font'] != '' && strpos($fonts, $king_option_css_value['font']) === false && !in_array($king_option_css_value['font'], $default)) {
                                 $fonts .= str_replace(' ', '+', $king_option_css_value['font'] . '|');
                                 array_push($default, $king_option_css_value['font']);
                             }
                         }
                     }
                     if (!empty($king_option_css_value)) {
                         $empty = true;
                         if (is_array($king_option_css_value)) {
                             foreach ($king_option_css_value as $key => $vl) {
                                 if (!empty($vl)) {
                                     $empty = false;
                                 }
                             }
                         } else {
                             $empty = false;
                         }
                         if ($empty == false) {
                             if (isset($king_option_css_value['font'])) {
                                 $fontsGets = @explode(':', $king_option_css_value['font']);
                                 $king_option_css_value['font'] = $fontsGets[0];
                             }
                             @$king->ext['ev']('global $king_option_css_value; $value = $king_option_css_value; ?>' . $field['css']);
                             $data .= ob_get_contents() . "\n";
                         }
                     }
                     ob_end_clean();
                 }
             }
         }
     }
     /*
      *	Process color style
      */
     if (isset($datas['colorStyle'])) {
         if ($datas['colorStyle'] != 'none' && $datas['colorStyle'] != '') {
             $file = king_child_theme_enqueue(THEME_PATH . DS . 'assets' . DS . 'css' . DS . 'colors' . DS . 'color-primary.css');
             $file = str_replace(SITE_URI . '/', ABSPATH, str_replace('/', DS, $file));
             if (file_exists($file)) {
                 $handle = $king->ext['fo']($file, 'r');
                 $css_data = $king->ext['fr']($handle, filesize($file));
                 if (strpos($datas['colorStyle'], '#') === false) {
                     $datas['colorStyle'] = '#' . $datas['colorStyle'];
                 }
                 $data .= str_replace('{color}', $datas['colorStyle'], $css_data);
             }
         }
     }
     /***/
     /* Do minify css code */
     $data = $this->minify(str_replace(array('%SITE_URI%', '%HOME_URL%'), array(SITE_URI, SITE_URI), $data));
     if (!empty($fonts)) {
         $fonts = rtrim($fonts, "|");
         $protocol = is_ssl() ? 'https' : 'http';
         $data = "\n@import url('{$protocol}://fonts.googleapis.com/css?family={$fonts}');\n\n" . $data;
     }
     /* Save css into database */
     if (!update_option('king_' . strtolower(THEME_NAME) . '_options_css', $data)) {
         add_option('king_' . strtolower(THEME_NAME) . '_options_css', $data);
     }
 }
Exemplo n.º 2
0
function king_enqueue_content_last()
{
    $css_dir = THEME_URI . '/assets/css/';
    wp_enqueue_style('king-ls-style', $css_dir . 'ls-style.css', false, KING_VERSION);
    wp_enqueue_style('king-responsive', king_child_theme_enqueue($css_dir . 'responsive.css'), false, KING_VERSION);
    /*wp_enqueue_style('king-bootstrap-resp', king_child_theme_enqueue( $css_dir.'bootstrap_responsive.css' ), false, KING_VERSION );*/
}