示例#1
0
文件: core.wp.php 项目: pcuervo/odc
 function axiom_show_breadcrumbs($args = array())
 {
     global $wp_query, $post;
     axiom_set_global('in_breadcrumbs', true);
     $args = array_merge(array('home' => __('Home', 'axiom'), 'home_url' => '', 'show_all_filters' => true, 'show_all_posts' => true, 'truncate_title' => 50, 'truncate_add' => '...', 'delimiter' => '<span class="breadcrumbs_delimiter"></span>', 'max_levels' => axiom_get_theme_option('breadcrumbs_max_level'), 'echo' => true), is_array($args) ? $args : array('home' => $args));
     $type = axiom_get_blog_type();
     $title = axiom_strshort(axiom_get_blog_title(), $args['truncate_title'], $args['truncate_add']);
     if (in_array($type, array('home', 'frontpage'))) {
         return '';
     }
     if ($args['max_levels'] <= 0) {
         $args['max_levels'] = 999;
     }
     $need_reset = true;
     $rez = $rez_parent = $rez_all = $rez_level = $rez_period = '';
     $cat = $parentTax = '';
     $level = $parent = $post_id = 0;
     // Get current post ID and path to current post/page/attachment ( if it have parent posts/pages )
     if ($type == 'page' || $type == 'attachment' || is_single()) {
         $pageParentID = isset($wp_query->post->post_parent) ? $wp_query->post->post_parent : 0;
         $post_id = $type == 'attachment' ? $pageParentID : (isset($wp_query->post->ID) ? $wp_query->post->ID : 0);
         while ($pageParentID > 0) {
             $pageParent = get_post($pageParentID);
             $level++;
             if ($level > $args['max_levels']) {
                 $rez_level = '...';
             } else {
                 $rez_parent = '<a class="breadcrumbs_item cat_post" href="' . get_permalink($pageParent->ID) . '">' . trim(axiom_strshort($pageParent->post_title, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
             }
             if (($pageParentID = $pageParent->post_parent) > 0) {
                 $post_id = $pageParentID;
             }
         }
     }
     $depth = 0;
     $taxonomy = apply_filters('axiom_filter_get_current_taxonomy', '', $type);
     $ex_cats = $taxonomy == 'category' ? explode(',', axiom_get_theme_option('exclude_cats')) : array();
     do {
         if ($depth++ == 0) {
             if (is_single() || is_attachment()) {
                 if ($args['show_all_filters']) {
                     $post_format = get_post_format($post_id);
                     if (($tpl_id = axiom_get_template_page_id('only-' . $post_format)) > 0) {
                         $level++;
                         if ($level > $args['max_levels']) {
                             $rez_level = '...';
                         } else {
                             $rez_all .= (!empty($rez_all) ? $args['delimiter'] : '') . '<a class="breadcrumbs_item all" href="' . get_permalink($tpl_id) . '">' . sprintf(__('All %s', 'axiom'), axiom_get_post_format_name($post_format, false)) . '</a>';
                         }
                     }
                 }
                 $cats = axiom_get_terms_by_post_id(array('post_id' => $post_id, 'taxonomy' => $taxonomy, 'exclude' => $ex_cats));
                 $cat = !empty($cats) && !empty($cats[$taxonomy]->terms) ? $cats[$taxonomy]->terms[0] : false;
                 if ($cat) {
                     $level++;
                     if ($level > $args['max_levels']) {
                         $rez_level = '...';
                     } else {
                         $rez_parent = '<a class="breadcrumbs_item cat_post" href="' . esc_url($cat->link) . '">' . trim(axiom_strshort($cat->name, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
                     }
                 }
             } else {
                 if ($type == 'category') {
                     $cat_id = (int) get_query_var('cat');
                     if (empty($cat_id)) {
                         $cat_id = get_query_var('category_name');
                     }
                     $cat = get_term_by((int) $cat_id > 0 ? 'id' : 'slug', $cat_id, 'category', OBJECT);
                 } else {
                     if (($tax = axiom_is_taxonomy()) != '') {
                         $cat = get_term_by('slug', get_query_var($tax), $tax, OBJECT);
                     }
                 }
             }
             if ($cat) {
                 $parent = $cat->parent;
                 $parentTax = $cat->taxonomy;
             }
         }
         if ($parent) {
             $cat = get_term_by('id', $parent, $parentTax, OBJECT);
             if ($cat) {
                 if (!in_array($cat->term_id, $ex_cats)) {
                     $cat_link = get_term_link($cat->slug, $cat->taxonomy);
                     $level++;
                     if ($level > $args['max_levels']) {
                         $rez_level = '...';
                     } else {
                         $rez_parent = '<a class="breadcrumbs_item cat_parent" href="' . esc_url($cat_link) . '">' . trim(axiom_strshort($cat->name, $args['truncate_title'], $args['truncate_add'])) . '</a>' . (!empty($rez_parent) ? $args['delimiter'] : '') . $rez_parent;
                     }
                 }
                 $parent = $cat->parent;
             }
         }
     } while ($parent);
     if ($args['show_all_posts']) {
         $all_title = axiom_get_stream_page_title($type);
         $all_parts = explode(':', $all_title);
         if (count($all_parts) > 1) {
             $all_title = trim($all_parts[1]);
         }
         if ($all_title && axiom_strtolower($title) != axiom_strtolower($all_title)) {
             $all_link = axiom_get_stream_page_link($type);
             $rez_all = '<a class="breadcrumbs_item all" href="' . esc_url($all_link) . '">' . $all_title . '</a>' . (!empty($rez_all) ? $args['delimiter'] : '') . $rez_all;
         }
     }
     $rez_period = apply_filters('axiom_filter_get_period_links', '', $type, $args['delimiter']);
     if (!is_front_page()) {
         // && !is_home()
         $rez .= (isset($args['home']) && $args['home'] != '' ? '<a class="breadcrumbs_item home" href="' . ($args['home_url'] ? $args['home_url'] : home_url()) . '">' . $args['home'] . '</a>' . $args['delimiter'] : '') . (!empty($rez_all) ? $rez_all . $args['delimiter'] : '') . (!empty($rez_level) ? $rez_level . $args['delimiter'] : '') . (!empty($rez_parent) ? $rez_parent . $args['delimiter'] : '') . (!empty($rez_period) ? $rez_period . $args['delimiter'] : '') . ($title ? '<span class="breadcrumbs_item current">' . $title . '</span>' : '');
     }
     if ($args['echo'] && !empty($rez)) {
         echo $rez;
     }
     axiom_set_global('in_breadcrumbs', false);
     return $rez;
 }
示例#2
0
    function axiom_woocommerce_close_item_wrapper($cat = '')
    {
        ?>
			</div>
		</div>
		<?php 
        axiom_set_global('in_product_item', false);
    }