public function load() { if (class_exists('JWP6_Plugin')) { if (vc_is_frontend_editor()) { JWP6_Shortcode::add_filters(); add_filter('query_vars', array('JWP6_Plugin', 'register_query_vars')); add_action('parse_request', array('JWP6_Plugin', 'parse_request'), 9); add_action('wp_enqueue_scripts', array('JWP6_Plugin', 'insert_javascript')); add_action('wp_head', array('JWP6_Plugin', 'insert_license_key')); add_action('wp_head', array('JWP6_Plugin', 'insert_jwp6_load_event')); add_action('vc_load_iframe_jscss', array(&$this, 'vc_load_iframe_jscss')); if (JWP6_USE_CUSTOM_SHORTCODE_FILTER) { remove_filter('the_content', array('JWP6_Shortcode', 'the_content_filter'), 11); remove_filter('the_excerpt', array('JWP6_Shortcode', 'the_excerpt_filter'), 11); remove_filter('widget_text', array('JWP6_Shortcode', 'widget_text_filter'), 11); add_shortcode('jwplayer', array('JWP6_Plugin', 'shortcode')); } JWP6_Plugin::insert_javascript(); } add_action('wp_enqueue_scripts', array(&$this, 'vc_load_iframe_jscss')); add_filter('vc_front_render_shortcodes', array(&$this, 'renderShortcodes')); add_filter('vc_shortcode_content_filter_after', array(&$this, 'renderShortcodesPreview')); } }
private function _embed_params($params = null, $parent = null) { $po = JWP6_Plugin::$player_options; if (is_null($params)) { $params = $this->config; unset($params['description']); } $new_params = array(); foreach ($params as $param => $value) { if (!$param) { continue; } $check_param = is_null($parent) ? $param : $parent . "__" . $param; // If the value is an array, we recurse into a deeper level if (is_array($value)) { $new_value = $this->_embed_params($value, $check_param); if (is_array($new_value) && count($new_value)) { $new_params[$param] = $new_value; } // Check if this param has a value that should exclude it's complete parent. } else { if ($parent && isset($po[$parent]['not_if'][$param]) && $value == $po[$parent]['not_if'][$param]) { return null; // if the param exists in the player options, it's a built-in option and we can // perform additional checks } else { if (array_key_exists($check_param, JWP6_Plugin::$player_options)) { // Check to see if the option is available for this license. if (JWP6_Plugin::option_available($check_param)) { $check_for_default = isset($po[$check_param]['discard_if_default']) && $po[$check_param]['discard_if_default'] ? true : false; if (!$check_for_default || $value != $po[$check_param]['default']) { if (true === $value && isset($po[$check_param]['embedval'])) { $value = json_decode($po[$check_param]['embedval']); } $new_params[$param] = $value; } } // no further checking the param was set by the user and we assume he/she // knows what he/she is doing. } else { $new_params[$param] = $value; } } } } return $new_params; }
public static function insert_javascript() { wp_enqueue_script('jwplayer', JWP6_Plugin::player_url()); }
public function embedcode() { global $jwp6_global; $jwp6_global['player_embed_count'] = array_key_exists('player_embed_count', $jwp6_global) ? $jwp6_global['player_embed_count'] + 1 : 0; // Make the code a little easier to read foreach ($this->media_params as $param => $value) { ${$param} = $value; } // MAIN MEDIA $file_url = null; // mediaid if (is_int($mediaid) || ctype_digit($mediaid)) { $media_post = get_post($mediaid); $file_url = JWP6_Plugin::url_from_post($media_post); } // file parameter overrules the mediaid if ($file) { $file_url = $file; } // playlistid if (!$playlist) { if (is_int($playlistid) || ctype_digit($playlistid)) { $playlist = JWP6_Plugin::playlist_object($playlistid); } else { $playlist = null; } } // If someone sets playlist and file, playlist has priority if ($file_url && $playlist) { unset($file_url); } // THUMBNAIL $image_url = null; // Direct image setting has priority if ($image) { if (is_int($image) || ctype_digit($image)) { $image_post = get_post($image); $image_url = $image_post->guid; } else { $image_url = $image; } } else { if ($mediaid) { $image_url = JWP6_Plugin::image_from_mediaid($mediaid); } } return $this->player->embedcode($jwp6_global['player_embed_count'], $file_url, $playlist, $image_url, $this->config_params); }
// <item> // <title>Sintel</title> // <description>Sintel is a fantasy computer generated short movie. It's the third // release from the Blender Open Movie Project.</description> // <media:thumbnail url="http://example.com/thumbs/sintel.jpg" /> // <media:content url="http://example.com/videos/sintel.mp4" /> // </item> // etc... // </channel> // </rss> echo "\n" . "<rss version='2.0' xmlns:media='http://search.yahoo.com/mrss/' >"; echo "\n\t" . '<channel>'; echo "\n\t\t" . '<title>' . esc_attr($title) . '</title>'; if (is_array($playlist_items)) { foreach ($playlist_items as $playlist_item_id) { $playlist_item = get_post($playlist_item_id); echo "\n\t\t" . '<item>'; echo "\n\t\t\t" . '<title>' . esc_attr(stripslashes($playlist_item->post_title)) . '</title>'; if ($playlist_item->post_description) { echo "\n\t\t\t" . '<description><![CDATA[' . esc_attr(stripslashes($playlist_item->post_title)) . ']]></description>'; } echo "\n\t\t\t" . "<media:content url='" . esc_attr($playlist_item->guid) . "' />"; $thumbnail = JWP6_Plugin::image_from_mediaid($playlist_item_id); if ($thumbnail) { echo "\n\t\t\t" . "<media:thumbnail url='" . esc_attr($thumbnail) . "' />"; } echo "\n\t\t" . '</item>'; } } echo "\n\t" . '</channel>'; echo "\n" . "</rss>\n";
echo JWP6; ?> mediaid" data-placeholder="Pick a video..." style="width: 90%;"> <option value=""></option> <?php foreach ($jwp6m->videos() as $attachment) { ?> <option value="<?php echo $attachment['id']; ?> " title="<?php echo $attachment['url']; ?> " data-thumb="<?php echo JWP6_Plugin::image_from_mediaid($attachment['id'], true); ?> "> <?php echo $attachment['title']; ?> (<?php echo $attachment['name']; ?> ) </option> <?php } ?> </select> </div>
private function _init_edit_page() { // Basic settings $cannot_edit = false; if ($this->imported_players && array_key_exists($this->player->get('description'), $this->imported_players)) { $cannot_edit = 'You cannot edit the description of this player, because this is an imported JW5 player configuration and the description is used to map your old shortcodes to this player.'; } else { if (!$this->player->get_id()) { $cannot_edit = 'You cannot edit the description of the default editor.'; } } if ($cannot_edit) { $description_field = new JWP6_Form_Field_Uneditable('description', array('value' => $this->player->get('description'), 'why_not' => $cannot_edit)); } else { $description_field = new JWP6_Form_Field('description', array('value' => $this->player->get('description'), 'validation' => "sanitize_text_field", 'placeholder' => "Use this short description as a reminder to identify the player.", 'class' => 'wide')); } $aspectratio_field = new JWP6_Form_Field_Select('aspectratio', array('label' => 'Player Size', 'value' => $this->player->get('aspectratio'), 'options' => JWP6_Plugin::$player_options['aspectratio']['options'], 'default' => JWP6_Plugin::$player_options['aspectratio']['default'], 'help_text' => JWP6_Plugin::$player_options['aspectratio']['help_text'])); $width_field = new JWP6_Form_Field('width', array('label' => 'Fixed width', 'value' => $this->player->get('width'), 'validation' => array('JWP6_Plugin', 'validate_int'), 'unit' => 'pixels wide.', 'class' => 'small right', 'only_if' => array('aspectratio' => 'NULL'))); $height_field = new JWP6_Form_Field('height', array('label' => 'Fixed height', 'value' => $this->player->get('height'), 'validation' => array('JWP6_Plugin', 'validate_int'), 'unit' => 'pixels high.', 'class' => 'small right', 'only_if' => array('aspectratio' => 'NULL'))); // LAYOUT $skin_field = JWP6_Plugin::option_available('skin') ? new JWP6_Form_Field_Select('skin', array('value' => $this->player->get('skin'), 'options' => JWP6_Plugin::$player_options['skin']['options'], 'default' => JWP6_Plugin::$player_options['skin']['default'])) : null; $controls_field = new JWP6_Form_Field_Toggle('controls', array('value' => $this->player->get('controls'), 'text' => JWP6_Plugin::$player_options['controls']['text'], 'help_text' => JWP6_Plugin::$player_options['controls']['help_text'])); $stretching_field = new JWP6_Form_Field_Select('stretching', array('value' => $this->player->get('stretching'), 'options' => JWP6_Plugin::$player_options['stretching']['options'], 'default' => JWP6_Plugin::$player_options['stretching']['default'], 'help_text' => JWP6_Plugin::$player_options['stretching']['help_text'])); // PLAYBACK $autostart_field = new JWP6_Form_Field_Toggle('autostart', array('value' => $this->player->get('autostart'), 'text' => JWP6_Plugin::$player_options['autostart']['text'], 'help_text' => JWP6_Plugin::$player_options['autostart']['help_text'])); $fallback_field = new JWP6_Form_Field_Toggle('fallback', array('value' => $this->player->get('fallback'), 'text' => JWP6_Plugin::$player_options['fallback']['text'])); $mute_field = new JWP6_Form_Field_Toggle('mute', array('value' => $this->player->get('mute'), 'text' => JWP6_Plugin::$player_options['mute']['text'])); $primary_field = new JWP6_Form_Field_Radio('primary', array('value' => $this->player->get('primary'), 'label' => 'Default rendering mode', 'options' => JWP6_Plugin::$player_options['primary']['options'], 'default' => JWP6_Plugin::$player_options['primary']['default'], 'help_text' => JWP6_Plugin::$player_options['primary']['help_text'], 'description_is_value' => true)); $repeat_field = new JWP6_Form_Field_Toggle('repeat', array('value' => $this->player->get('repeat'), 'text' => JWP6_Plugin::$player_options['repeat']['text'])); // TODO: STARTPARAM $listbar_position_field = new JWP6_Form_Field_Select('listbar__position', array('value' => $this->player->get('listbar__position'), 'options' => JWP6_Plugin::$player_options['listbar__position']['options'], 'default' => JWP6_Plugin::$player_options['listbar__position']['default'], 'help_text' => JWP6_Plugin::$player_options['listbar__position']['help_text'])); $listbar_size_field = new JWP6_Form_Field('listbar__size', array('value' => $this->player->get('listbar__size'), 'validation' => array('JWP6_Plugin', 'validate_int'), 'default' => JWP6_Plugin::$player_options['listbar__size']['default'], 'unit' => 'pixels.', 'class' => 'small right', 'help_text' => JWP6_Plugin::$player_options['listbar__size']['help_text'])); // LISTBAR // LOGO & RIGHTCLICK if (JWP6_Plugin::option_available('logo')) { $logo_file_field = new JWP6_Form_Field('logo__file', array('value' => $this->player->get('logo__file'), 'validation' => array('JWP6_Plugin', 'validate_empty_or_url'), 'placeholder' => "URL to the file to use for the image", 'class' => 'wide', 'help_text' => JWP6_Plugin::$player_options['logo__file']['help_text'])); $logo_hide_field = new JWP6_Form_Field_Toggle('logo__hide', array('value' => $this->player->get('logo__hide'), 'text' => JWP6_Plugin::$player_options['logo__hide']['text'])); $logo_link_field = new JWP6_Form_Field('logo__link', array('value' => $this->player->get('logo__link'), 'validation' => array('JWP6_Plugin', 'validate_empty_or_url'), 'placeholder' => "URL you want the logo to link to.", 'class' => 'wide', 'help_text' => JWP6_Plugin::$player_options['logo__link']['help_text'])); $logo_margin_field = new JWP6_Form_Field('logo__margin', array('value' => $this->player->get('logo__margin'), 'validation' => array('JWP6_Plugin', 'validate_int'), 'unit' => 'pixels.', 'class' => 'small right', 'help_text' => JWP6_Plugin::$player_options['logo__margin']['help_text'])); $logo_position_field = new JWP6_Form_Field_Select('logo__position', array('value' => $this->player->get('logo__position'), 'options' => JWP6_Plugin::$player_options['logo__position']['options'], 'default' => JWP6_Plugin::$player_options['logo__position']['default'], 'help_text' => JWP6_Plugin::$player_options['logo__position']['help_text'], 'description_is_value' => true)); // FIELDSETS $this->logo_settings_fields = array('logo_file_field' => $logo_file_field, 'logo_hide_field' => $logo_hide_field, 'logo_link_field' => $logo_link_field, 'logo_margin_field' => $logo_margin_field, 'logo_position_field' => $logo_position_field); } // Advertising if (JWP6_Plugin::option_available('advertising')) { $advertising_client_field = new JWP6_Form_Field_Select('advertising__client', array('value' => $this->player->get('advertising__client'), 'options' => JWP6_Plugin::$player_options['advertising__client']['options'], 'default' => JWP6_Plugin::$player_options['advertising__client']['default'])); $advertising_tag_field = new JWP6_Form_Field('advertising__tag', array('value' => $this->player->get('advertising__tag'), 'validation' => array('JWP6_Plugin', 'validate_empty_or_url'), 'placeholder' => "URL of your vast/googima tag", 'class' => 'wide', 'help_text' => JWP6_Plugin::$player_options['advertising__tag']['help_text'])); $this->advertising_fields = array('advertising_client_field' => $advertising_client_field, 'advertising_tag_field' => $advertising_tag_field); } // GOOGLE ANALYTICS & SHARING $this->other_settings_fields = array(); if (JWP6_Plugin::option_available('ga')) { $ga_field = new JWP6_Form_Field_Toggle('ga', array('value' => $this->player->get('ga'), 'text' => JWP6_Plugin::$player_options['ga']['text'], 'label' => 'Google Analytics')); $this->other_settings_fields['ga_field'] = $ga_field; } if (JWP6_Plugin::option_available('sharing')) { $sharing_field = new JWP6_Form_Field_Toggle('sharing', array('value' => $this->player->get('sharing'), 'text' => JWP6_Plugin::$player_options['sharing']['text'], 'label' => 'Sharing')); $this->other_settings_fields['sharing_field'] = $sharing_field; } if ($this->player->get('streamer')) { $this->other_settings_fields['streamer_field'] = new JWP6_Form_Field_Uneditable('streamer', array('value' => $this->player->get('streamer'), 'why_not' => "This is an imported JW Player 5 that had a custom streamer setting. JW player 6 only supports this setting as a legacy setting.")); } $this->basic_settings_fields = array('description_field' => $description_field, 'aspectratio_field' => $aspectratio_field, 'width_field' => $width_field, 'height_field' => $height_field); $this->layout_settings_fields = array('skin_field' => $skin_field, 'controls_field' => $controls_field, 'stretching_field' => $stretching_field); $this->playback_settings_fields = array('autostart_field' => $autostart_field, 'fallback_field' => $fallback_field, 'mute_field' => $mute_field, 'primary_field' => $primary_field, 'repeat_field' => $repeat_field); $this->listbar_settings_fields = array('listbar_position_field' => $listbar_position_field, 'listbar_size_field' => $listbar_size_field); $this->form_fields = array_merge($this->basic_settings_fields, $this->layout_settings_fields, $this->playback_settings_fields, $this->listbar_settings_fields); if (JWP6_Plugin::option_available('logo')) { $this->form_fields = array_merge($this->form_fields, $this->logo_settings_fields); } if (JWP6_Plugin::option_available('advertising')) { $this->form_fields = array_merge($this->form_fields, $this->advertising_fields); } if (count($this->other_settings_fields)) { $this->form_fields = array_merge($this->form_fields, $this->other_settings_fields); } }
$default->save(); // Import various plugin preferences JWP6_Legacy::import_jwp5_settings(); // Import JWP5 player configs $players = JWP6_Legacy::import_jwp5_players(); add_option(JWP6 . 'imported_jwp5_players', $players); // Set update message $license_page = admin_url('admin.php?page=' . JWP6 . 'menu_licensing'); $message = "You have upgraded to JW Player 6. Please remember to "; $message .= "<strong><a href='{$license_page}'>enter your player license key</a></strong> "; $message .= "to enable all the license specific settings of the player."; update_option(JWP6 . 'notification', $message); // Redirect to the new overview wp_redirect(admin_url('admin.php?page=' . JWP6 . 'menu_import')); } if ('revert' == $_GET['a']) { JWP6_Plugin::purge_settings(false); add_option(JWP6 . 'plugin_version', $plugin_version, '', 'yes'); wp_redirect(admin_url('admin.php?page=jwplayer-update')); } /* Disabled. Will be available with future release. if ( 'purge' == $_GET['a'] ) { $ok = JWP6_Legacy::purge_jwp5_settings(); $message = "Your JW Player 5 (plugin) settings and files (that the script had permission for) have been removed from your system."; update_option(JWP6 . 'notification', $message); delete_option(JWP6 . 'jwp5_players_imported'); delete_option(JWP6 . 'jwp5_playlists_imported'); wp_redirect(admin_url('admin.php?page=' . JWP6 . 'menu')); } */
public static function thumb_select_html($id, $attachments) { $output = $image_id = $image_url = $image_id_class = $image_url_class = ''; $thumbnail = get_post_meta($id, LONGTAIL_KEY . "thumbnail", true); $sel = false; if ($attachments) { if (is_int($thumbnail) || ctype_digit($thumbnail)) { $image_id = $thumbnail; $image_url_class = 'hidden'; } else { if ($thumbnail) { $image_url = JWP6_Plugin::image_from_mediaid($id); $image_id_class = 'hidden'; } else { $image_url_class = 'hidden'; } } } else { if ($thumbnail) { $image_url = $thumbnail; } } $output .= "<input name='attachments[{$id}][" . LONGTAIL_KEY . "thumbnail]' id='" . JWP6 . "the_image_value' type='hidden' value='{$thumbnail}' />"; if ($attachments) { $output .= "<span id='thumb_select_group' style='width: 100%' class='{$image_id_class}'>"; $output .= "<select name='" . JWP6 . "the_image_id' id='" . JWP6 . "the_image_id' style='width:100%;'>"; $output .= "<option value='' title='No thumb' data-thumb='" . JWP6_Plugin::default_image_url() . "'>No thumbnail</option>"; foreach ($attachments as $post) { if (substr($post->post_mime_type, 0, 5) == "image") { if ($post->ID == $image_id) { $selected = "selected='selected'"; $sel = true; } else { $selected = ""; } $output .= "<option value='" . $post->ID . "' data-thumb='" . $post->guid . "' " . $selected . ">" . $post->post_title . "</option>"; } } if (!$sel && isset($image_post) && isset($image_id) && $image_id != -1) { $image_post = get_post($image_id); $output .= "<option value='" . $image_post->ID . "' data-thumb='" . $image_post->guid . "' selected=selected >" . $image_post->post_title . "</option>"; } $output .= "</select>"; $output .= "\n\n <p class='description'>\n or <a href='#mm_thumb_url' class='fieldset_toggle' id=''>enter a url to your thumbnail</a>.\n </p>\n </span>\n "; } $output .= "\n <span id='thumb_url_group' class='{$image_url_class}'>\n <input type='text' name='" . JWP6 . "the_image_url' id='" . JWP6 . "the_image_url' value='{$image_url}' placeholder='e.g. http://example.com/thumbs/your_thumb.jpg' style='width:100%;' />\n "; if ($attachments) { $output .= "\n <p class='description'>\n or <a href='#mm_thumb_select' class='fieldset_toggle' id=''>pick a thumbnail from the media library</a>.\n </p>\n "; } $output .= "\n </span>\n "; if (isset($_REQUEST["post_id"])) { $output .= "\n <div class='jwp6_hr'></div>\n "; } return $output; }
// Enable the JW Player Embed Wizard with preview. // This can be buggy! define('JWP6_EMBED_WIZARD', false); // Simple function to log to the debug log. function jwp6_l($message) { if (WP_DEBUG === true) { if (is_array($message) || is_object($message)) { error_log(print_r($message, true)); } else { error_log($message); } } } // Let's make some space in the log. jwp6_l("\n--------------------------------------\nREQUEST: " . $_SERVER['REQUEST_URI'] . "\n\n"); define('JWP6_PLUGIN_URL', plugin_dir_url(__FILE__)); define('JWP6_PLUGIN_DIR', dirname(__FILE__)); // Global variable to manage states. $jwp6_global = array(); require_once dirname(__FILE__) . '/jwp6-class-plugin.php'; require_once dirname(__FILE__) . '/jwp6-class-player.php'; require_once dirname(__FILE__) . '/jwp6-class-shortcode.php'; require_once dirname(__FILE__) . '/jwp6-class-legacy.php'; // Register the actions JWP6_Plugin::register_actions(); if (is_admin()) { require_once dirname(__FILE__) . '/jwp6-class-admin.php'; require_once dirname(__FILE__) . '/jwp6-class-media.php'; $jwp6_admin = new JWP6_Admin(); }