diff --git a/wp-includes/post.php b/wp-includes/post.php index c7dcc13b8d..df509fd114 100644 --- a/wp-includes/post.php +++ b/wp-includes/post.php @@ -4159,12 +4159,14 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true ) * * For new posts check the primitive capability, for updates check the meta capability. */ - $post_type_object = get_post_type_object( $post_type ); + if ( 'pending' === $post_status ) { + $post_type_object = get_post_type_object( $post_type ); - if ( ! $update && 'pending' === $post_status && ! current_user_can( $post_type_object->cap->publish_posts ) ) { - $post_name = ''; - } elseif ( $update && 'pending' === $post_status && ! current_user_can( 'publish_post', $post_ID ) ) { - $post_name = ''; + if ( ! $update && $post_type_object && ! current_user_can( $post_type_object->cap->publish_posts ) ) { + $post_name = ''; + } elseif ( $update && ! current_user_can( 'publish_post', $post_ID ) ) { + $post_name = ''; + } } /* diff --git a/wp-includes/version.php b/wp-includes/version.php index 63d76a5260..bfd72937cd 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.1-alpha-53770'; +$wp_version = '6.1-alpha-53771'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.