function gdlr_generate_style_custom($options)
 {
     // for multisite
     $file_url = get_template_directory() . '/stylesheet/style-custom.css';
     if (is_multisite() && get_current_blog_id() > 1) {
         $file_url = get_template_directory() . '/stylesheet/style-custom' . get_current_blog_id() . '.css';
     }
     // open file
     $file_stream = @fopen($file_url, 'w');
     if (!$file_stream) {
         $ret = array('status' => 'failed', 'message' => '<span class="head">' . __('Cannot Generate Custom File', 'gdlr_translate') . '</span> ' . __('Please try changing the style-custom.css file permission to 775 or 777 for this.', 'gdlr_translate'));
         die(json_encode($ret));
     }
     // write file content
     $theme_option = get_option(THEME_SHORT_NAME . '_admin_option', array());
     // for updating google font list to use on front end
     global $gdlr_font_controller;
     $google_font_list = array();
     foreach ($options as $menu_key => $menu) {
         foreach ($menu['options'] as $submenu_key => $submenu) {
             if (!empty($submenu['options'])) {
                 foreach ($submenu['options'] as $option_slug => $option) {
                     if (!empty($option['selector'])) {
                         // prevents warning message
                         $option['data-type'] = empty($option['data-type']) ? 'color' : $option['data-type'];
                         if (!empty($theme_option[$option_slug])) {
                             $value = gdlr_check_option_data_type($theme_option[$option_slug], $option['data-type']);
                         } else {
                             $value = '';
                         }
                         if ($value) {
                             fwrite($file_stream, str_replace('#gdlr#', $value, $option['selector']) . "\r\n");
                         }
                         // updating google font list
                         if ($menu_key == 'font-settings' && $submenu_key == 'font-family') {
                             if (!empty($gdlr_font_controller->google_font_list[$theme_option[$option_slug]])) {
                                 $google_font_list[$theme_option[$option_slug]] = $gdlr_font_controller->google_font_list[$theme_option[$option_slug]];
                             }
                         }
                     }
                 }
             }
         }
     }
     // update google font list
     update_option(THEME_SHORT_NAME . '_google_font_list', $google_font_list);
     $skins = json_decode($theme_option['skin-settings'], true);
     $skins = empty($skins) ? array() : $skins;
     foreach ($skins as $skin) {
         $class = '.' . gdlr_string_to_class($skin['skin-title']);
         $style = '#class#, #class# .gdlr-skin-content{ color: ' . $skin['content'] . '; }' . "\r\n";
         $style .= '#class# i, #class# .gdlr-flex-prev, #class# .gdlr-flex-next{ color: ' . $skin['icon'] . '; }' . "\r\n";
         $style .= '#class# h1, #class# h2, #class# h3, #class# h4, #class# h5, #class# h6, ';
         $style .= '#class# .gdlr-skin-title, #class# .gdlr-skin-title a{ color: ' . $skin['title'] . '; }' . "\r\n";
         $style .= '#class# .gdlr-skin-title a:hover{ color: ' . $skin['title-hover'] . '; }' . "\r\n";
         $style .= '#class# .gdlr-skin-info, #class# .gdlr-skin-info a, #class# .gdlr-skin-info a:hover{ color: ' . $skin['info'] . '; }' . "\r\n";
         $style .= '#class# a, #class# .gdlr-skin-link, #class# .gdlr-skin-link-color{ color: ' . $skin['link'] . '; }' . "\r\n";
         $style .= '#class# a:hover, #class# .gdlr-skin-link:hover{ color: ' . $skin['link-hover'] . '; }' . "\r\n";
         $style .= '#class# .gdlr-skin-box, #class# .gdlr-column-service-item .gdlr-skin-box, #class# .gdlr-flex-prev, #class# .gdlr-flex-next{ background-color: ' . $skin['element-background'] . '; }' . "\r\n";
         $style .= '#class# *, #class# .gdlr-skin-border{ border-color: ' . $skin['border'] . '; }' . "\r\n";
         $style .= '#class# .gdlr-button, #class# .gdlr-button:hover, #class# input[type="button"], #class# input[type="submit"]{ ';
         $style .= 'color: ' . $skin['button-text'] . '; background-color: ' . $skin['button-background'] . ';  }' . "\r\n";
         $style = str_replace('#class#', $class, $style);
         fwrite($file_stream, $style);
     }
     $end_of_file = apply_filters('gdlr_style_custom_end', '', $theme_option);
     if (!empty($end_of_file)) {
         fwrite($file_stream, $end_of_file);
     }
     if (!empty($theme_option['additional-style'])) {
         fwrite($file_stream, $theme_option['additional-style']);
     }
     // close file after finish writing
     fclose($file_stream);
 }
Beispiel #2
0
 function gdlr_get_skin_list()
 {
     global $theme_option;
     $skin_list = array('no-skin' => __('No Skin', 'gdlr_translate'));
     if (!empty($theme_option['skin-settings'])) {
         $skins = json_decode($theme_option['skin-settings'], true);
         if (!empty($skins)) {
             foreach ($skins as $skin) {
                 $skin_list[gdlr_string_to_class($skin['skin-title'])] = $skin['skin-title'];
             }
         }
     }
     return $skin_list;
 }