[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/rest-api/endpoints/ -> class-wp-rest-url-details-controller.php (summary)

REST API: WP_REST_URL_Details_Controller class

File Size: 668 lines (21 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

WP_REST_URL_Details_Controller:: (17 methods):
  __construct()
  register_routes()
  get_item_schema()
  parse_url_details()
  permissions_check()
  get_remote_url()
  get_title()
  get_icon()
  get_description()
  get_image()
  prepare_metadata_for_output()
  build_cache_key_for_url()
  get_cache()
  set_cache()
  get_document_head()
  get_meta_with_content_elements()
  get_metadata_from_meta_element()


Class: WP_REST_URL_Details_Controller  - X-Ref

Controller which provides REST endpoint for retrieving information
from a remote site's HTML response.

__construct()   X-Ref
Constructs the controller.


register_routes()   X-Ref
Registers the necessary REST API routes.


get_item_schema()   X-Ref
Retrieves the item's schema, conforming to JSON Schema.

return: array Item schema data.

parse_url_details( $request )   X-Ref
Retrieves the contents of the title tag from the HTML response.

param: WP_REST_Request $request Full details about the request.
return: WP_REST_Response|WP_Error The parsed details as a response object. WP_Error if there are errors.

permissions_check()   X-Ref
Checks whether a given request has permission to read remote URLs.

return: true|WP_Error True if the request has permission, else WP_Error.

get_remote_url( $url )   X-Ref
Retrieves the document title from a remote URL.

param: string $url The website URL whose HTML to access.
return: string|WP_Error The HTTP response from the remote URL on success.

get_title( $html )   X-Ref
Parses the title tag contents from the provided HTML.

param: string $html The HTML from the remote website at URL.
return: string The title tag contents on success. Empty string if not found.

get_icon( $html, $url )   X-Ref
Parses the site icon from the provided HTML.

param: string $html The HTML from the remote website at URL.
param: string $url  The target website URL.
return: string The icon URI on success. Empty string if not found.

get_description( $meta_elements )   X-Ref
Parses the meta description from the provided HTML.

param: array $meta_elements {
return: string The meta description contents on success. Empty string if not found.

get_image( $meta_elements, $url )   X-Ref
Parses the Open Graph (OG) Image from the provided HTML.

See: https://ogp.me/.

param: array  $meta_elements {
param: string $url The target website URL.
return: string The OG image on success. Empty string if not found.

prepare_metadata_for_output( $metadata )   X-Ref
Prepares the metadata by:
- stripping all HTML tags and tag entities.
- converting non-tag entities into characters.

param: string $metadata The metadata content to prepare.
return: string The prepared metadata.

build_cache_key_for_url( $url )   X-Ref
Utility function to build cache key for a given URL.

param: string $url The URL for which to build a cache key.
return: string The cache key.

get_cache( $key )   X-Ref
Utility function to retrieve a value from the cache at a given key.

param: string $key The cache key.
return: mixed The value from the cache.

set_cache( $key, $data = '' )   X-Ref
Utility function to cache a given data set at a given cache key.

param: string $key  The cache key under which to store the value.
param: string $data The data to be stored at the given cache key.
return: bool True when transient set. False if not set.

get_document_head( $html )   X-Ref
Retrieves the head element section.

param: string $html The string of HTML to parse.
return: string The `<head>..</head>` section on success. Given `$html` if not found.

get_meta_with_content_elements( $html )   X-Ref
Gets all the meta tag elements that have a 'content' attribute.

param: string $html The string of HTML to be parsed.
return: array {

get_metadata_from_meta_element( $meta_elements, $attr, $attr_value )   X-Ref
Gets the metadata from a target meta element.

param: array  $meta_elements {
param: string $attr       Attribute that identifies the element with the target metadata.
param: string $attr_value The attribute's value that identifies the element with the target metadata.
return: string The metadata on success. Empty string if not found.



Generated : Tue Dec 24 08:20:01 2024 Cross-referenced by PHPXref