WordPress免插件集成ckplayer播放器,首先在ckplayer官網(wǎng)下載資源包,將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 '<p id="ckplayer-video-'.$nonce.'" class="ckplayer-video" style="margin-bottom:30px;"></p> <script type="text/javascript"> var videoObject'.$nonce.' = { container:"#ckplayer-video-'.$nonce.'", variable:"player", autoplay:false, video:"'.$content.'" }; var player=new ckplayer(videoObject'.$nonce.'); </script>';}
然后在發(fā)布文章時(shí)在內(nèi)容框里插入短代碼 [ckplayer]視頻url地址[/ckplayer] 即可。至于視頻的樣式可以通過(guò)js來(lái)自動(dòng)調(diào)整長(zhǎng)寬比例。
版權(quán)聲明: 本站資源均來(lái)自互聯(lián)網(wǎng)或會(huì)員發(fā)布,如果侵犯了您的權(quán)益請(qǐng)與我們聯(lián)系,我們將在24小時(shí)內(nèi)刪除!謝謝!
轉(zhuǎn)載請(qǐng)注明: WordPress集成ckplayer播放器教程