function __construct($id = false)
 {
     $this->builder_items = ST_Page_Builder_Items_Config();
     if ($id > 0) {
         $p = get_post($id);
         $this->post = $p;
         $this->id = $p->ID;
     } else {
         global $post, $pagenow;
         $this->post = $post;
         $this->id = $post->ID;
     }
     $this->saved_data = ST_Page_Builder::get_builder_settings($this->id, array());
     if (empty($this->saved_data) or !is_array($this->saved_data) or $this->id <= 0) {
         $this->no_value = false;
         $this->saved_data = array();
     }
     // parent::__construct();
     $this->items_sizes = ST_Page_Builder::get_builder_item_sizes();
     $this->class_to_items_size = ST_Page_Builder::class_to_items_size();
 }
/**
 * 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
 function st_search_posts(&$post)
 {
     if (!is_search()) {
         return $post;
     }
     $editor = get_post_meta($post->ID, '_st_current_editor', true);
     if ($editor == 'builder') {
         if ($post->post_excerpt == '') {
             $excerpt_length = apply_filters('excerpt_length', 30);
             if (class_exists('ST_Page_Builder')) {
                 $content = ST_Page_Builder::get_content($post->ID);
             } else {
                 $content = get_post_meta($post->ID, '_st_pagebuilder_content', true);
             }
             $post->post_content = $content;
             $post->post_excerpt = wp_trim_words(strip_shortcodes($content), $excerpt_length, '');
         }
     }
     return $post;
 }
Beispiel #5
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 __construct($builder_data, $post_id = 0)
 {
     $this->id = $post_id;
     $this->include_items = array();
     $this->builder_data = $builder_data;
     $this->builder_items = ST_Page_Builder_Items_Config();
     $this->items_sizes = ST_Page_Builder::get_builder_item_sizes();
     $this->class_to_items_size = ST_Page_Builder::class_to_items_size();
     // settings for colum
     add_filter('stpb_column_generate_settings_before', array($this, 'column_settings_before'), 10, 2);
     add_filter('stpb_column_generate_settings_after', array($this, 'column_settings_after'), 10, 2);
     // settings for row
     add_filter('stpb_row_generate_settings_before', array($this, 'column_settings_before'), 10, 2);
     add_filter('stpb_row_generate_settings_after', array($this, 'column_settings_after'), 10, 2);
 }
 /**
  * Save page builder data
  */
 function saveData($post_id)
 {
     // First we need to check if the current user is authorised to do this action.
     /*
     if ('page' == $_POST['post_type']) {
         if (!current_user_can('edit_page', $post_id))
             return;
     } else {
         if (!current_user_can('edit_post', $post_id))
             return;
     }
     */
     // Secondly we need to check if the user intended to change this value.
     if (!isset($_POST['stPageBuilder_nonce']) || !wp_verify_nonce($_POST['stPageBuilder_nonce'], st_create_nonce()) && !wp_verify_nonce($_POST['stPageBuilder_nonce'], plugin_basename(__FILE__))) {
         return;
     }
     ST_Page_Builder::save_page_options($post_id, $_POST[ST_Page_Builder::PAGE_OPTIONS_NAME]);
     update_post_meta($post_id, '_st_current_editor', $_POST['_st_current_editor']);
     // make sure page builder load completed
     if ($_POST['_st_page_builder_loaded'] == 1) {
         ST_Page_Builder::save_builder_settings($post_id, $_POST[ST_Page_Builder::BUILDER_SETTINGS_NAME]);
     }
 }
<?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();
        ?>