';
}
/* If the post type path returns nothing and there is a parent, get its parents. */
if ( empty( $path ) && 0 !== $parent || 'attachment' == $post_type ) $trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( $parent, '' ) );
/* Toggle the display of the posts page on single blog posts. */
if ( 'post' == $post_type && $show_posts_page == true && 'page' == get_option( 'show_on_front' ) ) {
$posts_page = get_option( 'page_for_posts' );
if ( $posts_page != '' && is_numeric( $posts_page ) ) {
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( $posts_page, '' ) );
}
}
/* Display terms for specific post type taxonomy if requested. */
if ( isset( $args["singular_{$post_type}_taxonomy"] ) && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) ) $trail[] = $terms;
/* End with the post title. */
$post_title = get_the_title( $post_id ); // Force the post_id to make sure we get the correct page title.
if ( !empty( $post_title ) ) $trail['trail_end'] = $post_title;
}
/* If we're viewing any type of archive. */
elseif ( is_archive() ) {
/* If viewing a taxonomy term archive. */
if ( is_tax() || is_category() || is_tag() ) {
/* Get some taxonomy and term variables. */
$term = $wp_query->get_queried_object();
$taxonomy = get_taxonomy( $term->taxonomy );
/* Get the path to the term archive. Use this to determine if a page is present with it. */
if ( is_category() )
$path = get_option( 'category_base' );
elseif ( is_tag() )
$path = get_option( 'tag_base' );
else {
if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
$path = trailingslashit( $wp_rewrite->front );
$path .= $taxonomy->rewrite['slug'];
}
/* Get parent pages by path if they exist. */
if ( $path )
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( '', $path ) );
/* If the taxonomy is hierarchical, list its parent terms. */
if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_term_parents( $term->parent, $term->taxonomy ) );
/* Add the term name to the trail end. */
$trail['trail_end'] = $term->name;
}
/* If viewing a post type archive. */
elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
/* Get the post type object. */
$post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
/* If $front has been set, add it to the $path. */
if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front )
$path .= trailingslashit( $wp_rewrite->front );
/* If there's a slug, add it to the $path. */
if ( !empty( $post_type_object->rewrite['archive'] ) )
$path .= $post_type_object->rewrite['archive'];
/* If there's a path, check for parents. */
if ( !empty( $path ) && '/' != $path )
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( '', $path ) );
/* Add the post type [plural] name to the trail end. */
$trail['trail_end'] = $post_type_object->labels->name;
}
/* If viewing an author archive. */
elseif ( is_author() ) {
/* If $front has been set, add it to $path. */
if ( !empty( $wp_rewrite->front ) )
$path .= trailingslashit( $wp_rewrite->front );
/* If an $author_base exists, add it to $path. */
if ( !empty( $wp_rewrite->author_base ) )
$path .= $wp_rewrite->author_base;
/* If $path exists, check for parent pages. */
if ( !empty( $path ) )
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( '', $path ) );
/* Add the author's display name to the trail end. */
$trail['trail_end'] = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
}
/* If viewing a time-based archive. */
elseif ( is_time() ) {
if ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
$trail['trail_end'] = get_the_time( __( 'g:i a', 'anaglyph-lite' ) );
elseif ( get_query_var( 'minute' ) )
$trail['trail_end'] = sprintf( __( 'Minute %1$s', 'anaglyph-lite' ), get_the_time( __( 'i', 'anaglyph-lite' ) ) );
elseif ( get_query_var( 'hour' ) )
$trail['trail_end'] = get_the_time( __( 'g a', 'anaglyph-lite' ) );
}
/* If viewing a date-based archive. */
elseif ( is_date() ) {
/* If $front has been set, check for parent pages. */
if ( $wp_rewrite->front )
$trail = array_merge( $trail, anaglyph_breadcrumbs_get_parents( '', $wp_rewrite->front ) );
if ( is_day() ) {
$trail[] = '
';
/* If viewing a 404 error page. */
elseif ( is_404() )
$trail['trail_end'] = __( '404 Not Found', 'anaglyph-lite' );
/* Connect the breadcrumb trail if there are items in the trail. */
if ( is_array( $trail ) ) {
/* If $before was set, wrap it in a container. */
if ( !empty( $before ) )
$breadcrumb .= '' . wp_kses_post( $before ) . ' ';
/* Wrap the $trail['trail_end'] value in a container. */
if ( !empty( $trail['trail_end'] ) && !is_search() )
$trail['trail_end'] = '
' . wp_kses_post( $trail['trail_end'] ) . '
';
/* Format the separator. */
if ( !empty( $separator ) )
$separator = '
' . wp_kses_post( $separator ) . '
';
/* Join the individual trail items into a single string. */
$breadcrumb .= join( " {$separator} ", $trail );
/* If $after was set, wrap it in a container. */
if ( !empty( $after ) )
$breadcrumb .= '