Пример #1
0
}
if (!$post_number) {
    if (is_search()) {
        showPostLayout(array('layout' => 'no-search-results'), false);
    } else {
        showPostLayout(array('layout' => 'no-articles'), false);
    }
} else {
    // Isotope filters list
    $ppp = (int) get_custom_option('posts_per_page');
    $filters = '';
    if (get_custom_option('show_filters') == 'yes') {
        if (get_custom_option('filter_taxonomy') == 'categories') {
            // Use categories as filter items
            $cat_id = (int) get_query_var('cat');
            $portfolio_parent = max(0, is_category() ? getParentCategoryByProperty($cat_id, 'show_filters', 'yes') : 0);
            $args2 = array('type' => 'post', 'child_of' => $portfolio_parent, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 0, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false);
            $portfolio_list = get_categories($args2);
            if (count($portfolio_list) > 0) {
                $filters .= '<li class="squareButton' . ($portfolio_parent == $cat_id ? ' active' : '') . '"><a href="#" data-filter="*">' . __('All', 'themerex') . '</a></li>';
                foreach ($portfolio_list as $cat) {
                    $filters .= '<li class="squareButton' . ($cat->term_id == $cat_id ? ' active' : '') . '"><a href="#" data-filter=".flt_' . $cat->term_id . '">' . $cat->name . '</a></li>';
                }
            }
        } else {
            // Use tags as filter items
            if (count($flt_ids) > 0) {
                $filters .= '<li class="squareButton active"><a href="#" data-filter="*">' . __('All', 'themerex') . '</a></li>';
                foreach ($flt_ids as $flt_id => $flt_name) {
                    $filters .= '<li class="squareButton"><a href="#" data-filter=".flt_' . esc_attr($flt_id) . '">' . esc_html($flt_name) . '</a></li>';
                }
Пример #2
0
function sc_blogger($atts, $content = null)
{
    if (in_shortcode_blogger(true)) {
        return '';
    }
    extract(shortcode_atts(array("id" => "", "class" => "", "style" => "regular", "filters" => "no", "ids" => "", "cat" => "", "count" => "3", "visible" => "", "offset" => "", "orderby" => "date", "order" => "desc", "only" => "no", "descr" => "0", "readmore" => "", "loadmore" => "no", "location" => "default", "dir" => "horizontal", "hover" => get_theme_option('hover_style'), "hover_dir" => get_theme_option('hover_dir'), "scroll" => "no", "controls" => "no", "rating" => "no", "info" => "yes", "links" => "yes", "date_format" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts));
    $s = getStyleString($top, $right, $bottom, $left, $width, $height);
    $width = getStyleValue($width);
    $height = getStyleValue($height);
    global $THEMEREX_sc_blogger_busy, $THEMEREX_sc_blogger_counter, $post;
    $THEMEREX_sc_blogger_busy = true;
    $THEMEREX_sc_blogger_counter = 0;
    if (empty($id)) {
        $id = "sc_blogger_" . str_replace('.', '', mt_rand());
    }
    if ($style == 'date' && empty($date_format)) {
        $date_format = 'd.m+Y';
    }
    if (!in_array($style, array('regular', 'date', 'image_large', 'image_medium', 'image_small', 'image_tiny', 'accordion_1', 'accordion_2', 'list', 'excerpt', 'related')) && !in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol'))) {
        $style = 'regular';
    }
    if (!empty($ids)) {
        $posts = explode(',', str_replace(' ', '', $ids));
        $count = count($posts);
    }
    if (in_array($style, array('accordion_1', 'accordion_2', 'list'))) {
        $dir = 'vertical';
    }
    if ($visible <= 0) {
        $visible = min(4, $count);
    }
    if (sc_param_is_on($scroll) && empty($id)) {
        $id = 'sc_blogger_' . str_replace('.', '', mt_rand());
    }
    $output = ($style == 'list' ? '<ul' : '<div') . ($id ? ' id="' . $id . '"' : '') . ' class="sc_blogger' . (!empty($class) ? ' ' . $class : '') . ' sc_blogger_' . ($dir == 'vertical' ? 'vertical' : 'horizontal') . ' style_' . (in_array($style, array('accordion_1', 'accordion_2')) ? 'accordion' : (themerex_strpos($style, 'image') !== false ? 'image style_' : '') . $style) . (in_array($style, array('accordion_1', 'accordion_2')) ? ' sc_accordion' : '') . ($style == 'accordion_1' ? ' sc_accordion_style_1' : '') . ($style == 'accordion_2' ? ' sc_accordion_style_2' : '') . (themerex_strpos($style, 'masonry') !== false || themerex_strpos($style, 'classic') !== false ? ' masonryWrap' : '') . (themerex_strpos($style, 'portfolio') !== false ? ' portfolioWrap' : '') . ($style == 'related' ? ' relatedPostWrap' : '') . (sc_param_is_on($scroll) && sc_param_is_on($controls) ? ' sc_scroll_controls sc_scroll_controls_' . $dir : '') . ($descr == 0 ? ' no_description' : '') . '"' . ($s != '' ? ' style="' . $s . '"' : '') . '>' . ($dir != 'vertical' && $style != 'date' && !in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol', 'excerpt')) ? '<div class="columnsWrap">' : '') . (sc_param_is_on($scroll) ? '<div id="' . $id . '_scroll" class="sc_scroll sc_scroll_' . $dir . ' sc_slider_noresize swiper-slider-container scroll-container"' . ' style="' . ($dir == 'vertical' ? 'height:' . ($height != '' ? $height : "230px") . ';' : 'width:' . ($width != '' ? $width : "100%") . ';') . '"' . '>' . '<div class="sc_scroll_wrapper swiper-wrapper">' . '<div class="sc_scroll_slide swiper-slide">' : '');
    if (themerex_strpos($style, 'masonry') !== false || themerex_strpos($style, 'classic') !== false) {
        if (!sc_param_is_off($filters)) {
            $output .= '<div class="isotopeFiltr"></div>';
        }
        $output .= '<section class="masonry ' . (!sc_param_is_off($filters) ? 'isotope' : 'isotopeNOanim') . '" data-columns="' . themerex_substr($style, -1) . '">';
    } else {
        if (themerex_strpos($style, 'portfolio') !== false) {
            if (!sc_param_is_off($filters)) {
                $output .= '<div class="isotopeFiltr"></div>';
            }
            $output .= '<section class="portfolio ' . (!sc_param_is_off($filters) ? 'isotope' : 'isotopeNOanim') . ' folio' . themerex_substr($style, -1) . 'col" data-columns="' . themerex_substr($style, -1) . '">';
        }
    }
    $args = array('post_status' => current_user_can('read_private_pages') && current_user_can('read_private_posts') ? array('publish', 'private') : 'publish', 'posts_per_page' => $count, 'ignore_sticky_posts' => 1, 'order' => $order == 'asc' ? 'asc' : 'desc', 'orderby' => 'date');
    if ($offset > 0 && empty($ids)) {
        $args['offset'] = $offset;
    }
    $args = addSortOrderInQuery($args, $orderby, $order);
    if (!sc_param_is_off($only)) {
        $args = addFiltersInQuery($args, array($only));
    }
    $args = addPostsAndCatsInQuery($args, $ids, $cat);
    $query = new WP_Query($args);
    $flt_ids = array();
    while ($query->have_posts()) {
        $query->the_post();
        $THEMEREX_sc_blogger_counter++;
        $args = array('layout' => in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol', 'excerpt', 'related')) ? themerex_substr($style, 0, 7) : 'blogger', 'show' => false, 'number' => $THEMEREX_sc_blogger_counter, 'add_view_more' => false, 'posts_on_page' => $count > 0 ? $count : $query->found_posts, "location" => $location, "descr" => $descr, "readmore" => $readmore, "loadmore" => $loadmore, "reviews" => sc_param_is_on($rating), "dir" => $dir, "scroll" => sc_param_is_on($scroll), "info" => sc_param_is_on($info), "links" => sc_param_is_on($links), "orderby" => $orderby, "posts_visible" => $visible, "date_format" => $date_format, 'thumb_size' => $style, 'thumb_crop' => themerex_strpos($style, 'masonry') === false, 'strip_teaser' => false, "categories_list" => in_array($style, array('excerpt')) || $filters == 'categories', "tags_list" => in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol', 'related')) || $filters == 'tags', 'filters' => sc_param_is_off($filters) ? '' : $filters, 'hover' => $hover, 'hover_dir' => $hover_dir);
        $post_data = getPostData($args);
        $output .= showPostLayout($args, $post_data);
        if (!sc_param_is_off($filters)) {
            if ($filters == 'tags') {
                // Use tags as filter items
                if (count($post_data['post_tags_list']) > 0) {
                    foreach ($post_data['post_tags_list'] as $tag) {
                        $flt_ids[$tag->term_id] = $tag->name;
                    }
                }
            }
        }
    }
    wp_reset_postdata();
    if (in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol'))) {
        if (themerex_strpos($style, 'masonry') !== false || themerex_strpos($style, 'classic') !== false) {
            $output .= '</section>';
        } else {
            if (themerex_strpos($style, 'portfolio') !== false) {
                $output .= '</section>';
            }
        }
        // Isotope filters list
        $filters_list = '';
        if (!sc_param_is_off($filters)) {
            if ($filters == 'categories') {
                // Use categories as filter items
                $portfolio_parent = max(0, getParentCategoryByProperty($cat, 'show_filters', 'yes'));
                $args2 = array('type' => 'post', 'child_of' => $portfolio_parent, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 0, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => 'category', 'pad_counts' => false);
                $portfolio_list = get_categories($args2);
                if (count($portfolio_list) > 0) {
                    $filters_list .= '<li class="squareButton' . ($portfolio_parent == $cat_id ? ' active' : '') . '"><a href="#" data-filter="*">' . __('All', 'themerex') . '</a></li>';
                    foreach ($portfolio_list as $cat) {
                        $filters_list .= '<li class="squareButton' . ($cat->term_id == $cat_id ? ' active' : '') . '"><a href="#" data-filter=".flt_' . $cat->term_id . '">' . $cat->name . '</a></li>';
                    }
                }
            } else {
                // Use tags as filter items
                if (count($flt_ids) > 0) {
                    $filters_list .= '<li class="squareButton active"><a href="#" data-filter="*">' . __('All', 'themerex') . '</a></li>';
                    foreach ($flt_ids as $flt_id => $flt_name) {
                        $filters_list .= '<li class="squareButton"><a href="#" data-filter=".flt_' . $flt_id . '">' . $flt_name . '</a></li>';
                    }
                }
            }
            if ($filters_list) {
                $output .= '<script type="text/javascript">' . 'jQuery(document).ready(function () {' . 'jQuery("#' . $id . ' .isotopeFiltr").append("<ul>' . addslashes($filters_list) . '</ul>");' . '});' . '</script>';
            }
        }
    }
    $output .= (sc_param_is_on($scroll) ? '</div></div><div id="' . $id . '_scroll_bar" class="sc_scroll_bar sc_scroll_bar_' . $dir . ' ' . $id . '_scroll_bar"></div></div>' . (sc_param_is_on($controls) ? '<ul class="flex-direction-nav"><li><a class="flex-prev" href="#"></a></li><li><a class="flex-next" href="#"></a></li></ul>' : '') : '') . ($dir != 'vertical' && $style != 'date' && !in_array(themerex_substr($style, 0, 7), array('classic', 'masonry', 'portfol', 'excerpt')) ? '</div>' : '') . ($style == 'list' ? '</ul>' : '</div>');
    if (in_array($style, array('accordion_1', 'accordion_2'))) {
        themerex_enqueue_script('jquery-ui-accordion', false, array('jquery', 'jquery-ui-core'), null, true);
    }
    $THEMEREX_sc_blogger_busy = false;
    return $output;
}