WP_REST_Post_Statuses_Controller::check_read_permission() WordPress Method

This method is used to check if the current user has permission to read a post status.

WP_REST_Post_Statuses_Controller::check_read_permission( object $status ) #

Checks whether a given post status should be visible.


Parameters

$status

(object)(Required)Post status.


Top ↑

Return

(bool) True if the post status is visible, otherwise false.


Top ↑

Source

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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.