WP_Theme_JSON::get_template_partspublicWP 5.9.0

Returns the template part data of active theme.

Метод класса: WP_Theme_JSON{}

Хуков нет.

Возвращает

Массив.

Использование

$WP_Theme_JSON = new WP_Theme_JSON();
$WP_Theme_JSON->get_template_parts();

Список изменений

С версии 5.9.0 Введена.

Код WP_Theme_JSON::get_template_parts() WP 7.0

public function get_template_parts() {
	$template_parts = array();
	if ( ! isset( $this->theme_json['templateParts'] ) || ! is_array( $this->theme_json['templateParts'] ) ) {
		return $template_parts;
	}

	foreach ( $this->theme_json['templateParts'] as $item ) {
		if ( isset( $item['name'] ) ) {
			$template_parts[ $item['name'] ] = array(
				'title' => $item['title'] ?? '',
				'area'  => $item['area'] ?? '',
			);
		}
	}
	return $template_parts;
}