Skip to content

Commit

Permalink
Remove post type 'viewable' compatibility shim (#7496)
Browse files Browse the repository at this point in the history
This was shipped with WordPress 4.9.6
  • Loading branch information
danielbachhuber authored Jun 25, 2018
1 parent bf69697 commit d5657c4
Showing 1 changed file with 0 additions and 33 deletions.
33 changes: 0 additions & 33 deletions lib/rest-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -365,39 +365,6 @@ function gutenberg_register_taxonomy_prepare_functions( $taxonomy ) {
}
add_filter( 'registered_taxonomy', 'gutenberg_register_taxonomy_prepare_functions' );

/**
* Includes the value for the 'viewable' attribute of a post type resource.
*
* @see https://core.trac.wordpress.org/ticket/43739
*
* @param object $post_type Post type response object.
* @return boolean Whether or not the post type can be viewed.
*/
function gutenberg_get_post_type_viewable( $post_type ) {
return is_post_type_viewable( $post_type['slug'] );
}

/**
* Adds the 'viewable' attribute to the REST API response of a post type.
*
* @see https://core.trac.wordpress.org/ticket/43739
*/
function gutenberg_register_rest_api_post_type_viewable() {
register_rest_field( 'type',
'viewable',
array(
'get_callback' => 'gutenberg_get_post_type_viewable',
'schema' => array(
'description' => __( 'Whether or not the post type can be viewed', 'gutenberg' ),
'type' => 'boolean',
'context' => array( 'edit' ),
'readonly' => true,
),
)
);
}
add_action( 'rest_api_init', 'gutenberg_register_rest_api_post_type_viewable' );

/**
* Gets revisions details for the selected post.
*
Expand Down

0 comments on commit d5657c4

Please sign in to comment.