Example #1
0
    function createCSSFile()
    {
        if ($this->createMultisitePath() === false) {
            return;
        }
        $content = null;
        $CSS = new ThemeCSS();
        $Validation = new ThemeValidation();
        $ResponsiveMode = new ThemeResponsiveMode($this->responsiveMode);
        ThemeOption::refreshOption();
        $media = $ResponsiveMode->getMedia();
        if (ThemeOption::getOption('responsive_mode_enable') != 1) {
            $media = $media[1];
        }
        $selector = array('base' => array('a', 'body', 'input', 'select', 'textarea', '.theme-page .gform_wrapper select', '.theme-page .gform_wrapper textarea', '.theme-page .gform_wrapper input[type="tel"]', '.theme-page .gform_wrapper input[type="url"]', '.theme-page .gform_wrapper input[type="text"]', '.theme-page .gform_wrapper input[type="email"]', '.theme-page .gform_wrapper input[type="number"]', '.theme-page .gform_wrapper input[type="password"]'), 'h1' => array('h1', 'h1 a'), 'h2' => array('h2', 'h2 a', '.pb-counter-box ul>li>div>div.pb-counter-box-text-counter', '.pb-pricing-plan>ul>li>div .pb-pricing-plan-item-price-box .pb-pricing-plan-item-price-box-value'), 'h3' => array('h3', 'h3 a', '.pb-testimonial ul.pb-layout-100>li>div>p', '.pb-twitter-user-timeline .pb-twitter-user-timeline-text', '.pb-twitter-user-timeline .pb-twitter-user-timeline-text a'), 'h4' => array('h4', 'h4 a'), 'h5' => array('h5', 'h5 a', 'h3.comment-reply-title', '.pb-zaccordion .pb-zaccordion-caption-box .pb-zaccordion-caption-box-title'), 'h6' => array('h6', 'h6 a', '.pb-testimonial ul.pb-layout-50x50>li>div>p', '.pb-testimonial ul.pb-layout-33x33x33>li>div>p', '.pb-testimonial ul.pb-layout-25x25x25x25>li>div>p', 'div.pb-counter-list>ul>li>span.pb-counter-list-label', 'div.pb-counter-list>ul>li>span.pb-counter-list-value', '.pb-blockquote blockquote', '.pb-blockquote blockquote p'));
        foreach ($selector as $index => $value) {
            $content .= $CSS->create(array('selector' => $value, 'property' => array('font-family' => array(ThemeOption::getOption('font_' . $index . '_family_google'), ThemeOption::getOption('font_' . $index . '_family_system')), 'font-size' => ThemeOption::getOption('font_' . $index . '_size'), 'font-style' => ThemeOption::getOption('font_' . $index . '_style'), 'font-weight' => ThemeOption::getOption('font_' . $index . '_weight'), 'line-height' => ThemeOption::getOption('font_' . $index . '_line_height'))));
        }
        $content .= $CSS->create(array('selector' => array('.pb-header-subheader .pb-subheader span'), 'property' => array('font-family' => array(ThemeOption::getOption('font_base_family_google'), ThemeOption::getOption('font_base_family_system')))));
        if (count($media)) {
            foreach ($media as $mediaIndex => $mediaValue) {
                foreach ($selector as $selectorIndex => $selectorValue) {
                    $content .= $CSS->create(array('media' => $mediaValue, 'selector' => $selectorValue, 'property' => array('font-size' => ThemeOption::getOption('font_' . $selectorIndex . '_size_' . $mediaIndex))));
                }
            }
        } else {
            foreach ($selector as $selectorIndex => $selectorValue) {
                $content .= $CSS->create(array('selector' => $selectorValue, 'property' => array('font-size' => ThemeOption::getOption('font_' . $selectorIndex . '_size_1'))));
            }
        }
        if (ThemeOption::getOption('responsive_mode_enable') == 1) {
            $maxWidth = ThemeOption::getOption('menu_responsive_level') - 1;
            $content .= $CSS->create(array('media' => array('min-width' => 0, 'max-width' => $maxWidth), 'selector' => array('ul.sf-menu'), 'property' => array('display' => 'none')));
            $content .= $CSS->create(array('media' => array('min-width' => 0, 'max-width' => $maxWidth), 'selector' => array('select.dp-menu'), 'property' => array('display' => 'block')));
        }
        foreach ($media as $index => $value) {
            if ($Validation->isNotEmpty(ThemeOption::getOption('custom_css_responsive_' . $index))) {
                if (array_key_exists('min-width', $value) && array_key_exists('max-width', $value)) {
                    $content .= '
					@media only screen  and (min-width:' . $value['min-width'] . 'px) and (max-width:' . $value['max-width'] . 'px)
					{
					' . ThemeOption::getOption('custom_css_responsive_' . $index) . '
					}
					';
                } else {
                    $content .= ThemeOption::getOption('custom_css_responsive_' . $index);
                }
            }
        }
        $file = THEME_PATH_MULTISITE_SITE_STYLE . 'style.css';
        @chmod($file, 0755);
        if (file_put_contents($file, $content) === false) {
            return false;
        }
        return true;
    }