Advertisement
jrf_nl

WordPress SEO by Yoast breadcrumb fix

Sep 13th, 2012
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.07 KB | None | 0 0
  1. File: wordpress-seo/frontend/class-breadcrumbs.php
  2.  
  3. Line 164 - 170:
  4.             } elseif ( is_404() ) {
  5.                 if ( isset( $options['breadcrumbs-404crumb'] ) && $options['breadcrumbs-404crumb'] != '' )
  6.                     $crumb404 = $options['breadcrumbs-404crumb'];
  7.                 else
  8.                     $crumb404 = __( 'Error 404: Page not found', 'wordpress-seo' );
  9.                 $links[] = array( 'text' => $crumb404 );
  10.             }
  11.  
  12. replace with:
  13.             } elseif ( is_404() ) {
  14.  
  15.                 if ( get_query_var( 'year' ) !== 0 || ( get_query_var( 'monthnum' ) !== 0 || get_query_var( 'day' ) !== 0 ) ) {
  16.                    
  17.                     if ( "page" == $on_front && !is_home() ) {
  18.                         if ( $blog_page && ( !isset( $options['breadcrumbs-blog-remove'] ) || !$options['breadcrumbs-blog-remove'] ) )
  19.                             $links[] = array( 'id' => $blog_page );
  20.                     }
  21.  
  22.                     if ( isset( $options['breadcrumbs-archiveprefix'] ) )
  23.                         $bc = $options['breadcrumbs-archiveprefix'];
  24.                     else
  25.                         $bc = __( 'Archives for', 'wordpress-seo' );
  26.  
  27.  
  28.                     if ( get_query_var( 'day' ) !== 0 ) {
  29.                         global $wp_locale;
  30.  
  31.                         $links[] = array(
  32.                             'url'  => get_month_link( get_query_var( 'year' ), get_query_var( 'monthnum' ) ),
  33.                             'text' => $wp_locale->get_month( get_query_var( 'monthnum' ) ) . ' ' . get_query_var( 'year' )
  34.                         );
  35.                         global $post;
  36.                         $original_p = $post;
  37.                         $post->post_date = sprintf("%04d-%02d-%02d 00:00:00", get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
  38.                         $links[] = array( 'text' => $bc . " " . get_the_date() );
  39.                         $post = $original_p;
  40.  
  41.                     } else if ( get_query_var( 'monthnum' ) !== 0 ) {
  42.                         $links[] = array( 'text' => $bc . " " . single_month_title( ' ', false ) );
  43.                     } else if ( get_query_var( 'year' ) !== 0 ) {
  44.                         $links[] = array( 'text' => $bc . " " . get_query_var( 'year' ) );
  45.                     }
  46.                 }
  47.                 else {
  48.                     if ( isset( $options['breadcrumbs-404crumb'] ) && $options['breadcrumbs-404crumb'] != '' )
  49.                         $crumb404 = $options['breadcrumbs-404crumb'];
  50.                     else
  51.                         $crumb404 = __( 'Error 404: Page not found', 'wordpress-seo' );
  52.                     $links[] = array( 'text' => $crumb404 );
  53.                 }
  54.             }
  55.  
  56.  
  57.  
  58.  
  59. File: wordpress-seo/frontend/class-frontend.php
  60.  
  61. Line 355-359:
  62.         } else if ( is_404() ) {
  63.             $title = $this->get_title_from_options( 'title-404' );
  64.  
  65.             if ( empty( $title ) )
  66.                 $title_part = __( 'Page not found', 'wordpress-seo' );
  67.  
  68. replace with:
  69.         } else if ( is_404() ) {
  70.            
  71.             if ( get_query_var( 'year' ) !== 0 || ( get_query_var( 'monthnum' ) !== 0 || get_query_var( 'day' ) !== 0 ) ) {
  72.  
  73.                 if ( get_query_var( 'day' ) !== 0 ) {
  74.  
  75.                     global $post;
  76.                     $original_p = $post;
  77.                     $post->post_date = sprintf("%04d-%02d-%02d 00:00:00", get_query_var( 'year' ), get_query_var( 'monthnum' ), get_query_var( 'day' ) );
  78.                     $title_part = sprintf( __( '%s Archives', 'wordpress-seo' ), get_the_date() );
  79.                     $post = $original_p;
  80.                 }
  81.                 else if ( get_query_var( 'monthnum' ) !== 0 ) {
  82.                     $title_part = sprintf( __( '%s Archives', 'wordpress-seo' ), single_month_title( ' ', false ) );
  83.                 }
  84.                 else if ( get_query_var( 'year' ) !== 0 ) {
  85.                     $title_part = sprintf( __( '%s Archives', 'wordpress-seo' ), get_query_var( 'year' ) );
  86.                 }
  87.                 else {
  88.                     $title_part = __( 'Archives', 'wordpress-seo' );
  89.                 }
  90.             }
  91.             else {
  92.                 $title = $this->get_title_from_options( 'title-404', array( 'term404' => get_query_var( 'pagename' ) ) );
  93.  
  94.                 if ( empty( $title ) )
  95.                     $title_part = __( 'Page not found', 'wordpress-seo' );
  96.             }
  97.  
  98.  
  99.  
  100. File: wordpress-seo/inc/wpseo-functions.php
  101.  
  102. Line 110-111:
  103.         'term_id'       => '',
  104.     );
  105.  
  106. replace with:
  107.         'term_id'       => '',
  108.         'term404'       => '',
  109.     );
  110.  
  111.  
  112. Line 173-174:
  113.         '%%caption%%'                   => $r->post_excerpt,
  114.     );
  115.  
  116. replace with:
  117.         '%%caption%%'                   => $r->post_excerpt,
  118.         '%%term404%%'           => sanitize_text_field ( str_replace( '-', ' ', $r->term404 ) ),
  119.     );
  120.  
  121.  
  122.  
  123. File: wordpress-seo/admin/pages/metas.php
  124.  
  125. Line 298-299:
  126.             </tr>
  127.             <tr>
  128.  
  129. replace with:
  130.             </tr>
  131.             <tr>
  132.                 <th>%%term404%%</th>
  133.                 <td>' . __( 'Replaced with the slug which caused the 404', 'wordpress-seo' ) . '</td>
  134.             </tr>
  135.             <tr>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement