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.

git-svn-id: https://develop.svn.wordpress.org/trunk@54273 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Jorge Costa
2022-09-21 12:27:33 +00:00
parent 30de259b07
commit 34ace2304b
3 changed files with 22 additions and 1 deletions
@@ -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',