REST API: Add visibility information to the Post Types controller.

Props spacedmonkey, peterwilsoncc.
Fixes #54055.


git-svn-id: https://develop.svn.wordpress.org/trunk@51959 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Timothy Jacobs
2021-10-31 05:17:53 +00:00
parent 9f9c81f567
commit 57ded3c85d
2 changed files with 30 additions and 1 deletions

View File

@@ -197,6 +197,13 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
$data['hierarchical'] = $post_type->hierarchical;
}
if ( in_array( 'visibility', $fields, true ) ) {
$data['visibility'] = array(
'show_in_nav_menus' => (bool) $post_type->show_in_nav_menus,
'show_ui' => (bool) $post_type->show_ui,
);
}
if ( in_array( 'viewable', $fields, true ) ) {
$data['viewable'] = is_post_type_viewable( $post_type );
}
@@ -337,6 +344,22 @@ class WP_REST_Post_Types_Controller extends WP_REST_Controller {
'context' => array( 'view', 'edit', 'embed' ),
'readonly' => true,
),
'visibility' => array(
'description' => __( 'The visibility settings for the post type.' ),
'type' => 'object',
'context' => array( 'edit' ),
'readonly' => true,
'properties' => array(
'show_ui' => array(
'description' => __( 'Whether to generate a default UI for managing this post type.' ),
'type' => 'boolean',
),
'show_in_nav_menus' => array(
'description' => __( 'Whether to make the post type is available for selection in navigation menus.' ),
'type' => 'boolean',
),
),
),
),
);