Exemple #1
0
function st_titlebar_style()
{
    if (!current_theme_supports('st-titlebar')) {
        return false;
    }
    $options = array('img' => '', 'color' => '', 'position' => '', 'repeat' => '', 'attachment' => '', 'more_style' => '');
    $theme_settings = $page_settings = array();
    // default options from theme settings
    if (function_exists('st_get_setting')) {
        if (st_get_setting('titlebar_type') == 'defined') {
            $list_titlebar_bg = apply_filters('st_titlebar_list_bg', array());
            $defined = st_get_setting('titlebar_defined');
            $theme_settings = isset($list_titlebar_bg[$defined]) ? $list_titlebar_bg[$defined] : array();
        } else {
            foreach ($options as $k => $v) {
                $theme_settings[$k] = st_get_setting('titlebar_bg_' . $k);
            }
        }
    }
    // if is post
    if (is_singular() || is_page()) {
        global $post;
        $post_options = ST_Page_Builder::get_page_options($post->ID);
        if ($post_options['titlebar'] == 'custom') {
            foreach ($options as $k => $v) {
                $page_settings[$k] = $post_options['titlebar_bg_' . $k];
            }
            // load bg image
            if ($page_settings['img'] != '') {
                $image_attributes = wp_get_attachment_image_src($page_settings['img'], 'full');
                $page_settings['img'] = $image_attributes[0];
            }
        } else {
            if ($post_options['titlebar'] == 'defined') {
                $list_titlebar_bg = apply_filters('st_titlebar_list_bg', array());
                $defined = $post_options['titlebar_defined'];
                $page_settings = isset($list_titlebar_bg[$defined]) ? $list_titlebar_bg[$defined] : array();
            }
        }
    }
    $style = false;
    if (!empty($page_settings)) {
        $style = st_bg($page_settings);
        $more_style = apply_filters('st_titlebar_general_more', $style, $post->ID, $page_settings);
    } elseif (!empty($theme_settings)) {
        $style = st_bg($theme_settings);
        $more_style = apply_filters('st_titlebar_page_more', $style, $post->ID, $post_options);
    }
    if ($style) {
        ?>
    <style type="text/css">
        .layout-title{ <?php 
        echo $style;
        ?>
}<?php 
        echo $more_style != '' ? $more_style : '';
        ?>
    </style>
    <?php 
    }
}
 /**
  * Settings  before column start
  * @param $col_data
  * @return string
  */
 function column_settings_before($default = '', $data = array())
 {
     $col_data = $data['settings'];
     if (!is_array($col_data) || empty($col_data)) {
         return '';
     }
     $col_data = wp_parse_args($col_data, array('_classes' => '', 'mod' => 'boxed', 'inside_mod' => 'boxed', 'custom_class' => '', 'custom_id' => '', 'padding' => '', 'bg_img' => '', 'bg_color' => '', 'bg_attachment' => '', 'bg_repeat' => '', 'margin_bottom' => '', 'margin_top' => '', 'padding_bottom' => '', 'padding_top' => '', 'is_parallax' => 'n', 'opacity' => '', 'effect' => '', 'vertical_align' => '', 'border' => ''));
     $attrs = array();
     $classes = array();
     $classes[] = trim($col_data['_classes']);
     $style = '';
     $container_open = '';
     if ($col_data['is_parallax'] == 'y' && $col_data['bg_img'] != '') {
         $attrs[] = ' data-bg="' . esc_attr($col_data['bg_img']) . '" ';
         $attrs[] = ' data-speed="0.4" ';
         if (is_numeric($col_data['opacity'])) {
             $attrs[] = ' data-opacity="' . esc_attr($col_data['opacity']) . '" ';
         }
         $classes[] = 'parallax';
     } else {
     }
     $bg_style = st_bg(array('img' => $col_data['bg_img'], 'color' => $col_data['bg_color'], 'attachment' => $col_data['bg_attachment'], 'repeat' => $col_data['bg_repeat'], 'position' => $col_data['bg_position']));
     $is_full_w = false;
     $fwpd = '';
     if ($col_data['padding'] == 'custom') {
         if (is_numeric($col_data['padding_left'])) {
             $fwpd .= ' padding-left: ' . esc_attr(trim($col_data['padding_left'])) . 'px; ';
         }
         if (is_numeric($col_data['padding_right'])) {
             $fwpd .= ' padding-right: ' . esc_attr(trim($col_data['padding_right'])) . 'px; ';
         }
     }
     if (strtolower($data['type']) == 'row') {
         $row_wrapper_class = isset($col_data['mod']) && $col_data['mod'] != '' ? $col_data['mod'] .= '' : 'boxed';
         if ($row_wrapper_class == 'full-width') {
             $is_full_w = true;
             if ($fwpd != '') {
                 $fwpd = ' style="' . $fwpd . '" ';
             }
             if ($col_data['inside_mod'] == 'full-width') {
                 $container_open = ' <div class="rc-inside rc-full-with"' . $fwpd . '>  ';
             } else {
                 $container_open = ' <div class="rc-inside rc-boxed container"' . $fwpd . '>  ';
             }
             $fwpd = '';
         }
         $row_wrapper_class .= '-mod';
         $row_wrapper_class .= ' settings-' . $data['type'];
     } else {
         $row_wrapper_class .= ' settings-col';
         $reffect = st_effect_attr($col_data['effect']);
         $classes[] = $reffect['class'];
         $attrs[] = $reffect['attr'];
         if ($col_data['vertical_align'] != '' && $col_data['vertical_align'] != 'top') {
             $classes[] = 'col-va va-' . esc_attr($col_data['vertical_align']);
         }
     }
     if (is_numeric($col_data['margin_bottom'])) {
         $style .= ' margin-bottom: ' . esc_attr(trim($col_data['margin_bottom'])) . 'px; ';
     }
     if (is_numeric($col_data['margin_top'])) {
         $style .= ' margin-top: ' . esc_attr(trim($col_data['margin_top'])) . 'px; ';
     }
     if ($col_data['padding'] == 'custom') {
         if (is_numeric($col_data['padding_bottom'])) {
             $style .= ' padding-bottom: ' . esc_attr(trim($col_data['padding_bottom'])) . 'px; ';
         }
         if (is_numeric($col_data['padding_top'])) {
             $style .= ' padding-top: ' . esc_attr(trim($col_data['padding_top'])) . 'px; ';
         }
         if (!$is_full_w && $fwpd != '') {
             $style .= $fwpd;
         }
     }
     if ($style != '' || $bg_style != '') {
         $style = ' style="' . $style . $bg_style . '" ';
     }
     if (!empty($attrs) || $style != '') {
         $row_wrapper_class .= ' has-custom alt-bg';
     } else {
         $row_wrapper_class .= ' no-custom';
     }
     if ($col_data['custom_id'] != '') {
         $attrs[] = ' id="' . esc_attr($col_data['custom_id']) . '" ';
     }
     $padding = $col_data['padding'];
     $classes[] = 'custom-settings';
     $classes[] = $padding;
     $classes[] = $row_wrapper_class;
     if ($col_data['custom_class'] != '') {
         $classes[] = esc_attr($col_data['custom_class']);
     }
     if ($col_data['border'] != '') {
         $classes[] = esc_attr($col_data['border']);
     }
     $attrs[] = ' class="' . esc_attr(join(' ', $classes)) . '" ';
     return '<div ' . $style . join(' ', $attrs) . '>' . $container_open;
 }