File: /home/bt667/public_html/wp-content/plugins/wp_mvplayer/settings/manage_playlist.php
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if( isset($_GET['delete'] ) && ($_GET['delete']=='success'))
echo '<div class="updated"><p><strong>'.__('Playlist(s) Deleted Successfully','mvp' ).'</strong></p></div>';
if( !class_exists( 'WP_List_Table' ) ){
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
class playlist_List_Table extends WP_List_Table{
function __construct(){
global $status, $page;
parent::__construct( array('items',));
}
function column_default($item, $column_name){
switch($column_name){
case 'Playlist_Id':
echo
'<div class="clipboard">
<input onclick="copyvideocode'.$item['id'].'()" class="copy-input" value="[MVP_playlist Playlist_Id='.$item['Playlist_Id'].']" id="copyClipboardVideo'.$item['id'].'" readonly>
<button class="copyButton" id="copyButton'.$item['id'].'">'.__('Copy','mvp').'</button>
</div>
<div id="copied-success" class="copied">
<span>'.__('Copied!','mvp').'</span>
</div>
<script>
jQuery("document").ready(function(){
var copied = "'.__( 'Copied', 'mvp' ).'";
jQuery("#copyButton'.$item['id'].'").on("click",function(e){
e.preventDefault();
copyvideocode'.$item['id'].'();
jQuery("#copyButton'.$item['id'].'").text(copied);
});
});
</script>
<script>
function copyvideocode'.$item['id'].'() {
var copyText = document.getElementById("copyClipboardVideo'.$item['id'].'");
copyText.select();
copyText.setSelectionRange(0, 99999);
document.execCommand("copy");
jQuery("#copied-success").fadeIn(800);
jQuery("#copied-success").fadeOut(800);
}
</script>';
break;
case 'Title':
case 'Video':
if(isset($item['Video'])){
$videos = json_decode($item['Video']);
if(!empty($videos)){
foreach($videos as $video){
if($video->video_source=='youtube_video'){
echo $video->filename2.'<br/>';
}elseif($video->video_source=='mp4_video'){
echo $video->filename.'<br/>';
}elseif($video->video_source=='vimeo_video'){
echo $video->filename3.'<br/>';
}
}
}
}
break;
case 'SocialEnable':
case 'OptinBox':
return $item[$column_name];
case 'VideoSource':
if($item['VideoSource']=='mp4_video'){return 'mp4';}
if($item['VideoSource']=='youtube_video'){return 'youtube';}
if($item['VideoSource']=='vimeo_video'){return 'vimeo';}
case 'PlayerSkin':
if(($item['PlayerSkin']=='none') || ($item['PlayerSkin']=='')){ return "<img src='".MV_PLAYER_URL."/image/none.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin1'){ return "<img src='".MV_PLAYER_URL."/image/skin6/skin6.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin2'){ return "<img src='".MV_PLAYER_URL."/image/skin3/skin3.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin3'){ return "<img src='".MV_PLAYER_URL."/image/skin15/skin15.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin4'){ return "<img src='".MV_PLAYER_URL."/image/skin1/skin1.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin5'){ return "<img src='".MV_PLAYER_URL."/image/skin23/skin23.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin6'){ return "<img src='".MV_PLAYER_URL."/image/newskin1/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin7'){ return "<img src='".MV_PLAYER_URL."/image/newskin2/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin8'){ return "<img src='".MV_PLAYER_URL."/image/newskin3/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin9'){ return "<img src='".MV_PLAYER_URL."/image/newskin4/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin10'){ return "<img src='".MV_PLAYER_URL."/image/newskin5/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin11'){ return "<img src='".MV_PLAYER_URL."/image/newskin6/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin12'){ return "<img src='".MV_PLAYER_URL."/image/newskin7/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin13'){ return "<img src='".MV_PLAYER_URL."/image/newskin8/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin14'){ return "<img src='".MV_PLAYER_URL."/image/newskin9/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin15'){ return "<img src='".MV_PLAYER_URL."/image/newskin10/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin16'){ return "<img src='".MV_PLAYER_URL."/image/newskin11/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin17'){ return "<img src='".MV_PLAYER_URL."/image/newskin12/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin18'){ return "<img src='".MV_PLAYER_URL."/image/newskin13/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin19'){ return "<img src='".MV_PLAYER_URL."/image/newskin14/demo.png' style='height:40px;width:40px;'>"; }
if($item['PlayerSkin']=='skin20'){ return "<img src='".MV_PLAYER_URL."/image/newskin15/demo.png' style='height:40px;width:40px;'>"; }
case 'ImageLogo':
if( !empty( $item['ImageLogo'] )){
return "<img src='" . $item['ImageLogo'] . "' style='height:30px;width:30px;' alt='".__( 'No Icon', 'mvp' )."'>";
}else{
return esc_html_e( 'Not Uploaded', 'mvp' );;
}
default:
case 'datetime':echo date('j-M-Y',strtotime($item['datetime']));
return false;
}
}
function column_Title($item){
$actions=array('edit'=>sprintf('<a href="?page=mv_player_add_playlist&view=update&Playlist_Id='.$item['Playlist_Id'].'">'.__('Edit','mvp').'</a>',$_REQUEST['page'],$item['Playlist_Id'],'edit'),
'delete' => sprintf('<a href="?page=%s&action=%s&Playlist_Id=%s">'.__('Delete','mvp').'</a>',$_REQUEST['page'],'delete',$item['Playlist_Id']),);
return sprintf('%1$s%3$s',$item['Title'],$item['Playlist_Id'],$this->row_actions($actions));
}
function column_cb($item){
return sprintf('<input type="checkbox" name="check[]" value="%1$s" />', $item['Playlist_Id'] );
}
function get_columns(){
$columns = array('cb'=>'<input type="checkbox"/>','Title'=> __('Title','mvp'),'Video'=>__('Video','mvp'),'VideoSource'=>__('Video Tpye','mvp'),'SocialEnable'=>__('Social Share','mvp'),'OptinBox'=>__('OptinBox','mvp'),'ImageLogo'=>__('Video Icon','mvp'),'PlayerSkin'=>__('PlayerSkin','mvp'),'Playlist_Id'=>__('Short Code','mvp'));
return $columns;
}
function get_sortable_columns(){
$sortable_columns = array('Title'=> array(__('Title','mvp'),false),
'Video' => array(__('Video','mvp'),false),
'VideoSource'=> array(__('VideoSource','mvp'),false),
'SocialEnable'=> array(__('SocialEnable','mvp'),false),
'OptinBox'=> array(__('OptinBox','mvp'),false),
'ImageLogo'=> array(__('ImageLogo','mvp'),false),
'PlayerSkin' => array(__('PlayerSkin','mvp'),false),
);
return $sortable_columns;
}
function get_bulk_actions(){
$actions = array('trash' => __('Trash','mvp'));
return $actions;
}
function process_bulk_action(){
global $wpdb;
$playlist_table = $wpdb->base_prefix . 'playlist_video';
$videobuttons_table = $wpdb->base_prefix . 'mvplayer_videobuttons';
if( 'delete'===$this->current_action() ){
if( isset($_REQUEST['Playlist_Id'])){
$Playlist_Id = $_REQUEST['Playlist_Id'];
$screen = get_current_screen();
$query = "delete FROM $playlist_table where Playlist_Id=$Playlist_Id ";
$wpdb->query($query);
$query2 = "delete FROM $videobuttons_table where VideoId=$Playlist_Id ";
$wpdb->query($query2);
wp_mvplayer_redirect("?page=mv_player_manage_playlist&delete=success");
}else{
wp_mvplayer_redirect("?page=mv_player_manage_playlist");
}
}
if(isset($check)){
if( 'trash'===$this->current_action() ){
foreach($check as $trashid){
$query = "delete FROM $playlist_table where Playlist_Id=$trashid ";
$wpdb->query($query);
$query2 = "delete FROM $videobuttons_table where VideoId=$Playlist_Id ";
$wpdb->query($query2);
}
wp_mvplayer_redirect("?page=mv_player_manage_playlist&delete=success");
}
}
}
function prepare_items(){
global $wpdb;
$per_page =20;
$screen = get_current_screen();
$playlist_table = $wpdb->base_prefix . 'playlist_video';
$query = "SELECT * FROM $playlist_table WHERE id IN ( SELECT min(id) FROM $playlist_table GROUP BY Playlist_Id )";
if(!empty($_REQUEST['s'])){
$query .= " AND Title LIKE '%".$_REQUEST['s']."%'";
}
$query .= " order by id desc";
$example_data = $wpdb->get_results($query, ARRAY_A);
$columns = $this->get_columns();
$hidden = array();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->process_bulk_action();
$tdata = array();
if(isset($item)){
foreach($example_data as $k){
$actions = $this->column_Title($item);
$tdata[]=array();
echo $k->Title;
}
}
if(isset($actions) && isset($k)){
$data=array( $k, $actions );
}
$data = $example_data;
if(isset($_REQUEST['orderby'])){
function usort_reorder($a,$b){
$orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'date';
$order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'desc';
$result = strcmp($a[$orderby], $b[$orderby]);
return ($order==='asc') ? $result : -$result;
}
usort($data, 'usort_reorder');
}
$current_page = $this->get_pagenum();
$total_items = count($data);
$data = array_slice($data,(($current_page-1)*$per_page),$per_page);
$this->items = $data;
$this->set_pagination_args(array('total_items'=>$total_items,'per_page'=> $per_page,
'total_pages'=>ceil($total_items/$per_page)) );
}
}
?>
<div class="wrap">
<div id="icon-edit" class="icon32"><br/></div>
<h2><?php echo __('Manage Playlist','mvp'); ?><a href="?page=mv_player_add_playlist" class="add-new-h2"><?php echo __('Add New','mvp'); ?></a></h2>
<form id="movies-filter" method="post">
<input type="hidden" name="page" value="<?php echo $_REQUEST['page'] ?>" />
<?php
$testListTable = new playlist_List_Table();
$testListTable->prepare_items();
$testListTable->search_box(__('Search','mvp'),'Title');
?>
<div><?php $testListTable->display(); ?></div>
</form>
</div>