Yoast\WP\SEO\Bulk_Editor\Domain\Posts
Posts_List{}
This class describes a list of posts.
Хуков нет.
Использование
$Posts_List = new Posts_List(); // use class methods
Методы
- public add( Post $post )
- public get()
- public to_array()
Код Posts_List{} Posts List{} Yoast 28.3
class Posts_List {
/**
* The posts.
*
* @var Post[]
*/
private $posts = [];
/**
* Adds a post to the list.
*
* @param Post $post The post to add.
*
* @return void
*/
public function add( Post $post ): void {
$this->posts[] = $post;
}
/**
* Returns the posts in the list.
*
* @return Post[] The posts in the list.
*/
public function get(): array {
return $this->posts;
}
/**
* Parses the post list to the expected key value representation.
*
* @return array<array<string, int|string>> The post list presented as the expected key value representation.
*/
public function to_array(): array {
return \array_map(
static function ( Post $post ) {
return $post->to_array();
},
$this->posts,
);
}
}