Testing this with the Embed Gutenberg Block. In the backend it actually shows the video so this seems wrong that it behaves differently there.
Registering embed handlers causes the to take priority over the (default) WordPress oEmebed handlers even when priority is set to PHP_INT_MAX
. I like to trigger them after the oembed handlers in case they fail. How can I do this?
This code is inside a mu-plugin, but I have more complicated code in my main plugin that has the same issue.
<?php
namespace Nextgenthemes\Debug;
disable_oembed_cache();
add_action( 'init', function() {
wp_embed_register_handler(
'arve_dailymotion',
'#https?://(www\.)?(dai\.ly|dailymotion\/video)/(?<id>[a-z0-9]+)#i',
__NAMESPACE__ . '\dailymotion_embed_handler',
PHP_INT_MAX
);
} );
function dailymotion_embed_handler( array $matches, array $attr, $url, array $rawattr ) {
return print_r( $matches );
}
function disable_oembed_cache() {
add_action( 'init', function() {
$GLOBALS['wpdb']->query( "DELETE FROM {$GLOBALS['wpdb']->postmeta} WHERE meta_key LIKE '%_oembed_%'" );
} );
add_action( 'template_redirect', function() {
$GLOBALS['wpdb']->query( "DELETE FROM {$GLOBALS['wpdb']->postmeta} WHERE meta_key LIKE '%_oembed_%'" );
$GLOBALS['wp_embed']->cache_oembed( get_queried_object_id() );
} );
add_filter( 'oembed_ttl', function( $ttl ) {
return 1;
} );
}
Sidenote: In my local testing with the Dailymotion oEmbed I get it to work only every 2nd/3rd time or so. Maybe because I deactivate the cache but its not happening for YouTube.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745192688a4615939.html
评论列表(0条)