mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-15 23:25:50 +01:00
Posts, Post Types: Check if the post type exists in wp_insert_post()
.
This avoids an `Attempt to read property "cap" on null` PHP warning when checking an unregistered post type's `publish_posts` capability to disallow contributors setting the post slug for pending posts. Follow-up to [9055], [42380]. Props Chouby, mukesh27, rafiahmedd, SergeyBiryukov. Fixes #55877. Built from https://develop.svn.wordpress.org/trunk@53771 git-svn-id: http://core.svn.wordpress.org/trunk@53330 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a7d02201ea
commit
ae807463ac
@ -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 = '';
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -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.
|
||||
|
Loading…
Reference in New Issue
Block a user