WordPress.org

Make WordPress Core

Changeset 49924


Ignore:
Timestamp:
01/03/2021 05:54:48 PM (4 months ago)
Author:
SergeyBiryukov
Message:

Canonical: Check if the post type exists when attempting a canonical redirect.

This avoids a PHP notice if the post type is no longer registered.

Follow-up to [14595], [35480].

Props bobbingwide, hareesh-pillai.
Fixes #40309.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/canonical.php

    r49622 r49924  
    149149            $post_type_obj = get_post_type_object( $redirect_post->post_type );
    150150
    151             if ( $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) {
     151            if ( $post_type_obj && $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) {
    152152                $redirect_url = get_permalink( $redirect_post );
    153153
Note: See TracChangeset for help on using the changeset viewer.