WordPress免插件集成CKPlayer播放器,首先在ckplayer官网下载资源包,将ckplayer文件夹放入所使用主题里(确保wp-content/themes/motheme/ckplayer/ckplayer.js存在),然后添加代码如下!
在主题的functions.php添加以下代码:
function MBThemes_ckplayer_scripts() {wp_enqueue_script( 'ckplayer', get_bloginfo('template_url') . '/ckplayer/ckplayer.js', false, '', false);}add_action('wp_enqueue_scripts', 'MBThemes_ckplayer_scripts');add_shortcode("ckplayer","MBThemes_ckplayer_shortcode");function MBThemes_ckplayer_shortcode( $atts, $content=null ){$nonce = wp_create_nonce(rand(10,1000));return '<div id="ckplayer-video-'.$nonce.'" class="ckplayer-video" style="margin-bottom:30px;"></div> <script type="text/javascript"> var videoObject'.$nonce.' = { container:"#ckplayer-video-'.$nonce.'", variable:"player", autoplay:false, video:"'.$content.'" }; var player=new ckplayer(videoObject'.$nonce.'); </script>';}然后在发布文章时在内容框里插入短代码 [ckplayer]视频url地址[/ckplayer] 即可。至于视频的样式可以通过js来自动调整长宽比例。