WP_Post::filter │ public │ WP 3.5.0

Applies the provided context filter for the current post.

If the requested filter was already applied, then it returns without any changes.

If the 'raw' filter is supplied, then a new instance of the post is obtained and this method _may_ return false in case the underlying post was deleted.

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

Хуков нет.

Возвращает

WP_Post|false.

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

$WP_Post = new WP_Post();
$WP_Post->filter( $filter );
$filter(строка) (обязательный)
Filter.

Список изменений

С версии 3.5.0 Введена.

Код WP_Post::filter() WP 7.1.4

public function filter( $filter ) {
	if ( $this->filter === $filter ) {
		return $this;
	}

	if ( 'raw' === $filter ) {
		return self::get_instance( $this->ID );
	}

	return sanitize_post( $this, $filter );
}