Exemple #1
0
 /**
  * Shortcode profile form
  */
 function st_profile_func($atts, $content = '')
 {
     $atts = shortcode_atts(array('login_link' => '', 'disable_link' => ''), $atts);
     extract($atts);
     $html = '';
     $login_link = empty($login_link) ? wp_login_url() : $login_link;
     if (!defined('ST_REGISTER')) {
         define('ST_REGISTER', true);
     }
     $links = array('login-link' => array('text' => __('Login', 'smooththemes'), 'href' => $login_link));
     $html .= st_get_content_from_file(ST_PAGEBUILDER_PATH . 'inc/user/profile.php', array('links' => $links, 'disable_link' => $disable_link));
     $html .= '';
     $html = apply_filters('st_profile_func', $html, $atts);
     return $html;
 }
Exemple #2
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;
 }
Exemple #3
0
 /**
  * Form login modal
  */
 function st_login_modal_func($atts, $content = '')
 {
     $atts = shortcode_atts(array('logout_redirect' => '', 'login_success_redirect' => '', 'register_success_redirect' => ''), $atts);
     extract($atts);
     $html = '';
     $logout_redirect = wp_logout_url(empty($logout_redirect) ? self::st_current_url('nologout') : $logout_redirect);
     $atts['logout_redirect'] = $logout_redirect;
     $html .= st_get_content_from_file(ST_PAGEBUILDER_PATH . 'inc/user/login-modal.php', $atts);
     $html = apply_filters('st_login_modal_func', $html, $atts);
     return $html;
 }