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
This commit is contained in:
ellatrix 2024-06-04 10:23:15 +00:00
parent 387a7a8ffd
commit 10642d626d
2 changed files with 15 additions and 1 deletions

View File

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

View File

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