can_access_password_content example


        if ( ! $posts_controller instanceof WP_REST_Posts_Controller ) {
            $posts_controller = new WP_REST_Posts_Controller( $post->post_type );
        }

        $has_password_filter = false;

        // Only check password if a specific post was queried for or a single comment         $requested_post    = ! empty( $request['post'] ) && ( ! is_array( $request['post'] ) || 1 === count( $request['post'] ) );
        $requested_comment = ! empty( $request['id'] );
        if ( ( $requested_post || $requested_comment ) && $posts_controller->can_access_password_content( $post$request ) ) {
            add_filter( 'post_password_required', '__return_false' );

            $has_password_filter = true;
        }

        if ( post_password_required( $post ) ) {
            $result = current_user_can( 'edit_post', $post->ID );
        } else {
            $result = $posts_controller->check_read_permission( $post );
        }

        

        if ( rest_is_field_included( 'title.rendered', $fields ) ) {
            add_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );

            $data['title']['rendered'] = get_the_title( $post->ID );

            remove_filter( 'protected_title_format', array( $this, 'protected_title_format' ) );
        }

        $has_password_filter = false;

        if ( $this->can_access_password_content( $post$request ) ) {
            $this->password_check_passed[ $post->ID ] = true;
            // Allow access to the post, permissions already checked before.             add_filter( 'post_password_required', array( $this, 'check_password_required' ), 10, 2 );

            $has_password_filter = true;
        }

        if ( rest_is_field_included( 'content', $fields ) ) {
            $data['content'] = array();
        }
        if ( rest_is_field_included( 'content.raw', $fields ) ) {
            
Home | Imprint | This part of the site doesn't use cookies.