Skip to content

Commit 3cf787a

Browse files
committed
Revert changes to the post_type_supports function
1 parent 13defce commit 3cf787a

File tree

2 files changed

+24
-21
lines changed

2 files changed

+24
-21
lines changed

src/wp-includes/post.php

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,27 +2350,8 @@ function get_all_post_type_supports( $post_type ) {
23502350
function post_type_supports( $post_type, $feature ) {
23512351
global $_wp_post_type_features;
23522352

2353-
if ( str_contains( $feature, '/' ) ) {
2354-
$parts = explode( '/', $feature, 2 );
2355-
$feature = $parts[0];
2356-
$sub_feature = $parts[1];
2357-
2358-
if ( ! isset( $_wp_post_type_features[ $post_type ][ $feature ] ) ) {
2359-
return false;
2360-
}
2361-
2362-
$feature_value = $_wp_post_type_features[ $post_type ][ $feature ];
2363-
2364-
if ( is_array( $feature_value ) && isset( $feature_value[0] ) && is_array( $feature_value[0] ) ) {
2365-
return ! empty( $feature_value[0][ $sub_feature ] );
2366-
}
2367-
2368-
return false;
2369-
}
2370-
23712353
return ( isset( $_wp_post_type_features[ $post_type ][ $feature ] ) );
23722354
}
2373-
23742355
/**
23752356
* Retrieves a list of post type names that support a specific feature.
23762357
*

src/wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function get_items_permissions_check( $request ) {
130130
foreach ( (array) $request['post'] as $post_id ) {
131131
$post = get_post( $post_id );
132132

133-
if ( $post && $is_note && ! post_type_supports( $post->post_type, 'editor/notes' ) ) {
133+
if ( $post && $is_note && ! $this->check_post_type_supports_notes( $post->post_type ) ) {
134134
return new WP_Error(
135135
'rest_comment_not_supported_post_type',
136136
__( 'Sorry, this post type does not support notes.' ),
@@ -566,7 +566,7 @@ public function create_item_permissions_check( $request ) {
566566
);
567567
}
568568

569-
if ( $is_note && ! post_type_supports( $post->post_type, 'editor/notes' ) ) {
569+
if ( $is_note && ! $this->check_post_type_supports_notes( $post->post_type ) ) {
570570
return new WP_Error(
571571
'rest_comment_not_supported_post_type',
572572
__( 'Sorry, this post type does not support notes.' ),
@@ -1978,4 +1978,26 @@ protected function check_is_comment_content_allowed( $prepared_comment ) {
19781978
*/
19791979
return '' !== $check['comment_content'];
19801980
}
1981+
1982+
/**
1983+
* Check if post type supports block comments.
1984+
*
1985+
* @param string $post_type Post type name.
1986+
* @return bool True if post type supports block comments, false otherwise.
1987+
*/
1988+
private function check_post_type_supports_notes( $post_type ) {
1989+
$supports = get_all_post_type_supports( $post_type );
1990+
if ( ! isset( $supports['editor'] ) ) {
1991+
return false;
1992+
}
1993+
if ( ! is_array( $supports['editor'] ) ) {
1994+
return false;
1995+
}
1996+
foreach ( $supports['editor'] as $item ) {
1997+
if ( is_array( $item ) && isset( $item['notes'] ) && true === $item['notes'] ) {
1998+
return true;
1999+
}
2000+
}
2001+
return true;
2002+
}
19812003
}

0 commit comments

Comments
 (0)