<?php
if(!function_exists('rockon_the_breadcrumb')){
	function rockon_the_breadcrumb($title = null) {
		global $post;
		$src = esc_url(get_template_directory_uri().'/images/seprator.png');
		echo '<!-- Breadcrumb-Start -->
<div class="container">
      <div class="rock_heading_div">
        <div class="rock_heading">
          <h1>'.__(esc_attr($title),'rockon').'</h1>
          <p>X</p>
        </div>
      </div>
      <div class="rock_pager">
       ';
		echo '<ul class="hs_breadcrumb">';
		if (!is_home()) {
			echo '<li><a href="';
			echo home_url();
			echo '">';
			echo 'Home';
			echo '</a></li>';
			if (is_category() || is_single()) {
				$categories = get_the_category($post->ID);
				if($categories){
					foreach($categories as $category) {
						echo '<li>';
						echo '<a href="'.get_category_link( $category->term_id ).'" >'.$category->cat_name.'</a>';
						echo '</li>';
					}
				}
				//the_category(' </li><li> ');  
				if (is_single()) {
					echo '</li><li>';
					the_title();
					echo '</li>';
				}
			} elseif (is_page()) {
				if($post->post_parent){
					$anc = get_post_ancestors( $post->ID );
					$title = get_the_title($post->ID);
					foreach ( $anc as $ancestor ) {
						$output = '<li><a href="'.esc_url(get_permalink($ancestor)).'" title="'.esc_attr(get_the_title($ancestor)).'">'.__(esc_attr(get_the_title($ancestor)),'rockon').'</a></li> ';
					}
					echo $output;
					echo '<li><strong title="'.esc_attr($title).'"> '.__(esc_attr($title),'rockon').'</strong></li>';
				} else {
					echo '<li><strong> '.__(get_the_title($post->ID),'rockon').'</strong></li>';
				}
			}
		}
		elseif (is_tag()) {single_tag_title();}
		elseif (is_day()) {echo"<li>Archive for "; the_time('F jS, Y'); echo'</li>';}
		elseif (is_month()) {echo"<li>Archive for "; the_time('F, Y'); echo'</li>';}
		elseif (is_year()) {echo"<li>Archive for "; the_time('Y'); echo'</li>';}
		elseif (is_author()) {echo"<li>Author Archive"; echo'</li>';}
		elseif (isset($_GET['paged']) && !empty($_GET['paged'])) {echo "<li>Blog Archives"; echo'</li>';}
		elseif (is_search()) {echo"<li>Search Results"; echo'</li>';}
		echo ' </ul>
      </div>
    </div>';
	}
}
?>