function jwplayer_admin_head() { $plugin_url = plugins_url('', __FILE__); $content_mask = jwplayer_get_content_mask(); if ($content_mask === JWPLAYER_CONTENT_MASK && is_ssl()) { $content_mask = 'https://' . $content_mask; } $nr_videos = intval(get_option('jwplayer_nr_videos')); ?> <script type="text/javascript"> jwplayerwp.plugin_url = '<?php echo esc_url($plugin_url); ?> '; jwplayerwp.content_mask = '<?php echo esc_url($content_mask); ?> '; jwplayerwp.nr_videos = <?php echo esc_js($nr_videos); ?> ; jwplayerwp.debug = <?php echo wp_json_encode(WP_DEBUG); ?> ; </script> <?php }
function jwplayer_setting_content_mask() { $content_mask = jwplayer_get_content_mask(); if (!$content_mask) { // An empty content mask, or the variable was somehow removed entirely $content_mask = JWPLAYER_CONTENT_MASK; update_option('jwplayer_content_mask', $content_mask); } echo '<input name="jwplayer_content_mask" id="jwplayer_content_mask" type="text" value="' . esc_attr($content_mask) . '" class="regular-text" />'; echo '<p class="description">'; echo 'The <a href="' . esc_url('http://support.jwplayer.com/customer/portal/articles/1433702-dns-masking-the-jw-platform') . '">DNS mask</a> of the content server.<br />'; echo '<strong>Note:</strong> https embeds will not work with a content mask.'; echo '</p>'; }
function jwplayer_admin_head() { $plugin_url = plugins_url('', __FILE__); $content_mask = jwplayer_get_content_mask(); $nr_videos = intval(get_option('jwplayer_nr_videos')); ?> <script type="text/javascript"> jwplayer.plugin_url = '<?php echo esc_url($plugin_url); ?> '; jwplayer.content_mask = '<?php echo esc_url($content_mask); ?> '; jwplayer.nr_videos = <?php echo esc_js($nr_videos); ?> ; </script> <?php }
function jwplayer_create_js_embed($arguments) { $video_hash = $arguments[1]; $player_hash = !empty($arguments[2]) ? $arguments[2] : get_option('jwplayer_player'); $content_mask = jwplayer_get_content_mask(); $timeout = intval(get_option('jwplayer_timeout')); $path = 'players/' . $video_hash . '-' . $player_hash . '.js'; if ($timeout < 1) { $url = '//' . $content_mask . '/' . $path; } else { $api_secret = get_option('jwplayer_api_secret'); $expires = time() + 60 * $timeout; $signature = md5($path . ':' . $expires . ':' . $api_secret); $url = '//' . $content_mask . '/' . $path . '?exp=' . $expires . '&sig=' . $signature; } return '<script type="text/javascript" src="' . esc_url($url) . '"></script>'; }
function jwplayer_shortcode_create_js_embed($media_hash, $player_hash = null, $params = array()) { global $jwplayer_shortcode_embedded_players; $player_hash = null === $player_hash ? get_option('jwplayer_player') : $player_hash; $content_mask = jwplayer_get_content_mask(); $protocol = is_ssl() && JWPLAYER_CONTENT_MASK === $content_mask ? 'https' : 'http'; if (in_array($player_hash, $jwplayer_shortcode_embedded_players, true)) { $player_script = ''; } else { // Injecting script tag because there's no way to properly enqueue a javascript // at this point in the process :'-( $player_script = true; $jwplayer_shortcode_embedded_players[] = $player_hash; } $element_id = "jwplayer_{$media_hash}_{$player_hash}_div"; $timeout = intval(get_option('jwplayer_timeout')); $js_lib = "{$protocol}://{$content_mask}/libraries/{$player_hash}.js"; $json = "{$protocol}://{$content_mask}/feeds/{$media_hash}.json"; if ($timeout > 0) { $api_secret = get_option('jwplayer_api_secret'); $expires = time() + 60 * $timeout; $js_lib_sig = md5("libraries/{$player_hash}.js:" . $expires . ':' . $api_secret); $js_lib = "{$js_lib}?exp={$expires}&sig={$js_lib_sig}"; $json_sig = md5("feeds/{$media_hash}.json:" . $expires . ':' . $api_secret); $json = "{$json}?exp={$expires}&sig={$json_sig}"; } $params = jwplayer_shortcode_filter_player_params($params); if (count($params)) { // Support for player tracks. foreach (array('sources', 'tracks') as $option) { if (isset($params[$option])) { $json = '[' . $params[$option] . ']'; $obj = json_decode(preg_replace('/[{, ]{1}(\\w+):/i', '"\\1":', $json)); if (null === $obj) { $json = str_replace(array('"', "'"), array('\\"', '"'), $json); $obj = json_decode(preg_replace('/[{, ]{1}(\\w+):/i', '"\\1":', $json)); } $params[$option] = $obj; } } } if (!isset($params['source'])) { $params['playlist'] = $json; } // Set ph value for player hosting source $params['ph'] = 2; // Redeclare fitVids to stop it from breaking the JW Player embedding. if (JWPLAYER_DISABLE_FITVIDS) { if ($player_script) { return "\n\t\t<script type='text/javascript' src='" . esc_url($js_lib) . "'></script>\n\t\t\t<div id='" . esc_attr($element_id) . "'></div>\n\t\t<script type='text/javascript'>\n\t\t\t" . 'if(typeof(jQuery)=="function"){(function($){$.fn.fitVids=function(){}})(jQuery)};' . "\n\t\t\t\tjwplayer('" . esc_attr($element_id) . "').setup(\n\t\t\t\t" . wp_json_encode($params) . "\n\t\t\t);\n\t\t</script>\n\t"; } else { // no player script return "\n\t\t\t<div id='" . esc_attr($element_id) . "'></div>\n\t\t<script type='text/javascript'>\n\t\t\t" . 'if(typeof(jQuery)=="function"){(function($){$.fn.fitVids=function(){}})(jQuery)};' . "\n\t\t\t\tjwplayer('" . esc_attr($element_id) . "').setup(\n\t\t\t\t" . wp_json_encode($params) . "\n\t\t\t);\n\t\t</script>\n\t"; } } else { // no fitvids script here. if ($player_script) { return "\n\t\t<script type='text/javascript' src='" . esc_url($js_lib) . "></script>\n\t\t\t<div id='" . esc_attr($element_id) . "'></div>\n\t\t<script type='text/javascript'>\n\t\t\t\tjwplayer('" . esc_attr($element_id) . "').setup(\n\t\t\t\t" . wp_json_encode($params) . "\n\t\t\t);\n\t\t</script>\n\t"; } else { // no player script return "\n\t\t\t<div id='" . esc_attr($element_id) . "'></div>\n\t\t<script type='text/javascript'>\n\t\t\t\tjwplayer('" . esc_attr($element_id) . "').setup(\n\t\t\t\t" . wp_json_encode($params) . "\n\t\t\t);\n\t\t</script>\n\t"; } } }
function jwplayer_shortcode_create_js_embed($media_hash, $player_hash = null, $params = array()) { global $jwplayer_shortcode_embedded_players; $player_hash = null === $player_hash ? get_option('jwplayer_player') : $player_hash; $content_mask = jwplayer_get_content_mask(); $protocol = is_ssl() && $content_mask === BOTR_CONTENT_MASK ? 'https' : 'http'; if (in_array($player_hash, $jwplayer_shortcode_embedded_players)) { $player_script = ''; } else { // Injecting script tag because there's no way to properly enqueue a javascript // at this point in the process :'-( $player_script = "<script type='text/javascript' src='{$protocol}://{$content_mask}/libraries/{$player_hash}.js'></script>"; $jwplayer_shortcode_embedded_players[] = $player_hash; } $element_id = "jwplayer_{$media_hash}_{$player_hash}_div"; $timeout = intval(get_option('jwplayer_timeout')); $xml = "{$protocol}://{$content_mask}/jw6/{$media_hash}.xml"; if ($timeout > 0) { $api_secret = get_option('jwplayer_api_secret'); $expires = time() + 60 * $timeout; $signature = md5("jw6/{$media_hash}.xml:" . $expires . ':' . $api_secret); $xml = "{$xml}?exp={$expires}&sig={$signature}"; } $params = jwplayer_shortcode_filter_player_params($params); if (count($params)) { // Support for player tracks. foreach (array('sources', 'tracks') as $option) { if (isset($params[$option])) { $json = '[' . $params[$option] . ']'; $obj = json_decode(preg_replace('/[{, ]{1}(\\w+):/i', '"\\1":', $json)); if (null === $obj) { $json = str_replace(array('"', "'"), array('\\"', '"'), $json); $obj = json_decode(preg_replace('/[{, ]{1}(\\w+):/i', '"\\1":', $json)); } $params[$option] = $obj; } } } if (!isset($params['source'])) { $params['playlist'] = $xml; } $paramstring = json_encode($params); foreach (array('&' => '&', '&' => '&', '\\/' => '/') as $from => $to) { $paramstring = str_replace($from, $to, $paramstring); } // Redeclare fitVids to stop it from breaking the JW Player embedding. $fitbits = JWPLAYER_DISABLE_FITVIDS ? 'if(typeof(jQuery)=="function"){(function($){$.fn.fitVids=function(){}})(jQuery)};' : ''; return "\n\t\t{$player_script}\n\t\t<div id='{$element_id}'></div>\n\t\t<script type='text/javascript'>\n\t\t\t{$fitbits}\n\t\t\tjwplayer('{$element_id}').setup(\n\t\t\t\t{$paramstring}\n\t\t\t);\n\t\t</script>\n\t"; }