
为WordPress添加ckplayer播放器而无需插件


首先在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播放器手机版,您可以使用js自动调整宽高比.

集成后的手机演示屏幕截图如下: 
Ckplayer播放器(2)
本文来自电脑杂谈,转载请注明本文网址:
https://www.pc-fly.com/a/bofangqi/article-146610-1.html
打个比方
它仍然会嬉皮笑脸的试探
舍