示例#1
0
文件: core.wp.php 项目: pcuervo/odc
 function axiom_get_parent_category_by_property($id, $prop, $values, $highest = true)
 {
     return axiom_get_parent_taxonomy_by_property($id, $prop, $values, $highest, 'category');
 }
示例#2
0
function axiom_sc_blogger($atts, $content = null)
{
    if (axiom_sc_in_shortcode_blogger(true)) {
        return '';
    }
    extract(axiom_sc_html_decode(shortcode_atts(array("style" => "regular", "filters" => "no", "post_type" => "post", "ids" => "", "cat" => "", "count" => "3", "columns" => "", "offset" => "", "orderby" => "date", "order" => "desc", "only" => "no", "descr" => "", "readmore" => "", "loadmore" => "no", "location" => "default", "dir" => "horizontal", "hover" => axiom_get_theme_option('hover_style'), "hover_dir" => axiom_get_theme_option('hover_dir'), "scroll" => "no", "controls" => "no", "rating" => "no", "info" => "yes", "links" => "yes", "date_format" => "", "id" => "", "class" => "", "css" => "", "animation" => "", "width" => "", "height" => "", "top" => "", "bottom" => "", "left" => "", "right" => ""), $atts)));
    $css .= axiom_get_css_position_from_values($top, $right, $bottom, $left, $width, $height);
    $width = axiom_prepare_css_value($width);
    $height = axiom_prepare_css_value($height);
    global $post, $AXIOM_GLOBALS;
    $AXIOM_GLOBALS['sc_blogger_busy'] = true;
    $AXIOM_GLOBALS['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 (!empty($ids)) {
        $posts = explode(',', str_replace(' ', '', $ids));
        $count = count($posts);
    }
    if ($descr == '') {
        $descr = axiom_get_custom_option('post_excerpt_maxlength' . ($columns > 1 ? '_masonry' : ''));
    }
    if (!axiom_sc_param_is_off($scroll)) {
        axiom_enqueue_slider();
        if (empty($id)) {
            $id = 'sc_blogger_' . str_replace('.', '', mt_rand());
        }
    }
    $class = apply_filters('axiom_filter_blog_class', 'sc_blogger' . ' layout_' . esc_attr($style) . ' template_' . esc_attr(axiom_get_template_name($style)) . (!empty($class) ? ' ' . esc_attr($class) : '') . ' ' . esc_attr(axiom_get_template_property($style, 'container_classes')) . ' sc_blogger_' . ($dir == 'vertical' ? 'vertical' : 'horizontal') . (axiom_sc_param_is_on($scroll) && axiom_sc_param_is_on($controls) ? ' sc_scroll_controls sc_scroll_controls_type_top sc_scroll_controls_' . esc_attr($dir) : '') . ($descr == 0 ? ' no_description' : ''), array('style' => $style, 'dir' => $dir, 'descr' => $descr));
    $container = apply_filters('axiom_filter_blog_container', axiom_get_template_property($style, 'container'), array('style' => $style, 'dir' => $dir));
    $container_start = $container_end = '';
    if (!empty($container)) {
        $container = explode('%s', $container);
        $container_start = !empty($container[0]) ? $container[0] : '';
        $container_end = !empty($container[1]) ? $container[1] : '';
    }
    $output = (strpos($style, 'list') !== 'FALSE' ? '<ul' : '<div') . ($id ? ' id="' . esc_attr($id) . '"' : '') . ' class="' . esc_attr($class) . '"' . ($css != '' ? ' style="' . esc_attr($css) . '"' : '') . (!axiom_sc_param_is_off($animation) ? ' data-animation="' . esc_attr(axiom_sc_get_animation_classes($animation)) . '"' : '') . '>' . $container_start . ($dir == 'horizontal' && $columns > 1 && axiom_get_template_property($style, 'need_columns') ? '<div class="columns_wrap">' : '') . (axiom_sc_param_is_on($scroll) ? '<div id="' . esc_attr($id) . '_scroll" class="sc_scroll sc_scroll_' . esc_attr($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 (axiom_get_template_property($style, 'need_isotope')) {
        if (!axiom_sc_param_is_off($filters)) {
            $output .= '<div class="isotope_filters"></div>';
        }
        if ($columns < 1) {
            $columns = axiom_substr($style, -1);
        }
        $output .= '<div class="isotope_wrap" data-columns="' . max(1, min(4, $columns)) . '">';
    }
    $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 = axiom_query_add_sort_order($args, $orderby, $order);
    if (!axiom_sc_param_is_off($only)) {
        $args = axiom_query_add_filters($args, $only);
    }
    $args = axiom_query_add_posts_and_cats($args, $ids, $post_type, $cat);
    $query = new WP_Query($args);
    $flt_ids = array();
    while ($query->have_posts()) {
        $query->the_post();
        $AXIOM_GLOBALS['sc_blogger_counter']++;
        $args = array('layout' => $style, 'show' => false, 'number' => $AXIOM_GLOBALS['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" => axiom_sc_param_is_on($rating), "dir" => $dir, "scroll" => axiom_sc_param_is_on($scroll), "info" => axiom_sc_param_is_on($info), "links" => axiom_sc_param_is_on($links), "orderby" => $orderby, "columns_count" => $columns, "date_format" => $date_format, 'strip_teaser' => false, 'content' => axiom_get_template_property($style, 'need_content'), 'terms_list' => true, 'filters' => axiom_sc_param_is_off($filters) ? '' : $filters, 'hover' => $hover, 'hover_dir' => $hover_dir);
        $post_data = axiom_get_post_data($args);
        $output .= axiom_show_post_layout($args, $post_data);
        if (!axiom_sc_param_is_off($filters)) {
            if ($filters == 'tags') {
                // Use tags as filter items
                if (!empty($post_data['post_terms'][$post_data['post_taxonomy_tags']]->terms)) {
                    foreach ($post_data['post_terms'][$post_data['post_taxonomy_tags']]->terms as $tag) {
                        $flt_ids[$tag->term_id] = $tag->name;
                    }
                }
            }
        }
    }
    wp_reset_postdata();
    // Close isotope wrapper
    if (axiom_get_template_property($style, 'need_isotope')) {
        $output .= '</div>';
    }
    // Isotope filters list
    if (!axiom_sc_param_is_off($filters)) {
        $filters_list = '';
        if ($filters == 'categories') {
            // Use categories as filter items
            $taxonomy = axiom_get_taxonomy_categories_by_post_type($post_type);
            $portfolio_parent = $cat ? max(0, axiom_get_parent_taxonomy_by_property($cat, 'show_filters', 'yes', true, $taxonomy)) : 0;
            $args2 = array('type' => $post_type, 'child_of' => $portfolio_parent, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 0, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => $taxonomy, 'pad_counts' => false);
            $portfolio_list = get_categories($args2);
            if (count($portfolio_list) > 0) {
                $filters_list .= '<a href="#" data-filter="*" class="theme_button active">' . __('All', 'axiom') . '</a>';
                foreach ($portfolio_list as $cat) {
                    $filters_list .= '<a href="#" data-filter=".flt_' . esc_attr($cat->term_id) . '" class="theme_button">' . $cat->name . '</a>';
                }
            }
        } else {
            // Use tags as filter items
            if (count($flt_ids) > 0) {
                $filters_list .= '<a href="#" data-filter="*" class="theme_button active">' . __('All', 'axiom') . '</a>';
                foreach ($flt_ids as $flt_id => $flt_name) {
                    $filters_list .= '<a href="#" data-filter=".flt_' . esc_attr($flt_id) . '" class="theme_button">' . $flt_name . '</a>';
                }
            }
        }
        if ($filters_list) {
            $output .= '<script type="text/javascript">' . 'jQuery(document).ready(function () {' . 'jQuery("#' . esc_attr($id) . ' .isotope_filters").append("' . addslashes($filters_list) . '");' . '});' . '</script>';
        }
    }
    $output .= (axiom_sc_param_is_on($scroll) ? '</div></div><div id="' . esc_attr($id) . '_scroll_bar" class="sc_scroll_bar sc_scroll_bar_' . esc_attr($dir) . ' ' . esc_attr($id) . '_scroll_bar"></div></div>' . (!axiom_sc_param_is_off($controls) ? '<div class="sc_scroll_controls_wrap"><a class="sc_scroll_prev" href="#"></a><a class="sc_scroll_next" href="#"></a></div>' : '') : '') . ($dir == 'horizontal' && $columns > 1 && axiom_get_template_property($style, 'need_columns') ? '</div>' : '') . $container_end . (strpos($style, 'list') !== 'FALSE' ? '</ul>' : '</div>');
    // Add template specific scripts and styles
    do_action('axiom_action_blog_scripts', $style);
    $AXIOM_GLOBALS['sc_blogger_busy'] = false;
    if (strpos($style, 'accordion') !== 'FALSE') {
        axiom_enqueue_script('jquery-ui-accordion', false, array('jquery', 'jquery-ui-core'), null, true);
    }
    return apply_filters('axiom_shortcode_output', $output, 'trx_blogger', $atts, $content);
}
示例#3
0
文件: blog.php 项目: pcuervo/odc
echo $container_end;
if (!$post_number) {
    if (is_search()) {
        axiom_show_post_layout(array('layout' => 'no-search'), false);
    } else {
        axiom_show_post_layout(array('layout' => 'no-articles'), false);
    }
} else {
    // Isotope filters list
    $filters = '';
    $filter_button_classes = 'isotope_filters_button';
    if ($show_filters == 'categories') {
        // Use categories as filter items
        $taxonomy = axiom_is_taxonomy();
        $cur_term = $taxonomy ? axiom_get_current_term($taxonomy) : 0;
        $portfolio_parent = $cur_term ? max(0, axiom_get_parent_taxonomy_by_property($cur_term->term_id, 'show_filters', 'yes', true, $taxonomy)) : 0;
        $args2 = array('type' => !empty($args['post_type']) ? $args['post_type'] : 'post', 'child_of' => $portfolio_parent, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => 1, 'hierarchical' => 0, 'exclude' => '', 'include' => '', 'number' => '', 'taxonomy' => $taxonomy, 'pad_counts' => false);
        $portfolio_list = get_categories($args2);
        if (count($portfolio_list) > 0) {
            $filters .= '<a href="#" data-filter="*" class="' . esc_attr($filter_button_classes . ($portfolio_parent == $cur_term->term_id ? ' active' : '')) . '">' . __('All', 'axiom') . '</a>';
            foreach ($portfolio_list as $cat) {
                $filters .= '<a href="#" data-filter=".flt_' . esc_attr($cat->term_id) . '" class="' . esc_attr($filter_button_classes . ($cat->term_id == $cur_term->term_id ? ' active' : '')) . '">' . $cat->name . '</a>';
            }
        }
    } else {
        if ($show_filters == 'tags') {
            // Use tags as filter items
            if (count($flt_ids) > 0) {
                $filters .= '<a href="#" data-filter="*" class="' . esc_attr($filter_button_classes) . ' active">' . __('All', 'axiom') . '</a>';
                foreach ($flt_ids as $flt_id => $flt_name) {
                    $filters .= '<a href="#" data-filter=".flt_' . esc_attr($flt_id) . '" class="' . esc_attr($filter_button_classes) . '">' . $flt_name . '</a>';