<?php
/*
Plugin Name:极酷阳光V3.5视频插件
Plugin URI: http://v3.cuplayer.com/help/Help515.html
Description: 极酷阳光Wordpress视频插件/支持PC,安卓,苹果终端/基于极酷阳光网页视频播放器V3.5/简单实用就是这么任性
Version: 3.5 
Author: ocean
Author URI:  http://www.CuPlayer.com/
*/

function CK_Video_addbuttons() {
	// Add only in Rich Editor mode
	if ( get_user_option('rich_editing') == 'true') {
	// add the button for wp25 in a new way
		add_filter("mce_external_plugins", "add_cuvideo_tinymce_plugin", 5);
		add_filter('mce_buttons', 'register_cuvideo_button', 5);
	}
}

// Load the TinyMCE plugin : editor_plugin.js (wp2.5)
function add_cuvideo_tinymce_plugin($plugin_array) {
	$plugin_array['cuvideo'] = plugins_url('',__FILE__).'/editor_plugin.js';	
	return $plugin_array;
}
// used to insert button in wordpress 2.5x editor
function register_cuvideo_button($buttons) {
	array_push($buttons, "separator", "cuvideo");
	return $buttons;
}

add_action('init', 'CK_Video_addbuttons');

//视频   
    function CK_Video($atts, $content=null){
    $neturl = get_option('siteurl');	
    extract(shortcode_atts(array(   
    "vtype" => '视频源',   
          "url" => '视频ID',   
          "auto" => '0', 
          "width" => '610', 
          "height" => '460', 
		   "images" => 'imagesurl'
    ), $atts));  
	 ////vWidth,vHeight,vFile,vPlayer,vMp4url,vPic,vID
	$randomid = 'cuplayer'.rand(1,20);
         return '<div id="'.$randomid.'" style="background:#000000;">loading...</div><script class="CuPlayerVideo" data-mce-role="CuPlayerVideo" type="text/javascript" src="/wp-content/plugins/playerV35/CuSunCross.js"></script><script type="text/javascript" >setCuSunPlayerVideo("'.$width.'","'.$height.'","/wp-content/plugins/playerV35/player/CuSunV3set.xml","/wp-content/plugins/playerV35/player/player.swf?JcScpAutoPlay='.$auto.'","'.$url.'","'.$images.'","'.$randomid.'");</script>';}
    add_shortcode('cuvideo','CK_Video');   
    function CK_Video_Next($atts, $content=null){
    $neturl = get_option('siteurl');	
    extract(shortcode_atts(array(   
    "vtype" => '视频源',   
          "url" => '视频ID',   
          "auto" => '0', 
    ), $atts));   
         return '<a href="'.$neturl.'/wp-content/plugins/ck-video/ck/?content='. $content .'&auto='.$auto.'&url='.$url.'" target="video">'. $content .'</a>' ;       
       }   
    add_shortcode('cuvideonext','CK_Video_Next'); 	
?>