WP_Block_Templates_Registry::get_by_slug()
Retrieves a registered template by its slug.
Метод класса: WP_Block_Templates_Registry{}
Хуков нет.
Возвращает
WP_Block_Template|null
. The registered template, or null if it is not registered.
Использование
$WP_Block_Templates_Registry = new WP_Block_Templates_Registry(); $WP_Block_Templates_Registry->get_by_slug( $template_slug );
- $template_slug(строка) (обязательный)
- Slug of the template.
Список изменений
С версии 6.7.0 | Введена. |
Код WP_Block_Templates_Registry::get_by_slug() WP Block Templates Registry::get by slug WP 6.7.1
public function get_by_slug( $template_slug ) { $all_templates = $this->get_all_registered(); if ( ! $all_templates ) { return null; } foreach ( $all_templates as $template ) { if ( $template->slug === $template_slug ) { return $template; } } return null; }