默认情况下,通过运行内容the_content
过滤器会自动检查oEmbed内容。但是,当通过返回数据时heartbeat_received
oEmbed的过滤器似乎不起作用。
例如-
function test_heartbeat_received( $response, $data ) {
if( $data[\'test_heartbeat\'] == \'test\' ) {
$content = "https://twitter.com/WordPress/status/456502643738030080";
// Doesn\'t work
global $wp_embed;
$content = $wp_embed->autoembed( $content );
$response[\'test_heartbeat\'] = $content;
// Also doesn\'t work
$response[\'test_heartbeat\'] = apply_filters( \'the_content\', $content );
}
return $response;
}
add_filter( \'heartbeat_received\', \'test_heartbeat_received\', 10, 2 );
add_filter( \'heartbeat_nopriv_received\', \'test_heartbeat_received\', 10, 2 );
在不使用心跳的情况下进行完全相同的操作似乎是可行的。正在应用内容筛选器,因为格式存在,只是没有oEmbed。有什么建议吗?
谢谢