From 10642d626d70cd336c70d031585215f5725ccc8e Mon Sep 17 00:00:00 2001 From: ellatrix Date: Tue, 4 Jun 2024 10:23:15 +0000 Subject: [PATCH] REST API: Add post class list field. See https://github.com/WordPress/gutenberg/pull/60642. See https://github.com/WordPress/wordpress-develop/pull/6716. Fixes #61360. Props antonvlasenko, timothyblynjacobs, ellatrix, oandregal. Built from https://develop.svn.wordpress.org/trunk@58326 git-svn-id: http://core.svn.wordpress.org/trunk@57783 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../endpoints/class-wp-rest-posts-controller.php | 14 ++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index ec1588b02f..a29f92c56f 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1998,6 +1998,10 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { $data['generated_slug'] = $sample_permalink[1]; } } + + if ( rest_is_field_included( 'class_list', $fields ) ) { + $data['class_list'] = get_post_class( array(), $post->ID ); + } } $context = ! empty( $request['context'] ) ? $request['context'] : 'view'; @@ -2353,6 +2357,16 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { 'context' => array( 'edit' ), 'readonly' => true, ); + + $schema['properties']['class_list'] = array( + 'description' => __( 'An array of the class names for the post container element.' ), + 'type' => 'array', + 'context' => array( 'view', 'edit' ), + 'readonly' => true, + 'items' => array( + 'type' => 'string', + ), + ); } if ( $post_type_obj->hierarchical ) { diff --git a/wp-includes/version.php b/wp-includes/version.php index 6599f6a9bc..967df0cbe5 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.6-alpha-58325'; +$wp_version = '6.6-alpha-58326'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.