Advertisement
Guest User

Untitled

a guest
Aug 26th, 2012
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. <?php
  2.  
  3. class simple_breadcrumb{
  4. var $options;
  5.  
  6. function simple_breadcrumb(){
  7.  
  8. $this->options = array( //change this array if you want another output scheme
  9. 'before' => '<span class="breadarrow"> ',
  10. 'after' => ' </span>',
  11. 'delimiter' => '&rarr;'
  12. );
  13.  
  14. $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
  15.  
  16. global $post;
  17. echo '<p class="crumbs"><a href="'.get_bloginfo('url').'">';
  18. //bloginfo('name');
  19.  
  20. esc_html_e('Home', 'mytheme');
  21. echo "</a>";
  22. if(!is_front_page()){echo $markup;};
  23.  
  24. $output = $this->simple_breadcrumb_case($post);
  25.  
  26. echo "<span class='current_crumb'>";
  27.  
  28. if ( !is_front_page()) {
  29. the_title();
  30. }else{
  31. echo $output;
  32. }
  33. echo "</span></p> ";
  34. }
  35.  
  36.  
  37. function simple_breadcrumb_case($der_post){
  38. global $post;
  39. $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
  40. if (is_page()){
  41. if($der_post->post_parent) {
  42. $my_query = get_post($der_post->post_parent);
  43. $this->simple_breadcrumb_case($my_query);
  44. $link = '<a href="';
  45. $link .= get_permalink($my_query->ID);
  46. $link .= '">';
  47. $link .= ''. get_the_title($my_query->ID) . '</a>'. $markup;
  48. echo $link;
  49. }
  50. return;
  51. }
  52.  
  53.  
  54. if(is_single()){
  55. $category = get_the_category();
  56. if (is_attachment()){
  57. $my_query = get_post($der_post->post_parent);
  58. $category = get_the_category($my_query->ID);
  59. if( $category != null ) {
  60. $ID = $category[0]->cat_ID;
  61. echo get_category_parents($ID, TRUE, $markup, FALSE );
  62. }
  63. previous_post_link("%link $markup");
  64.  
  65. } elseif ( get_post_type( $post ) == 'post' ) {
  66. $ID = $category[0]->cat_ID;
  67. get_category_parents_for_breadcrumbs( $ID, TRUE, $markup, FALSE );
  68.  
  69.  
  70. $type = get_post_type($post->ID);
  71.  
  72. if( $type == 'Portfolio') {
  73. echo '<a href="' . 'http://www.mysite.com/web-portfolio' . '">' . 'Portfolio' . '</a>' .$markup;
  74.  
  75.  
  76. } else if( $type == 'Artwork')
  77. echo '<a href="' . 'http://www.mysite.com/art-portfolio' . '">' . 'Artwork' . '</a>' .$markup;
  78.  
  79. }
  80.  
  81. }
  82.  
  83.  
  84.  
  85.  
  86. if(is_category()){
  87. $category = get_the_category();
  88. $i = $category[0]->cat_ID;
  89. $parent = $category[0]-> category_parent;
  90.  
  91. if($parent > 0 && $category[0]->cat_name == single_cat_title("", false)){
  92. echo get_category_parents($parent, TRUE, $markup, FALSE);
  93. }
  94. return single_cat_title('',FALSE);
  95. }
  96.  
  97. if (is_tax()) { // taxonomy
  98. $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  99. echo $term->name;
  100. }
  101.  
  102. if(is_author()){
  103. $curauth = get_userdatabylogin(get_query_var('author_name'));
  104. return esc_html__('Author: ', 'mytheme').$curauth->nickname;
  105. }
  106. if(is_tag()){ return esc_html__('Tag: ', 'mytheme').single_tag_title('',FALSE); }
  107.  
  108. if(is_404()){ return esc_html__('404 - Page not Found', 'mytheme'); }
  109.  
  110. if(is_search()){ return esc_html__('Search', 'mytheme'); }
  111.  
  112. if(is_year()){ return get_the_time('Y'); }
  113.  
  114. if(is_month()){
  115. $k_year = get_the_time('Y');
  116. echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  117. return get_the_time('F'); }
  118.  
  119. if(is_day() || is_time()){
  120. $k_year = get_the_time('Y');
  121. $k_month = get_the_time('m');
  122. $k_month_display = get_the_time('F');
  123. echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  124. echo "<a href='".get_month_link($k_year, $k_month)."'>".$k_month_display."</a>".$markup;
  125.  
  126. return get_the_time('jS (l)'); }
  127.  
  128. }
  129.  
  130. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement