Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.

WP_REST_URL_Details_Controller::get_description() WordPress Method

The WP_REST_URL_Details_Controller::get_description() method is used to get the description of a URL. This is useful for when you need to know more about a URL before you access it.

WP_REST_URL_Details_Controller::get_description( array $meta_elements ) #

Parses the meta description from the provided HTML.


Parameters

$meta_elements

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

  • (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.


Top ↑

Return

(string) The meta description contents on success. Empty string if not found.


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php

	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 );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.