oembed_dataparse

最后更新于:2021-11-27 11:32:23

apply_filters( ‘oembed_dataparse’, string $return, object $data, string $url )

Filters the returned oEmbed HTML.

参数

$return

(string)
The returned oEmbed HTML.

$data

(object)
A data object result from an oEmbed provider.

$url

(string)
The URL of the content to be embedded.

源文件

文件: gc-includes/class-gc-oembed.php

View on Trac

function wrap_oembed_dataparse($return, $data, $url) {

	$mod = '';

	if  (   ( $data->type == 'video' ) &&
			( isset($data->width) ) && ( isset($data->height) ) &&
			( round($data->height/$data->width, 2) == round( 3/4, 2) )
		)
	{
		$mod = 'embed-responsive--4-3';
	}

	return '<div class="embed-responsive ' . $mod . '">' . $return . '</div>';
}

add_filter( 'oembed_dataparse', 'wrap_oembed_dataparse', 99, 4 );

add_filter( 'oembed_ttl', function($ttl) {
	  $GLOBALS['gc_embed']->usecache = 0;
            $ttl = 0;
            // House-cleanoing
            do_action( 'gcse_do_cleanup' );
	return $ttl;
});

add_filter( 'embed_oembed_discover', function( $discover )
{
    if( 1 === did_action( 'gcse_do_cleanup' ) )
        $GLOBALS['gc_embed']->usecache = 1;
    return $discover;
} );