@@ -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