if ( ! function_exists( 'presscore_get_breadcrumbs' ) ) :
/**
* Returns breadcrumbs html
* original script you can find on http://dimox.net
*
* @since 1.0.0
*
* @param array $args
*
* @return string Breadcrumbs html
*/
function presscore_get_breadcrumbs( $args = array() ) {
$default_args = array(
'text' => array(
'home' => __( 'Home', 'the7mk2'),
'category' => __( 'Category "%s"', 'the7mk2'),
'search' => __( 'Results for "%s"', 'the7mk2'),
'tag' => __( 'Entries tagged with "%s"', 'the7mk2'),
'author' => __( 'Article author %s', 'the7mk2'),
'404' => __( 'Error 404', 'the7mk2'),
),
'showCurrent' => true,
'showOnHome' => true,
'delimiter' => '',
'before' => '<li class="current">',
'after' => '</li>',
'linkBefore' => '<li typeof="v:Breadcrumb">',
'linkAfter' => '</li>',
'linkAttr' => ' rel="v:url" property="v:title"',
'beforeBreadcrumbs' => '',
'afterBreadcrumbs' => '',
'listAttr' => ' class="breadcrumbs text-small"'
);
$args = wp_parse_args( $args, $default_args );
$breadcrumbs_html = apply_filters( 'presscore_get_breadcrumbs-html', '', $args );
if ( $breadcrumbs_html ) {
return $breadcrumbs_html;
}
extract( array_intersect_key( $args, $default_args ), EXTR_OVERWRITE );
$link = $linkBefore . '<a' . $linkAttr . ' href="%1$s" title="">%2$s</a>' . $linkAfter;
$breadcrumbs_html .= '<div class="assistive-text">' . __( 'You are here:', 'the7mk2' ) . '</div>';
$homeLink = trailingslashit( home_url() );
global $post;
$current_words_num = apply_filters( 'presscore_get_breadcrumbs-current_words_num', 5 );
if (is_home() || is_front_page()) {
if ($showOnHome) {
$breadcrumbs_html .= '<ol' . $listAttr . '><a href="' . $homeLink . '">' . $text['home'] . '</a></ol>';
}
} else {
$breadcrumbs_html .= '<ol' . $listAttr . ' xmlns:v="http://rdf.data-vocabulary.org/#">' . sprintf($link, $homeLink, $text['home']) . $delimiter;
if ( is_category() ) {
$thisCat = get_category(get_query_var('cat'), false);
if ($thisCat->parent !== 0) {
$cats = get_category_parents($thisCat->parent, TRUE, $delimiter);
$cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
$cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
if(preg_match( '/title="/', $cats ) ===0) {
$cats = preg_replace('/title=""/', 'title=""', $cats);
}
$breadcrumbs_html .= $cats;
}
$breadcrumbs_html .= '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="'.get_home_url().'/products/">Продукция</a></li>';
$breadcrumbs_html .= $before . single_cat_title('', false). $after;
} elseif ( is_search() ) {
$breadcrumbs_html .= $before . sprintf($text['search'], get_search_query()) . $after;
} elseif ( is_day() ) {
$breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
$breadcrumbs_html .= sprintf($link, get_month_link(get_the_time('Y'),get_the_time('m')), get_the_time('F')) . $delimiter;
$breadcrumbs_html .= $before . get_the_time('d') . $after;
} elseif ( is_month() ) {
$breadcrumbs_html .= sprintf($link, get_year_link(get_the_time('Y')), get_the_time('Y')) . $delimiter;
$breadcrumbs_html .= $before . get_the_time('F') . $after;
} elseif ( is_year() ) {
$breadcrumbs_html .= $before . get_the_time('Y') . $after;
} elseif ( is_single() && !is_attachment() ) {
$post_type = get_post_type();
if ( $post_type !== 'post' ) {
$post_type_obj = get_post_type_object( $post_type );
if($post_type == "new") {
$breadcrumbs_html .= sprintf($link, home_url('news'), $post_type_obj->labels->singular_name);
} else {
$breadcrumbs_html .= sprintf($link, get_post_type_archive_link( $post_type ), $post_type_obj->labels->singular_name);
}
if ($showCurrent) {
$breadcrumbs_html .= $delimiter . $before . wp_trim_words( get_the_title(), $current_words_num ) . $after;
}
} else {
if(is_single([2190, 2573, 2577, 2582, 2567,3045,2570,])) {
$cat = get_the_category();
if ( $cat ) {
$cat = $cat[0];
$cats = get_category_parents($cat, TRUE, $delimiter);
if ( ! is_wp_error( $cats ) ) {
if (! $showCurrent) {
$cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);
}
$cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
$cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
$breadcrumbs_html .= '<li typeof="v:Breadcrumb"><a rel="v:url" property="v:title" href="'.get_home_url().'/products/">Продукция</a></li>';
}
}
}
else {
$cat = get_the_category();
if ( $cat ) {
$cat = $cat[0];
$cats = get_category_parents($cat, TRUE, $delimiter);
if ( ! is_wp_error( $cats ) ) {
if (! $showCurrent) {
$cats = preg_replace("#^(.+)$delimiter$#", "$1", $cats);
}
$cats = str_replace('<a', $linkBefore . '<a' . $linkAttr, $cats);
$cats = str_replace('</a>', '</a>' . $linkAfter, $cats);
$breadcrumbs_html .= $cats;
}
}
}
if ($showCurrent) {
$breadcrumbs_html .= $before . wp_trim_words( get_the_title(), $current_words_num ) . $after;
}
}
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type_obj = get_post_type_object(get_post_type());
if ( $post_type_obj ) {
$breadcrumbs_html .= $before . $post_type_obj->labels->singular_name . $after;
}
} elseif ( is_attachment() ) {
if ($showCurrent) {
$breadcrumbs_html .= $delimiter . $before . wp_trim_words( get_the_title(), $current_words_num ) . $after;
}
} elseif ( is_page() && !$post->post_parent ) {
if ($showCurrent) {
$breadcrumbs_html .= $before . wp_trim_words( get_the_title(), $current_words_num ) . $after;
}
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_post($parent_id);
$breadcrumbs[] = sprintf($link, get_permalink($page->ID), get_the_title($page->ID));
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
for ($i = 0; $i < count($breadcrumbs); $i++) {
$breadcrumbs_html .= $breadcrumbs[$i];
if ($i != count($breadcrumbs)-1) {
$breadcrumbs_html .= $delimiter;
}
}
if ($showCurrent) {
$breadcrumbs_html .= $delimiter . $before . wp_trim_words( get_the_title(), $current_words_num ) . $after;
}
} elseif ( is_tag() ) {
$breadcrumbs_html .= $before . sprintf($text['tag'], single_tag_title('', false)) . $after;
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
$breadcrumbs_html .= $before . sprintf($text['author'], $userdata->display_name) . $after;
} elseif ( is_404() ) {
$breadcrumbs_html .= $before . $text['404'] . $after;
}
if ( get_query_var('paged') ) {
$breadcrumbs_html .= $before;
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) {
$breadcrumbs_html .= ' (';
}
$breadcrumbs_html .= __( 'Page', 'the7mk2' ) . ' ' . get_query_var('paged');
if ( is_category() || is_day() || is_month() || is_year() || is_search() || is_tag() || is_author() ) {
$breadcrumbs_html .= ')';
}
$breadcrumbs_html .= $after;
}
$breadcrumbs_html .= '</ol>';
}
return apply_filters( 'presscore_get_breadcrumbs', $beforeBreadcrumbs . $breadcrumbs_html . $afterBreadcrumbs, $args );
}
endif;
if(is_single([2190, 2573, 2577, 2582, 2567,3045,2570,]))