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

Props spacedmonkey, peterwilsoncc.
Fixes #54055.

Built from https://develop.svn.wordpress.org/trunk@51959


git-svn-id: http://core.svn.wordpress.org/trunk@51548 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
TimothyBlynJacobs 2021-10-31 05:19:01 +00:00
parent 3d86f8af55
commit f76071026b
2 changed files with 24 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',
),
),
),
),
);

View File

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