Editor: Add has_archive property to the post types REST endpoint.

Backports PHP changes in WordPress/gutenberg#42746 to the core. Adds a has_archive field to the post types endpoint.

Props mcsf, ntsekouras, oandregal.
See #56467.
Built from https://develop.svn.wordpress.org/trunk@54273


git-svn-id: http://core.svn.wordpress.org/trunk@53832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
jorgefilipecosta 2022-09-21 12:29:13 +00:00
parent 325e60a744
commit 73cf7271bc
2 changed files with 11 additions and 1 deletions

View File

@ -198,6 +198,10 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
$data['hierarchical'] = $post_type->hierarchical;
}
if ( rest_is_field_included( 'hierarchical', $fields ) ) {
$data['has_archive'] = $post_type->has_archive;
}
if ( rest_is_field_included( 'visibility', $fields ) ) {
$data['visibility'] = array(
'show_in_nav_menus' => (bool) $post_type->show_in_nav_menus,
@ -353,6 +357,12 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
'context' => array( 'edit' ),
'readonly' => true,
),
'has_archive' => array(
'description' => __( 'If the value is a string, the value will be used as the archive slug. If the value is false the post type has no archive.' ),
'type' => array( 'string', 'boolean' ),
'context' => array( 'view', 'edit' ),
'readonly' => true,
),
'taxonomies' => array(
'description' => __( 'Taxonomies associated with post type.' ),
'type' => 'array',

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-54272';
$wp_version = '6.1-alpha-54273';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.