/**
 * Gets the items for the breadcrumb trail.  This is the heart of the script.  It checks the current page 
 * being viewed and decided based on the information provided by WordPress what items should be
 * added to the breadcrumb trail.
 *
 * @since 0.4.0
 * @todo Build in caching based on the queried object ID.
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_items($args = array())
{
    global $wp_rewrite;
    /* Get the textdomain. */
    $textdomain = breadcrumb_trail_textdomain();
    /* Set up an empty trail array and empty path. */
    $trail = array();
    $path = '';
    /* If $show_home is set and we're not on the front page of the site, link to the home page. */
    if (!is_front_page() && $args['show_home']) {
        $trail[] = '<a href="' . home_url() . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
    }
    /* If viewing the front page of the site. */
    if (is_front_page()) {
        if ($args['show_home'] && $args['front_page']) {
            $trail['trail_end'] = "{$args['show_home']}";
        }
    } elseif (is_home()) {
        $home_page = get_page(get_queried_object_id());
        $trail = array_merge($trail, breadcrumb_trail_get_parents($home_page->post_parent, ''));
        $trail['trail_end'] = get_the_title($home_page->ID);
    } elseif (is_singular()) {
        /* Get singular post variables needed. */
        $post = get_queried_object();
        $post_id = absint(get_queried_object_id());
        $post_type = $post->post_type;
        $parent = absint($post->post_parent);
        /* Get the post type object. */
        $post_type_object = get_post_type_object($post_type);
        /* If viewing a singular 'post'. */
        if ('post' == $post_type) {
            /* If $front has been set, add it to the $path. */
            $path .= trailingslashit($wp_rewrite->front);
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Map the permalink structure tags to actual links. */
            $trail = array_merge($trail, breadcrumb_trail_map_rewrite_tags($post_id, get_option('permalink_structure'), $args));
        } elseif ('attachment' == $post_type) {
            /* If $front has been set, add it to the $path. */
            $path .= trailingslashit($wp_rewrite->front);
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Map the post (parent) permalink structure tags to actual links. */
            $trail = array_merge($trail, breadcrumb_trail_map_rewrite_tags($post->post_parent, get_option('permalink_structure'), $args));
        } elseif ('page' !== $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['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* If there's an archive page, add it to the trail. */
            if (!empty($post_type_object->has_archive)) {
                $trail[] = '<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">' . $post_type_object->labels->name . '</a>';
            }
        }
        /* 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, breadcrumb_trail_get_parents($parent, ''));
        } elseif (0 !== $parent && is_post_type_hierarchical($post_type)) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($parent, ''));
        }
        /* Display terms for specific post type taxonomy if requested. */
        if (!empty($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();
        if (!empty($post_title)) {
            $trail['trail_end'] = $post_title;
        }
    } elseif (is_archive()) {
        /* If viewing a taxonomy term archive. */
        if (is_tax() || is_category() || is_tag()) {
            /* Get some taxonomy and term variables. */
            $term = 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, breadcrumb_trail_get_parents('', $path));
            }
            /* If the taxonomy is hierarchical, list its parent terms. */
            if (is_taxonomy_hierarchical($term->taxonomy) && $term->parent) {
                $trail = array_merge($trail, breadcrumb_trail_get_term_parents($term->parent, $term->taxonomy));
            }
            /* Add the term name to the trail end. */
            $trail['trail_end'] = single_term_title('', false);
        } elseif (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['slug'])) {
                $path .= $post_type_object->rewrite['slug'];
            }
            /* If there's a path, check for parents. */
            if (!empty($path)) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
            }
            /* Add the post type [plural] name to the trail end. */
            $trail['trail_end'] = $post_type_object->labels->name;
        } 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, breadcrumb_trail_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'));
        } elseif (is_time()) {
            if (get_query_var('minute') && get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g:i a', $textdomain));
            } elseif (get_query_var('minute')) {
                $trail['trail_end'] = sprintf(__('Minute %1$s', $textdomain), get_the_time(__('i', $textdomain)));
            } elseif (get_query_var('hour')) {
                $trail['trail_end'] = get_the_time(__('g a', $textdomain));
            }
        } elseif (is_date()) {
            /* If $front has been set, check for parent pages. */
            if ($wp_rewrite->front) {
                $trail = array_merge($trail, breadcrumb_trail_get_parents('', $wp_rewrite->front));
            }
            if (is_day()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail[] = '<a href="' . get_month_link(get_the_time('Y'), get_the_time('m')) . '" title="' . get_the_time(esc_attr__('F', $textdomain)) . '">' . get_the_time(__('F', $textdomain)) . '</a>';
                $trail['trail_end'] = get_the_time(__('d', $textdomain));
            } elseif (get_query_var('w')) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail['trail_end'] = sprintf(__('Week %1$s', $textdomain), get_the_time(esc_attr__('W', $textdomain)));
            } elseif (is_month()) {
                $trail[] = '<a href="' . get_year_link(get_the_time('Y')) . '" title="' . get_the_time(esc_attr__('Y', $textdomain)) . '">' . get_the_time(__('Y', $textdomain)) . '</a>';
                $trail['trail_end'] = get_the_time(__('F', $textdomain));
            } elseif (is_year()) {
                $trail['trail_end'] = get_the_time(__('Y', $textdomain));
            }
        }
    } elseif (is_search()) {
        $trail['trail_end'] = sprintf(__('Search results for &quot;%1$s&quot;', $textdomain), esc_attr(get_search_query()));
    } elseif (is_404()) {
        $trail['trail_end'] = __('404 Not Found', $textdomain);
    }
    /* Allow devs to step in and filter the $trail array. */
    return apply_filters('breadcrumb_trail_items', $trail, $args);
}
Example #2
0
/**
 * Shows a breadcrumb for all types of pages.  Themes and plugins can filter $args or 
 * input directly.  Allow filtering of only the $args using get_the_breadcrumb_args.
 *
 * @since 0.1
 * @param array $args Mixed arguments for the menu.
 * @return string Output of the breadcrumb menu.
 */
function breadcrumb_trail( $args = array() ) {
	global $wp_query, $wp_rewrite;

	/* Get the textdomain. */
	$textdomain = hybrid_get_textdomain();

	/* Create an empty array for the trail. */
	$trail = array();

	/* Set up the default arguments for the breadcrumb. */
	$defaults = array(
		'separator' => '/',
		'before' => '<span class="breadcrumb-title">' . __( 'Browse:', $textdomain ) . '</span>',
		'after' => false,
		'front_page' => true,
		'show_home' => __( 'Home', $textdomain ),
		'single_tax' => false, // @deprecated 0.3 Use singular_{$post_type}_taxonomy.
		'echo' => true
	);

	/* Allow singular post views to have a taxonomy's terms prefixing the trail. */
	if ( is_singular() )
		$defaults["singular_{$wp_query->post->post_type}_taxonomy"] = false;

	/* Apply filters to the arguments. */
	$args = apply_filters( 'breadcrumb_trail_args', $args );

	/* Parse the arguments and extract them for easy variable naming. */
	extract( wp_parse_args( $args, $defaults ) );

	/* For backwards compatibility, set $single_tax if it's explicitly given. */
	if ( $single_tax )
		$args['singular_post_taxonomy'] = $single_tax;

	/* Format the separator. */
	if ( $separator )
		$separator = '<span class="sep">' . $separator . '</span>';

	/* If $show_home is set and we're not on the front page of the site, link to the home page. */
	if ( !is_front_page() && $show_home )
		$trail[] = '<a href="' . home_url() . '" title="' . get_bloginfo( 'name' ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';

	/* If viewing the front page of the site. */
	if ( is_front_page() ) {
		if ( !$front_page )
			$trail = false;
		elseif ( $show_home )
			$trail['trail_end'] = "{$show_home}";
	}

	/* If viewing the "home"/posts page. */
	elseif ( is_home() ) {
		$home_page = get_page( $wp_query->get_queried_object_id() );
		$trail = array_merge( $trail, breadcrumb_trail_get_parents( $home_page->post_parent, '' ) );
		$trail['trail_end'] = get_the_title( $home_page->ID );
	}

	/* If viewing a singular post (page, attachment, etc.). */
	elseif ( is_singular() ) {

		/* Get singular post variables needed. */
		$post_id = absint( $wp_query->post->ID );
		$post_type = $wp_query->post->post_type;
		$parent = $wp_query->post->post_parent;

		/* If a custom post type, check if there are any pages in its hierarchy based on the slug. */
		if ( 'page' !== $post_type ) {

			$post_type_object = get_post_type_object( $post_type );

			/* If $front has been set, add it to the $path. */
			if ( 'post' == $post_type || 'attachment' == $post_type || ( $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['slug'] ) )
				$path .= $post_type_object->rewrite['slug'];

			/* If there's a path, check for parents. */
			if ( !empty( $path ) )
				$trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
		}

		/* If the post type is hierarchical or is an attachment, get its parents. */
		if ( is_post_type_hierarchical( $post_type ) || is_attachment() )
			$trail = array_merge( $trail, breadcrumb_trail_get_parents( $parent, '' ) );

		/* Display terms for specific post type taxonomy if requested. */
		if ( $args["singular_{$post_type}_taxonomy"] && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) )
			$trail[] = $terms;

		/* End with the post title. */
		$trail['trail_end'] = get_the_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, breadcrumb_trail_get_parents( '', $path ) );

			/* If the taxonomy is hierarchical, list its parent terms. */
			if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
				$trail = array_merge( $trail, breadcrumb_trail_get_term_parents( $term->parent, $term->taxonomy ) );

			/* Add the term name to the trail end. */
			$trail['trail_end'] = $term->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, breadcrumb_trail_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', $textdomain ) );

			elseif ( get_query_var( 'minute' ) )
				$trail['trail_end'] = sprintf( __( 'Minute %1$s', $textdomain ), get_the_time( __( 'i', $textdomain ) ) );

			elseif ( get_query_var( 'hour' ) )
				$trail['trail_end'] = get_the_time( __( 'g a', $textdomain ) );
		}

		/* 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, breadcrumb_trail_get_parents( '', $wp_rewrite->front ) );

			if ( is_day() ) {
				$trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
				$trail[] = '<a href="' . get_month_link( get_the_time( __( 'Y', $textdomain ) ), get_the_time( __( 'm', $textdomain ) ) ) . '" title="' . get_the_time( __( 'F', $textdomain ) ) . '">' . get_the_time( __( 'F', $textdomain ) ) . '</a>';
				$trail['trail_end'] = get_the_time( __( 'j', $textdomain ) );
			}

			elseif ( get_query_var( 'w' ) ) {
				$trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
				$trail['trail_end'] = sprintf( __( 'Week %1$s', 'hybrid' ), get_the_time( __( 'W', $textdomain ) ) );
			}

			elseif ( is_month() ) {
				$trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
				$trail['trail_end'] = get_the_time( __( 'F', $textdomain ) );
			}

			elseif ( is_year() ) {
				$trail['trail_end'] = get_the_time( __( 'Y', $textdomain ) );
			}
		}
	}

	/* If viewing search results. */
	elseif ( is_search() )
		$trail['trail_end'] = sprintf( __( 'Search results for &quot;%1$s&quot;', $textdomain ), esc_attr( get_search_query() ) );

	/* If viewing a 404 error page. */
	elseif ( is_404() )
		$trail['trail_end'] = __( '404 Not Found', $textdomain );

	/* Connect the breadcrumb trail if there are items in the trail. */
	if ( is_array( $trail ) ) {
		$breadcrumb = '<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail">';
		$breadcrumb .= " {$before} ";
		$breadcrumb .= join( " {$separator} ", $trail );
		$breadcrumb .= " {$after} ";
		$breadcrumb .= '</div></div>';
	}

	$breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb );

	/* Output the breadcrumb. */
	if ( $echo )
		echo $breadcrumb;
	else
		return $breadcrumb;
}
Example #3
0
/**
 * Gets the items for the breadcrumb trail if bbPress is installed.
 *
 * @since 0.5.0
 * @access private
 * @param array $args Mixed arguments for the menu.
 * @return array List of items to be shown in the trail.
 */
function breadcrumb_trail_get_bbpress_items($args = array())
{
    /* Set up a new trail items array. */
    $trail = array();
    /* Get the forum post type object. */
    $post_type_object = get_post_type_object(bbp_get_forum_post_type());
    /* If not viewing the forum root/archive page and a forum archive exists, add it. */
    if (!empty($post_type_object->has_archive) && !bbp_is_forum_archive()) {
        $trail[] = '<a href="' . get_post_type_archive_link(bbp_get_forum_post_type()) . '">' . bbp_get_forum_archive_title() . '</a>';
    }
    /* If viewing the forum root/archive. */
    if (bbp_is_forum_archive()) {
        $trail[] = bbp_get_forum_archive_title();
    } elseif (bbp_is_topic_archive()) {
        $trail[] = bbp_get_topic_archive_title();
    } elseif (bbp_is_topic_tag()) {
        $trail[] = bbp_get_topic_tag_name();
    } elseif (bbp_is_topic_tag_edit()) {
        $trail[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
        $trail[] = __('Edit', 'breadcrumb-trail');
    } elseif (bbp_is_single_view()) {
        $trail[] = bbp_get_view_title();
    } elseif (bbp_is_single_topic()) {
        /* Get the queried topic. */
        $topic_id = get_queried_object_id();
        /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_topic_forum_id($topic_id)));
        /* If viewing a split, merge, or edit topic page, show the link back to the topic.  Else, display topic title. */
        if (bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit()) {
            $trail[] = '<a href="' . bbp_get_topic_permalink($topic_id) . '">' . bbp_get_topic_title($topic_id) . '</a>';
        } else {
            $trail[] = bbp_get_topic_title($topic_id);
        }
        /* If viewing a topic split page. */
        if (bbp_is_topic_split()) {
            $trail[] = __('Split', 'breadcrumb-trail');
        } elseif (bbp_is_topic_merge()) {
            $trail[] = __('Merge', 'breadcrumb-trail');
        } elseif (bbp_is_topic_edit()) {
            $trail[] = __('Edit', 'breadcrumb-trail');
        }
    } elseif (bbp_is_single_reply()) {
        /* Get the queried reply object ID. */
        $reply_id = get_queried_object_id();
        /* Get the parent items for the reply, which should be its topic. */
        $trail = array_merge($trail, breadcrumb_trail_get_parents(bbp_get_reply_topic_id($reply_id)));
        /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
        if (bbp_is_reply_edit()) {
            $trail[] = '<a href="' . bbp_get_reply_url($reply_id) . '">' . bbp_get_reply_title($reply_id) . '</a>';
            $trail[] = __('Edit', 'breadcrumb-trail');
        } else {
            $trail[] = bbp_get_reply_title($reply_id);
        }
    } elseif (bbp_is_single_forum()) {
        /* Get the queried forum ID and its parent forum ID. */
        $forum_id = get_queried_object_id();
        $forum_parent_id = bbp_get_forum_parent_id($forum_id);
        /* If the forum has a parent forum, get its parent(s). */
        if (0 !== $forum_parent_id) {
            $trail = array_merge($trail, breadcrumb_trail_get_parents($forum_parent_id));
        }
        /* Add the forum title to the end of the trail. */
        $trail[] = bbp_get_forum_title($forum_id);
    } elseif (bbp_is_single_user() || bbp_is_single_user_edit()) {
        if (bbp_is_single_user_edit()) {
            $trail[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field('display_name') . '</a>';
            $trail[] = __('Edit', 'breadcrumb-trail');
        } else {
            $trail[] = bbp_get_displayed_user_field('display_name');
        }
    }
    /* Return the bbPress breadcrumb trail items. */
    return apply_filters('breadcrumb_trail_get_bbpress_items', $trail, $args);
}
Example #4
0
 function nice_breadcrumbs($args = array())
 {
     global $wp_rewrite;
     $defaults = apply_filters('nice_breadcrumbs_default_args', array('separator' => '/', 'before' => '', 'after' => false, 'front_page' => true, 'show_home' => __('Home', 'nicethemes'), 'echo' => true));
     if (is_singular()) {
         $post = get_queried_object();
         $defaults["singular_{$post->post_type}_taxonomy"] = false;
     }
     $args = wp_parse_args($args, $defaults);
     $args = apply_filters('nice_breadcrumbs_args', $args);
     do_action('nice_breadcrumbs_before', $args);
     $trail = array();
     $path = '';
     if (!is_front_page() && $args['show_home']) {
         $trail[] = '<a href="' . home_url() . '" title="' . esc_attr(get_bloginfo('name')) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
     }
     if (is_singular()) {
         $post = get_queried_object();
         $post_id = absint(get_queried_object_id());
         $post_type = $post->post_type;
         $parent = absint($post->post_parent);
         $post_type_object = get_post_type_object($post_type);
         if ($post_type == 'post') {
             /* If $front has been set, add it to the $path. */
             $path .= trailingslashit($wp_rewrite->front);
             /* If there's a path, check for parents. */
             if (!empty($path)) {
                 $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
             }
             /* Map the permalink structure tags to actual links. */
             //$trail = array_merge( $trail, breadcrumb_trail_map_rewrite_tags( $post_id, get_option( 'permalink_structure' ), $args ) );
         } elseif ('page' !== $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['slug'])) {
                 $path .= $post_type_object->rewrite['slug'];
             }
             /* If there's a path, check for parents. */
             if (!empty($path)) {
                 $trail = array_merge($trail, breadcrumb_trail_get_parents('', $path));
             }
             /* If there's an archive page, add it to the trail. */
             if (!empty($post_type_object->has_archive)) {
                 $trail[] = '<a href="' . get_post_type_archive_link($post_type) . '" title="' . esc_attr($post_type_object->labels->name) . '">' . $post_type_object->labels->name . '</a>';
             }
         }
         /* 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, breadcrumb_trail_get_parents($parent, ''));
         } elseif (0 !== $parent && is_post_type_hierarchical($post_type)) {
             $trail = array_merge($trail, breadcrumb_trail_get_parents($parent, ''));
         }
         /* Display terms for specific post type taxonomy if requested. */
         if (!empty($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();
         if (!empty($post_title)) {
             $trail['trail_end'] = $post_title;
         }
     }
     if (!empty($trail) && is_array($trail)) {
         /* Open the breadcrumb trail containers. */
         $nice_breadcrumbs = '<div class="breadcrumb breadcrumbs nice-breadcrumb"><div class="breadcrumb-trail">';
         /* If $before was set, wrap it in a container. */
         $nice_breadcrumbs .= !empty($args['before']) ? '<span class="trail-before">' . $args['before'] . '</span> ' : '';
         /* Wrap the $trail['trail_end'] value in a container. */
         if (!empty($trail['trail_end'])) {
             $trail['trail_end'] = '<span class="trail-end">' . $trail['trail_end'] . '</span>';
         }
         /* Format the separator. */
         $separator = !empty($args['separator']) ? '<span class="sep">' . $args['separator'] . '</span>' : '<span class="sep">/</span>';
         /* Join the individual trail items into a single string. */
         $nice_breadcrumbs .= join(" {$separator} ", $trail);
         /* If $after was set, wrap it in a container. */
         $nice_breadcrumbs .= !empty($args['after']) ? ' <span class="trail-after">' . $args['after'] . '</span>' : '';
         /* Close the breadcrumb trail containers. */
         $nice_breadcrumbs .= '</div></div>';
     }
     /* Allow developers to filter the breadcrumb trail HTML. */
     $nice_breadcrumbs = apply_filters('breadcrumb_trail', $nice_breadcrumbs, $args);
     /* Output the breadcrumb. */
     if ($args['echo']) {
         echo $nice_breadcrumbs;
     } else {
         return $nice_breadcrumbs;
     }
 }