Skip to content

Commit

Permalink
Editor: Add has_archive property to the post types REST endpoint.
Browse files Browse the repository at this point in the history
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: https://core.svn.wordpress.org/trunk@53832 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
jorgefilipecosta committed Sep 21, 2022
1 parent e4bb08f commit 2c70893
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ public function prepare_item_for_response( $item, $request ) {
$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,
Expand Down Expand Up @@ -353,6 +357,12 @@ public function get_item_schema() {
'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',
Expand Down
2 changes: 1 addition & 1 deletion wp-includes/version.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 2c70893

Please sign in to comment.