From 73cf7271bc95974bc5810a1e28c8f273256926f5 Mon Sep 17 00:00:00 2001 From: jorgefilipecosta Date: Wed, 21 Sep 2022 12:29:13 +0000 Subject: [PATCH] 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 --- .../endpoints/class-wp-rest-post-types-controller.php | 10 ++++++++++ wp-includes/version.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php index 8223f1dd6f..02a03cd1a5 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-post-types-controller.php @@ -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', diff --git a/wp-includes/version.php b/wp-includes/version.php index f4821601a5..8c68bfe25c 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.