WP_REST_URL_Details_Controller::get_title()privateWP 5.9.0

Parses the title tag contents from the provided HTML.

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

Хуков нет.

Возвращает

Строку. The title tag contents on success. Empty string if not found.

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

// private - только в коде основоного (родительского) класса
$result = $this->get_title( $html );
$html(строка) (обязательный)
The HTML from the remote website at URL.

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

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

Код WP_REST_URL_Details_Controller::get_title() WP 6.7.1

private function get_title( $html ) {
	$pattern = '#<title[^>]*>(.*?)<\s*/\s*title>#is';
	preg_match( $pattern, $html, $match_title );

	if ( empty( $match_title[1] ) || ! is_string( $match_title[1] ) ) {
		return '';
	}

	$title = trim( $match_title[1] );

	return $this->prepare_metadata_for_output( $title );
}