在函数中。php i使用此更改youtube的宽度url:
add_action(\'save_post\', \'set_url_youtube\');
function set_url_youtube() {
$post = get_post($post_id);
$content = $post->post_content;
preg_match_all(\'#(http://www.youtube.com)?/(v/([-|~_0-9A-Za-z]+)|watch\\?v\\=([-|~_0-9A-Za-z]+)&?.*?)#i\', $content, $urls, PREG_SET_ORDER);
if(is_array($urls)) {
foreach ($urls as $url)
$videos_url[] = $url[0];
}
if (is_array($videos_url)) {
$videos_url = array_unique($videos_url);
rsort($videos_url);
}
if($videos_url) {
foreach ($videos_url as $video_url) {
$content = str_replace($video_url, $video_url.\'&w=550\', $content);
}
remove_action( \'save_post\', \'set_url_youtube\' );
wp_update_post( array(\'ID\' => $post_id, \'post_content\' => $content) );
add_action( \'save_post\', \'set_url_youtube\' );
}
}
?>
但当save post为时,url
http://www.youtube.com/watch?v=KTRPVo0d90w
不更改为
http://www.youtube.com/watch?v=KTRPVo0d90w&w=550
如何修复它?