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.
Built from https://develop.svn.wordpress.org/trunk@49924


git-svn-id: http://core.svn.wordpress.org/trunk@49623 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2021-01-03 17:56:06 +00:00
parent 7d4a40f4ee
commit d495eb4548
2 changed files with 2 additions and 2 deletions

View File

@ -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(

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.7-alpha-49923';
$wp_version = '5.7-alpha-49924';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.