From 087ff2f8efef4ff64d0ac5734ace8c69d98773c4 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sun, 3 Jan 2021 17:54:48 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@49924 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/canonical.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/canonical.php b/src/wp-includes/canonical.php index 167b5cf562..617bcb352d 100644 --- a/src/wp-includes/canonical.php +++ b/src/wp-includes/canonical.php @@ -148,7 +148,7 @@ function redirect_canonical( $requested_url = null, $do_redirect = true ) { if ( $redirect_post ) { $post_type_obj = get_post_type_object( $redirect_post->post_type ); - if ( $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { + if ( $post_type_obj && $post_type_obj->public && 'auto-draft' !== $redirect_post->post_status ) { $redirect_url = get_permalink( $redirect_post ); $redirect['query'] = _remove_qs_args_if_not_in_url(