maybe_redirect_404

Correct 404 redirects when NOBLOGREDIRECT is defined.

Description

maybe_redirect_404(); 

Usage

  1. if ( !function_exists( 'maybe_redirect_404' ) ) { 
  2. require_once ABSPATH . WPINC . '/ms-functions.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = maybe_redirect_404(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/ms-functions.php  
  1. function maybe_redirect_404() { 
  2. /** 
  3. * Filters the redirect URL for 404s on the main site. 
  4. * The filter is only evaluated if the NOBLOGREDIRECT constant is defined. 
  5. * @since 3.0.0 
  6. * @param string $no_blog_redirect The redirect URL defined in NOBLOGREDIRECT. 
  7. */ 
  8. if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) { 
  9. if ( $destination == '%siteurl%' ) 
  10. $destination = network_home_url(); 
  11. wp_redirect( $destination ); 
  12. exit();