Advertisement
Guest User

Untitled

a guest
Aug 16th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.32 KB | None | 0 0
  1. <?php
  2. /*
  3. Plugin Name: Simple Breadcrumb Navigation
  4. Plugin URI: http://www.kriesi.at/archives/wordpress-plugin-simple-breadcrumb-navigation
  5. Description: A simple and very lightweight breadcrumb navigation that covers nested pages and categories
  6. Version: 1
  7. Author: Christian "Kriesi" Budschedl
  8. Author URI: http://www.kriesi.at/
  9. */
  10.  
  11. /*
  12. This program is free software; you can redistribute it and/or modify
  13. it under the terms of the GNU General Public License as published by
  14. the Free Software Foundation; either version 3 of the License, or
  15. (at your option) any later version.
  16.  
  17. This program is distributed in the hope that it will be useful,
  18. but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. GNU General Public License for more details.
  21.  
  22. You should have received a copy of the GNU General Public License
  23. along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25.  
  26. class simple_breadcrumb{
  27. var $options;
  28.  
  29. function simple_breadcrumb(){
  30.  
  31. $this->options = array( //change this array if you want another output scheme
  32. 'before' => '<span class="breadarrow"> ',
  33. 'after' => ' </span>',
  34. 'delimiter' => '&rarr;'
  35. );
  36.  
  37. $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
  38.  
  39. global $post;
  40. echo '<p class="crumbs"><a href="'.get_bloginfo('url').'">';
  41. //bloginfo('name');
  42.  
  43. esc_html_e('Home', 'statusquo');
  44. echo "</a>";
  45. if(!is_front_page()){echo $markup;};
  46.  
  47. $output = $this->simple_breadcrumb_case($post);
  48.  
  49. echo "<span class='current_crumb'>";
  50.  
  51. if ( !is_front_page()) {
  52. the_title();
  53. }else{
  54. echo $output;
  55. }
  56. echo "</span></p> ";
  57. }
  58.  
  59.  
  60. function simple_breadcrumb_case($der_post){
  61. global $post;
  62. $markup = $this->options['before'].$this->options['delimiter'].$this->options['after'];
  63. if (is_page()){
  64. if($der_post->post_parent) {
  65. $my_query = get_post($der_post->post_parent);
  66. $this->simple_breadcrumb_case($my_query);
  67. $link = '<a href="';
  68. $link .= get_permalink($my_query->ID);
  69. $link .= '">';
  70. $link .= ''. get_the_title($my_query->ID) . '</a>'. $markup;
  71. echo $link;
  72. }
  73. return;
  74. }
  75.  
  76.  
  77. if(is_single()){
  78. $category = get_the_category();
  79. if (is_attachment()){
  80. $my_query = get_post($der_post->post_parent);
  81. $category = get_the_category($my_query->ID);
  82. if( $category != null ) {
  83. $ID = $category[0]->cat_ID;
  84. echo get_category_parents($ID, TRUE, $markup, FALSE );
  85. }
  86. previous_post_link("%link $markup");
  87.  
  88. } elseif ( get_post_type( $post ) == 'post' ) {
  89. $ID = $category[0]->cat_ID;
  90. get_category_parents_for_breadcrumbs( $ID, TRUE, $markup, FALSE );
  91.  
  92. } else { // custom types
  93. echo ucwords( get_post_type( $post ) ) . $markup;
  94. }
  95. return;
  96. }
  97.  
  98. if(is_category()){
  99. $category = get_the_category();
  100. $i = $category[0]->cat_ID;
  101. $parent = $category[0]-> category_parent;
  102.  
  103. if($parent > 0 && $category[0]->cat_name == single_cat_title("", false)){
  104. echo get_category_parents($parent, TRUE, $markup, FALSE);
  105. }
  106. return single_cat_title('',FALSE);
  107. }
  108.  
  109. if (is_tax()) { // taxonomy
  110. $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) );
  111. echo $term->name;
  112. }
  113.  
  114. if (is_Portfolio == get_post_type()){
  115. $term = get_term_by( 'slug', name, label, get_query_var( 'taxonomy' ) );
  116. echo $term->name;
  117. }
  118.  
  119. if(is_author()){
  120. $curauth = get_userdatabylogin(get_query_var('author_name'));
  121. return esc_html__('Author: ', 'statusquo').$curauth->nickname;
  122. }
  123. if(is_tag()){ return esc_html__('Tag: ', 'statusquo').single_tag_title('',FALSE); }
  124.  
  125. if(is_404()){ return esc_html__('404 - Page not Found', 'statusquo'); }
  126.  
  127. if(is_search()){ return esc_html__('Search', 'statusquo'); }
  128.  
  129. if(is_year()){ return get_the_time('Y'); }
  130.  
  131. if(is_month()){
  132. $k_year = get_the_time('Y');
  133. echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  134. return get_the_time('F'); }
  135.  
  136. if(is_day() || is_time()){
  137. $k_year = get_the_time('Y');
  138. $k_month = get_the_time('m');
  139. $k_month_display = get_the_time('F');
  140. echo "<a href='".get_year_link($k_year)."'>".$k_year."</a>".$markup;
  141. echo "<a href='".get_month_link($k_year, $k_month)."'>".$k_month_display."</a>".$markup;
  142.  
  143. return get_the_time('jS (l)'); }
  144.  
  145. }
  146.  
  147. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement