Uses
| Uses | Description |
|---|---|
| wp-includes/capabilities.php: current_user_can() | Returns whether the current user has the specified capability. |
| wp-includes/post.php: get_post_types() | Get a list of all registered post type objects. |
Checks whether a given post status should be visible.
(object) (Required) Post status.
(bool) True if the post status is visible, otherwise false.
File: wp-includes/rest-api/endpoints/class-wp-rest-post-statuses-controller.php
protected function check_read_permission( $status ) {
if ( true === $status->public ) {
return true;
}
if ( false === $status->internal || 'trash' === $status->name ) {
$types = get_post_types( array( 'show_in_rest' => true ), 'objects' );
foreach ( $types as $type ) {
if ( current_user_can( $type->cap->edit_posts ) ) {
return true;
}
}
}
return false;
} | Version | Description |
|---|---|
| 4.7.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/classes/wp_rest_post_statuses_controller/check_read_permission