WP_Theme_JSON::get_custom_templates
Returns the page templates of the active theme.
Метод класса: WP_Theme_JSON{}
Хуков нет.
Возвращает
Массив.
Использование
$WP_Theme_JSON = new WP_Theme_JSON(); $WP_Theme_JSON->get_custom_templates();
Список изменений
| С версии 5.9.0 | Введена. |
Код WP_Theme_JSON::get_custom_templates() WP Theme JSON::get custom templates WP 7.0
public function get_custom_templates() {
$custom_templates = array();
if ( ! isset( $this->theme_json['customTemplates'] ) || ! is_array( $this->theme_json['customTemplates'] ) ) {
return $custom_templates;
}
foreach ( $this->theme_json['customTemplates'] as $item ) {
if ( isset( $item['name'] ) ) {
$custom_templates[ $item['name'] ] = array(
'title' => $item['title'] ?? '',
'postTypes' => $item['postTypes'] ?? array( 'page' ),
);
}
}
return $custom_templates;
}