// Include the necessary admin stuff.
require_once '../../../../wp-load.php';
require_once '../../../../wp-admin/includes/admin.php';
if (!current_user_can('administrator') && !current_user_can('editor') && !current_user_can('contributor')) {
    exit;
}
//global $wp_version;
define('MEDIA_MANAGER_35', version_compare($wp_version, '3.5', '>='));
require_once JWP6_PLUGIN_DIR . '/jwp6-class-plugin.php';
require_once JWP6_PLUGIN_DIR . '/jwp6-class-media.php';
require_once JWP6_PLUGIN_DIR . '/jwp6-class-shortcode.php';
$jwp6m = new JWP6_Media();
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if ($_POST[JWP6 . 'mediaid'] || $_POST[JWP6 . 'file'] || $_POST[JWP6 . 'playlistid']) {
        $shortcode = new JWP6_Shortcode();
        media_send_to_editor($shortcode->shortcode());
        exit;
    } else {
        $no_video_error = true;
    }
}
?>
<!DOCTYPE html>
<html>

<head>
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    <link rel="stylesheet" href="<?php 
echo JWP6_PLUGIN_URL;
?>
/css/jquery.select2.css" type="text/css" media="screen" />
 public static function media_send_to_editor($html, $send_id, $attachment)
 {
     if (isset($_POST['attachment']) && isset($_POST['action']) && $_POST['action'] == 'send-attachment-to-editor' && isset($_POST['attachment'][JWP6 . 'insert_jwplayer'])) {
         $shortcode = new JWP6_Shortcode(null, $_POST['attachment']);
     } else {
         if (isset($_POST['send'][$send_id]) && isset($_POST['attachments'][$send_id][JWP6 . 'insert_with_player'])) {
             $player_name = $_POST['attachments'][$send_id][JWP6 . 'insert_with_player'] ? $_POST['attachments'][$send_id][JWP6 . 'insert_with_player'] : 0;
             $shortcode = new JWP6_Shortcode(null, array('player_name' => $player_name, 'mediaid' => $send_id));
         }
     }
     if (isset($shortcode)) {
         return $shortcode->shortcode();
     }
     return $html;
 }