WP_REST_URL_Details_Controller::get_title() – Parses the `<title>` contents from the provided HTML.
You appear to be a bot. Output may be restricted
Description
Parses the title tag contents from the provided HTML.
Usage
$string = WP_REST_URL_Details_Controller::get_title( $html );
Parameters
- $html
- ( string ) required – The HTML from the remote website at URL.
Returns
string The title tag contents on success. Empty string if not found.
Source
File name: wordpress/wp-includes/rest-api/endpoints/class-wp-rest-url-details-controller.php
Lines:
1 to 12 of 12
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 ); }