Yoast\WP\SEO\Surfaces

Meta_Surface::is_post_readable │ public │ Yoast 1.0

Checks if the current user is allowed to read a given post.

Метод класса: Meta_Surface{}

Хуков нет.

Возвращает

bool. Whether the post is publicly viewable or readable by the current user.

Использование

$Meta_Surface = new Meta_Surface();
$Meta_Surface->is_post_readable( $post_id );
$post_id(int) (обязательный)
The post ID.

Код Meta_Surface::is_post_readable() Yoast 28.9

public function is_post_readable( $post_id ) {
	$post = \get_post( $post_id );

	if ( ! $post ) {
		return false;
	}

	if ( \is_post_publicly_viewable( $post ) ) {
		return true;
	}

	return \current_user_can( 'read_post', $post->ID );
}