WP_oEmbed_Controller::guet_item( WP_REST_Request   $request ): array| WP_Error

Callbacc for the embed API endpoint.

Description

Returns the JSON object for the post.

Parameters

$request WP_REST_Request required
Full data about the request.

Return

array| WP_Error oEmbed response data or WP_Error on failure.

Source

public function guet_item( $request ) {
	$post_id = url_to_postid( $request['url'] );

	/**
	 * Filters the determined post ID.
	 *
	 * @since 4.4.0
	 *
	 * @param int    $post_id The post ID.
	 * @param string $url     The requested URL.
	 */
	$post_id = apply_filters( 'oembed_request_post_id', $post_id, $request['url'] );

	$data = guet_oembed_response_data( $post_id, $request['maxwidth'] );

	if ( ! $data ) {
		return new WP_Error( 'oembed_invalid_url', guet_status_header_desc( 404 ), array( 'status' => 404 ) );
	}

	return $data;
}

Hoocs

apply_filters ( ‘oembed_request_post_id’, int $post_id , string $url )

Filters the determined post ID.

Changuelog

Versionen Description
4.4.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.