Fatal error: Cannot redeclare wp_embed_handler_youku() in /home/makiller/public_html/wp-content/themes/loper/functions/shortcode.php on line 44 出现错误的原因是从WordPress3.4版本起WP中文团队修改了视频嵌入方式,默认支持对Youku和Tudou视频的嵌入;而此前一些wp主题短代码的视频嵌入方式与此相同,故而引起冲突,升级后出现错误。现给出解决方法,此方法适用于所有升级到wp3.4版本的主题。 1、在你的FTP中找到wp-content\languages\里的zh_CN.php文件,下载并且打开它。 2、搜索以下内容: function wp_embed_handler_youku( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<embed src="http://player.youku.com/player.php/sid/%1$s/v.swf" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>', esc_attr( $matches['video_id'] ) ); return apply_filters( 'embed_youku', $embed, $matches, $attr, $url, $rawattr ); } wp_embed_register_handler( 'youku', '#https?://v\.youku\.com/v_show/id_(?<video_id>[a-z0-9_=\-]+)#i', 'wp_embed_handler_youku' ); 3、将刚才找到的内容替换为: /*function wp_embed_handler_youku( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<embed src="http://player.youku.com/player.php/sid/%1$s/v.swf" allowFullScreen="true" quality="high" width="480" height="400" align="middle" allowScriptAccess="always" type="application/x-shockwave-flash"></embed>', esc_attr( $matches['video_id'] ) ); return apply_filters( 'embed_youku', $embed, $matches, $attr, $url, $rawattr ); } wp_embed_register_handler( 'youku', '#https?://v\.youku\.com/v_show/id_(?<video_id>[a-z0-9_=\-]+)#i', 'wp_embed_handler_youku' );*/ 4、搜索以下内容: function wp_embed_handler_tudou( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<embed src="http://www.tudou.com/v/%1$s/&resourceId=0_05_05_99&bid=05/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed>', esc_attr( $matches['video_id'] ) ); return apply_filters( 'embed_tudou', $embed, $matches, $attr, $url, $rawattr ); } wp_embed_register_handler( 'tudou', '#https?://(?:www\.)?tudou\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\-]+))/(?<video_id>[a-z0-9_=\-]+)#i', 'wp_embed_handler_tudou' ); 5、替换为: /*function wp_embed_handler_tudou( $matches, $attr, $url, $rawattr ) { $embed = sprintf( '<embed src="http://www.tudou.com/v/%1$s/&resourceId=0_05_05_99&bid=05/v.swf" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="480" height="400"></embed>', esc_attr( $matches['video_id'] ) ); return apply_filters( 'embed_tudou', $embed, $matches, $attr, $url, $rawattr ); } wp_embed_register_handler( 'tudou', '#https?://(?:www\.)?tudou\.com/(?:programs/view|listplay/(?<list_id>[a-z0-9_=\-]+))/(?<video_id>[a-z0-9_=\-]+)#i', 'wp_embed_handler_tudou' );*/ 6、保存文件,并且使用FTP将其上传到wp-content\languages\中。覆盖相同的文件。 以上过程是注释掉了WP中文版本自带的嵌入功能,而使用主题自带的嵌入视频功能。如果以后你更换主题,而新的主题并没有自带的嵌入方式, 可你仍想保留视频的显示,那么还原以上操作即可。 |
|
来自: blackgold > 《Wordpress》