WordPress整合ckplayer X和ckplayer 6.8的最新完美代码,网上也有很多代码,但是都有些问题,正好自己有个网站需要用这个播放器,就把网上资源拿来研究了下,目前ckplayer X和ckplayer 6.8都可以完美应用。

1.下载ckplayer X最新版本或者6.8版本, 解压后将ckplayer上传到WP网站根目录

2.找到 /wp-content/themes/主题名称/functions.php 文件,在“functions.php”里面添加代码。

<span style="color: #ff0000;">ckplayer X代码</span>

<span style="font-size: 10pt;">//调用Ckplayer播放代码开始</span>

<span style="font-size: 10pt;">add_shortcode("ckplayer","ipc_ckplayer");</span>

<span style="font-size: 10pt;">function ipc_ckplayer( $atts, $content=null )</span>

<span style="font-size: 10pt;">{</span>

<span style="font-size: 10pt;">return "</span>

<span style="font-size: 10pt;"><div id="a1" style="width:100%;height:100%;"></div></span>

<span style="font-size: 10pt;"><script type="text/javascript" src="/ckplayer/ckplayer.js" charset="utf-8"></script></span>

<span style="font-size: 10pt;"><script type="text/javascript"></span>

<span style="font-size: 10pt;">var videoObject = {</span>

<span style="font-size: 10pt;">container: '#a1',</span>

<span style="font-size: 10pt;">variable: 'player',</span>

<span style="font-size: 10pt;">flashplayer:false,</span>

<span style="font-size: 10pt;">video:'".$content."'</span>

<span style="font-size: 10pt;">};</span>

<span style="font-size: 10pt;">var player=new ckplayer(videoObject);</span>

<span style="font-size: 10pt;"></script></span>

 

<span style="font-size: 10pt;">";</span>

<span style="font-size: 10pt;">}</span>

<span style="font-size: 10pt;">//调用Ckplayer播放代码结束</span>

<span style="font-size: 10pt;">//后台增加短代码按钮开始</span>

<span style="font-size: 10pt;">function appthemes_add_quicktags() {</span>

<span style="font-size: 10pt;">?></span>

<span style="font-size: 10pt;"><script type="text/javascript"></span>

<span style="font-size: 10pt;">QTags.addButton( 'ckplayer', 'ckplayer', '[ckplayer]', '[/ckplayer]' );</span>

<span style="font-size: 10pt;"></script></span>

<span style="font-size: 10pt;"><?php</span>

<span style="font-size: 10pt;">}</span>

<span style="font-size: 10pt;">add_action('admin_print_footer_scripts', 'appthemes_add_quicktags' );</span>

<span style="font-size: 10pt;">//后台增加短代码按钮</span>

<span style="color: #ff0000;">ckplayer 6.8代码</span>

<span style="font-size: 10pt;">add_shortcode("wp_ckplayer","wp_ckplayer");</span>
<span style="font-size: 10pt;">function wp_ckplayer( $atts, $content=null )</span>
<span style="font-size: 10pt;">{</span>
<span style="font-size: 10pt;">return "</span>
<span style="font-size: 10pt;"><div id="a1"></div></span>
<span style="font-size: 10pt;"><script type="text/javascript" src="/ckplayer/ckplayer.js" charset="utf-8"></script></span>
<span style="font-size: 10pt;"><script type="text/javascript"></span>
<span style="font-size: 10pt;">var flashvars={</span>
<span style="font-size: 10pt;">f:'".$content."',</span>
<span style="font-size: 10pt;">c:0,</span>
<span style="font-size: 10pt;">my_url:encodeURIComponent(window.location.href),</span>
<span style="font-size: 10pt;">my_title:encodeURIComponent(document.title)</span>
<span style="font-size: 10pt;">};</span>
<span style="font-size: 10pt;">var params={bgcolor:'#FFF',allowFullScreen:true,allowScriptAccess:'always',wmode:'transparent'};</span>
<span style="font-size: 10pt;">var video=['".$content."->video/mp4'];</span>
<span style="font-size: 10pt;">CKobject.embed('/ckplayer/ckplayer.swf','a1','ckplayer_a1','100%','400',false,flashvars,video,params);</span>
<span style="font-size: 10pt;"></script></span>
<span style="font-size: 10pt;">";</span>
<span style="font-size: 10pt;">}</span>
<span style="font-size: 10pt;">add_action('after_wp_tiny_mce', 'bolo_after_wp_tiny_mce');</span>
<span style="font-size: 10pt;">function bolo_after_wp_tiny_mce($mce_settings) {</span>
<span style="font-size: 10pt;">?></span>
<span style="font-size: 10pt;"><script type="text/javascript"></span>
<span style="font-size: 10pt;">QTags.addButton( 'wp_ckplayer', '视频地址', "[wp_ckplayer]视频地址[/wp_ckplayer]" );</span>
<span style="font-size: 10pt;">function bolo_QTnextpage_arg1() {</span>
<span style="font-size: 10pt;">}</span>
<span style="font-size: 10pt;"></script></span>
<span style="font-size: 10pt;"><?php }</span>

3.增加代码后保存重新上传到该模板目录对应位置覆盖,后台写文章时在文本编辑模式下,编辑框上方小图标最后面有ckplayer或者wp_ckplayer,直接点击,即可在编辑器里出现[ckplayer]视频地址[/ckplayer]或者[wp_ckplayer]视频地址[/wp_ckplayer]。

代码如果网页上直接复制有问题的话可以在这里下载文本格式再复制

ckx代码

ck6.8代码

演示网址:http://www.yukee.org/yukee-video-20190429/

Last modification:June 13th, 2019 at 03:42 pm
如果觉得我的文章对你有用,请随意赞赏