WP_REST_URL_Details_Controller::get_description()privateWP 5.9.0

Parses the meta description from the provided HTML.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->get_description( $meta_elements );
$meta_elements(массив) (обязательный)

A multi-dimensional indexed array on success, else empty array.

  • 0(string[])
    Meta elements with a content attribute.

  • 1(string[])
    Content attribute's opening quotation mark.

  • 2(string[])
    Content attribute's value for each meta element.

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

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

Код WP_REST_URL_Details_Controller::get_description() WP 6.5.2

private function get_description( $meta_elements ) {
	// Bail out if there are no meta elements.
	if ( empty( $meta_elements[0] ) ) {
		return '';
	}

	$description = $this->get_metadata_from_meta_element(
		$meta_elements,
		'name',
		'(?:description|og:description)'
	);

	// Bail out if description not found.
	if ( '' === $description ) {
		return '';
	}

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