yan-k
4/1/2016 - 2:34 PM

full-breadcrumbs.php

<?php 
/*
	 * Yan&Co Modifications - Full Breadcrumbs
	 */
	if(!function_exists('yanco_breadcrumbs')) {
		function yanco_breadcrumbs( $echo = false ) {
			$_trail = '';

			if( is_singular() ) {
				$vocabulary = 'xmlns:v="http://rdf.data-vocabulary.org/#"';
				$_trail .= '<div class="breadcrumb breadcrumbs avia-breadcrumbs"><div class="breadcrumb-trail" '.$vocabulary.'>';

				$_post_id = get_the_ID();
				$_post = get_post( $_post_id );
				$_post_type = $_post->post_type;
				$_parent = $_post->post_parent;

				if ( 'page' !== $_post_type && 'post' !== $_post_type ) {
					$_post_type_object = get_post_type_object( $_post_type );
				}
				
				$_trail .= '<span class="trail-before">';
				$_trail .= '<span class="breadcrumb-title">' . __( 'You are here:', 'avia_framework' ) . '</span>';
				$_trail .= '</span>';
				$_trail .= '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" rel="home" class="trail-begin">' . __( 'Home', 'avia_framework' ) . '</a>';
				
				if ( !empty( $_post_type_object->has_archive ) && function_exists( 'get_post_type_archive_link' ) ) {
					$_trail .= '<span class="sep">/</span>';
					$_trail .= '<a href="' . get_post_type_archive_link( $_post_type ) . '" title="' . esc_attr( $_post_type_object->labels->name ) . '">' . $_post_type_object->labels->name . '</a>';	
				}
				
				$_trail .= '<span class="sep">/</span>';
				$_breadcrumbs = avia_breadcrumbs_get_parents( $_post_id, '' );

				if( is_array($_breadcrumbs) ) {
					unset( $_breadcrumbs[count($_breadcrumbs)-1] );
				}
				
				foreach ($_breadcrumbs as $_breadcrumb_index => $_breadcrumb_value) {
					$_trail .= 	$_breadcrumb_value;
					$_trail .= '<span class="sep">/</span>';
				}

				$_trail .='<span class="trail-end">'. $_post->post_title .'</span>';

				$_trail .= '</div></div>';

				//d($_trail);
			}

			if( $echo ) {
				echo $_trail;
			} else {
				return $_trail;
			}
		}
	}