From f76071026be8b8264396ff1b41d98af33d1e0f66 Mon Sep 17 00:00:00 2001 From: TimothyBlynJacobs Date: Sun, 31 Oct 2021 05:19:01 +0000 Subject: [PATCH] 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 --- .../class-wp-rest-post-types-controller.php | 23 +++++++++++++++++++ wp-includes/version.php | 2 +- 2 files changed, 24 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 1301246dea..e2598ac89d 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 @@ -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', + ), + ), + ), ), ); diff --git a/wp-includes/version.php b/wp-includes/version.php index a66a0224ab..60d7f4b0c6 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.