Yoast\WP\SEO\Bulk_Editor\Domain\Content_Types
Content_Types_List{}
This class describes a list of content types.
Хуков нет.
Использование
$Content_Types_List = new Content_Types_List(); // use class methods
Методы
- public add( Content_Type $content_type )
- public get()
- public to_array()
Код Content_Types_List{} Content Types List{} Yoast 28.9
class Content_Types_List {
/**
* The content types.
*
* @var array<string, Content_Type>
*/
private $content_types = [];
/**
* Adds a content type to the list.
*
* @param Content_Type $content_type The content type to add.
*
* @return void
*/
public function add( Content_Type $content_type ): void {
$this->content_types[ $content_type->get_name() ] = $content_type;
}
/**
* Returns the content types in the list.
*
* @return array<string, Content_Type> The content types in the list.
*/
public function get(): array {
return $this->content_types;
}
/**
* Parses the content type list to the expected key value representation.
*
* @return array<array<string, string>> The content type list presented as the expected key value representation.
*/
public function to_array(): array {
$array = [];
foreach ( $this->content_types as $content_type ) {
$array[] = [
'name' => $content_type->get_name(),
'label' => $content_type->get_label(),
'singularLabel' => $content_type->get_singular_label(),
];
}
return $array;
}
}