Beispiel #1
0
/**
 * Check maybe this post use template page builder
 * @param $post_id
 * @return bool
 *
 */
function stpb_check_template($post_id)
{
    $check = false;
    $dont_check = false;
    $type = get_post_type($post_id);
    if ($type == 'page') {
        $editor = get_post_meta($post_id, '_st_current_editor', true);
        if (empty($editor) || $editor == '') {
            $editor = 'editor';
        }
        if ($editor != 'editor') {
            $check = true;
        }
        //$dont_check = true;
    }
    if ($type == "post") {
        $check = true;
    } elseif (!$check && !$dont_check) {
        $page_options = ST_Page_Builder::get_page_options($post_id);
        if (isset($page_options['layout']) && $page_options['layout'] != '' && $page_options['layout'] != 'default') {
            $check = true;
        }
    }
    $check = apply_filters('stpb_check_template', $check, $post_id, get_post_type($post_id));
    return $check;
}
/**
 * Images column for posr type
 */
function st_manage_post_type_columns($column_name, $id)
{
    global $wpdb;
    $size = 'thumbnail';
    switch ($column_name) {
        case 'images':
            $html = '';
            // echo $id;
            $options = ST_Page_Builder::get_page_options($id);
            //  echo get_the_post_thumbnail($id,array(40,40));
            switch (strtolower($options['thumb_type'])) {
                case 'video':
                    $html = '<span class="video-thumb" style="  video="' . $data['type'] . '" size=' . $size . ' video-id="' . $data['video_id'] . '"><i class="iconentypo-video"></i></span>';
                    break;
                case 'gallery':
                case 'slider':
                    $image_ids = $options['gallery'];
                    $image_ids = explode(',', $image_ids);
                    if (count($image_ids)) {
                        foreach ($image_ids as $img_id) {
                            $thumb_image_url = wp_get_attachment_image_src($img_id, $size);
                            $html .= '  <img  alt="" src="' . $thumb_image_url[0] . '" >';
                        }
                    }
                    break;
                default:
                    if (has_post_thumbnail($id)) {
                        $thumb_image_url = wp_get_attachment_image_src(get_post_thumbnail_id($id), $size);
                        $html = '  <img alt="" src="' . $thumb_image_url[0] . '" >';
                    } else {
                    }
            }
            echo apply_filters('st_post_type_thumb_col', $html, $id, $options);
            break;
        default:
            break;
    }
    // end switch
}
Beispiel #3
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 
    }
}
Beispiel #4
0
 /**
  * BP Item Blog
  */
 function st_blog_func($atts, $content = '')
 {
     $atts = shortcode_atts(array('number' => -1, 'cats' => array(), 'exclude' => array(), 'include' => array(), 'offset' => 0, 'thumbnail_type' => '', 'columns' => 1, 'display_style' => 'list', 'excerpt_length' => 70, 'pagination' => 'no', 'order_by' => 'ID', 'order' => 'desc'), $atts);
     extract($atts);
     global $post, $paged;
     $current_post_options = ST_Page_Builder::get_page_options($post->ID);
     $html = '';
     if (is_string($cats)) {
         $cats = explode(',', $cats);
     }
     if (is_array($cats) && count($cats) > 0) {
         if (in_array(0, $cats)) {
             $cats = array();
         }
     }
     $exclude = $exclude != '' ? explode(',', $exclude) : $exclude;
     $include = $include != '' ? explode(',', $include) : $include;
     $number = $number != '' ? $number : get_option('posts_per_page', 10);
     $args = array('posts_per_page' => (int) $number, 'category__in' => (array) $cats, 'post__not_in' => $exclude, 'post__in' => $include, 'offset' => $offset, 'orderby' => $order_by, 'order' => $order);
     if ($paged > 0) {
         $args['paged'] = $paged;
     } else {
         $paged = isset($_REQUEST['paged']) ? intval($_REQUEST['paged']) : 1;
         $args['paged'] = $paged;
     }
     if (st_is_wpml()) {
         $args['sippress_filters'] = true;
         $args['language'] = get_bloginfo('language');
     }
     $wp_query = new WP_Query($args);
     $myposts = $wp_query->posts;
     $func = st_excerpt_length($excerpt_length);
     $columns = intval($columns);
     // support display type list or gird only
     if (!in_array($display_style, array('list', 'gird'))) {
         $display_style = 'list';
     }
     /*
     blog loop templates:
        Gird:
        1 -loop-post-gird-{$columns}.php // (optional) template for each column
        2 -loop-post-gird.php  // (optional) if number columns larger than 1 if have not any templates above
     
        List:
        3 -loop-post-list.php          // (optional) for display style as list
     
        Default:
        4 -loop-post.php                // (requested) if have not any templates above
     */
     $file_template = st_get_template('loop/loop-post.php');
     $thumb_size = 'large';
     if ($display_style == 'gird') {
         // display gird
         if (is_file(st_get_template('loop/loop-post-gird-' . $columns . '.php'))) {
             $file_template = st_get_template('loop/loop-post-gird-' . $columns . '.php');
         } elseif (is_file(st_get_template('loop/loop-post-gird.php'))) {
             $file_template = st_get_template('loop/loop-post-gird.php');
         }
         if (isset($thumbnail_type) && $thumbnail_type != '') {
             if ($columns < 2) {
                 if ($current_post_options['layout'] == 'no-sidebar') {
                     $thumb_size = 'blog-full';
                 } else {
                     $thumb_size = 'blog-large';
                 }
             } elseif ($columns > 3) {
                 $thumb_size = 'blog-medium';
             } else {
                 $thumb_size = 'blog-large';
             }
         }
     } else {
         // display list
         if (is_file(st_get_template('loop/loop-post-list.php'))) {
             $file_template = st_get_template('loop/loop-post-list.php');
         }
         if (isset($thumbnail_type) && $thumbnail_type != '') {
             if ($thumbnail_type == 'full-width') {
                 if ($current_post_options['layout'] == 'no-sidebar') {
                     $thumb_size = 'blog-full';
                 } else {
                     $thumb_size = 'blog-large';
                 }
             } else {
                 if ($current_post_options['layout'] == 'no-sidebar') {
                     $thumb_size = 'blog-large';
                 } else {
                     $thumb_size = 'blog-medium';
                 }
             }
         }
     }
     if ($display_style != 'gird') {
         // list display
         foreach ($myposts as $i => $post) {
             setup_postdata($post);
             $html .= st_get_content_from_file($file_template, array('thumbnail_type' => $thumbnail_type, 'thumb_size' => $thumb_size));
         }
     } else {
         // gird display
         $j = 0;
         $c = 1;
         $groups = array();
         $col_num = intval(12 / $columns);
         foreach ($myposts as $i => $post) {
             setup_postdata($post);
             $groups[$j][] = '<div class="blog-style ' . stpb_number_to_words($col_num) . '">' . st_get_content_from_file($file_template, array('item_index' => $i, 'thumbnail_type' => $thumbnail_type, 'thumb_size' => $thumb_size)) . '</div>';
             if ($c == $columns) {
                 $c = 1;
                 $j++;
             } else {
                 $c++;
             }
         }
         $n = count($groups);
         foreach ($groups as $i => $g) {
             $html .= join(' ', $g);
             if ($i < $n - 1) {
                 $html .= '<div class="clearfix item-sp item-index-' . $i . '"></div>';
             } else {
                 $html .= '<div class="clearfix item-sp item-index-' . $i . ' last"></div>';
             }
         }
     }
     $p = '';
     // if(!is_home() && !is_front_page()) { // only true if not is home page or front page
     if ($pagination == 'yes') {
         $p = st_post_pagination($wp_query->max_num_pages, 2, false);
         if ($p != '') {
             $p = '<div class="st-pagination-wrap">' . $p . '</div>';
         }
     }
     // }
     wp_reset_query();
     remove_filter('excerpt_length', $func);
     $html = '<div class="list-post ' . ($display_style == 'gird' ? 'gird row' : 'list') . '">' . $html . '</div>';
     $html = apply_filters('st_blog_func', $html . $p, $atts);
     return $html;
 }
    function page_options_inferface()
    {
        global $post;
        $name = ST_Page_Builder::PAGE_OPTIONS_NAME;
        $save_values = ST_Page_Builder::get_page_options($post->ID, array());
        $layouts = st_page_layout_config();
        $inter = new ST_Page_Builder_Interface();
        $sidebars = $inter->get_sidebar_widgets();
        wp_nonce_field(plugin_basename(__FILE__), 'stPageBuilder_nonce');
        ?>
        <div class="st-page-options stpb-lb-content-settings">

          <?php 
        do_action('st_page_options_before_settings', $name, $save_values);
        ?>

            <div class="st-option-item item">
                <div class="width-50 left">
                    <?php 
        stpb_input_select_one($name . '[layout]', $save_values['layout'], $layouts, '.st-select-sidebar', '', true);
        ?>
                </div>
                <div class="width-50 right">
                    <strong><?php 
        _e('Layout', 'smooththemes');
        ?>
</strong>
                    <span><?php 
        _e('Select the desired Page layout', 'smooththemes');
        ?>
</span>
                </div>

            </div>

            <div class="item st-option-item show-on-select-change st-select-sidebar" show-on="right-sidebar left-right-sidebar">
                <div class="width-50 left">
                    <?php 
        stpb_input_select_one($name . '[right_sidebar]', $save_values['right_sidebar'], $sidebars, '', '', true);
        ?>
                </div>
                <div class="width-50 right">
                    <strong><?php 
        _e('Right Sidebar', 'smooththemes');
        ?>
</strong>
                    <span><?php 
        _e('Choose a custom right sidebar for this entry', 'smooththemes');
        ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change st-select-sidebar" show-on="left-sidebar left-right-sidebar">
                <div class="width-50 left">
                    <?php 
        stpb_input_select_one($name . '[left_sidebar]', $save_values['left_sidebar'], $sidebars, '', '', true);
        ?>
                </div>
                <div class="width-50 right">
                    <strong><?php 
        _e('Left Sidebar', 'smooththemes');
        ?>
</strong>
                    <span><?php 
        _e('Choose a custom left sidebar for this entry', 'smooththemes');
        ?>
</span>
                </div>

            </div>

            <div class="item st-option-item">
                <div class="width-50  left">
                    <?php 
        stpb_input_select_one($name . '[show_page_el]', $save_values['show_page_el'], array('yes' => __('Yes', 'smooththemes'), 'no' => __('No', 'smooththemes')), '.show_page_el', '', true);
        ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
        _e('Show Top Elements', 'smooththemes');
        ?>
</strong>
                    <span><?php 
        _e('Display the Header with Page Title, Breadcrumb Navigation,...', 'smooththemes');
        ?>
</span>
                </div>
            </div>

            <?php 
        do_action('st_after_show_page_el_settings', $name, $save_values);
        // title bar settings
        if (current_theme_supports('st-titlebar')) {
            ?>
            <div class="item st-option-item show-on-select-change show_page_el" show-on="yes">
                <div class="width-50  left">
                    <?php 
            stpb_input_select_one($name . '[titlebar]', $save_values['titlebar'], array('default' => __('Default - Set in Theme Options', 'smooththemes'), 'defined' => __('Defined Style', 'smooththemes'), 'custom' => __('Custom', 'smooththemes')), '.title_bar_style', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Title bar Style', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="yes defined">
                <div class="width-50  left">
                    <?php 
            $list_titlebar_bg = apply_filters('st_titlebar_list_bg', array());
            stpb_input_layout($name . '[titlebar_defined]', $save_values['titlebar_defined'], $list_titlebar_bg, true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Title bar style', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('Select defined title bar style.', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="custom">
                <div class="width-50  left">
                    <?php 
            stpb_input_media($name . '[titlebar_bg_img]', $save_values['titlebar_bg_img'], 'image', __('Select/Change image', 'smooththemes'), '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Titlebar background image', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="custom">
                <div class="left width-50">
                    <?php 
            stpb_input_color($name . '[titlebar_bg_color]', $save_values['titlebar_bg_color'], '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e(' Titlebar Background Color', 'smooththemes');
            ?>
</strong>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="custom">
                <div class="left width-50">
                    <?php 
            stpb_input_select_one($name . '[titlebar_bg_position]', $save_values['titlebar_bg_position'], array('tl' => __('Top left', 'smooththemes'), 'tc' => __('Top center', 'smooththemes'), 'tr' => __('Top right', 'smooththemes'), 'cc' => __('Center', 'smooththemes'), 'bl' => __('Bottom left', 'smooththemes'), 'bc' => __('Bottom center', 'smooththemes'), 'br' => __('Bottom right', 'smooththemes')), '', '', true);
            ?>
                </div>
                <div class="right  width-50">
                    <strong><?php 
            _e('Titlebar Background Image Position', 'smooththemes');
            ?>
</strong>
                </div>
            </div>


            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="custom">
                <div class="left width-50">
                    <?php 
            stpb_input_select_one($name . '[titlebar_bg_repeat]', $save_values['titlebar_bg_repeat'], array('repeat' => __('Repeat', 'smooththemes'), 'no-repeat' => __('No repeat', 'smooththemes'), 'repeat-x' => __('Horizontally', 'smooththemes'), 'repeat-y' => __('Vertically', 'smooththemes')), '', '', true);
            ?>
                </div>
                <div class="right  width-50">
                    <strong><?php 
            _e('Titlebar Background Repeat', 'smooththemes');
            ?>
</strong>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change title_bar_style show_page_el" show-on="custom">
                <div class="left width-50">
                    <?php 
            stpb_input_select_one($name . '[titlebar_bg_attachment]', $save_values['titlebar_bg_attachment'], array('scroll' => __('Scroll', 'smooththemes'), 'fixed' => __('Fixed', 'smooththemes'), 'stretch' => __('Stretch to fit', 'smooththemes')), '', '', true);
            ?>
                </div>
                <div class="right  width-50">
                    <strong><?php 
            _e('Titlebar Background Attachment', 'smooththemes');
            ?>
</strong>
                </div>
            </div>

            <?php 
            do_action('st_more_titlebar_settings', $name, $save_valuess);
        }
        // end title bar settings
        ?>


            <?php 
        if ($post->ID == st_get_shop_page()) {
            ?>

            <div class="item st-option-item">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['shop_columns']) || $save_values['shop_columns'] == '') {
                $save_values['shop_columns'] = 3;
            }
            stpb_input_select_one($name . '[shop_columns]', $save_values['shop_columns'], array(2 => 2, 3 => 3, 4 => 4, 6 => 6), '', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number columns', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many columns of products to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['number_product']) || $save_values['number_product'] == '') {
                $save_values['number_product'] = 9;
            }
            stpb_input_text($name . '[number_product]', $save_values['number_product'], '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number Products', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many products per page to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <?php 
            // ---------relative product ---------------------------
            ?>
            <div class="item st-option-item">
                <div class="width-50  left">
                    <?php 
            stpb_input_select_one($name . '[show_relative_prod]', $save_values['show_relative_prod'], array('yes' => __('Yes', 'smooththemes'), 'no' => __('No', 'smooththemes')), '.number_relative_prod', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Show relative products', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('Display relative product on single product', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change number_relative_prod" show-on="yes">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['number_relative_prod']) || $save_values['number_relative_prod'] == '') {
                $save_values['number_relative_prod'] = 3;
            }
            stpb_input_text($name . '[number_relative_prod]', $save_values['number_relative_prod'], '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number Relative Products', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many relative products to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change number_relative_prod" show-on="yes">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['relative_prod_num_col']) || $save_values['relative_prod_num_col'] == '') {
                $save_values['relative_prod_num_col'] = 3;
            }
            stpb_input_select_one($name . '[relative_prod_num_col]', $save_values['relative_prod_num_col'], array(2 => 2, 3 => 3, 4 => 4, 6 => 6), '', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number Relative columns', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many columns of Relative products to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <?php 
            // ---------upsells product ---------------------------
            ?>

            <div class="item st-option-item">
                <div class="width-50  left">
                    <?php 
            stpb_input_select_one($name . '[show_upsells_prod]', $save_values['show_upsells_prod'], array('yes' => __('Yes', 'smooththemes'), 'no' => __('No', 'smooththemes')), '.number_upsells_prod', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Show Up-Sells products', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('Display Up-Sells product on single product', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change number_upsells_prod" show-on="yes">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['number_upsells_prod']) || $save_values['number_upsells_prod'] == '') {
                $save_values['number_upsells_prod'] = 3;
            }
            stpb_input_text($name . '[number_upsells_prod]', $save_values['number_upsells_prod'], '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number Up-Sells Products', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many Up-Sells products to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>

            <div class="item st-option-item show-on-select-change number_upsells_prod" show-on="yes">
                <div class="width-50  left">
                    <?php 
            if (!isset($save_values['upsells_prod_num_col']) || $save_values['upsells_prod_num_col'] == '') {
                $save_values['upsells_prod_num_col'] = 3;
            }
            stpb_input_select_one($name . '[upsells_prod_num_col]', $save_values['upsells_prod_num_col'], array(2 => 2, 3 => 3, 4 => 4, 6 => 6), '', '', true);
            ?>
                </div>
                <div class="right width-50">
                    <strong><?php 
            _e('Number Up-Sells columns', 'smooththemes');
            ?>
</strong>
                    <span><?php 
            _e('How many columns of Up-Sells products to show ?', 'smooththemes');
            ?>
</span>
                </div>
            </div>




            <?php 
        }
        ?>

            <?php 
        do_action('st_page_options_more_settings', $name, $save_values);
        ?>

        </div>
    <?php 
    }
<?php

get_header();
global $post, $st_options;
the_post();
$page_options = ST_Page_Builder::get_page_options($post->ID, array());
// do something width $page_options
// e.g:  var_dump($page_options);
?>

<div class="row" >
    <div class="col-lg-12">
        <h1>Template builder - Plugin Template</h1>
    </div>

    <?php 
switch ($page_options['layout']) {
    case 'no-sidebar':
        // full width no siderbar - one- columns
        ?>
            <div class="col-lg-12 col-sm-12 col-md-12 column">
                <h2 class="page-title"><?php 
        the_title();
        ?>
</h2>
            </div>

            <div class="col-lg-12 col-sm-12 col-md-12  column">
                <div <?php 
        post_class();
        ?>