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
This commit is contained in:
Sergey Biryukov 2020-09-28 11:52:00 +00:00
parent b6f5a94631
commit f070145fa9
1 changed files with 1 additions and 1 deletions

View File

@ -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 );
}
}