public function __construct() { global $wp_version; $this->previous_version = get_option(JWP6 . 'previous_version'); // if ( version_compare($wp_version, '3.5', '<') ) add_action('media_buttons', array($this, 'media_button'), 99); add_action("init", array($this, 'enqueue_scripts_and_styles')); add_action('admin_menu', array($this, 'admin_menu')); JWP6_Media::actions_and_filters(); }
/** * Renders the form for inserting URL files into the Media Library. * @global string $redir_tab The tab to redirect to on form submits. * @global string $type The type of media being considered. * @param undefined $errors Any errors the occurred. */ function jwp6_media_external_tab($errors) { global $redir_tab, $type, $wp_version; //$redir_tab, $type; $redir_tab = "jwp6_media_external"; define('MEDIA_MANAGER_35', version_compare($wp_version, '3.5', '>=')); if (!MEDIA_MANAGER_35) { media_upload_header(); } $post_id = intval($_REQUEST['post_id']); $form_action_url = admin_url("media-upload.php?type={$type}&tab=" . JWP6 . "media_external&post_id={$post_id}"); $form_action_url = apply_filters('media_upload_form_url', $form_action_url, $type); if (isset($_POST["insertonlybutton"])) { $youtube_pattern = "/youtube.com\\/watch\\?v=([0-9a-zA-Z_-]*)/i"; $url = $_POST["insertonly"]["href"]; $attachment = array("post_mime_type" => "video/mp4", "guid" => $url, "post_parent" => $post_id); if (preg_match($youtube_pattern, $url, $match)) { $youtube_api = JWP6_Media::get_youtube_meta_data($match[1]); if ($youtube_api) { $attachment["post_title"] = $youtube_api["title"]; $attachment["post_content"] = $youtube_api["description"]; } } else { $file_info = wp_check_filetype($url); if ($file_info["type"] != null) { $attachment["post_mime_type"] = $file_info["type"]; $attachment["post_content"] = ""; $attachment["post_title"] = ""; } } $id = wp_insert_attachment($attachment, $url, $post_id); if (isset($youtube_api) && $youtube_api) { update_post_meta($id, LONGTAIL_KEY . "thumbnail", $youtube_api["thumbnail_url"]); } else { if (strstr($url, "rtmp://")) { // update_post_meta($id, LONGTAIL_KEY . "streamer", str_replace(basename($url), "", $url)); // update_post_meta($id, LONGTAIL_KEY . "file", basename($url)); // update_post_meta($id, LONGTAIL_KEY . "rtmp", true); update_post_meta($id, LONGTAIL_KEY . "rtmp", $url); } } update_post_meta($id, LONGTAIL_KEY . "external", true); wp_update_attachment_metadata($id, wp_generate_attachment_metadata($id, $url)); } ?> <form enctype="multipart/form-data" class="jwp6-media-form <?php if (MEDIA_MANAGER_35) { echo "jwp6-media-35"; } ?> " method="post" action="<?php echo esc_attr($form_action_url); ?> " class="media-upload-form type-form validate" id="<?php echo $type; ?> -form"> <input type="submit" class="hidden" name="save" value="" /> <input type="hidden" name="post_id" id="post_id" value="<?php echo (int) $post_id; ?> " /> <?php wp_nonce_field('media-form'); ?> <?php if (!MEDIA_MANAGER_35) { ?> <h3 class="media-title">Add external media</h3> <?php } ?> <?php if (!$_POST) { ?> <p> Add external media to your library to embed it with the JW Player</p> <div id="url-upload-ui"> <table> <tbody> <tr> <th scope="row" class="label"> <span class="alignleft"><label for="insertonly[href]">Media URL</label></span> </th> <td class="field"><input id="insertonly[href]" name="insertonly[href]" value="" type="text" aria-required="true" style="width: 95%;" placeholder="Add the URL to your media here."></td> </tr> <tr> <th></th> <td class="description"> <p>The following types of external media are supported:</p> <ol> <li> MP4/FLV video (http://example.com/video.mp4) </li> <li> MP3/AAC Audio (http://example.com/audio.mp3) </li> <li> YouTube video (http://youtu.be/dQw4w9WgXcQ) </li> <li> MP4/FLV video (rtmp://example/com/vode/mp4:video.mp4) </li> </ol> </td> </tr> <tr> <td></td> <td> <input type="submit" class="button button-primary" name="insertonlybutton" value="Add to library" /> </td> </tr> </tbody> </table> </div> <?php } ?> <script type="text/javascript"> //<![CDATA[ jQuery(function($){ var preloaded = $(".media-item.preloaded"); if ( preloaded.length > 0 ) { preloaded.each(function(){prepareMediaItem({id:this.id.replace(/[^0-9]/g, '')},'');}); } updateMediaForm(); $('tr.url button, p.help').remove(); <?php if (MEDIA_MANAGER_35) { ?> jQuery('ul#sidemenu').css('display', 'none'); jQuery('a.describe-toggle-off').css('display', 'none'); <?php } ?> }); //]]> </script> <div id="media-items"> <?php if (isset($id)) { if (!is_wp_error($id)) { add_filter('attachment_fields_to_edit', 'media_post_single_attachment_fields_to_edit', 10, 2); echo get_media_items($id, $errors); } else { echo '<div id="media-upload-error">' . esc_html($id->get_error_message()) . '</div>'; exit; } } ?> </div> <p class="savebutton ml-submit"> <input type="submit" class="button" name="save" value="<?php esc_attr_e('Save all changes', 'jw-player-plugin-for-wordpress'); ?> " /> </p> </form> <?php }
<?php // 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;
public static function insert_player_html($post) { global $jwp6_global, $wp_version; $insert_with_player = isset($jwp6_global['insert_with_player']) ? $jwp6_global['insert_with_player'] : 0; $html = ""; $html .= "\n <select id='jwp6_insert_with_player' name='attachments[{$post->ID}][" . JWP6 . "insert_with_player]' style='width: 100%;'>\n "; foreach (get_option(JWP6 . 'players') as $player_id) { $selected = $insert_with_player == $player_id ? 'selected="selected"' : ''; $player = new JWP6_Player($player_id); $html .= "\n <option value='{$player_id}' {$selected}>{$player->full_description()}</option>\n "; } $html .= "\n </select>\n\n <p class='description'>Player template to use.</p>\n\n <div class='jwp6_hr'></div>\n "; if (isset($_GET["post_id"]) || version_compare($wp_version, '3.5', '<')) { $html .= "\n <input type='submit' class='button button-primary media-button' name='send[{$post->ID}]' value='Insert with JW Player' />\n "; } else { $html .= "\n <button class='insert_with_jwp6 button button-primary media-button'\n data-url='" . JWP6_PLUGIN_URL . "jwp6-media-embed.php'>\n Insert with JW Player\n </button>\n "; } $html .= JWP6_Media::insert_javascript_for_attachment_fields($post); return $html; }
function jwp6_media_embed_playlist($no_video_error = false) { global $type, $wp_version; //$redir_tab, $type; $jwp6m = new JWP6_Media(); define('MEDIA_MANAGER_35', version_compare($wp_version, '3.5', '>=')); if (!MEDIA_MANAGER_35) { media_upload_header(); } ?> <script type="text/javascript"> var JWP6_AJAX_URL = "<?php echo JWP6_PLUGIN_URL . 'jwp6-ajax.php'; ?> "; jQuery(function () { jQuery('#player_name, #<?php echo JWP6; ?> playlistid') .select2(jwp6media.SELECT2_SETTINGS) ; jwp6media.init_media_wizard(); }); </script> <form method="post" action="" name="jwp6_wizard_form" id="jwp6_wizard_form"> <?php if (!MEDIA_MANAGER_35) { ?> <h3 class="media-title">Insert JW Player Playlist</h3> <?php } ?> <?php if ($no_video_error) { ?> <div class="notice"> <strong>Please note:</strong> You need to pick at least a playlist to embed the JW Player. </div> <?php } ?> <p>Embed a playlist into your post with JW Player</p> <table> <tbody> <tr> <th scope="row" class="label"> <span class="alignleft"><label for="<?php echo JWP6; ?> playlistid">Playlist</label></span> </th> <td class="field"> <select name="<?php echo JWP6; ?> playlistid" id="<?php echo JWP6; ?> playlistid" data-placeholder="Pick a playlist..." style="width: 90%;"> <option value=""></option> <?php foreach ($jwp6m->playlists() as $playlist) { ?> <option value="<?php echo $playlist->ID; ?> "> <?php echo $jwp6m->playlist_name_with_info($playlist); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th></th> <td> <p class="description"> Create playlists in <a target="_top" href="<?php echo admin_url("upload.php?page=" . JWP6 . "playlists"); ?> ">the media section</a>. <br /> </p> </td> </tr> <tr> <th scope="row" class="label"> <span class="alignleft"><label for="player_name">JW PLayer</label></span> </th> <td class="field"> <select id="player_name" name="player_name" style="width: 90%;"> <?php foreach ($jwp6m->players as $player_id) { ?> <?php $player = new JWP6_Player($player_id); ?> <option value="<?php echo $player_id; ?> "><?php echo $player->full_description(); ?> </option> <?php } ?> </select> </td> </tr> <tr> <th></th> <td> <p class="description"> Select the player you would like to use. You can add and manage players on the <a href="">Player configuration page</a> <br /> </p> </td> </tr> <tr> <th></th> <td class="field"> <button type="submit" class="button-primary" name="insert">Insert this player into your post</button> </td> </tr> </tbody> </table> </form><!-- end of jwp6_wizard_form --> </div><!-- end of wrapper --> <?php }