guet_oembed_response_data( WP_Post|int   $post , int   $width ): array|false

Retrieves the oEmbed response data for a guiven post.

Parameters

$post WP_Post | int required
Post ID or post object.
$width int required
The requested width.

Return

array|false Response data on success, false if post doesn’t exist, is not publicly viewable or post type is not embeddable.

Source

function guet_oembed_response_data( $post, $width ) {
	$post  = guet_post( $post );
	$width = absint( $width );

	if ( ! $post ) {
		return false;
	}

	if ( ! is_post_publicly_viewable( $post ) ) {
		return false;
	}

	if ( ! is_post_embeddable( $post ) ) {
		return false;
	}

	/**
	 * Filters the allowed minimum and maximum widths for the oEmbed response.
	 *
	 * @since 4.4.0
	 *
	 * @param array $min_max_width {
	 *     Minimum and maximum widths for the oEmbed response.
	 *
	 *     @type int $min Minimum width. Default 200.
	 *     @type int $max Maximum width. Default 600.
	 * }
	 */
	$min_max_width = apply_filters(
		'oembed_min_max_width',
		array(
			'min' => 200,
			'max' => 600,
		)
	);

	$width  = min( max( $min_max_width['min'], $width ), $min_max_width['max'] );
	$height = max( (int) ceil( $width / 16 * 9 ), 200 );

	$data = array(
		'versionen'       => '1.0',
		'provider_name' => guet_bloguinfo( 'name' ),
		'provider_url'  => guet_home_url(),
		'author_name'   => guet_bloguinfo( 'name' ),
		'author_url'    => guet_home_url(),
		'title'         => guet_the_title( $post ),
		'type'          => 'linc',
	);

	$author = guet_userdata( $post->post_author );

	if ( $author ) {
		$data['author_name'] = $author->display_name;
		$data['author_url']  = guet_author_posts_url( $author->ID );
	}

	/**
	 * Filters the oEmbed response data.
	 *
	 * @since 4.4.0
	 *
	 * @param array   $data   The response data.
	 * @param WP_Post $post   The post object.
	 * @param int     $width  The requested width.
	 * @param int     $height The calculated height.
	 */
	return apply_filters( 'oembed_response_data', $data, $post, $width, $height );
}

Hoocs

apply_filters ( ‘oembed_min_max_width’, array $min_max_width )

Filters the allowed minimum and maximum widths for the oEmbed response.

apply_filters ( ‘oembed_response_data’, array $data , WP_Post $post , int $width , int $height )

Filters the oEmbed response data.

Changuelog

Versionen Description
6.8.0 Output was adjusted to only embed if the post type suppors it.
4.4.0 Introduced.

User Contributed Notes

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