示例#1
0
    $loop_args = array('overlay' => 'none', 'excerpt' => 'excerpt', 'readmore' => __('Read more', 'themeton'), 'grid' => $columns, 'element_style' => 'default');
    $result = '';
    $function = 'blox_loop_regular';
    if (function_exists('blox_loop_' . $loop_layout)) {
        $function = 'blox_loop_' . $loop_layout;
    }
    while (have_posts()) {
        the_post();
        ob_start();
        call_user_func($function, $loop_args);
        $result .= ob_get_contents();
        ob_end_clean();
    }
    $pager_html = '';
    ob_start();
    themeton_pager();
    $pager_html .= ob_get_contents();
    ob_end_clean();
    // Grid container
    if (strpos($loop_layout, 'grid') !== false) {
        $result = '<div class="blox-element blog grid-loop">
								                            <div class="row">
								                                <div class="loop-container">' . $result . '</div>
								                            </div>
								                            ' . $pager_html . '
								                        </div>';
    } else {
        if (strpos($loop_layout, 'masonry') !== false) {
            $result = '<div class="blox-element blog grid-loop">
								                            <div class="row">
								                                <div class="loop-masonry">' . $result . '</div>
示例#2
0
function blox_portfolio_parse_hook($atts)
{
    extract(shortcode_atts(array('title' => '', 'style' => 'default', 'categories' => '', 'count' => '5', 'pager' => '0', 'height' => '', 'readmore' => __('Read more', 'themeton'), 'ignoresticky' => 'yes', 'filter' => '1', 'content_type' => 'default', 'overlay' => 'none', 'exclude' => '', 'order' => '', 'extra_class' => '', 'element_style' => 'default', 'skin' => '', 'visibility' => ''), $atts));
    $visibility = str_replace(',', ' ', $visibility);
    global $query, $post, $paged;
    $temp_qry = $query;
    $temp_post = $post;
    wp_reset_query();
    wp_reset_postdata();
    if (is_front_page()) {
        $paged = get_query_var('page') ? get_query_var('page') : 1;
    }
    /* Build queries
       ================================================*/
    $args = array('post_type' => 'portfolio', 'post__not_in' => explode(',', $exclude), 'posts_per_page' => (int) $count, 'paged' => $paged, 'ignore_sticky_posts' => $ignoresticky == 'yes' ? 1 : 0);
    $cats_filter = array();
    if ($categories != '') {
        $format_array = explode(',', $categories);
        $args['tax_query'] = array(array('taxonomy' => 'portfolio_entries', 'field' => 'id', 'terms' => $format_array));
        foreach ($format_array as $term) {
            $the_term = get_term($term, 'portfolio_entries');
            $temp_cat = array('id' => $the_term->term_id, 'title' => $the_term->name, 'slug' => $the_term->slug);
            if (!in_array($temp_cat, $cats_filter)) {
                $cats_filter[] = $temp_cat;
            }
        }
    }
    if ($order == 'dateasc') {
        $args['orderby'] = 'date';
        $args['order'] = 'ASC';
    } elseif ($order == 'titleasc') {
        $args['orderby'] = 'title';
        $args['order'] = 'ASC';
    } elseif ($order == 'titledes') {
        $args['orderby'] = 'title';
        $args['order'] = 'DESC';
    } elseif ($order == 'comment') {
        $args['orderby'] = 'comment_count';
    } elseif ($order == 'postid') {
        $args['orderby'] = 'ID';
    } elseif ($order == 'random') {
        $args['orderby'] = 'rand';
        add_action('posts_orderby', 'edit_posts_orderby');
    }
    $result = '';
    $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : '';
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        $item_number = 0;
        while ($query->have_posts()) {
            $query->the_post();
            // If it is grid style, there don't need image scaled cropping
            $image_height = 0;
            if (strpos($style, 'grid') !== false) {
                $image_height = $height != '' ? (int) $height : 0;
            }
            $item_number++;
            $class = 'col-md-3 col-sm-6 col-xs-12';
            $image_width = 539;
            if ($style == 'masonry3' || $style == 'grid3') {
                $class = 'col-md-4 col-sm-6 col-xs-12';
                $image_width = 344;
            } else {
                if ($style == 'masonry4' || $style == 'grid4') {
                    $class = 'col-md-3 col-sm-6 col-xs-12';
                    $image_width = 247;
                } else {
                    if ($style == 'masonry2' || $style == 'grid2') {
                        $class = 'col-md-6 col-sm-6 col-xs-12';
                        $image_width = 0;
                    }
                }
            }
            // If it is centered style, there don't need image overlay
            if ($style == 'centered') {
                $overlay = 'nothing';
            }
            $current_filter_classes = '';
            $terms = wp_get_post_terms(get_the_ID(), 'portfolio_entries');
            foreach ($terms as $term) {
                $current_filter_classes .= 'filter-' . $term->slug . ' ';
                if (empty($format_array)) {
                    $temp_cat = array('id' => $term->term_id, 'title' => $term->name, 'slug' => $term->slug);
                    if (!in_array($temp_cat, $cats_filter)) {
                        $cats_filter[] = $temp_cat;
                    }
                }
            }
            $thumb = '';
            if (has_post_thumbnail(get_the_ID())) {
                $fimage = wp_get_attachment_url(get_post_thumbnail_id(get_the_ID()));
                $thumb = $fimage !== false ? $fimage : THEME_NOIMAGE;
            } else {
                $gallery_field = tt_getmeta('portfolio_gallery');
                $gimages = explode(',', $gallery_field);
                if (isset($gimages[0]) && $gimages[0] != '') {
                    $thumb = wp_get_attachment_url($gimages[0]);
                    $thumb = $thumb !== false ? $thumb : THEME_NOIMAGE;
                }
            }
            $cols = (int) str_replace('grid', '', str_replace('masonry', '', $style));
            $img_w = 520;
            $img_w = $cols == 3 ? 337 : $img_w;
            $img_w = $cols == 4 ? 245 : $img_w;
            $height = $height != '' ? $height : '0';
            $thumb = $thumb != '' ? blox_aq_resize($thumb, $img_w, $height, true) : '';
            $folio_arg = array('item_style' => $content_type, 'overlay' => $overlay, 'thumb' => $thumb, 'class' => $class . ' ' . $current_filter_classes, 'width' => $img_w, 'height' => $height);
            $result .= blox_loop_portfolio($folio_arg);
        }
        $pager_html = '';
        if ($pager == '1') {
            ob_start();
            themeton_pager($query);
            $pager_html .= ob_get_contents();
            ob_end_clean();
        }
        $filter_html = '';
        if ($filter == '1') {
            $cat_filter_html = '';
            foreach ($cats_filter as $cat) {
                $cat_filter_html .= '<li><a href="javascript:;" title="' . $cat['title'] . '" data-filter="filter-' . $cat['slug'] . '">' . $cat['title'] . '</a></li>';
            }
            if ($cat_filter_html != '') {
                $filter_html = '<div class="row">
                                    <div class="col-md-12">
                                        <div class="portfolio-filter">
                                            <div class="pull-left">
                                                <h3>' . __('All', 'themeton') . '</h3>
                                            </div>
                                            <div class="pull-right">
                                                <ul class="nav nav-pills">
                                                    <li class="dropdown active">
                                                        <a class="dropdown-toggle navInst" data-toggle="dropdown" href="#">
                                                            ' . __('Sort Portfolio', 'themeton') . ' <span class="caret"></span>
                                                        </a>
                                                        <ul class="dropdown-menu" role="menu">
                                                            <li><a href="javascript:;" title="All" data-filter="all" class="active">' . __('All', 'themeton') . '</a></li>
                                                            <li class="divider"></li>
                                                            ' . $cat_filter_html . '
                                                        </ul>
                                                    </li>
                                                </ul>
                                            </div>
                                            <div class="clearfix"></div>
                                        </div>
                                    </div>
                                </div>';
            }
        }
        // Grid container
        $masonry_class = '';
        if (strpos($style, 'masonry') !== false) {
            $masonry_class = 'portfolio-masonry';
        }
        $result = '<div class="blox-element grid-loop portfolio ' . $element_style . ' ' . $masonry_class . ' ' . $extra_class . ' ' . $visibility . '">
                        ' . $filter_html . '
                        <div class="row masonry-container">' . $result . '</div>
                        ' . $pager_html . '
                    </div>';
    }
    wp_reset_query();
    wp_reset_postdata();
    $query = $temp_qry;
    $post = $temp_post;
    return $result;
}
示例#3
0
function ttwc_pagination()
{
    global $wp_query;
    themeton_pager($wp_query);
}
示例#4
0
function blox_parse_blog_hook($atts)
{
    extract(shortcode_atts(array('title' => '', 'blog_type' => 'default', 'categories' => 'all', 'blog_filter' => '', 'count' => '5', 'pager' => '1', 'content' => 'both', 'readmore' => __('Read more', 'themeton'), 'ignoresticky' => 'yes', 'overlay' => 'none', 'exclude' => '', 'order' => '', 'skip' => '0', 'extra_class' => '', 'skin' => 'default', 'visibility' => ''), $atts));
    $element_style = $skin;
    $visibility = str_replace(',', ' ', $visibility);
    $extra_class .= ' ' . $visibility;
    global $query, $post, $paged;
    $temp_qry = $query;
    $temp_post = $post;
    wp_reset_query();
    wp_reset_postdata();
    /*
        Build queries
        ===============================================================*/
    if (is_front_page()) {
        $paged = get_query_var('page') ? get_query_var('page') : 1;
    }
    $args = array('paged' => $paged, 'posts_per_page' => (int) $count + (int) $skip, 'ignore_sticky_posts' => $ignoresticky == 'yes' ? 1 : 0);
    if ($categories == 'categories') {
        $args['cat'] = $blog_filter;
    } else {
        if ($categories == 'tags') {
            $args['tag'] = $blog_filter;
        } else {
            if ($categories == 'format') {
                $format_array = explode(',', $blog_filter);
                $array = array();
                foreach ($format_array as $value) {
                    $array[] = 'post-format-' . $value;
                }
                $args['tax_query'] = array(array('taxonomy' => 'post_format', 'field' => 'slug', 'terms' => $array));
            }
        }
    }
    // Exclude posts
    if ($exclude != '') {
        $args['post__not_in'] = explode(',', $exclude);
    }
    if ($order == 'dateasc') {
        $args['orderby'] = 'date';
        $args['order'] = 'ASC';
    } elseif ($order == 'titleasc') {
        $args['orderby'] = 'title';
        $args['order'] = 'ASC';
    } elseif ($order == 'titledes') {
        $args['orderby'] = 'title';
        $args['order'] = 'DESC';
    } elseif ($order == 'comment') {
        $args['orderby'] = 'comment_count';
    } elseif ($order == 'postid') {
        $args['orderby'] = 'ID';
    } elseif ($order == 'random') {
        $args['orderby'] = 'rand';
        add_action('posts_orderby', 'edit_posts_orderby');
    }
    /*
        Build queries
        ===============================================================*/
    $title = $title != '' ? '<h3 class="element-title">' . $title . '</h3>' : '';
    $element_style = $element_style != 'default' ? $element_style : '';
    $column_str = $blog_type;
    $column_str = str_replace('grid', '', $column_str);
    $column_str = str_replace('masonry', '', $column_str);
    $column = (int) $column_str;
    $result = '';
    $open_grid_pager = $close_grid_pager = '';
    $query = new WP_Query($args);
    if ($query->have_posts()) {
        $cats_filter = array();
        $item_number = 1;
        while ($query->have_posts()) {
            $query->the_post();
            $loop_args = array('overlay' => $overlay, 'excerpt' => $content, 'readmore' => $readmore, 'grid' => $column, 'element_style' => $element_style);
            ob_start();
            $post_format = get_post_format();
            if (function_exists('blox_loop_' . $blog_type)) {
                call_user_func('blox_loop_' . $blog_type, $loop_args);
            } else {
                call_user_func('blox_loop_regular', $loop_args);
            }
            $result .= ob_get_contents();
            ob_end_clean();
        }
        $pager_html = '';
        if ($pager == '1') {
            ob_start();
            themeton_pager($query);
            $pager_html .= ob_get_contents();
            ob_end_clean();
        }
        // Grid container
        if (strpos($blog_type, 'grid') !== false) {
            $result = '<div class="blox-element blog grid-loop ' . $element_style . ' ' . $extra_class . '">
                            <div class="row">
                                <div class="loop-container">' . $result . '</div>
                            </div>
                            ' . $pager_html . '
                        </div>';
        } else {
            if (strpos($blog_type, 'masonry') !== false) {
                $result = '<div class="blox-element blog grid-loop ' . $element_style . ' ' . $extra_class . '">
                            <div class="row">
                                <div class="loop-masonry">' . $result . '</div>
                            </div>
                            ' . $pager_html . '
                        </div>';
            } else {
                $result = '<div class="blox-element blog medium-loop ' . $element_style . ' ' . $extra_class . '">
                        <div class="row">
                            <div class="col-md-12">' . $result . '</div>
                        </div>
                        ' . $pager_html . '
                      </div>';
            }
        }
    }
    wp_reset_query();
    wp_reset_postdata();
    $query = $temp_qry;
    $post = $temp_post;
    return $result;
}