Yoast\WP\SEO\Abilities\Infrastructure
Site_Representation_Field_Validators::has_published_posts
Checks whether a user has published posts, of the post types the users REST endpoint considers for this.
Метод класса: Site_Representation_Field_Validators{}
Хуков нет.
Возвращает
bool. Whether the user has published posts.
Использование
// private - только в коде основоного (родительского) класса $result = $this->has_published_posts( $user_id ): bool;
- $user_id(int) (обязательный)
- The ID of the user.
Код Site_Representation_Field_Validators::has_published_posts() Site Representation Field Validators::has published posts Yoast 28.8
private function has_published_posts( int $user_id ): bool {
return (int) \count_user_posts( $user_id, \get_post_types( [ 'show_in_rest' => true ] ), true ) > 0;
}