mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2025-10-16 12:05:38 +00:00
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
This commit is contained in:
parent
a6a021d037
commit
087ff2f8ef
@ -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(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user