Advertisement
alexgieg

WPSEO Breadcrumbs (Diff version)

Jun 19th, 2012
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 19.81 KB | None | 0 0
  1. diff -rupN wordpress-seo-orig/frontend/class-breadcrumbs.php wordpress-seo/frontend/class-breadcrumbs.php
  2. --- wordpress-seo-orig/frontend/class-breadcrumbs.php   2012-06-15 05:24:48.000000000 -0300
  3. +++ wordpress-seo/frontend/class-breadcrumbs.php    2012-06-21 13:53:34.917656300 -0300
  4. @@ -116,34 +116,48 @@ class WPSEO_Breadcrumbs {
  5.         $on_front   = get_option('show_on_front');
  6.         $blog_page  = get_option('page_for_posts');
  7.         $sep        = ( isset($opt['breadcrumbs-sep']) && $opt['breadcrumbs-sep'] != '' ) ? $opt['breadcrumbs-sep'] : '»';
  8. -       $home       = ( isset($opt['breadcrumbs-home']) && $opt['breadcrumbs-home'] != '' ) ? $opt['breadcrumbs-home'] : __('Home','wordpress-seo');
  9. +       $hometitle  = ( isset($opt['breadcrumbs-home']) && $opt['breadcrumbs-home'] != '' ) ? $opt['breadcrumbs-home'] : __('Home','wordpress-seo');
  10. +       // This doesn't seem to be used:
  11.         $selmenu    = ( isset($opt['breadcrumbs-selectedmenu']) && $opt['breadcrumbs-selectedmenu'] != '' ) ? $opt['breadcrumbs-selectedmenu'] : 0;
  12. +       $breadcrumb_array   = array();
  13.        
  14.         if ( "page" == $on_front && 'post' == get_post_type() ) {
  15. -           $homelink = '<a href="'.get_permalink(get_option('page_on_front')).'">'.$home.'</a>';
  16. -           $bloglink = $homelink;
  17. -           if ( $blog_page && ( !isset($opt['breadcrumbs-blog-remove']) || !$opt['breadcrumbs-blog-remove'] ) )
  18. -               $bloglink = $homelink.' '.$sep.' <a href="'.get_permalink($blog_page).'">'.$this->get_bc_title($blog_page).'</a>';
  19. +           $homeurl = get_permalink(get_option('page_on_front'));
  20.         } else {
  21. -           $homelink = '<a href="'.get_bloginfo('url').'">'.$home.'</a>';
  22. -           $bloglink = $homelink;
  23. +           $homeurl = get_bloginfo('url');
  24.         }
  25.  
  26. -       if ( ( $on_front == "page" && is_front_page() ) || ( $on_front == "posts" && is_home() ) ) {
  27. -           $output = $this->bold_or_not($home);
  28. +       if ( $on_front == "page" && is_front_page() ) {
  29. +           $breadcrumb_array[] = array( 'title' => $hometitle, 'url' => '', 'class' => '', 'type' => 'home', 'ID' => null );
  30. +       } else if ( $on_front == "posts" && is_home() ) {
  31. +           $breadcrumb_array[] = array( 'title' => $hometitle, 'url' => '', 'class' => '', 'type' => 'home', 'ID' => null );
  32.         } else if ( $on_front == "page" && is_home() ) {
  33. -           $output = $homelink.' '.$sep.' '.$this->bold_or_not( $this->get_bc_title($blog_page) );
  34. +           $breadcrumb_array[] = array( 'title' => $hometitle, 'url' => $homeurl, 'class' => '', 'type' => 'home', 'ID' => null );
  35. +           $breadcrumb_array[] = array( 'title' => $this->get_bc_title($blog_page), 'url' => '', 'class' => '', 'type' => get_post_type($blog_page), 'ID' => (int) $blog_page );
  36.         } else if ( is_singular() ) {
  37. -           $output = $bloglink.' '.$sep.' ';
  38. +           $breadcrumb_array[] = array( 'title' => $hometitle, 'url' => $homeurl, 'class' => '', 'type' => 'home', 'ID' => null );
  39. +          
  40. +           if ( $blog_page && 'page' == $on_front && 'post' == get_post_type() && ( !isset($opt['breadcrumbs-blog-remove']) || !$opt['breadcrumbs-blog-remove'] ) ) {
  41. +               $breadcrumb_array[] = array( 'title' => $this->get_bc_title($blog_page), 'url' => get_permalink($blog_page), 'class' => '', 'type' => get_post_type($blog_page), 'ID' => (int) $blog_page );
  42. +           }
  43.  
  44. +           // This doesn't seem to be used:
  45.             if( isset($opt['breadcrumbs-menus']) && $opt['breadcrumbs-menus'] = 'on'){
  46.                 $use_menu = $this->in_menu( $selmenu );
  47.             }
  48.             if ( function_exists('bbp_body_class') && count( bbp_body_class( array() ) ) > 1 ) {
  49.                 remove_filter('bbp_get_breadcrumb','__return_false');
  50. -               $output .= bbp_get_breadcrumb( ' '.$sep.' ' );
  51. +               $bbp_bc_array = explode( ';;;;;', bbp_get_breadcrumb( ';;;;;' ) );
  52. +               if ( !empty($bbp_bc_array[0]) ) {
  53. +                   foreach ( $bbp_bc_array as $bbp_bc ) {
  54. +                       if ( preg_match( '/(<(a .*href="(?P<url>.*?)"( .*class="(?P<class>.*?)")?.*?)>)?(?P<title>.*)/', trim($bbp_bc), $bbp_pc_results ) ) {
  55. +                           $breadcrumb_array[] = array ( 'title' => trim(strip_tags($bbp_pc_results['title'])), 'url' => $bbp_pc_results['url'], 'class' => $bbp_pc_results['class'], 'type' => 'bbpress', 'ID' => null );
  56. +                       }
  57. +                   }
  58. +               }
  59.                 add_filter('bbp_get_breadcrumb','__return_false');
  60.             } else if( isset( $use_menu ) && $use_menu ){
  61. +               // This whole block doesn't seem to be used:
  62.                 $trail = $this->get_menu_trail();
  63.                 $trail = array_reverse ( $trail );
  64.                 $trailposts = array();
  65. @@ -152,169 +166,230 @@ class WPSEO_Breadcrumbs {
  66.                 }
  67.                 for($t = 0; $t < count($trail); $t++){
  68.                     $bctitle = ( get_the_title( $trail[$t] ) == '' ) ? get_the_title( $trailposts[$t] ) : get_the_title( $trail[$t] );
  69. -                   $output .= '<a href="' . get_permalink( $trailposts[$t] ) . '">' . $bctitle .'</a> ' . $sep . ' ';
  70. +                   $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => get_permalink( $trailposts[$t] ), 'class' => '', 'type' => get_post_type( $trailposts[$t] ), 'ID' => (int) $trailposts[$t] );
  71.                 }
  72. -               $output .= $this->bold_or_not( $this->get_bc_title( $post->ID ) );
  73. +               $breadcrumb_array[] = array( 'title' => $this->get_bc_title( $post->ID ), 'url' => '', 'class' => '', 'type' => get_post_type( $post->ID ), 'ID' => (int) $post->ID );
  74.             } else {
  75. -              
  76.                 $post_type = get_post_type();
  77.                 if ( function_exists('get_post_type_archive_link') && get_post_type_archive_link( $post_type ) ) {
  78.                     if ( isset($options['bctitle-ptarchive-'.$post_type]) && '' != $options['bctitle-ptarchive-'.$post_type] ) {
  79.                         $archive_title = $options['bctitle-ptarchive-'.$post_type];
  80.                     } else {
  81.                         $post_type_obj = get_post_type_object( $post_type );
  82. -                       $archive_title = $post_type_obj->labels->menu_name;
  83. +                       //$archive_title = $post_type_obj->labels->menu_name;
  84. +                       $archive_title = $post_type_obj->labels->name;
  85.                     }
  86. -                   $output .= '<a href="'.get_post_type_archive_link( $post_type ).'">'.$archive_title.'</a> ' . $sep . ' ';
  87. +                   $breadcrumb_array[] = array( 'title' => $archive_title, 'url' => get_post_type_archive_link( $post_type ), 'class' => '', 'type' => $post_type, 'ID' => null );
  88.                 }
  89. -
  90. +              
  91.                 if ( 0 == $post->post_parent ) {
  92.                     if ( isset( $opt['post_types-'.$post->post_type.'-maintax'] ) && $opt['post_types-'.$post->post_type.'-maintax'] != '0' ) {
  93.                         $main_tax = $opt['post_types-'.$post->post_type.'-maintax'];
  94. -                       $terms = wp_get_object_terms( $post->ID, $main_tax );
  95. -                       if ( is_taxonomy_hierarchical($main_tax) && $terms[0]->parent != 0 ) {
  96. -                           $parents = $this->get_term_parents($terms[0], $main_tax);
  97. -                           $parents = array_reverse($parents);
  98. -                           foreach($parents as $parent) {
  99. -                               $bctitle = wpseo_get_term_meta( $parent, $main_tax, 'bctitle' );
  100. -                               if (!$bctitle)
  101. -                                   $bctitle = $parent->name;
  102. -                               $output .= '<a href="'.get_term_link( $parent, $main_tax ).'">'.$bctitle.'</a> '.$sep.' ';
  103. -                           }
  104. -                       }
  105. +                       $terms = wp_get_object_terms( $post->ID, $main_tax, apply_filters( 'wp_seo_get_bc_taxonomy_args', array( 'orderby' => 'term_order' ) ) );
  106.                         if ( count($terms) > 0 ) {
  107. +                           if ( is_taxonomy_hierarchical($main_tax) && $terms[0]->parent != 0 ) {
  108. +                               $parents = $this->get_term_parents($terms[0], $main_tax);
  109. +                               $parents = array_reverse($parents);
  110. +                               foreach($parents as $parent) {
  111. +                                   $bctitle = wpseo_get_term_meta( $parent, $main_tax, 'bctitle' );
  112. +                                   if (!$bctitle) {
  113. +                                       $bctitle = $parent->name;
  114. +                                   }
  115. +                                   $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => get_term_link( $parent, $main_tax ), 'class' => '', 'type' => $main_tax, 'ID' => (int) $parent->term_id );
  116. +                               }
  117. +                           }
  118.                             $bctitle = wpseo_get_term_meta( $terms[0], $main_tax, 'bctitle' );
  119. -                           if (!$bctitle)
  120. +                           if (!$bctitle) {
  121.                                 $bctitle = $terms[0]->name;
  122. -                               $output .= '<a href="'.get_term_link($terms[0], $main_tax).'">'.$bctitle.'</a> '.$sep.' ';
  123. +                           }
  124. +                           $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => get_term_link($terms[0], $main_tax), 'class' => '', 'type' => $main_tax, 'ID' => (int) $terms[0]->term_id );
  125.                         }
  126.                     }
  127. -                   $output .= $this->bold_or_not( $this->get_bc_title( $post->ID ) );
  128. +                   $breadcrumb_array[] = array( 'title' => $this->get_bc_title( $post->ID ), 'url' => '', 'class' => '', 'type' => $post_type, 'ID' => (int) $post->ID );
  129.                 } else {
  130.                     if (isset($post->ancestors)) {
  131. -                       if (is_array($post->ancestors))
  132. +                       if (is_array($post->ancestors)) {
  133.                             $ancestors = array_values($post->ancestors);
  134. -                       else
  135. -                           $ancestors = array($post->ancestors);              
  136. +                       } else {
  137. +                           $ancestors = array($post->ancestors);
  138. +                       }
  139.                     } else {
  140.                         $ancestors = array($post->post_parent);
  141.                     }
  142.  
  143. -                   // Reverse the order so it's oldest to newest
  144. -                   $ancestors = array_reverse( apply_filters( 'wp_seo_get_bc_ancestors', $ancestors ) );
  145. -
  146. +                   $ancestors = array_reverse( $ancestors ); // Reverse the order so it's oldest to newest
  147.                     foreach ( $ancestors as $ancestor ) {
  148. -                       $output .= '<a href="'.get_permalink($ancestor).'">'.$this->get_bc_title( $ancestor ).'</a> '.$sep.' ';
  149. +                       $breadcrumb_array[] = array( 'title' => $this->get_bc_title( $ancestor ), 'url' => get_permalink($ancestor), 'class' => '', 'type' => get_post_type($ancestor), 'ID' => (int) $ancestor );
  150.                     }
  151.  
  152. -                   $output .= $this->bold_or_not( $this->get_bc_title( $post->ID ) );
  153. -               }                  
  154. +                   $breadcrumb_array[] = array( 'title' => $this->get_bc_title( $post->ID ), 'url' => '', 'class' => '', 'type' => $post_type, 'ID' => (int) $post->ID );
  155. +               }
  156.             }
  157.         } else {
  158. -           if (! is_404() ) {
  159. -               $output = $bloglink.' '.$sep.' ';
  160. -           } else {
  161. -               $output = $homelink.' '.$sep.' ';
  162. +           $breadcrumb_array[] = array( 'title' => $hometitle, 'url' => $homeurl, 'class' => '', 'type' => 'home', 'ID' => null );
  163. +           if ( !is_404() && $blog_page && 'page' == $on_front && 'post' == get_post_type() && ( !isset($opt['breadcrumbs-blog-remove']) || !$opt['breadcrumbs-blog-remove'] ) ) {
  164. +               $breadcrumb_array[] = array( 'title' => $this->get_bc_title($blog_page), 'url' => get_permalink($blog_page), 'class' => '', 'type' => get_post_type($blog_page), 'ID' => (int) $blog_page );
  165.             }
  166. -          
  167. -           if ( function_exists('is_post_type_archive') && is_post_type_archive() ) {
  168. +           if ( function_exists('is_post_type_archive') && is_post_type_archive() && get_post_type() ) {
  169.                 $post_type = get_post_type();
  170.                 if ( isset($options['bctitle-ptarchive-'.$post_type]) && '' != $options['bctitle-ptarchive-'.$post_type] ) {
  171.                     $archive_title = $options['bctitle-ptarchive-'.$post_type];
  172.                 } else {
  173.                     $post_type_obj = get_post_type_object( $post_type );
  174. -                   $archive_title = $post_type_obj->labels->menu_name;
  175. +                   //$archive_title = $post_type_obj->labels->menu_name;
  176. +                   $archive_title = $post_type_obj->labels->name;
  177.                 }
  178. -               $output .= $this->bold_or_not( $archive_title );
  179. +               $breadcrumb_array[] = array( 'title' => $archive_title, 'url' => '', 'class' => '', 'type' => $post_type, 'ID' => null );
  180.             } else if ( is_tax() || is_tag() || is_category() ) {
  181.                 $term = $wp_query->get_queried_object();
  182.  
  183.                 if ( isset($options['taxonomy-'.$term->taxonomy.'-ptparent']) && $options['taxonomy-'.$term->taxonomy.'-ptparent'] != '' ) {
  184.                     $post_type = $options['taxonomy-'.$term->taxonomy.'-ptparent'];
  185. -                   if ( 'post' == $post_type && get_option('show_on_front') == 'page' ) {
  186. -                       $posts_page = get_option('page_for_posts');
  187. -                       if ( $posts_page ) {
  188. -                           $output .= '<a href="'.get_permalink( $posts_page ).'">'.$this->get_bc_title( $posts_page ).'</a> '.$sep.' ';
  189. -                       }
  190. +                   if ( $blog_page && 'post' == $post_type && 'page' == $on_front  ) {
  191. +                       $breadcrumb_array[] = array( 'title' => $this->get_bc_title($blog_page), 'url' => get_permalink($blog_page), 'class' => '', 'type' => $post_type, 'ID' => $blog_page );
  192.                     } else {
  193.                         if ( isset($options['bctitle-ptarchive-'.$post_type]) && '' != $options['bctitle-ptarchive-'.$post_type] ) {
  194.                             $archive_title = $options['bctitle-ptarchive-'.$post_type];
  195.                         } else {
  196.                             $post_type_obj = get_post_type_object( $post_type );
  197. -                           $archive_title = $post_type_obj->labels->menu_name;
  198. +                           //$archive_title = $post_type_obj->labels->menu_name;
  199. +                           $archive_title = $post_type_obj->labels->name;
  200.                         }
  201. -                       $output .= '<a href="'.get_post_type_archive_link( $post_type ).'">'.$archive_title.'</a> '.$sep.' ';
  202. +                       $breadcrumb_array[] = array( 'title' => $archive_title, 'url' => get_post_type_archive_link( $post_type ), 'class' => '', 'type' => $post_type, 'ID' => null );
  203.                     }
  204.                 }
  205. -                  
  206. +              
  207.                 if ( is_taxonomy_hierarchical($term->taxonomy) && $term->parent != 0 ) {
  208.                     $parents = $this->get_term_parents($term, $term->taxonomy);
  209.                     $parents = array_reverse( $parents );
  210.                    
  211.                     foreach($parents as $parent) {
  212.                         $bctitle = wpseo_get_term_meta( $parent, $term->taxonomy, 'bctitle' );
  213. -                       if (!$bctitle)
  214. +                       if (!$bctitle) {
  215.                             $bctitle = $parent->name;
  216. -                       $output .= '<a href="'.get_term_link( $parent, $term->taxonomy ).'">'.$bctitle.'</a> '.$sep.' ';
  217. +                       }
  218. +                       $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => get_term_link( $parent, $term->taxonomy ), 'class' => '', 'type' => $parent->taxonomy, 'ID' => (int) $parent->term_id );
  219.                     }
  220.                 }
  221.  
  222.                 $bctitle = wpseo_get_term_meta( $term, $term->taxonomy, 'bctitle' );
  223. -               if (!$bctitle)
  224. +               if (!$bctitle) {
  225.                     $bctitle = $term->name;
  226. +               }
  227.                
  228. -               if ($paged)
  229. -                   $output .= $this->bold_or_not('<a href="'.get_term_link( $term, $term->taxonomy ).'">'.$bctitle.'</a>');
  230. -               else
  231. -                   $output .= $this->bold_or_not($bctitle);
  232. +               if ($paged) {
  233. +                   $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => get_term_link( $term, $term->taxonomy ), 'class' => '', 'type' => $term->taxonomy, 'ID' => (int) $term->term_id );
  234. +               } else {
  235. +                   $breadcrumb_array[] = array( 'title' => $bctitle, 'url' => '', 'class' => '', 'type' => $term->taxonomy, 'ID' => (int) $term->term_id );
  236. +               }
  237.             } else if ( is_date() ) {
  238. -               if ( isset($opt['breadcrumbs-archiveprefix']) )
  239. +               if ( isset($opt['breadcrumbs-archiveprefix']) ) {
  240.                     $bc = $opt['breadcrumbs-archiveprefix'];
  241. -               else
  242. +               } else {
  243.                     $bc = __('Archives for','wordpress-seo');
  244. +               }
  245.                 if ( is_day() ) {
  246.                     global $wp_locale;
  247. -                   $output .= '<a href="'.get_month_link( get_query_var('year'), get_query_var('monthnum') ).'">'.$wp_locale->get_month( get_query_var('monthnum') ).' '.get_query_var('year').'</a> '.$sep.' ';
  248. -                   $output .= $this->bold_or_not( $bc." ".get_the_date() );
  249. +                   $breadcrumb_array[] = array( 'title' => $wp_locale->get_month( get_query_var('monthnum') ).' '.get_query_var('year'), 'url' => get_month_link( get_query_var('year'), get_query_var('monthnum') ), 'class' => '', 'type' => 'date', 'ID' => null );
  250. +                   $breadcrumb_array[] = array( 'title' => $bc." ".get_the_date(), 'url' => '', 'class' => '', 'type' => 'date', 'ID' => null );
  251.                 } else if ( is_month() ) {
  252. -                   $output .= $this->bold_or_not( $bc." ".single_month_title(' ',false) );
  253. +                   $breadcrumb_array[] = array( 'title' => $bc." ".single_month_title(' ',false), 'url' => '', 'class' => '', 'type' => 'date', 'ID' => null );
  254.                 } else if ( is_year() ) {
  255. -                   $output .= $this->bold_or_not( $bc." ".get_query_var('year') );
  256. +                   $breadcrumb_array[] = array( 'title' => $bc." ".get_query_var('year'), 'url' => '', 'class' => '', 'type' => 'date', 'ID' => null );
  257.                 }
  258.             } elseif ( is_author() ) {
  259. -               if ( isset($opt['breadcrumbs-archiveprefix']) )
  260. +               if ( isset($opt['breadcrumbs-archiveprefix']) ) {
  261.                     $bc = $opt['breadcrumbs-archiveprefix'];
  262. -               else
  263. +               } else {
  264.                     $bc = __('Archives for','wordpress-seo');
  265. +               }
  266.                 $user = $wp_query->get_queried_object();
  267. -               $output .= $this->bold_or_not($bc." ".$user->display_name);
  268. +               $breadcrumb_array[] = array( 'title' => $bc." ".$user->display_name, 'url' => '', 'class' => '', 'type' => 'author', 'ID' => $user->ID );
  269.             } elseif ( is_search() ) {
  270. -               if ( isset($opt['breadcrumbs-searchprefix']) && $opt['breadcrumbs-searchprefix'] != '' )
  271. +               if ( isset($opt['breadcrumbs-searchprefix']) && $opt['breadcrumbs-searchprefix'] != '' ) {
  272.                     $bc = $opt['breadcrumbs-searchprefix'];
  273. -               else
  274. +               } else {
  275.                     $bc = __('You searched for','wordpress-seo');
  276. -               $output .= $this->bold_or_not($bc.' "'.stripslashes(strip_tags(get_search_query())).'"');
  277. +               }
  278. +               $breadcrumb_array[] = array( 'title' => $bc.' "'.stripslashes(strip_tags(get_search_query())).'"', 'url' => '', 'class' => '', 'type' => 'search', 'ID' => null );
  279.             } elseif ( isset( $wp_query->query_vars['bbp_topic_tag'] ) ) {
  280.                 remove_filter('bbp_get_breadcrumb','__return_false');
  281. -               $output .= bbp_get_breadcrumb( ' '.$sep.' ' );
  282. +               $bbp_bc_array = explode( ';;;;;', bbp_get_breadcrumb( ';;;;;' ) );
  283. +               if ( !empty($bbp_bc_array[0]) ) {
  284. +                   foreach ( $bbp_bc_array as $bbp_bc ) {
  285. +                       if ( preg_match( '/(<(a .*href="(?P<url>.*?)"( .*class="(?P<class>.*?)")?.*?)>)?(?P<title>.*)/', trim($bbp_bc), $bbp_pc_results ) ) {
  286. +                           $breadcrumb_array[] = array ( 'title' => trim(strip_tags($bbp_pc_results['title'])), 'url' => $bbp_pc_results['url'], 'class' => $bbp_pc_results['class'], 'type' => 'bbpress', 'ID' => null );
  287. +                       }
  288. +                   }
  289. +               }
  290.                 add_filter('bbp_get_breadcrumb','__return_false');
  291.             } elseif ( is_404() ) {
  292. -               if ( isset($opt['breadcrumbs-404crumb']) && $opt['breadcrumbs-404crumb'] != '' )
  293. +               if ( isset($opt['breadcrumbs-404crumb']) && $opt['breadcrumbs-404crumb'] != '' ) {
  294.                     $crumb404 = $opt['breadcrumbs-404crumb'];
  295. -               else
  296. +               } else {
  297.                     $crumb404 = __('Error 404: Page not found','wordpress-seo');
  298. -               $output .= $this->bold_or_not($crumb404);
  299. +               }
  300. +               $breadcrumb_array[] = array ( 'title' => $crumb404, 'url' => '', 'class' => '', 'type' => '404-not-found', 'ID' => null );
  301.             }
  302.         }
  303.        
  304. -       if ( isset($opt['breadcrumbs-prefix']) && $opt['breadcrumbs-prefix'] != "" ) {
  305. -           $output = $opt['breadcrumbs-prefix']." ".$output;
  306. +       $breadcrumb_array = apply_filters( 'wp_seo_get_bc_ancestors', $breadcrumb_array );
  307. +
  308. +       $output = '';
  309. +       if ( !empty($breadcrumb_array) ) {
  310. +           $output .= $prefix;
  311. +           if ( isset($opt['breadcrumbs-prefix']) && $opt['breadcrumbs-prefix'] != "" ) {
  312. +               $output .= $opt['breadcrumbs-prefix'].' ';
  313. +           }
  314. +
  315. +           $breadcrumb_total = count( $breadcrumb_array ) - 1; // Since arrays start at 0.
  316. +           for ( $i = 0 ; $i <= $breadcrumb_total ; $i++ ) {
  317. +               $breadcrumb = $breadcrumb_array[$i];
  318. +              
  319. +               $pre_out = $post_out = '';
  320. +               $mid_out = $breadcrumb['title'];
  321. +              
  322. +               // We don't want search engines displaying the home link in the snippet breadcrumb. Also,
  323. +               // a breadcrumb DIV for the very last item (the current page) is ignored. So we deal with
  324. +               // the special cases:
  325. +               if ( ( $i == 0 && $breadcrumb['type'] != 'home' ) || ( $i > 0 && $i < $breadcrumb_total ) ) {
  326. +                   $pre_out .= '<div';
  327. +                   if ( ( $i == 1 && $breadcrumb_array[0]['type'] != 'home' ) || $i > 1 ) {
  328. +                       $pre_out .= ' itemprop="child"';
  329. +                   }
  330. +                   $pre_out .= ' itemscope itemtype="http://data-vocabulary.org/Breadcrumb" style="display: inline;">';
  331. +                   $mid_out = '<span itemprop="title">'.$mid_out.'</span>';
  332. +                   $suffix = '</div>'.$suffix;
  333. +               }
  334. +              
  335. +               if ( $breadcrumb['url'] ) {
  336. +                   $pre_out .= '<a href="'.esc_url($breadcrumb['url']).'"';
  337. +                   if ( $breadcrumb['class'] ) {
  338. +                       $pre_out .= ' class="'.esc_attr($breadcrumb['class']).'"';
  339. +                   }
  340. +                   if ( $i == 0 && $breadcrumb['type'] != 'home' ) {
  341. +                       $pre_out .= ' itemprop="url"';
  342. +                   }
  343. +                   $pre_out .= '>';
  344. +                   $post_out .= '</a>';
  345. +               }
  346. +              
  347. +               if ( $i < $breadcrumb_total ) {
  348. +                   $post_out .= ' '.$sep.' ';
  349. +               } else {
  350. +                   $mid_out = $this->bold_or_not( $mid_out );
  351. +               }
  352. +              
  353. +               $output .= $pre_out.$mid_out.$post_out;
  354. +           }
  355. +           $output .= $suffix;
  356.         }
  357. +      
  358.         if ($display) {
  359. -           echo $prefix.$output.$suffix;
  360. +           echo $output;
  361.             return true;
  362.         } else {
  363. -           return $prefix.$output.$suffix;
  364. +           return $output;
  365.         }
  366.     }
  367.  }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement