代码:
function wp_embed_handler_tudou( $matches, $attr, $url, $rawattr ) {
// If the user supplied a fixed width AND height, use it
if ( !empty($rawattr['width']) && !empty($rawattr['height']) ) {
$width = (int) $rawattr['width'];
$height = (int) $rawattr['height'];
} else {
list( $width, $height ) = wp_expand_dimensions( 420, 363, $attr['width'], $attr['height'] );
}
return apply_filters( 'embed_tudou', '<object width="' . esc_attr($width) . '" height="' . esc_attr($height) . '"><param name="movie" value="http://www.tudou.com/v/' . esc_attr($matches[1]) . '"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><param name="wmode" value="opaque"></param><embed src="http://www.tudou.com/v/' . esc_attr($matches[1]) . '" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="' . esc_attr($width) . '" height="' . esc_attr($height) . '"></embed></object>', $matches, $attr, $url, $rawattr );
}
wp_embed_register_handler( 'tudou', '#http://www.tudou.com/programs/view/(.*?)/#i', 'wp_embed_handler_tudou' );
使用方法:
在写日志的时候直接输入土豆视频的地址:
如:
http://www.tudou.com/programs/view/XXXXXXX/
或者
[embed]http://www.tudou.com/programs/view/XXXXXXX/[/embed]
其中 XXXXXXX 是视频的 ID
