WordPress.org

Make WordPress Core

Ticket #16557: new filter to replace redirect_guess_404_permalink.diff

File new filter to replace redirect_guess_404_permalink.diff, 705 bytes (added by simonwheatley, 3 years ago)

New filter to replace redirect_guess_404_permalink

  • wp-includes/canonical.php

     
    9292                        } 
    9393                } 
    9494 
    95                 if ( ! $redirect_url ) 
    96                         $redirect_url = redirect_guess_404_permalink(); 
     95                $redirect_url = apply_filters( '404_guess_permalink', $redirect_url ); 
    9796 
    9897        } elseif ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) { 
    9998                // rewriting of old ?p=X, ?m=2004, ?m=200401, ?m=20040101 
     
    409408        return get_permalink($post_id); 
    410409} 
    411410 
     411add_filter( '404_guess_permalink', 'redirect_guess_404_permalink' ); 
     412 
    412413add_action('template_redirect', 'redirect_canonical'); 
    413414 
    414415?>