From f070145fa9a8eb177e3045297613b802f3c61ac7 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Mon, 28 Sep 2020 11:52:00 +0000 Subject: [PATCH] Posts, Post Types: Avoid a PHP notice in `wp_get_shortlink()` if the post type is no longer registered. Props apedog. Fixes #51376. git-svn-id: https://develop.svn.wordpress.org/trunk@49067 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/link-template.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/link-template.php b/src/wp-includes/link-template.php index e913f3bf58..b1294db5be 100644 --- a/src/wp-includes/link-template.php +++ b/src/wp-includes/link-template.php @@ -3913,7 +3913,7 @@ function wp_get_shortlink( $id = 0, $context = 'post', $allow_slugs = true ) { if ( 'page' === $post->post_type && get_option( 'page_on_front' ) == $post->ID && 'page' === get_option( 'show_on_front' ) ) { $shortlink = home_url( '/' ); - } elseif ( $post_type->public ) { + } elseif ( $post_type && $post_type->public ) { $shortlink = home_url( '?p=' . $post_id ); } }