\';
$html = '';
$html .= '
';
global $post;
$html .= '- ' . esc_attr__('Home', 'nighty') . '
';
if ( is_category() ) {
global $wp_query;
$cat_obj = $wp_query->get_queried_object();
$thisCat = $cat_obj->term_id;
$thisCat = get_category($thisCat);
$parentCat = get_category($thisCat->parent);
if ($thisCat->parent != 0) $html .= $separator.'- '.get_category_parents($parentCat, TRUE, ' ').'
';
$html .= $separator.'- ' . single_cat_title('', false) . '
';
} elseif ( is_day() ) {
$html .= $separator.'- ' . get_the_time('Y') . '
';
$html .= $separator.'- ' . get_the_time('m') . '
';
$html .= $separator.'- ' . get_the_time('d').'
';
} elseif ( is_month() ) {
$html .= $separator.'- ' . get_the_time('Y') . '
';
$html .= $separator.'- ' . get_the_time('m') . '
';
} elseif ( is_year() ) {
$html .= $separator.'- ' . get_the_time('Y') . '
';
} elseif ( is_single() && !is_attachment() ) {
if ( get_post_type() != 'post' ) {
$post_type = get_post_type_object(get_post_type());
if( $post_type->rewrite && get_option('permalink_structure') ){
$html .= $separator.'- ' . $post_type->labels->singular_name . '
';
}
$html .= $separator.'- ' . get_the_title() . '
';
} else {
$cat = get_the_category();
$cat = isset( $cat[0] ) ? $cat[0] : '';
if( $cat ){
$html .= $separator.'- '.get_category_parents( $cat, TRUE, '' ).'
';
$html .= $separator.'- ' . get_the_title() . '
';
}
}
} elseif ( is_search()) {
$html .= $separator.'- ' . esc_html__('Search results for', 'nighty').' ' . get_search_query() . '
';
} elseif ( !is_single() && !is_page() && get_post_type() != 'post' && !is_404() ) {
$post_type = get_post_type_object(get_post_type());
if ( is_archive() && single_term_title('', false) ) {
$html .= single_term_title('', false) ? $separator.'- ' . single_term_title('', false) . '
' : '';
} else {
$html .= $post_type ? $separator.'- ' . $post_type->labels->singular_name . '
' : '';
}
} elseif ( is_attachment() ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) $html .= $separator .'- '. $crumb.'
';
$html .= $separator. '- ' . get_the_title() . '
';
} elseif ( is_page() && !$post->post_parent ) {
$html .= $separator. '- ' . get_the_title() . '
';
} elseif ( is_page() && $post->post_parent ) {
$parent_id = $post->post_parent;
$breadcrumbs = array();
while ($parent_id) {
$page = get_page($parent_id);
$breadcrumbs[] = '' . get_the_title($page->ID) . '';
$parent_id = $page->post_parent;
}
$breadcrumbs = array_reverse($breadcrumbs);
foreach ($breadcrumbs as $crumb) $html .= $separator .'- '. $crumb.'
';
$html .= $separator.'- ' . get_the_title() . '
';
} elseif ( is_tag() ) {
$html .= $separator.'- ' . esc_html__('Archive by tag', 'nighty').' ' . single_tag_title('', false) . '
';
} elseif ( is_author() ) {
global $author;
$userdata = get_userdata($author);
$html .= $separator.'- ' . esc_html__('Articles posted by', 'nighty').' ' . $userdata->display_name . '
';
} elseif ( is_home() ){
$html .= $separator.'- ' . esc_html__('Blog', 'nighty').' ' . '
';
} elseif ( is_404() ) {
$html .= $separator.'- ' . esc_html__('Page not found', 'nighty') . '
';
}
$html .= '
';
$html .= '
';
$args = array(
'a' => array(
'href' => array(),
'title' => array()
),
'div' => array(
'id' => array(),
'class' => array(),
),
'ul' => array(
'id' => array(),
'class' => array(),
),
'li' => array(
'id' => array(),
'class' => array(),
),
'span' => array(
'id' => array(),
'class' => array(),
),
'i' => array(
'class' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
);
echo wp_kses( $html, $args );
}
} else {
$args = array(
'delimiter' => '',
'wrap_before' => '',
'before' => '',
'after' => '',
'home' => esc_html__( 'Home', 'nighty' )
);
woocommerce_breadcrumb( $args );
}