WPCOM_JSON_API_Endpoint::current_user_can_access_post_type PHP Method

current_user_can_access_post_type() public method

Check whether a user can view or edit a post type
public current_user_can_access_post_type ( string $post_type, string $context = 'display' ) : boolean
$post_type string post type to check
$context string 'display' or 'edit'
return boolean
    function current_user_can_access_post_type($post_type, $context = 'display')
    {
        $post_type_object = get_post_type_object($post_type);
        if (!$post_type_object) {
            return false;
        }
        switch ($context) {
            case 'edit':
                return current_user_can($post_type_object->cap->edit_posts);
            case 'display':
                return $post_type_object->public || current_user_can($post_type_object->cap->read_private_posts);
            default:
                return false;
        }
    }