| 1 |
<?php |
| 2 |
/* |
| 3 |
PowerPress player options |
| 4 |
*/ |
| 5 |
|
| 6 |
|
| 7 |
function powerpressplayer_get_next_id() |
| 8 |
{ |
| 9 |
if( !isset($GLOBALS['g_powerpress_player_id']) ) // Use the global unique player id variable for the surrounding div |
| 10 |
$GLOBALS['g_powerpress_player_id'] = rand(0, 10000); |
| 11 |
else |
| 12 |
$GLOBALS['g_powerpress_player_id']++; // increment the player id for the next div so it is unique |
| 13 |
return $GLOBALS['g_powerpress_player_id']; |
| 14 |
} |
| 15 |
|
| 16 |
function powerpressplayer_get_extension($media_url, $EpisodeData = array() ) |
| 17 |
{ |
| 18 |
$qpos = strpos($media_url, "?"); |
| 19 |
if ($qpos!==false) { |
| 20 |
$ext = powerpressplayer_get_extension(substr($media_url, 0, $qpos)); |
| 21 |
if ($ext != 'unknown') { |
| 22 |
return $ext; |
| 23 |
} |
| 24 |
} |
| 25 |
|
| 26 |
$extension = 'unknown'; |
| 27 |
$parts = pathinfo($media_url); |
| 28 |
if( !empty($parts['extension']) ) |
| 29 |
$extension = strtolower($parts['extension']); |
| 30 |
|
| 31 |
$qpos = strpos($extension, "?"); |
| 32 |
if ($qpos!==false) { |
| 33 |
$extension = substr($extension, 0, $qpos); |
| 34 |
} |
| 35 |
|
| 36 |
// Hack to use the audio/mp3 content type to set extension to mp3, some folks use tinyurl.com to mp3 files which remove the file extension... |
| 37 |
if( isset($EpisodeData['type']) && $EpisodeData['type'] == 'audio/mpeg' && $extension != 'mp3' ) |
| 38 |
$extension = 'mp3'; |
| 39 |
|
| 40 |
return $extension; |
| 41 |
} |
| 42 |
|
| 43 |
/* |
| 44 |
Initialize powerpress player handling |
| 45 |
*/ |
| 46 |
function powerpressplayer_init($GeneralSettings) |
| 47 |
{ |
| 48 |
add_shortcode('skipto', 'powerpress_shortcode_skipto'); // skipto shortcode |
| 49 |
|
| 50 |
if( !empty($GeneralSettings['seo_video_objects']) ) |
| 51 |
add_filter('powerpress_player', 'powerpressplayer_mediaobjects_video', 1, 3); // Before everythign is added |
| 52 |
if( !empty($GeneralSettings['seo_audio_objects']) ) |
| 53 |
add_filter('powerpress_player', 'powerpressplayer_mediaobjects_audio', 1, 3); // Before everythign is added |
| 54 |
if( !empty($GeneralSettings['seo_audio_objects']) || !empty($GeneralSettings['seo_video_objects']) ) |
| 55 |
add_filter('powerpress_player', 'powerpressplayer_mediaobjects_post', 1000, 3); // After everythign is added |
| 56 |
|
| 57 |
if( isset($_GET['powerpress_pinw']) ) |
| 58 |
powerpress_do_pinw(htmlspecialchars($_GET['powerpress_pinw']), !empty($GeneralSettings['process_podpress']) ); |
| 59 |
|
| 60 |
if( isset($_GET['powerpress_embed']) ) |
| 61 |
{ |
| 62 |
$player = ( !empty($_GET['powerpress_player']) ? $_GET['powerpress_player'] : 'mejs-v' ); |
| 63 |
powerpress_do_embed($player, htmlspecialchars($_GET['powerpress_embed']), !empty($GeneralSettings['process_podpress']) ); |
| 64 |
} |
| 65 |
|
| 66 |
// If we are to process podpress data.. |
| 67 |
if( !empty($GeneralSettings['process_podpress']) ) |
| 68 |
{ |
| 69 |
add_shortcode('display_podcast', 'powerpress_shortcode_handler'); |
| 70 |
} |
| 71 |
/* |
| 72 |
// include what's needed for each plaer |
| 73 |
if( defined('POWERPRESS_JS_DEBUG') ) |
| 74 |
wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.js'); |
| 75 |
else |
| 76 |
wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.min.js'); |
| 77 |
|
| 78 |
|
| 79 |
$enqueue_mejs = false; |
| 80 |
if( !isset($GeneralSettings['player']) || !isset($GeneralSettings['video_player']) ) |
| 81 |
{ |
| 82 |
$enqueue_mejs = true; |
| 83 |
} |
| 84 |
else if( !empty($GeneralSettings['player']) && $GeneralSettings['player'] == 'mediaelement-audio' ) |
| 85 |
{ |
| 86 |
$enqueue_mejs = true; |
| 87 |
} |
| 88 |
else if( !empty($GeneralSettings['video_player']) && $GeneralSettings['video_player'] == 'mediaelement-video' ) |
| 89 |
{ |
| 90 |
$enqueue_mejs = true; |
| 91 |
} |
| 92 |
|
| 93 |
if( $enqueue_mejs ) |
| 94 |
{ |
| 95 |
wp_enqueue_style('wp-mediaelement'); |
| 96 |
wp_enqueue_script('wp-mediaelement'); |
| 97 |
} |
| 98 |
*/ |
| 99 |
} |
| 100 |
|
| 101 |
|
| 102 |
function powerpress_shortcode_handler( $attributes, $content = null ) |
| 103 |
{ |
| 104 |
global $post, $g_powerpress_player_added; |
| 105 |
|
| 106 |
// We can't add flash players to feeds |
| 107 |
if( is_feed() ) |
| 108 |
return ''; |
| 109 |
|
| 110 |
$return = ''; |
| 111 |
$feed = ''; |
| 112 |
$channel = ''; |
| 113 |
$slug = ''; // latest and preferred way to specify the feed slug |
| 114 |
$url = ''; |
| 115 |
$image = ''; |
| 116 |
$width = ''; |
| 117 |
$height = ''; |
| 118 |
$sample = ''; |
| 119 |
|
| 120 |
if (is_array($attributes)) { |
| 121 |
$attributes = array_filter($attributes, function ($var) { |
| 122 |
$var_without_whitespace = preg_replace("/\s+/", "", $var); |
| 123 |
if (strpos($var_without_whitespace, 'javascript:') === 0) { |
| 124 |
return ''; |
| 125 |
} else { |
| 126 |
return $var; |
| 127 |
} |
| 128 |
}); |
| 129 |
} |
| 130 |
|
| 131 |
extract( shortcode_atts( array( |
| 132 |
'url' => '', |
| 133 |
'feed' => '', |
| 134 |
'channel' => '', |
| 135 |
'slug' => '', |
| 136 |
'image' => '', |
| 137 |
'width' => '', |
| 138 |
'height' => '', |
| 139 |
'sample' => '' |
| 140 |
), $attributes ) ); |
| 141 |
|
| 142 |
$url = esc_url_raw($url); |
| 143 |
$image = esc_url_raw($image); |
| 144 |
|
| 145 |
if( empty($channel) && !empty($feed) ) // Feed for backward compat. |
| 146 |
$channel = $feed; |
| 147 |
if( !empty($slug) ) // Foward compatibility |
| 148 |
$channel = $slug; |
| 149 |
|
| 150 |
if( !$url && $content ) |
| 151 |
{ |
| 152 |
$content_url = trim($content); |
| 153 |
if( filter_var($content_url, FILTER_VALIDATE_URL) ) |
| 154 |
$url = esc_url_raw($content_url); |
| 155 |
} |
| 156 |
|
| 157 |
if( $url && !$sample ) |
| 158 |
{ |
| 159 |
$url = powerpress_add_redirect_url($url); |
| 160 |
$content_type = ''; |
| 161 |
// Handle the URL differently... |
| 162 |
do_action('wp_powerpress_player_scripts'); |
| 163 |
$return = apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($url, 'p'), array('image'=>$image, 'type'=>$content_type,'width'=>$width, 'height'=>$height) ); |
| 164 |
} |
| 165 |
else if( $channel ) |
| 166 |
{ |
| 167 |
if (!empty($post)) { |
| 168 |
$post_id = $post->ID; |
| 169 |
} else { |
| 170 |
$post_id = -1; |
| 171 |
} |
| 172 |
$EpisodeData = powerpress_get_enclosure_data($post_id, $channel); |
| 173 |
if( !empty($EpisodeData['embed']) ) |
| 174 |
$return = SanitizeEmbed($EpisodeData['embed']); |
| 175 |
|
| 176 |
// Shortcode over-ride settings: |
| 177 |
if( !empty($image) ) |
| 178 |
$EpisodeData['image'] = $image; |
| 179 |
if( !empty($width) ) |
| 180 |
$EpisodeData['width'] = $width; |
| 181 |
if( !empty($height) ) |
| 182 |
$EpisodeData['height'] = $height; |
| 183 |
if (!empty($url)) { |
| 184 |
$EpisodeData['url'] = $url; |
| 185 |
} |
| 186 |
if ($sample && empty($EpisodeData['url'])) { |
| 187 |
// sample player for edit screen block pre-publish |
| 188 |
$return .= "<p>This is a placeholder. Upon publishing, it will be replaced with the actual audio or video player.</p>"; |
| 189 |
$EpisodeData['url'] = "https://media.blubrry.com/blubrrypreview/content.blubrry.com/blubrrypreview/transcript_test_episode.mp3"; |
| 190 |
} |
| 191 |
if (empty($EpisodeData['feed']) && !empty($channel)) { |
| 192 |
$EpisodeData['feed'] = $channel; |
| 193 |
} |
| 194 |
if (empty($EpisodeData['type'])) { |
| 195 |
$EpisodeData['type'] = ''; |
| 196 |
} |
| 197 |
|
| 198 |
|
| 199 |
$GeneralSettings = get_option('powerpress_general', []); |
| 200 |
if( isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($channel) ) |
| 201 |
{ |
| 202 |
$return .= powerpress_premium_content_message($post_id, $channel, $EpisodeData); |
| 203 |
} |
| 204 |
else |
| 205 |
{ |
| 206 |
// If the shortcode specifies a channel, than we definitely want to include the player even if $EpisodeData['no_player'] is true... |
| 207 |
if( !isset($EpisodeData['no_player']) && !empty($EpisodeData['url']) ) { |
| 208 |
do_action('wp_powerpress_player_scripts'); |
| 209 |
$return .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), array('id'=>$post_id,'feed'=>$channel, 'channel'=>$channel, 'image'=>$image, 'type'=>$EpisodeData['type'],'width'=>$width, 'height'=>$height) ); |
| 210 |
} |
| 211 |
if( empty($EpisodeData['no_links']) && !empty($EpisodeData['url']) ) { |
| 212 |
do_action('wp_powerpress_player_scripts'); |
| 213 |
$return .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); |
| 214 |
$return .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData ); |
| 215 |
} |
| 216 |
} |
| 217 |
} |
| 218 |
else |
| 219 |
{ |
| 220 |
$GeneralSettings = get_option('powerpress_general', []); |
| 221 |
if( !isset($GeneralSettings['custom_feeds']['podcast']) ) |
| 222 |
$GeneralSettings['custom_feeds']['podcast'] = 'Podcast Feed'; // Fixes scenario where the user never configured the custom default podcast feed. |
| 223 |
|
| 224 |
// If we have post type podcasting enabled, then we need to use the podcast post type feeds instead here... |
| 225 |
if( !empty($GeneralSettings['posttype_podcasting']) ) |
| 226 |
{ |
| 227 |
$post_type = get_query_var('post_type'); |
| 228 |
if ( is_array( $post_type ) ) { |
| 229 |
$post_type = reset( $post_type ); // get first element in array |
| 230 |
} |
| 231 |
|
| 232 |
// Get the feed slugs and titles for this post type |
| 233 |
$PostTypeSettingsArray = get_option('powerpress_posttype_'.$post_type, []); |
| 234 |
// Loop through this array... |
| 235 |
if( !empty($PostTypeSettingsArray) ) |
| 236 |
{ |
| 237 |
switch($post_type) |
| 238 |
{ |
| 239 |
case 'post': |
| 240 |
case 'page': { |
| 241 |
// Do nothing!, we want the default podcast and channels to appear in these post types |
| 242 |
}; break; |
| 243 |
default: { |
| 244 |
$GeneralSettings['custom_feeds'] = array(); // reset this array since we're working with a custom post type |
| 245 |
}; |
| 246 |
} |
| 247 |
|
| 248 |
if (is_array($PostTypeSettingsArray)) { |
| 249 |
foreach ($PostTypeSettingsArray as $feed_slug => $postTypeSettings) { |
| 250 |
if (!empty($postTypeSettings['title'])) |
| 251 |
$GeneralSettings['custom_feeds'][$feed_slug] = $postTypeSettings['title']; |
| 252 |
else |
| 253 |
$GeneralSettings['custom_feeds'][$feed_slug] = $feed_slug; |
| 254 |
} |
| 255 |
} |
| 256 |
} |
| 257 |
} |
| 258 |
|
| 259 |
if (is_array($GeneralSettings['custom_feeds'])) { |
| 260 |
foreach ($GeneralSettings['custom_feeds'] as $feed_slug => $feed_title) { |
| 261 |
if (isset($GeneralSettings['disable_player']) && isset($GeneralSettings['disable_player'][$feed_slug])) |
| 262 |
continue; |
| 263 |
|
| 264 |
$EpisodeData = powerpress_get_enclosure_data($post->ID, $feed_slug); |
| 265 |
if (!$EpisodeData && !empty($GeneralSettings['process_podpress']) && $feed_slug == 'podcast') |
| 266 |
$EpisodeData = powerpress_get_enclosure_data_podpress($post->ID); |
| 267 |
|
| 268 |
if (!$EpisodeData) |
| 269 |
continue; |
| 270 |
|
| 271 |
if (!empty($EpisodeData['embed'])) |
| 272 |
$return .= SanitizeEmbed($EpisodeData['embed']); |
| 273 |
|
| 274 |
// Shortcode over-ride settings: |
| 275 |
if (!empty($image)) |
| 276 |
$EpisodeData['image'] = $image; |
| 277 |
if (!empty($width)) |
| 278 |
$EpisodeData['width'] = $width; |
| 279 |
if (!empty($height)) |
| 280 |
$EpisodeData['height'] = $height; |
| 281 |
|
| 282 |
if (isset($GeneralSettings['premium_caps']) && $GeneralSettings['premium_caps'] && !powerpress_premium_content_authorized($feed_slug)) { |
| 283 |
$return .= powerpress_premium_content_message($post->ID, $feed_slug, $EpisodeData); |
| 284 |
continue; |
| 285 |
} |
| 286 |
|
| 287 |
if (!isset($EpisodeData['no_player'])) { |
| 288 |
do_action('wp_powerpress_player_scripts'); |
| 289 |
$return .= apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData); |
| 290 |
} |
| 291 |
if (!isset($EpisodeData['no_links'])) { |
| 292 |
do_action('wp_powerpress_player_scripts'); |
| 293 |
$return .= apply_filters('powerpress_player_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData); |
| 294 |
$return .= apply_filters('powerpress_player_subscribe_links', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), $EpisodeData); |
| 295 |
} |
| 296 |
} |
| 297 |
} |
| 298 |
} |
| 299 |
|
| 300 |
return $return; |
| 301 |
} |
| 302 |
|
| 303 |
add_shortcode('powerpress', 'powerpress_shortcode_handler'); |
| 304 |
if( !defined('PODCASTING_VERSION') ) |
| 305 |
{ |
| 306 |
add_shortcode('podcast', 'powerpress_shortcode_handler'); |
| 307 |
} |
| 308 |
|
| 309 |
function wp_powerpress_player_scripts() |
| 310 |
{ |
| 311 |
// include what's needed for each plaer |
| 312 |
if( defined('POWERPRESS_JS_DEBUG') ) |
| 313 |
wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.js'); |
| 314 |
else |
| 315 |
wp_enqueue_script( 'powerpress-player', powerpress_get_root_url() .'player.min.js'); |
| 316 |
} |
| 317 |
add_action( 'wp_powerpress_player_scripts', 'wp_powerpress_player_scripts' ); |
| 318 |
|
| 319 |
|
| 320 |
/* |
| 321 |
// Everything in $ExtraData except post_id |
| 322 |
*/ |
| 323 |
function powerpress_generate_embed($player, $EpisodeData) // $post_id, $feed_slug, $width=false, $height=false, $media_url = false, $autoplay = false) |
| 324 |
{ |
| 325 |
if( empty($EpisodeData['id']) && empty($EpisodeData['feed']) ) |
| 326 |
return ''; |
| 327 |
|
| 328 |
if( $player == 'blubrryaudio' || $player == 'blubrrymodern') |
| 329 |
{ |
| 330 |
$extension = powerpressplayer_get_extension($EpisodeData['url']); |
| 331 |
if( $extension == 'mp3' || $extension == 'm4a' ) |
| 332 |
{ |
| 333 |
return powerpressplayer_build_blubrryaudio($EpisodeData['url'], $EpisodeData); |
| 334 |
} |
| 335 |
return ''; |
| 336 |
} |
| 337 |
|
| 338 |
$width = absint($EpisodeData['width'] ?? 0); |
| 339 |
$height = absint($EpisodeData['height'] ?? 0); |
| 340 |
|
| 341 |
// More efficient, only pull the general settings if necessary |
| 342 |
if( $height == 0 || $width == 0 ) |
| 343 |
{ |
| 344 |
$GeneralSettings = get_option('powerpress_general', []); |
| 345 |
if( $width == 0 ) |
| 346 |
{ |
| 347 |
$width = 400; |
| 348 |
if( !empty($GeneralSettings['player_width']) ) |
| 349 |
$width = absint($GeneralSettings['player_width']); |
| 350 |
} |
| 351 |
|
| 352 |
if( $height == 0 ) |
| 353 |
{ |
| 354 |
$height = 400; |
| 355 |
if( !empty($GeneralSettings['player_height']) ) |
| 356 |
$height = absint($GeneralSettings['player_height']); |
| 357 |
} |
| 358 |
|
| 359 |
$extension = powerpressplayer_get_extension($EpisodeData['url']); |
| 360 |
if( $player == 'mediaelement-audio' ) |
| 361 |
{ |
| 362 |
if( $extension == 'mp3' || $extension == 'm4a' || $extension == 'oga') |
| 363 |
{ |
| 364 |
$height = 30; // Hack for audio to only include the player without the poster art |
| 365 |
$width = 320; |
| 366 |
if( !empty($GeneralSettings['player_width_audio']) ) |
| 367 |
$width = absint($GeneralSettings['player_width_audio']); |
| 368 |
} |
| 369 |
} |
| 370 |
else if ( $player == 'default' ) |
| 371 |
{ |
| 372 |
if( ($extension == 'mp3' || $extension == 'm4a' ) && empty($GeneralSettings['poster_image_audio']) ) |
| 373 |
{ |
| 374 |
$height = 24; // Hack for audio to only include the player without the poster art |
| 375 |
$width = 320; |
| 376 |
if( !empty($GeneralSettings['player_width_audio']) ) |
| 377 |
$width = $GeneralSettings['player_width_audio']; |
| 378 |
} |
| 379 |
} |
| 380 |
} |
| 381 |
|
| 382 |
$embed = ''; |
| 383 |
$url = get_bloginfo('url') .'/?powerpress_embed=' . $EpisodeData['id'] .'-'. $EpisodeData['feed']; |
| 384 |
if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] ) |
| 385 |
$url .= '&autoplay=true'; |
| 386 |
|
| 387 |
$url .= '&powerpress_player='.$player; |
| 388 |
$iframeTitle = esc_attr( __('Blubrry Podcast Player', 'powerpress') ); |
| 389 |
$embed .= '<iframe'; |
| 390 |
//$embed .= ' class="powerpress-player-embed"'; |
| 391 |
$embed .= ' width="'. absint($width) .'"'; |
| 392 |
$embed .= ' height="'. absint($height) .'"'; |
| 393 |
$embed .= ' src="'. htmlspecialchars($url) .'"'; |
| 394 |
$embed .= ' title="'. htmlspecialchars($iframeTitle) .'"'; |
| 395 |
$embed .= ' frameborder="0" scrolling="no"'; |
| 396 |
if($extension != 'mp3' && $extension != 'm4a' && $extension != 'oga') |
| 397 |
$embed .= ' webkitAllowFullScreen mozallowfullscreen allowFullScreen'; |
| 398 |
$embed .= '></iframe>'; |
| 399 |
return $embed; |
| 400 |
} |
| 401 |
|
| 402 |
function do_powerpressplayer_embed($player, $media_url, $EpisodeData = array()) |
| 403 |
{ |
| 404 |
// Includde the stuff we need... |
| 405 |
wp_enqueue_style('wp-mediaelement'); |
| 406 |
wp_enqueue_script('wp-mediaelement'); |
| 407 |
|
| 408 |
$mejs_video = false; |
| 409 |
$mejs_audio = false; |
| 410 |
$content_type = powerpress_get_contenttype($media_url); |
| 411 |
if( preg_match('/audio\/(mpeg|x-m4a|ogg)/i', $content_type ) ) |
| 412 |
$mejs_audio = true; |
| 413 |
else if( preg_match('/video\/(mpeg|mp4|x-m4v|ogg)/i', $content_type ) ) |
| 414 |
$mejs_video = true; |
| 415 |
|
| 416 |
$content = ''; |
| 417 |
$content .= '<!DOCTYPE html>'. PHP_EOL; |
| 418 |
$content .= '<html xmlns="http://www.w3.org/1999/xhtml">'. PHP_EOL; |
| 419 |
$content .= '<head>'. PHP_EOL; |
| 420 |
$content .= '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />'. PHP_EOL; |
| 421 |
$content .= '<title>'. __('Blubrry PowerPress Player', 'powerpress') .'</title>'. PHP_EOL; |
| 422 |
$content .= '<meta name="robots" content="noindex" />'. PHP_EOL; |
| 423 |
echo $content; |
| 424 |
|
| 425 |
wp_print_styles(); |
| 426 |
wp_print_scripts(); |
| 427 |
|
| 428 |
$content = ''; |
| 429 |
$content .= '<script type="text/javascript"><!--'. PHP_EOL; |
| 430 |
$content .= 'jQuery(document).ready(function($) {'. PHP_EOL; |
| 431 |
$content .= ' powerpress_load_player();'. PHP_EOL; |
| 432 |
$content .= ' jQuery(window).resize(function() {'. PHP_EOL; |
| 433 |
$content .= ' powerpress_resize_player();'. PHP_EOL; |
| 434 |
$content .= ' });'. PHP_EOL; |
| 435 |
$content .= '});'. PHP_EOL; |
| 436 |
|
| 437 |
$content .= 'function powerpress_load_player() {'. PHP_EOL; |
| 438 |
$content .= ' powerpress_resize_player();'.PHP_EOL; |
| 439 |
$content .= '}'. PHP_EOL; |
| 440 |
|
| 441 |
$content .= 'function powerpress_resize_player() { '. PHP_EOL; |
| 442 |
if( $mejs_video ) |
| 443 |
{ |
| 444 |
$content .= ' if( ( parseInt(jQuery(window).width()) * 0.5625) >= parseInt(jQuery(window).height() ) ) {'. PHP_EOL; |
| 445 |
$content .= ' var height = parseInt(jQuery(window).height())-10;'. PHP_EOL; |
| 446 |
$content .= ' var width = Math.round((height*16) / 9)+\'px\';'. PHP_EOL; |
| 447 |
$content .= ' jQuery(\'.powerpress_player\').css(\'width\', width );'. PHP_EOL; |
| 448 |
$content .= ' jQuery(\'.powerpress_player\').css(\'height\', height+\'px\' );'. PHP_EOL; |
| 449 |
$content .= ' } else {'. PHP_EOL; |
| 450 |
$content .= ' jQuery(\'.powerpress_player\').css(\'width\', \'100%\' );'. PHP_EOL; |
| 451 |
$content .= ' jQuery(\'.powerpress_player\').css(\'height\', \'100%\' );'. PHP_EOL; |
| 452 |
$content .= ' }'. PHP_EOL; |
| 453 |
} |
| 454 |
$content .= '}'. PHP_EOL; |
| 455 |
$content .= "//-->\n"; |
| 456 |
$content .= '</script>'. PHP_EOL; |
| 457 |
$content .= '<style type="text/css" media="screen">' . PHP_EOL; |
| 458 |
$content .= ' body { font-size: 13px; font-family: Arial, Helvetica, sans-serif; margin: 0; padding: 0; background-color:transparent; } img { border: 0; } ' . PHP_EOL; |
| 459 |
|
| 460 |
if( $mejs_video ) |
| 461 |
{ |
| 462 |
$content .= ' |
| 463 |
.powerpress_player { margin: 0 auto; } |
| 464 |
.mejs-container { |
| 465 |
width: 100% !important; |
| 466 |
height: auto !important; |
| 467 |
max-height: 500px !important; |
| 468 |
padding-top: 57%; |
| 469 |
} |
| 470 |
.mejs-overlay, .mejs-poster { |
| 471 |
width: 100% !important; |
| 472 |
height: 100% !important; |
| 473 |
} |
| 474 |
.mejs-mediaelement video { |
| 475 |
position: absolute; |
| 476 |
top: 0; left: 0; right: 0; bottom: 0; |
| 477 |
width: 100% !important; |
| 478 |
height: 100% !important; |
| 479 |
} |
| 480 |
'; |
| 481 |
} |
| 482 |
else |
| 483 |
{ |
| 484 |
$content .= '.powerpress_player .wp-audio-shortcode { |
| 485 |
max-width: 100% !important; |
| 486 |
}'; |
| 487 |
} |
| 488 |
$content .= '</style>' . PHP_EOL; |
| 489 |
$content .= '</head>'. PHP_EOL; |
| 490 |
$content .= '<body>'. PHP_EOL; |
| 491 |
|
| 492 |
// Body specific content for player |
| 493 |
if( $mejs_audio ) |
| 494 |
$content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData, true); |
| 495 |
else if( $mejs_video ) |
| 496 |
$content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData, true); |
| 497 |
else |
| 498 |
$content .= '<strong>'. __('Player Not Available', 'powerpress') .'</strong>'; |
| 499 |
|
| 500 |
$content .= '</body>'. PHP_EOL; |
| 501 |
$content .= '</html>'. PHP_EOL; |
| 502 |
echo $content; |
| 503 |
} |
| 504 |
|
| 505 |
|
| 506 |
/* |
| 507 |
Audio Players - Flash/HTML5 compliant mp3 audio |
| 508 |
|
| 509 |
@since 2.0 |
| 510 |
@content - |
| 511 |
@param string $content Content of post or page to add player to |
| 512 |
@param string $media_url Media URL to add player for |
| 513 |
@param array $EpisodeData Array of key/value settings that optionally can contribute to player being added |
| 514 |
@return string $content The content, possibly modified wih player added |
| 515 |
*/ |
| 516 |
function powerpressplayer_player_audio($content, $media_url, $EpisodeData = array() ) |
| 517 |
{ |
| 518 |
$extension = powerpressplayer_get_extension($media_url); |
| 519 |
switch( $extension ) |
| 520 |
{ |
| 521 |
// MP3 |
| 522 |
case 'mp3': |
| 523 |
{ |
| 524 |
$Settings = get_option('powerpress_general', []); |
| 525 |
if( !isset($Settings['player']) ) |
| 526 |
$Settings['player'] = 'mediaelement-audio'; |
| 527 |
|
| 528 |
switch( $Settings['player'] ) |
| 529 |
{ |
| 530 |
case 'blubrryaudio': |
| 531 |
case 'blubrrymodern': { |
| 532 |
$content .= powerpressplayer_build_blubrryaudio($media_url, $EpisodeData); |
| 533 |
}; break; |
| 534 |
case 'html5audio': { |
| 535 |
$content .= powerpressplayer_build_html5audio($media_url, $EpisodeData); |
| 536 |
}; break; |
| 537 |
case 'mediaelement-audio': |
| 538 |
default: { |
| 539 |
$content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData); |
| 540 |
}; break; |
| 541 |
} |
| 542 |
|
| 543 |
}; break; |
| 544 |
case 'm4a': { |
| 545 |
|
| 546 |
$Settings = get_option('powerpress_general', []); |
| 547 |
if( !isset($Settings['player']) ) |
| 548 |
$Settings['player'] = 'mediaelement-audio'; |
| 549 |
|
| 550 |
switch( $Settings['player'] ) |
| 551 |
{ |
| 552 |
case 'blubrryaudio': |
| 553 |
case 'blubrrymodern': { |
| 554 |
$content .= powerpressplayer_build_blubrryaudio($media_url, $EpisodeData); |
| 555 |
}; break; |
| 556 |
case 'html5audio': { |
| 557 |
$content .= powerpressplayer_build_html5audio($media_url, $EpisodeData); |
| 558 |
}; break; |
| 559 |
case 'mediaelement-audio': { |
| 560 |
$content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData); |
| 561 |
}; break; |
| 562 |
default: { |
| 563 |
$content .= powerpressplayer_build_playimageaudio($media_url, true); |
| 564 |
}; |
| 565 |
} |
| 566 |
|
| 567 |
// Use Flow player if configured |
| 568 |
}; break; |
| 569 |
case 'ogg': { |
| 570 |
if( defined('POWERPRESS_OGG_VIDEO') && POWERPRESS_OGG_VIDEO ) |
| 571 |
return $content; // Ogg is handled as video |
| 572 |
} |
| 573 |
case 'oga': { |
| 574 |
|
| 575 |
$Settings = get_option('powerpress_general', []); |
| 576 |
if( !isset($Settings['player']) ) |
| 577 |
$Settings['player'] = 'mediaelement-audio'; |
| 578 |
|
| 579 |
switch( $Settings['player'] ) |
| 580 |
{ |
| 581 |
case 'mediaelement-audio': { |
| 582 |
$content .= powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData); |
| 583 |
}; break; |
| 584 |
case 'html5audio': |
| 585 |
default: { |
| 586 |
$content .= powerpressplayer_build_html5audio($media_url, $EpisodeData); |
| 587 |
} |
| 588 |
} |
| 589 |
}; break; |
| 590 |
} |
| 591 |
|
| 592 |
return $content; |
| 593 |
} |
| 594 |
|
| 595 |
/* |
| 596 |
Video Players - HTML5/Flash compliant video formats |
| 597 |
*/ |
| 598 |
function powerpressplayer_player_video($content, $media_url, $EpisodeData = array() ) |
| 599 |
{ |
| 600 |
$extension = powerpressplayer_get_extension($media_url); |
| 601 |
switch( $extension ) |
| 602 |
{ |
| 603 |
// OGG (audio or video) |
| 604 |
case 'ogg': { |
| 605 |
// Ogg special case, we treat as audio unless specified otherwise |
| 606 |
if( !defined('POWERPRESS_OGG_VIDEO') || POWERPRESS_OGG_VIDEO == false ) |
| 607 |
return $content; |
| 608 |
} |
| 609 |
// OGG Video / WebM |
| 610 |
case 'webm': |
| 611 |
case 'ogv': { // Use native player when possible |
| 612 |
$Settings = get_option('powerpress_general', []); |
| 613 |
if( !isset($Settings['video_player']) ) |
| 614 |
$Settings['video_player'] = 'mediaelement-video'; |
| 615 |
else if( !isset($Settings['video_player']) ) |
| 616 |
$Settings['video_player'] = 'html5video'; |
| 617 |
|
| 618 |
// HTML5 Video as an embed |
| 619 |
switch( $Settings['video_player'] ) |
| 620 |
{ |
| 621 |
case 'videojs-html5-video-player-for-wordpress': { |
| 622 |
$content .= powerpressplayer_build_videojs($media_url, $EpisodeData); |
| 623 |
}; break; |
| 624 |
case 'mediaelement-video': { |
| 625 |
$content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData); |
| 626 |
}; break; |
| 627 |
default: { |
| 628 |
$content .= powerpressplayer_build_html5video($media_url, $EpisodeData); |
| 629 |
}; break; |
| 630 |
} |
| 631 |
}; break; |
| 632 |
// H.264 |
| 633 |
case 'm4v': |
| 634 |
case 'mp4': |
| 635 |
// Okay, lets see if we we have a player setup to handle this |
| 636 |
{ |
| 637 |
$Settings = get_option('powerpress_general', []); |
| 638 |
if( !isset($Settings['video_player']) ) |
| 639 |
$Settings['video_player'] = 'mediaelement-video'; |
| 640 |
|
| 641 |
switch( $Settings['video_player'] ) |
| 642 |
{ |
| 643 |
case 'videojs-html5-video-player-for-wordpress': { |
| 644 |
$content .= powerpressplayer_build_videojs($media_url, $EpisodeData); |
| 645 |
}; break; |
| 646 |
case 'html5video': { |
| 647 |
// HTML5 Video as an embed |
| 648 |
$content .= powerpressplayer_build_html5video($media_url, $EpisodeData); |
| 649 |
}; break; |
| 650 |
case 'mediaelement-video': |
| 651 |
default: { |
| 652 |
$content .= powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData); |
| 653 |
}; break; |
| 654 |
} |
| 655 |
}; break; |
| 656 |
} |
| 657 |
|
| 658 |
return $content; |
| 659 |
} |
| 660 |
|
| 661 |
function powerpressplayer_player_other($content, $media_url, $EpisodeData = array() ) |
| 662 |
{ |
| 663 |
// Very important setting, we need to know if the media should auto play or not... |
| 664 |
$autoplay = false; // (default) |
| 665 |
if( isset($EpisodeData['autoplay']) && $EpisodeData['autoplay'] ) |
| 666 |
$autoplay = true; |
| 667 |
$cover_image = ''; |
| 668 |
if( !empty($EpisodeData['image']) ) |
| 669 |
$cover_image = $EpisodeData['image']; |
| 670 |
|
| 671 |
$extension = powerpressplayer_get_extension($media_url); |
| 672 |
|
| 673 |
switch( $extension ) |
| 674 |
{ |
| 675 |
// Common formats, we already handle them separately |
| 676 |
case 'mp3': |
| 677 |
case 'mp4': |
| 678 |
case 'm4v': |
| 679 |
case 'webm': |
| 680 |
case 'ogg': |
| 681 |
case 'ogv': |
| 682 |
case 'oga': |
| 683 |
case 'flv': |
| 684 |
case 'm4a': { |
| 685 |
|
| 686 |
return $content; |
| 687 |
}; break; |
| 688 |
case 'swf': // No more support for flash swf files |
| 689 |
case 'avi': |
| 690 |
case 'mpg': |
| 691 |
case 'mpeg': |
| 692 |
case 'm4b': |
| 693 |
case 'm4r': |
| 694 |
case 'qt': |
| 695 |
case 'mov': |
| 696 |
// Windows Media: |
| 697 |
case 'wma': |
| 698 |
case 'wmv': |
| 699 |
case 'asf': { // No more quicktime on multiple platforms, lets display an image with a link and hope for the best |
| 700 |
|
| 701 |
$content .= powerpressplayer_build_playimage($media_url, $EpisodeData, true); |
| 702 |
|
| 703 |
}; break; |
| 704 |
case 'pdf': { |
| 705 |
$content .= powerpressplayer_build_playimagepdf($media_url, true); |
| 706 |
}; break; |
| 707 |
case 'epub': { |
| 708 |
$content .= powerpressplayer_build_playimageepub($media_url, true); |
| 709 |
}; break; |
| 710 |
|
| 711 |
// Default, just display the play image. |
| 712 |
default: { |
| 713 |
|
| 714 |
$content .= powerpressplayer_build_playimage($media_url, $EpisodeData, true); |
| 715 |
|
| 716 |
}; break; |
| 717 |
} |
| 718 |
|
| 719 |
return $content; |
| 720 |
} |
| 721 |
|
| 722 |
function powerpressplayer_mediaobjects_video($content, $media_url, $EpisodeData = array()) |
| 723 |
{ |
| 724 |
$extension = powerpressplayer_get_extension($media_url); |
| 725 |
switch( $extension ) |
| 726 |
{ |
| 727 |
// OGG (audio or video) |
| 728 |
case 'ogg': { |
| 729 |
// Ogg special case, we treat as audio unless specified otherwise |
| 730 |
if( !defined('POWERPRESS_OGG_VIDEO') || POWERPRESS_OGG_VIDEO == false ) |
| 731 |
{ |
| 732 |
return $content; |
| 733 |
} |
| 734 |
} // let fall through and handle as video... |
| 735 |
case 'mp4': |
| 736 |
case 'm4v': |
| 737 |
case 'webm': |
| 738 |
case 'ogv': { |
| 739 |
$VideoObject = true; |
| 740 |
}; break; |
| 741 |
default: return $content; |
| 742 |
} |
| 743 |
|
| 744 |
return powerpressplayer_mediaobjects('video', $content, $media_url, $EpisodeData); |
| 745 |
} |
| 746 |
|
| 747 |
function powerpressplayer_mediaobjects_audio($content, $media_url, $EpisodeData = array()) |
| 748 |
{ |
| 749 |
$extension = powerpressplayer_get_extension($media_url); |
| 750 |
switch( $extension ) |
| 751 |
{ |
| 752 |
// OGG (audio or video) |
| 753 |
case 'ogg': { |
| 754 |
// Ogg special case, we treat as audio unless specified otherwise |
| 755 |
if( defined('POWERPRESS_OGG_VIDEO') && POWERPRESS_OGG_VIDEO ) |
| 756 |
{ |
| 757 |
return $content; |
| 758 |
} |
| 759 |
} // let fall through and handle as video... |
| 760 |
case 'mp3': |
| 761 |
case 'm4a': |
| 762 |
case 'oga': { |
| 763 |
$AudioObject = true; |
| 764 |
}; break; |
| 765 |
default: return $content; |
| 766 |
} |
| 767 |
|
| 768 |
return powerpressplayer_mediaobjects('audio', $content, $media_url, $EpisodeData); |
| 769 |
} |
| 770 |
|
| 771 |
function powerpressplayer_mediaobjects($type, $content, $media_url, $EpisodeData = array()) |
| 772 |
{ |
| 773 |
$GLOBALS['g_powerpress_complete_mediaobject'] = true; |
| 774 |
$addhtml = ''; |
| 775 |
$addhtml .= '<div itemscope itemtype="http://schema.org/'. ($type=='video'?'VideoObject':'AudioObject') .'">'.PHP_EOL_WEB; |
| 776 |
|
| 777 |
if( !empty($EpisodeData['title']) ) |
| 778 |
{ |
| 779 |
// We want to use the post title so ignore this for now |
| 780 |
} |
| 781 |
|
| 782 |
$media_url = powerpress_add_flag_to_redirect_url($media_url, 's'); // Search tag |
| 783 |
|
| 784 |
//var_dump($EpisodeData); |
| 785 |
$post_title = get_the_title(); |
| 786 |
if( !empty($post_title) ) { |
| 787 |
$addhtml .= '<meta itemprop="name" content="'. htmlspecialchars($post_title) .'" />'.PHP_EOL_WEB; |
| 788 |
} |
| 789 |
|
| 790 |
$addhtml .= '<meta itemprop="uploadDate" content="'. esc_attr( get_the_date('c') ) .'" />'.PHP_EOL_WEB; |
| 791 |
$addhtml .= '<meta itemprop="encodingFormat" content="'. powerpress_get_contenttype($media_url) .'" />'.PHP_EOL_WEB; |
| 792 |
if( !empty($EpisodeData['duration']) ) { |
| 793 |
$addhtml .= '<meta itemprop="duration" content="'. powerpress_iso8601_duration($EpisodeData['duration']) .'" />'.PHP_EOL_WEB; // http://en.wikipedia.org/wiki/ISO_8601#Durations |
| 794 |
} |
| 795 |
|
| 796 |
if( !empty($EpisodeData['subtitle']) ) { |
| 797 |
$addhtml .= '<meta itemprop="description" content="'. htmlspecialchars($EpisodeData['subtitle']) .'" />'.PHP_EOL_WEB; |
| 798 |
} |
| 799 |
else |
| 800 |
{ // Get the current post object... |
| 801 |
$post = get_post( ); |
| 802 |
if (!empty($post)) { |
| 803 |
// Get a subtitle from the post content or excerpt... |
| 804 |
$subtitle = strip_tags($post->post_excerpt); |
| 805 |
if (empty($subtitle)) { |
| 806 |
$subtitle = $post->post_content; |
| 807 |
$subtitle = strip_shortcodes($subtitle); |
| 808 |
$subtitle = str_replace(']]>', ']]>', $subtitle); |
| 809 |
$subtitle = strip_tags($subtitle); |
| 810 |
|
| 811 |
$length = (function_exists('mb_strlen') ? mb_strlen($subtitle) : strlen($subtitle)); |
| 812 |
if ($length > 250) { |
| 813 |
$subtitle = (function_exists('mb_substr') ? mb_substr($subtitle, 0, 250) : substr($subtitle, 0, 250)) . '...'; |
| 814 |
} |
| 815 |
} |
| 816 |
|
| 817 |
if (empty($subtitle)) |
| 818 |
$subtitle = $post_title; |
| 819 |
|
| 820 |
$addhtml .= '<meta itemprop="description" content="' . htmlspecialchars($subtitle) . '" />' . PHP_EOL_WEB; |
| 821 |
} |
| 822 |
} |
| 823 |
$addhtml .= '<meta itemprop="contentUrl" content="'. esc_url($media_url) .'" />'.PHP_EOL_WEB; |
| 824 |
|
| 825 |
// For thumbnail image, use the podcast artwork |
| 826 |
if( !empty($EpisodeData['image']) ) |
| 827 |
{ |
| 828 |
$addhtml .= '<meta itemprop="thumbnailURL" content="'. esc_url($EpisodeData['image']) .'" />'.PHP_EOL_WEB; |
| 829 |
} |
| 830 |
|
| 831 |
if( !empty($EpisodeData['size']) ) |
| 832 |
{ |
| 833 |
$addhtml .= '<meta itemprop="contentSize" content="'. number_format($EpisodeData['size'] / (1024 * 1024), 1) .'" />'.PHP_EOL_WEB; |
| 834 |
} |
| 835 |
|
| 836 |
// <meta itemprop="videoQuality" content="HD"/> |
| 837 |
if( !empty($EpisodeData['height']) && is_numeric($EpisodeData['height']) ) |
| 838 |
{ |
| 839 |
$addhtml .= '<meta itemprop="height" content="'. absint($EpisodeData['height']) .'" />'.PHP_EOL_WEB; |
| 840 |
} |
| 841 |
|
| 842 |
if( !empty($EpisodeData['width']) && is_numeric($EpisodeData['width']) ) |
| 843 |
{ |
| 844 |
$addhtml .= '<meta itemprop="width" content="'. absint($EpisodeData['width']) .'" />'.PHP_EOL_WEB; |
| 845 |
} |
| 846 |
|
| 847 |
return $content . $addhtml; |
| 848 |
} |
| 849 |
|
| 850 |
function powerpress_iso8601_duration($duration) |
| 851 |
{ |
| 852 |
$seconds = 0; |
| 853 |
$parts = array_map('absint', explode(':', $duration)); |
| 854 |
|
| 855 |
if( count($parts) == 3 ) |
| 856 |
$seconds = $parts[2] + ($parts[1]*60) + ($parts[0]*60*60); |
| 857 |
else if ( count($parts) == 2 ) |
| 858 |
$seconds = $parts[1] + ($parts[0]*60); |
| 859 |
else |
| 860 |
$seconds = $parts[0]; |
| 861 |
|
| 862 |
$hours = 0; |
| 863 |
$minutes = 0; |
| 864 |
if( $seconds >= (60*60) ) |
| 865 |
{ |
| 866 |
$hours = floor( $seconds /(60*60) ); |
| 867 |
$seconds -= (60*60*$hours); |
| 868 |
} |
| 869 |
if( $seconds >= (60) ) |
| 870 |
{ |
| 871 |
$minutes = floor( $seconds /(60) ); |
| 872 |
$seconds -= (60*$minutes); |
| 873 |
} |
| 874 |
|
| 875 |
if( $hours ) // X:XX:XX (readable) |
| 876 |
return sprintf('PT%dH%02dM%02dS', $hours, $minutes, $seconds); |
| 877 |
|
| 878 |
return sprintf('PT%dM%02dS', $minutes, $seconds); // X:XX or 0:XX (readable) |
| 879 |
} |
| 880 |
|
| 881 |
function powerpressplayer_mediaobjects_post($content, $media_url, $EpisodeData = array()) |
| 882 |
{ |
| 883 |
if( !empty($GLOBALS['g_powerpress_complete_mediaobject']) ) |
| 884 |
{ |
| 885 |
$content .= '</div>'; |
| 886 |
unset($GLOBALS['g_powerpress_complete_mediaobject']); |
| 887 |
} |
| 888 |
return $content; |
| 889 |
} |
| 890 |
|
| 891 |
|
| 892 |
add_filter('powerpress_player', 'powerpressplayer_player_audio', 10, 3); // Audio players (mp3) |
| 893 |
add_filter('powerpress_player', 'powerpressplayer_player_video', 10, 3); // Video players (mp4/m4v, webm, ogv) |
| 894 |
add_filter('powerpress_player', 'powerpressplayer_player_other', 10, 3); // Audio/Video flv, wmv, wma, oga, m4a and other non-standard media files |
| 895 |
|
| 896 |
|
| 897 |
/* |
| 898 |
Filters for media links, appear below the selected player |
| 899 |
*/ |
| 900 |
function powerpressplayer_link_download($content, $media_url, $ExtraData = array() ) |
| 901 |
{ |
| 902 |
$media_url = esc_url(powerpress_add_flag_to_redirect_url($media_url,'s')); |
| 903 |
$GeneralSettings = get_option('powerpress_general', []); |
| 904 |
if( !isset($GeneralSettings['podcast_link']) ) |
| 905 |
$GeneralSettings['podcast_link'] = 1; |
| 906 |
|
| 907 |
$player_links = ''; |
| 908 |
if( $GeneralSettings['podcast_link'] == 1 ) |
| 909 |
{ |
| 910 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a>".PHP_EOL_WEB; |
| 911 |
} |
| 912 |
else if( $GeneralSettings['podcast_link'] == 2 ) |
| 913 |
{ |
| 914 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($ExtraData['size']).") ".PHP_EOL_WEB; |
| 915 |
} |
| 916 |
else if( $GeneralSettings['podcast_link'] == 3 ) |
| 917 |
{ |
| 918 |
if( !empty($ExtraData['duration']) && ltrim($ExtraData['duration'], '0:') != '' ) |
| 919 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (". htmlspecialchars(POWERPRESS_DURATION_TEXT) .": " . powerpress_readable_duration($ExtraData['duration']) ." — ".powerpress_byte_size($ExtraData['size']).")".PHP_EOL_WEB; |
| 920 |
else |
| 921 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_d\" title=\"". POWERPRESS_DOWNLOAD_TEXT ."\" rel=\"nofollow\" download=\"". htmlspecialchars(basename($media_url)) ."\">". POWERPRESS_DOWNLOAD_TEXT ."</a> (".powerpress_byte_size($ExtraData['size']).")".PHP_EOL_WEB; |
| 922 |
} |
| 923 |
|
| 924 |
if( $player_links && !empty($content) ) |
| 925 |
$content .= ' '.POWERPRESS_LINK_SEPARATOR .' '; |
| 926 |
|
| 927 |
return $content . $player_links; |
| 928 |
} |
| 929 |
|
| 930 |
function powerpressplayer_link_pinw($content, $media_url, $ExtraData = array() ) |
| 931 |
{ |
| 932 |
$GeneralSettings = get_option('powerpress_general', []); |
| 933 |
if( !isset($GeneralSettings['player_function']) ) |
| 934 |
$GeneralSettings['player_function'] = 1; |
| 935 |
$is_pdf = (strtolower( substr($media_url, -3) ) == 'pdf' ); |
| 936 |
|
| 937 |
$player_links = ''; |
| 938 |
$media_url = htmlspecialchars($media_url); |
| 939 |
switch( $GeneralSettings['player_function'] ) |
| 940 |
{ |
| 941 |
case 1: // Play on page and new window |
| 942 |
case 3: // Play in new window only |
| 943 |
case 5: { // Play in page and new window |
| 944 |
if( $is_pdf ) |
| 945 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". __('Open in New Window', 'powerpress') ."\" rel=\"nofollow\">". __('Open in New Window', 'powerpress') ."</a>".PHP_EOL_WEB; |
| 946 |
else if( !empty($ExtraData['id']) && !empty($ExtraData['feed']) ) { |
| 947 |
$pinw_url = get_bloginfo('url') ."/?powerpress_pinw={$ExtraData['id']}-{$ExtraData['feed']}"; |
| 948 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" onclick=\"return powerpress_pinw('". esc_js($pinw_url) ."');\" rel=\"nofollow\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL_WEB; |
| 949 |
} |
| 950 |
else |
| 951 |
$player_links .= "<a href=\"{$media_url}\" class=\"powerpress_link_pinw\" target=\"_blank\" title=\"". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."\" rel=\"nofollow\">". POWERPRESS_PLAY_IN_NEW_WINDOW_TEXT ."</a>".PHP_EOL_WEB; |
| 952 |
}; break; |
| 953 |
}//end switch |
| 954 |
|
| 955 |
if( $player_links && !empty($content) ) |
| 956 |
$content .= ' '.POWERPRESS_LINK_SEPARATOR .' '; |
| 957 |
|
| 958 |
return $content . $player_links; |
| 959 |
} |
| 960 |
|
| 961 |
function powerpressplayer_embedable($media_url, $ExtraData = array()) |
| 962 |
{ |
| 963 |
if( empty($ExtraData['id']) || empty($ExtraData['feed']) ) |
| 964 |
return false; |
| 965 |
|
| 966 |
$extension = powerpressplayer_get_extension($media_url); |
| 967 |
$player = false; |
| 968 |
if( preg_match('/(mp3|m4a|oga|mp4|m4v|webm|ogg|ogv)/i', $extension ) ) |
| 969 |
{ |
| 970 |
$GeneralSettings = get_option('powerpress_general', []); |
| 971 |
if( empty($GeneralSettings['podcast_embed']) ) |
| 972 |
return false; |
| 973 |
if( empty($GeneralSettings['player']) || $GeneralSettings['player'] == 'flow-player-classic' ) |
| 974 |
$GeneralSettings['player'] = 'mediaelement-audio'; |
| 975 |
|
| 976 |
|
| 977 |
if( empty($GeneralSettings['video_player']) || $GeneralSettings['video_player'] == 'flow-player-classic' ) |
| 978 |
$GeneralSettings['video_player'] = 'mediaelement-video'; |
| 979 |
|
| 980 |
switch( $extension ) |
| 981 |
{ |
| 982 |
case 'mp3': |
| 983 |
case 'oga': |
| 984 |
case 'm4a': { |
| 985 |
if( in_array( $GeneralSettings['player'], array('mediaelement-audio', 'default', 'blubrryaudio', 'blubrrymodern') ) ) |
| 986 |
$player = $GeneralSettings['player']; |
| 987 |
}; break; |
| 988 |
case 'mp4': |
| 989 |
case 'm4v': |
| 990 |
case 'webm': |
| 991 |
case 'ogg': |
| 992 |
case 'ogv': { |
| 993 |
if( in_array( $GeneralSettings['video_player'], array('mediaelement-video', 'html5video') ) ) |
| 994 |
$player = $GeneralSettings['video_player']; |
| 995 |
}; break; |
| 996 |
} |
| 997 |
} |
| 998 |
|
| 999 |
return $player; |
| 1000 |
} |
| 1001 |
|
| 1002 |
function powerpressplayer_link_embed($content, $media_url, $ExtraData = array() ) |
| 1003 |
{ |
| 1004 |
$player_links = ''; |
| 1005 |
|
| 1006 |
$player = powerpressplayer_embedable($media_url, $ExtraData); |
| 1007 |
if( $player ) |
| 1008 |
{ |
| 1009 |
$player_links .= "<a href=\"#\" class=\"powerpress_link_e\" title=\"". htmlspecialchars(POWERPRESS_EMBED_TEXT) ."\" onclick=\"return powerpress_show_embed('{$ExtraData['id']}-{$ExtraData['feed']}');\" rel=\"nofollow\">". htmlspecialchars(POWERPRESS_EMBED_TEXT) ."</a>"; |
| 1010 |
} |
| 1011 |
|
| 1012 |
if( $player_links && !empty($content) ) |
| 1013 |
$content .= ' '.POWERPRESS_LINK_SEPARATOR .' '; |
| 1014 |
return $content . $player_links; |
| 1015 |
} |
| 1016 |
|
| 1017 |
function powerpressplayer_link_title($content, $media_url, $ExtraData = array() ) |
| 1018 |
{ |
| 1019 |
if( $content ) |
| 1020 |
{ |
| 1021 |
$extension = 'unknown'; |
| 1022 |
$parts = pathinfo($media_url); |
| 1023 |
if( $parts && isset($parts['extension']) ) |
| 1024 |
$extension = strtolower($parts['extension']); |
| 1025 |
|
| 1026 |
$prefix = ''; |
| 1027 |
if( $extension == 'pdf' ) { |
| 1028 |
$prefix = __('E-Book PDF', 'powerpress'); |
| 1029 |
$feed_safe = esc_html($ExtraData['feed']); |
| 1030 |
$suffix = (( $feed_safe === 'pdf' || $feed_safe === 'podcast') |
| 1031 |
? '' |
| 1032 |
: " ({$feed_safe})") . POWERPRESS_TEXT_SEPARATOR; |
| 1033 |
|
| 1034 |
$prefix .= $suffix; |
| 1035 |
} |
| 1036 |
else if( $ExtraData['feed'] != 'podcast' ) |
| 1037 |
$prefix .= esc_html(POWERPRESS_LINKS_TEXT) .' ('. esc_html($ExtraData['feed']) .')'. POWERPRESS_TEXT_SEPARATOR; |
| 1038 |
else |
| 1039 |
$prefix .= esc_html(POWERPRESS_LINKS_TEXT) . POWERPRESS_TEXT_SEPARATOR; |
| 1040 |
if( !empty($prefix) ) |
| 1041 |
$prefix .= ' '; |
| 1042 |
|
| 1043 |
$return = '<p class="powerpress_links powerpress_links_'. sanitize_html_class($extension) .'" style="margin-bottom: 1px !important;">'. $prefix . $content . '</p>'; |
| 1044 |
$player = powerpressplayer_embedable($media_url, $ExtraData); |
| 1045 |
if( $player ) |
| 1046 |
{ |
| 1047 |
if( !empty($ExtraData['embed']) ) |
| 1048 |
$iframe_src = $ExtraData['embed']; |
| 1049 |
else |
| 1050 |
$iframe_src = powerpress_generate_embed($player, $ExtraData); |
| 1051 |
|
| 1052 |
$id_safe = esc_attr($ExtraData['id']); |
| 1053 |
$feed_safe = esc_attr($ExtraData['feed']); |
| 1054 |
$return .= '<p class="powerpress_embed_box" id="powerpress_embed_'. "{$id_safe}-{$feed_safe}" .'" style="display: none;">'; |
| 1055 |
$return .= '<input id="powerpress_embed_'. "{$id_safe}-{$feed_safe}" .'_t" type="text" value="'. htmlspecialchars(str_replace("&", "&", $iframe_src)) .'" onclick="javascript: this.select();" onfocus="javascript: this.select();" style="width: 70%;" readOnly>'; |
| 1056 |
$return .= '</p>'; |
| 1057 |
} |
| 1058 |
return $return; |
| 1059 |
} |
| 1060 |
return ''; |
| 1061 |
} |
| 1062 |
|
| 1063 |
add_filter('powerpress_player_links', 'powerpressplayer_link_pinw', 30, 3); |
| 1064 |
add_filter('powerpress_player_links', 'powerpressplayer_link_download', 50, 3); |
| 1065 |
add_filter('powerpress_player_links', 'powerpressplayer_link_embed', 50, 3); |
| 1066 |
add_filter('powerpress_player_links', 'powerpressplayer_link_title', 1000, 3); |
| 1067 |
|
| 1068 |
/* |
| 1069 |
Do Play in new Window |
| 1070 |
*/ |
| 1071 |
function powerpress_do_pinw($pinw, $process_podpress) |
| 1072 |
{ |
| 1073 |
if( !WP_DEBUG && defined('POWERPRESS_FIX_WARNINGS') ) |
| 1074 |
{ |
| 1075 |
@error_reporting( E_ALL | E_CORE_ERROR | E_COMPILE_ERROR | E_PARSE ); |
| 1076 |
} |
| 1077 |
|
| 1078 |
list($post_id, $feed_slug) = explode('-', $pinw, 2); |
| 1079 |
$EpisodeData = powerpress_get_enclosure_data($post_id, $feed_slug); |
| 1080 |
|
| 1081 |
if( $EpisodeData == false && $process_podpress && $feed_slug == 'podcast' ) |
| 1082 |
{ |
| 1083 |
$EpisodeData = powerpress_get_enclosure_data_podpress($post_id); |
| 1084 |
} |
| 1085 |
|
| 1086 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1087 |
|
| 1088 |
echo '<!DOCTYPE html>'; // HTML5! |
| 1089 |
?> |
| 1090 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
| 1091 |
<head> |
| 1092 |
<meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" /> |
| 1093 |
<title><?php echo __('Blubrry PowerPress Player', 'powerpress'); ?></title> |
| 1094 |
<meta name="robots" content="noindex" /> |
| 1095 |
<?php |
| 1096 |
do_action('wp_powerpress_player_scripts'); |
| 1097 |
?> |
| 1098 |
<style type="text/css"> |
| 1099 |
body { font-size: 13px; font-family: Arial, Helvetica, sans-serif; /* width: 100%; min-height: 100%; } html { height: 100%; */ } |
| 1100 |
</style> |
| 1101 |
</head> |
| 1102 |
<body> |
| 1103 |
<div style="margin: 5px;"> |
| 1104 |
<?php |
| 1105 |
|
| 1106 |
if( !$EpisodeData ) |
| 1107 |
{ |
| 1108 |
echo '<p>'. __('Unable to retrieve media information.', 'powerpress') .'</p>'; |
| 1109 |
} |
| 1110 |
else if( !empty($GeneralSettings['premium_caps']) && !powerpress_premium_content_authorized($feed_slug) ) |
| 1111 |
{ |
| 1112 |
echo powerpress_premium_content_message($post_id, $feed_slug, $EpisodeData); |
| 1113 |
} |
| 1114 |
else if( !empty($EpisodeData['embed']) ) |
| 1115 |
{ |
| 1116 |
echo SanitizeEmbed($EpisodeData['embed']); |
| 1117 |
} |
| 1118 |
else // if( !isset($EpisodeData['no_player']) ) // Even if there is no player set, if the play in new window option is enabled then it should play here... |
| 1119 |
{ |
| 1120 |
echo apply_filters('powerpress_player', '', powerpress_add_flag_to_redirect_url($EpisodeData['url'], 'p'), array('feed'=>$feed_slug, 'autoplay'=>true, 'type'=>$EpisodeData['type']) ); |
| 1121 |
} |
| 1122 |
|
| 1123 |
wp_print_styles(); |
| 1124 |
wp_print_scripts(); |
| 1125 |
?> |
| 1126 |
</div> |
| 1127 |
</body> |
| 1128 |
</html> |
| 1129 |
<?php |
| 1130 |
exit; |
| 1131 |
} |
| 1132 |
|
| 1133 |
/* |
| 1134 |
Do embed |
| 1135 |
*/ |
| 1136 |
function powerpress_do_embed($player, $embed, $process_podpress) |
| 1137 |
{ |
| 1138 |
list($post_id, $feed_slug) = explode('-', $embed, 2); |
| 1139 |
$EpisodeData = powerpress_get_enclosure_data($post_id, $feed_slug); |
| 1140 |
|
| 1141 |
if( $EpisodeData == false && $process_podpress && $feed_slug == 'podcast' ) |
| 1142 |
{ |
| 1143 |
$EpisodeData = powerpress_get_enclosure_data_podpress($post_id); |
| 1144 |
} |
| 1145 |
|
| 1146 |
// Embeds are only available for the following players |
| 1147 |
do_powerpressplayer_embed($player, htmlspecialchars($EpisodeData['url']), $EpisodeData); |
| 1148 |
exit; |
| 1149 |
} |
| 1150 |
|
| 1151 |
/* |
| 1152 |
HTTML 5 Video Player |
| 1153 |
*/ |
| 1154 |
function powerpressplayer_build_html5video($media_url, $EpisodeData=array(), $embed = false ) |
| 1155 |
{ |
| 1156 |
$player_id = powerpressplayer_get_next_id(); |
| 1157 |
$cover_image = ''; |
| 1158 |
$player_width = 400; |
| 1159 |
$player_height = 225; |
| 1160 |
$autoplay = false; |
| 1161 |
// Global Settings |
| 1162 |
$Settings = get_option('powerpress_general', []); |
| 1163 |
if( !empty($Settings['player_width']) ) |
| 1164 |
$player_width = $Settings['player_width']; |
| 1165 |
if( !empty($Settings['player_height']) ) |
| 1166 |
$player_height = $Settings['player_height']; |
| 1167 |
if( !empty($Settings['poster_image']) ) |
| 1168 |
$cover_image = $Settings['poster_image']; |
| 1169 |
// Episode Settings |
| 1170 |
if( !empty($EpisodeData['image']) ) |
| 1171 |
$cover_image = $EpisodeData['image']; |
| 1172 |
if( !empty($EpisodeData['width']) ) |
| 1173 |
$player_width = $EpisodeData['width']; |
| 1174 |
if( !empty($EpisodeData['height']) ) |
| 1175 |
$player_height = $EpisodeData['height']; |
| 1176 |
if( !empty($EpisodeData['autoplay']) ) |
| 1177 |
$autoplay = true; |
| 1178 |
|
| 1179 |
$content = ''; |
| 1180 |
if( $embed ) |
| 1181 |
{ |
| 1182 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL_WEB; |
| 1183 |
$content .= '<video width="'. htmlspecialchars($player_width) .'" height="'. htmlspecialchars($player_height) .'" controls="controls"'; |
| 1184 |
if( $cover_image ) |
| 1185 |
$content .= ' poster="'. htmlspecialchars($cover_image) .'"'; |
| 1186 |
if( $autoplay ) |
| 1187 |
$content .= ' autoplay="autoplay"'; |
| 1188 |
else |
| 1189 |
$content .= ' preload="none"'; |
| 1190 |
|
| 1191 |
$content .= '>'.PHP_EOL_WEB; |
| 1192 |
$content_type = powerpress_get_contenttype($media_url); |
| 1193 |
$content .='<source src="'. htmlspecialchars($media_url) .'" type="'. $content_type .'" />'; |
| 1194 |
|
| 1195 |
if( !empty($EpisodeData['webm_src']) ) |
| 1196 |
{ |
| 1197 |
$EpisodeData['webm_src'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p'); |
| 1198 |
$content .='<source src="'. htmlspecialchars($EpisodeData['webm_src']) .'" type="video/webm" />'; |
| 1199 |
} |
| 1200 |
|
| 1201 |
$content .= powerpressplayer_build_playimage($media_url, $EpisodeData); |
| 1202 |
$content .= '</video>'.PHP_EOL_WEB; |
| 1203 |
$content .= '</div>'.PHP_EOL_WEB; |
| 1204 |
} |
| 1205 |
else |
| 1206 |
{ |
| 1207 |
|
| 1208 |
if( !$cover_image ) |
| 1209 |
$cover_image = powerpress_get_root_url() . 'black.png'; |
| 1210 |
$webm_src = ''; |
| 1211 |
if( !empty($EpisodeData['webm_src']) ) |
| 1212 |
$webm_src = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p'); |
| 1213 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'; |
| 1214 |
$content .= '<a href="'. htmlspecialchars($media_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="return powerpress_embed_html5v(\''.$player_id.'\',\''.htmlspecialchars($media_url).'\',\''. htmlspecialchars($player_width) .'\',\''. htmlspecialchars($player_height) .'\', \''. htmlspecialchars($webm_src) .'\');" target="_blank" style="position: relative;">'; |
| 1215 |
if( !empty($EpisodeData['custom_play_button']) ) // This currently does not apply |
| 1216 |
{ |
| 1217 |
$cover_image = $EpisodeData['custom_play_button']; |
| 1218 |
$Settings['poster_play_image'] = false; |
| 1219 |
$content .= '<img class="powerpress-player-poster" src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" />'; |
| 1220 |
} |
| 1221 |
else |
| 1222 |
{ |
| 1223 |
$content .= '<img class="powerpress-player-poster" src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="width: '. htmlspecialchars($player_width) .'px; height: '. htmlspecialchars($player_height) .'px;" />'; |
| 1224 |
} |
| 1225 |
|
| 1226 |
if(!isset($Settings['poster_play_image']) || $Settings['poster_play_image'] ) |
| 1227 |
{ |
| 1228 |
$play_image_button_url = powerpress_get_root_url() .'play_video.png'; |
| 1229 |
if( !empty($Settings['video_custom_play_button']) ) |
| 1230 |
$play_image_button_url = $Settings['video_custom_play_button']; |
| 1231 |
|
| 1232 |
$bottom = floor(($player_height/2)-30); |
| 1233 |
if( $bottom < 0 ) |
| 1234 |
$bottom = 0; |
| 1235 |
$left = floor(($player_width/2)-30); |
| 1236 |
if( $left < 0 ) |
| 1237 |
$left = 0; |
| 1238 |
$content .= '<img class="powerpress-player-play-image" src="'. htmlspecialchars($play_image_button_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="position: absolute; bottom: '. $bottom .'px; left: '. $left .'px; border:0;" />'; |
| 1239 |
} |
| 1240 |
$content .= '</a>'; |
| 1241 |
$content .= "</div>\n"; |
| 1242 |
|
| 1243 |
if( $autoplay ) |
| 1244 |
{ |
| 1245 |
$content .= '<script type="text/javascript"><!--'.PHP_EOL; |
| 1246 |
$content .= "powerpress_embed_html5v('{$player_id}','" . htmlspecialchars($media_url) . "'," . htmlspecialchars($player_width) . "," . htmlspecialchars($player_height) . ",'" . htmlspecialchars($webm_src) . "');\n"; |
| 1247 |
$content .= "//-->\n"; |
| 1248 |
$content .= "</script>\n"; |
| 1249 |
} |
| 1250 |
} |
| 1251 |
return $content; |
| 1252 |
} |
| 1253 |
|
| 1254 |
/* |
| 1255 |
MediaElement.js Video Player |
| 1256 |
*/ |
| 1257 |
function powerpressplayer_build_mediaelementvideo($media_url, $EpisodeData=array(), $embed = false ) |
| 1258 |
{ |
| 1259 |
if( !function_exists('wp_video_shortcode') ) |
| 1260 |
{ |
| 1261 |
// Return the HTML5 video shortcode instead |
| 1262 |
return powerpressplayer_build_html5video($media_url, $EpisodeData, $embed); |
| 1263 |
} |
| 1264 |
|
| 1265 |
$player_id = powerpressplayer_get_next_id(); |
| 1266 |
$cover_image = ''; |
| 1267 |
$player_width = ''; |
| 1268 |
$player_height = ''; |
| 1269 |
$autoplay = false; |
| 1270 |
// Global Settings |
| 1271 |
$Settings = get_option('powerpress_general', []); |
| 1272 |
if( !empty($Settings['player_width']) ) |
| 1273 |
$player_width = $Settings['player_width']; |
| 1274 |
if( !empty($Settings['player_height']) ) |
| 1275 |
$player_height = $Settings['player_height']; |
| 1276 |
if( !empty($Settings['poster_image']) ) |
| 1277 |
$cover_image = $Settings['poster_image']; |
| 1278 |
// Episode Settings |
| 1279 |
if( !empty($EpisodeData['image']) ) |
| 1280 |
$cover_image = $EpisodeData['image']; |
| 1281 |
if( !empty($EpisodeData['width']) ) |
| 1282 |
$player_width = $EpisodeData['width']; |
| 1283 |
if( !empty($EpisodeData['height']) ) |
| 1284 |
$player_height = $EpisodeData['height']; |
| 1285 |
if( !empty($EpisodeData['autoplay']) ) |
| 1286 |
$autoplay = true; |
| 1287 |
|
| 1288 |
if( $embed ) |
| 1289 |
{ |
| 1290 |
$player_height = '123'; |
| 1291 |
$player_width = '456'; |
| 1292 |
} |
| 1293 |
|
| 1294 |
|
| 1295 |
$content = ''; |
| 1296 |
|
| 1297 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL_WEB; |
| 1298 |
$attr = array('src'=> esc_url($media_url), 'poster'=>'', 'loop'=>'', 'autoplay'=>'', 'preload'=>'none'); // , 'width'=>'', 'height'=>''); |
| 1299 |
if( !empty($player_width) ) |
| 1300 |
$attr['width'] = absint($player_width); |
| 1301 |
if( !empty($player_height) ) |
| 1302 |
$attr['height'] = absint($player_height); |
| 1303 |
if( !empty($cover_image) ) |
| 1304 |
$attr['poster'] = esc_url($cover_image); |
| 1305 |
if( !empty($autoplay) ) |
| 1306 |
$attr['autoplay'] = 'on'; |
| 1307 |
if( !empty($EpisodeData['webm_src']) ) |
| 1308 |
$attr['webm'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p'); |
| 1309 |
|
| 1310 |
// Double check that WordPress is providing the shortcode... |
| 1311 |
global $shortcode_tags; |
| 1312 |
if( !defined('POWERPRESS_DO_SHORTCODE') ) { |
| 1313 |
$shortcode = wp_video_shortcode( $attr ); |
| 1314 |
} else { |
| 1315 |
$shortcode_value = '[video '; |
| 1316 |
foreach( $attr as $tag_name => $tag_value ) { |
| 1317 |
$shortcode_value .= ' '.esc_attr($tag_name).'="'. esc_attr($tag_value) .'"'; |
| 1318 |
} |
| 1319 |
$shortcode_value .= ']'; |
| 1320 |
$shortcode = do_shortcode($shortcode_value); |
| 1321 |
} |
| 1322 |
|
| 1323 |
|
| 1324 |
if( $embed ) |
| 1325 |
{ |
| 1326 |
$shortcode = str_replace( array('"123"', '"456"', '456px;'), array('"100%"', '"100%"', '100%;'), $shortcode); |
| 1327 |
} |
| 1328 |
$content .= $shortcode; |
| 1329 |
$content .= '</div>'.PHP_EOL_WEB; |
| 1330 |
return $content; |
| 1331 |
} |
| 1332 |
|
| 1333 |
/* |
| 1334 |
HTTML 5 Audio Player |
| 1335 |
*/ |
| 1336 |
function powerpressplayer_build_html5audio($media_url, $EpisodeData=array(), $embed = false ) |
| 1337 |
{ |
| 1338 |
$player_id = powerpressplayer_get_next_id(); |
| 1339 |
$autoplay = false; |
| 1340 |
// Episode Settings |
| 1341 |
if( !empty($EpisodeData['autoplay']) ) |
| 1342 |
$autoplay = true; |
| 1343 |
$content = ''; |
| 1344 |
if( $embed ) |
| 1345 |
{ |
| 1346 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL_WEB; |
| 1347 |
$content .= '<audio controls="controls"'; |
| 1348 |
$content .=' src="'. htmlspecialchars($media_url) .'"'; |
| 1349 |
if( $autoplay ) |
| 1350 |
$content .= ' autoplay="autoplay"'; |
| 1351 |
else |
| 1352 |
$content .= ' preload="none"'; |
| 1353 |
$content .= '>'.PHP_EOL_WEB; |
| 1354 |
|
| 1355 |
$content .= powerpressplayer_build_playimageaudio($media_url); |
| 1356 |
$content .= '</audio>'.PHP_EOL_WEB; |
| 1357 |
$content .= '</div>'.PHP_EOL_WEB; |
| 1358 |
} |
| 1359 |
else |
| 1360 |
{ |
| 1361 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1362 |
$cover_image = powerpress_get_root_url() . 'play_audio.png'; |
| 1363 |
$cover_image_default = $cover_image; |
| 1364 |
if( !empty($EpisodeData['custom_play_button']) ) |
| 1365 |
{ |
| 1366 |
$cover_image = $EpisodeData['custom_play_button']; |
| 1367 |
} |
| 1368 |
else if( !empty($GeneralSettings['audio_custom_play_button']) ) |
| 1369 |
{ |
| 1370 |
$cover_image = $GeneralSettings['audio_custom_play_button']; |
| 1371 |
} |
| 1372 |
|
| 1373 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'; |
| 1374 |
$content .= '<a href="'. htmlspecialchars($media_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" onclick="return powerpress_embed_html5a(\''.$player_id.'\',\''.htmlspecialchars($media_url).'\');" target="_blank">'; |
| 1375 |
if( $cover_image_default == $cover_image ) |
| 1376 |
$content .= '<img src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="border:0;" width="23px" height="24px" />'; |
| 1377 |
else |
| 1378 |
$content .= '<img src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="border:0;" />'; |
| 1379 |
$content .= '</a>'; |
| 1380 |
$content .= "</div>\n"; |
| 1381 |
|
| 1382 |
if( $autoplay ) |
| 1383 |
{ |
| 1384 |
$content .= '<script type="text/javascript"><!--'.PHP_EOL; |
| 1385 |
$content .= "powerpress_embed_html5a('{$player_id}','" . htmlspecialchars($media_url) . "');\n"; |
| 1386 |
$content .= "//-->\n"; |
| 1387 |
$content .= "</script>\n"; |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
return $content; |
| 1392 |
} |
| 1393 |
|
| 1394 |
|
| 1395 |
/* |
| 1396 |
*/ |
| 1397 |
function powerpressplayer_build_blubrryaudio($media_url, $EpisodeData=array(), $embed = false ) |
| 1398 |
{ |
| 1399 |
static $instance = 0; |
| 1400 |
$instance++; |
| 1401 |
|
| 1402 |
// media URL is all we need., as long as it's hosted at blubrry.com... |
| 1403 |
if( preg_match('/(content|protected|ins|mc)\.blubrry\.com/', $media_url) ) |
| 1404 |
{ |
| 1405 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1406 |
$playerSettings = get_option('powerpress_bplayer', []); |
| 1407 |
$hash = ''; |
| 1408 |
if(!empty($playerSettings)){ |
| 1409 |
if(is_string($playerSettings)){ |
| 1410 |
$decodedSettings = json_decode($playerSettings); |
| 1411 |
|
| 1412 |
if($decodedSettings && isset($decodedSettings->mode) && isset($decodedSettings->border) && isset($decodedSettings->progress)){ |
| 1413 |
$hash = 'mode-' . $decodedSettings->mode . '&border-' . $decodedSettings->border . '&progress-' . $decodedSettings->progress; |
| 1414 |
$hash = str_replace('#', '', $hash); // remove # symbol from hex colors |
| 1415 |
$hash = '#' . $hash; |
| 1416 |
|
| 1417 |
} else { |
| 1418 |
$hash = '#mode-Light&border-000000&progress-000000'; |
| 1419 |
} |
| 1420 |
} else { |
| 1421 |
$hash = '#mode-Light&border-000000&progress-000000'; |
| 1422 |
} |
| 1423 |
} |
| 1424 |
|
| 1425 |
if( !empty($EpisodeData['podcast_id']) ) { |
| 1426 |
$url = 'https://player.blubrry.com/?podcast_id='. intval($EpisodeData['podcast_id']) . '&media_url='. urlencode($media_url); |
| 1427 |
if ($GeneralSettings['player'] == 'blubrrymodern') { |
| 1428 |
$url .= '&modern=1'; |
| 1429 |
} |
| 1430 |
} else { |
| 1431 |
$url = 'https://player.blubrry.com/?media_url='. urlencode($media_url); |
| 1432 |
if ($GeneralSettings['player'] == 'blubrrymodern') { |
| 1433 |
$url .= '&modern=1'; |
| 1434 |
} |
| 1435 |
if( !empty($EpisodeData['id']) ) { |
| 1436 |
// Get permalink URL |
| 1437 |
$permalink = get_permalink( $EpisodeData['id'] ); |
| 1438 |
if( !empty($permalink) ) |
| 1439 |
$url.= '&podcast_link='. urlencode($permalink); |
| 1440 |
} |
| 1441 |
if( !empty($EpisodeData['itunes_image']) ) { |
| 1442 |
if(isset($GeneralSettings['bp_episode_image']) && $GeneralSettings['bp_episode_image'] != false) |
| 1443 |
$url.= '&artwork_url='. urlencode($EpisodeData['itunes_image']); |
| 1444 |
} |
| 1445 |
|
| 1446 |
} |
| 1447 |
$url = $url.$hash; |
| 1448 |
$playerID = sprintf('blubrryplayer-%d', $instance); |
| 1449 |
|
| 1450 |
$feedSlug = 'podcast'; |
| 1451 |
if( !empty($EpisodeData['feed']) ) |
| 1452 |
$feedSlug = $EpisodeData['feed']; |
| 1453 |
|
| 1454 |
if( empty($GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ] ) ) |
| 1455 |
$GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ] = $playerID; |
| 1456 |
|
| 1457 |
$iframeTitle = esc_attr( __('Blubrry Podcast Player', 'powerpress') ); |
| 1458 |
|
| 1459 |
// 'sample' signifies that this player is appearing inside the block editor and therefore requires the sandbox attribute to render |
| 1460 |
if (!empty($EpisodeData['sample'])) { |
| 1461 |
return '<iframe sandbox="allow-scripts allow-popups allow-forms" src="' . $url . '" scrolling="no" width="100%" height="165" frameborder="0" id="' . $playerID . '" class="blubrryplayer" title="' . $iframeTitle . '"></iframe>'; |
| 1462 |
} else { |
| 1463 |
return '<iframe src="' . $url . '" scrolling="no" width="100%" height="165" frameborder="0" id="' . $playerID . '" class="blubrryplayer" title="' . $iframeTitle . '"></iframe>'; |
| 1464 |
} |
| 1465 |
} |
| 1466 |
|
| 1467 |
return powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData, $embed); |
| 1468 |
} |
| 1469 |
|
| 1470 |
function powerpressplayer_build_blubrryaudio_by_id($playerSettings = false){ |
| 1471 |
$local = (strpos($_SERVER['HTTP_HOST'], '.local') !== false); |
| 1472 |
$playerUrl = ($local ? 'http://player.blubrry.local' : 'https://player.blubrry.com'); |
| 1473 |
$directory_episode_id = ($local ? 12559710 : 80155910); |
| 1474 |
$playerUrlSrc = $playerUrl . '/?id=' . $directory_episode_id . '&preview=1&cache=' . time(); |
| 1475 |
if(!empty($playerSettings)){ |
| 1476 |
$playerUrlSrc .= '#mode-' . str_replace('#', '', $playerSettings->mode) . '&border-' . str_replace('#', '', $playerSettings->border) . '&progress-' . str_replace('#', '', $playerSettings->progress); |
| 1477 |
} |
| 1478 |
|
| 1479 |
$iframeTitle = esc_attr(__('Modern Blubrry Player', 'powerpress')); |
| 1480 |
return '<iframe src="' . $playerUrlSrc . '" id="playeriframe" class="" scrolling="yes" width="100%" height="165px" frameborder="0" title="' . $iframeTitle . '"></iframe>'; |
| 1481 |
} |
| 1482 |
|
| 1483 |
/* |
| 1484 |
MediaElement.js Audio Player |
| 1485 |
*/ |
| 1486 |
function powerpressplayer_build_mediaelementaudio($media_url, $EpisodeData=array(), $embed = false ) |
| 1487 |
{ |
| 1488 |
if( !function_exists('wp_audio_shortcode') ) |
| 1489 |
{ |
| 1490 |
// Return the HTML5 audio shortcode instead |
| 1491 |
return powerpressplayer_build_html5audio($media_url, $EpisodeData, $embed); |
| 1492 |
} |
| 1493 |
|
| 1494 |
$player_id = powerpressplayer_get_next_id(); |
| 1495 |
$autoplay = false; |
| 1496 |
// Episode Settings |
| 1497 |
if( !empty($EpisodeData['autoplay']) ) |
| 1498 |
$autoplay = true; |
| 1499 |
$content = ''; |
| 1500 |
|
| 1501 |
|
| 1502 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'.PHP_EOL_WEB; |
| 1503 |
|
| 1504 |
$attr = array( |
| 1505 |
'src' => htmlspecialchars($media_url), |
| 1506 |
'loop' => '', // off |
| 1507 |
'autoplay' => ( $autoplay ?'on':''), |
| 1508 |
'preload' => 'none' |
| 1509 |
); |
| 1510 |
|
| 1511 |
// Double check that WordPress is providing the shortcode... |
| 1512 |
global $shortcode_tags; |
| 1513 |
$player = ''; |
| 1514 |
if( !defined('POWERPRESS_DO_SHORTCODE') ) { // && !empty($shortcode_tags['audio']) && is_string($shortcode_tags['audio']) && $shortcode_tags['audio'] == 'wp_audio_shortcode' ) { |
| 1515 |
$player .= wp_audio_shortcode( $attr ); |
| 1516 |
} else { |
| 1517 |
$player .= do_shortcode( '[audio src="'. esc_attr($media_url) .'" autoplay="'. ( $autoplay ?'on':'') .'" loop="" preload="none"]'); |
| 1518 |
} |
| 1519 |
|
| 1520 |
// Get the DIV id for this element |
| 1521 |
$feedSlug = 'podcast'; |
| 1522 |
if( !empty($EpisodeData['feed']) ) |
| 1523 |
$feedSlug = $EpisodeData['feed']; |
| 1524 |
|
| 1525 |
if( empty($GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ]) && preg_match('/\<audio.*id="([^"]*)"/i', $player, $matches) ) { |
| 1526 |
$GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ] = $matches[1]; |
| 1527 |
} |
| 1528 |
|
| 1529 |
$content .= $player .'</div>'.PHP_EOL_WEB; |
| 1530 |
return $content; |
| 1531 |
} |
| 1532 |
|
| 1533 |
|
| 1534 |
function powerpressplayer_build_playimage($media_url, $EpisodeData = array(), $include_div = false) |
| 1535 |
{ |
| 1536 |
$content = ''; |
| 1537 |
$autoplay = false; |
| 1538 |
if( !empty($EpisodeData['autoplay']) && $EpisodeData['autoplay'] ) |
| 1539 |
$autoplay = true; |
| 1540 |
$player_width = 400; |
| 1541 |
$player_height = 225; |
| 1542 |
$cover_image = ''; |
| 1543 |
|
| 1544 |
// Global settings |
| 1545 |
$Settings = get_option('powerpress_general', []); |
| 1546 |
if( !empty($Settings['player_width']) ) |
| 1547 |
$player_width = absint($Settings['player_width']); |
| 1548 |
if( !empty($Settings['player_height']) ) |
| 1549 |
$player_height = absint($Settings['player_height']); |
| 1550 |
if( !empty($Settings['poster_image']) ) |
| 1551 |
$cover_image = esc_url_raw($Settings['poster_image']); |
| 1552 |
|
| 1553 |
// episode settings |
| 1554 |
if( !empty($EpisodeData['width']) ) |
| 1555 |
$player_width = absint($EpisodeData['width']); |
| 1556 |
if( !empty($EpisodeData['height']) ) |
| 1557 |
$player_height = absint($EpisodeData['height']); |
| 1558 |
if( !empty($EpisodeData['image']) ) |
| 1559 |
$cover_image = esc_url_raw($EpisodeData['image']); |
| 1560 |
|
| 1561 |
if( !$cover_image ) |
| 1562 |
$cover_image = powerpress_get_root_url() . 'black.png'; |
| 1563 |
|
| 1564 |
if( $include_div ) |
| 1565 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">'; |
| 1566 |
$content .= '<a href="'. esc_url($media_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" target="_blank" style="position: relative;">'; |
| 1567 |
$content .= '<img src="'. esc_url($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="width: '. absint($player_width) .'px; height: '. absint($player_height) .'px;" />'; |
| 1568 |
if(!isset($Settings['poster_play_image']) || $Settings['poster_play_image'] ) |
| 1569 |
{ |
| 1570 |
$play_image_button_url = powerpress_get_root_url() .'play_video.png'; |
| 1571 |
if( !empty($Settings['video_custom_play_button']) ) |
| 1572 |
$play_image_button_url = esc_url_raw($Settings['video_custom_play_button']); |
| 1573 |
|
| 1574 |
$bottom = floor(($player_height/2)-30); |
| 1575 |
if( $bottom < 0 ) |
| 1576 |
$bottom = 0; |
| 1577 |
$left = floor(($player_width/2)-30); |
| 1578 |
if( $left < 0 ) |
| 1579 |
$left = 0; |
| 1580 |
$content .= '<img src="'. esc_url($play_image_button_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="position: absolute; bottom:'. $bottom .'px; left:'. $left .'px; border:0;" />'; |
| 1581 |
} |
| 1582 |
$content .= '</a>'; |
| 1583 |
if( $include_div ) |
| 1584 |
$content .= "</div>\n"; |
| 1585 |
return $content; |
| 1586 |
} |
| 1587 |
|
| 1588 |
function powerpressplayer_build_playimageaudio($media_url, $include_div = false) |
| 1589 |
{ |
| 1590 |
$content = ''; |
| 1591 |
$cover_image = powerpress_get_root_url() . 'play_audio.png'; |
| 1592 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1593 |
if( !empty($GeneralSettings['custom_play_button']) ) |
| 1594 |
$cover_image = $GeneralSettings['custom_play_button']; |
| 1595 |
|
| 1596 |
if( $include_div ) |
| 1597 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">'; |
| 1598 |
$content .= '<a href="'. htmlspecialchars($media_url) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" target="_blank">'; |
| 1599 |
$content .= '<img src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_PLAY_TEXT) .'" style="border:0;" />'; |
| 1600 |
$content .= '</a>'; |
| 1601 |
if( $include_div ) |
| 1602 |
$content .= "</div>\n"; |
| 1603 |
return $content; |
| 1604 |
} |
| 1605 |
|
| 1606 |
function powerpressplayer_build_playimagepdf($media_url, $include_div = false) |
| 1607 |
{ |
| 1608 |
$content = ''; |
| 1609 |
$cover_image = powerpress_get_root_url() . 'play_pdf.png'; |
| 1610 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1611 |
if( !empty($GeneralSettings['pdf_custom_play_button']) ) |
| 1612 |
$cover_image = $GeneralSettings['pdf_custom_play_button']; |
| 1613 |
|
| 1614 |
if( $include_div ) |
| 1615 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">'; |
| 1616 |
$content .= '<a href="'. htmlspecialchars($media_url) .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" target="_blank">'; |
| 1617 |
$content .= '<img src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" style="border:0;" />'; |
| 1618 |
$content .= '</a>'; |
| 1619 |
if( $include_div ) |
| 1620 |
$content .= "</div>\n"; |
| 1621 |
return $content; |
| 1622 |
} |
| 1623 |
|
| 1624 |
function powerpressplayer_build_playimageepub($media_url, $include_div = false) |
| 1625 |
{ |
| 1626 |
$content = ''; |
| 1627 |
$cover_image = powerpress_get_root_url() . 'play_epub.png'; |
| 1628 |
$GeneralSettings = get_option('powerpress_general', []); |
| 1629 |
if( !empty($GeneralSettings['epub_custom_play_button']) ) |
| 1630 |
$cover_image = $GeneralSettings['epub_custom_play_button']; |
| 1631 |
|
| 1632 |
if( $include_div ) |
| 1633 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. powerpressplayer_get_next_id() .'">'; |
| 1634 |
$content .= '<a href="'. htmlspecialchars($media_url) .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" target="_blank">'; |
| 1635 |
$content .= '<img src="'. htmlspecialchars($cover_image) .'" title="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" alt="'. htmlspecialchars(POWERPRESS_READ_TEXT) .'" style="border:0;" />'; |
| 1636 |
$content .= '</a>'; |
| 1637 |
if( $include_div ) |
| 1638 |
$content .= "</div>\n"; |
| 1639 |
return $content; |
| 1640 |
} |
| 1641 |
|
| 1642 |
/* |
| 1643 |
VideoJS for PowerPress 4.0 |
| 1644 |
*/ |
| 1645 |
function powerpressplayer_build_videojs($media_url, $EpisodeData = array()) |
| 1646 |
{ |
| 1647 |
$content = ''; |
| 1648 |
if( function_exists('add_videojs_header') ) |
| 1649 |
{ |
| 1650 |
// Global Settings |
| 1651 |
$Settings = get_option('powerpress_general', []); |
| 1652 |
|
| 1653 |
$player_id = powerpressplayer_get_next_id(); |
| 1654 |
$cover_image = ''; |
| 1655 |
$player_width = 400; |
| 1656 |
$player_height = 225; |
| 1657 |
$autoplay = false; |
| 1658 |
|
| 1659 |
if( !empty($Settings['player_width']) ) |
| 1660 |
$player_width = $Settings['player_width']; |
| 1661 |
if( !empty($Settings['player_height']) ) |
| 1662 |
$player_height = $Settings['player_height']; |
| 1663 |
if( !empty($Settings['poster_image']) ) |
| 1664 |
$cover_image = $Settings['poster_image']; |
| 1665 |
|
| 1666 |
// Episode Settings |
| 1667 |
if( !empty($EpisodeData['image']) ) |
| 1668 |
$cover_image = $EpisodeData['image']; |
| 1669 |
if( !empty($EpisodeData['width']) ) |
| 1670 |
$player_width = $EpisodeData['width']; |
| 1671 |
if( !empty($EpisodeData['height']) ) |
| 1672 |
$player_height = $EpisodeData['height']; |
| 1673 |
if( !empty($EpisodeData['autoplay']) ) |
| 1674 |
$autoplay = true; |
| 1675 |
|
| 1676 |
// Poster image supplied |
| 1677 |
$poster_attribute = ''; |
| 1678 |
if ($cover_image) |
| 1679 |
$poster_attribute = ' poster="'.htmlspecialchars($cover_image).'"'; |
| 1680 |
|
| 1681 |
// Autoplay the video? |
| 1682 |
$autoplay_attribute = ''; |
| 1683 |
if ( $autoplay ) |
| 1684 |
$autoplay_attribute = ' autoplay'; |
| 1685 |
|
| 1686 |
// We never do pre-poading for podcasting as it inflates statistics |
| 1687 |
|
| 1688 |
// Is there a custom class? |
| 1689 |
$class = ''; |
| 1690 |
if ( !empty($Settings['videojs_css_class']) ) |
| 1691 |
$class = ' '. htmlspecialchars($Settings['videojs_css_class']); |
| 1692 |
|
| 1693 |
$content .= '<div class="powerpress_player" id="powerpress_player_'. $player_id .'">'; |
| 1694 |
|
| 1695 |
$content .= '<video id="videojs_player_'. $player_id .'" class="video-js vjs-default-skin'. $class .'" width="'. htmlspecialchars($player_width) .'" height="'. htmlspecialchars($player_height) .'"'. $poster_attribute .' controls '. $autoplay_attribute .' data-setup="{}">'; |
| 1696 |
|
| 1697 |
$content_type = powerpress_get_contenttype($media_url); |
| 1698 |
if( $content_type == 'video/x-m4v' ) |
| 1699 |
$content_type = 'video/mp4'; // Mp4 |
| 1700 |
$content .='<source src="'. htmlspecialchars($media_url) .'" type="'. $content_type .'" />'; |
| 1701 |
|
| 1702 |
if( !empty($EpisodeData['webm_src']) ) |
| 1703 |
{ |
| 1704 |
$EpisodeData['webm_src'] = powerpress_add_flag_to_redirect_url($EpisodeData['webm_src'], 'p'); |
| 1705 |
$content .='<source src="'. htmlspecialchars($EpisodeData['webm_src']) .'" type="video/webm; codecs="vp8, vorbis" />'; |
| 1706 |
} |
| 1707 |
|
| 1708 |
$content .= '</video>'; |
| 1709 |
$content .= "</div>\n"; |
| 1710 |
} |
| 1711 |
else |
| 1712 |
{ |
| 1713 |
$content .= powerpressplayer_build_html5video($media_url, $EpisodeData); |
| 1714 |
} |
| 1715 |
|
| 1716 |
return $content; |
| 1717 |
} |
| 1718 |
|
| 1719 |
function powerpress_shortcode_skipto($attributes, $content = null) |
| 1720 |
{ |
| 1721 |
$pos = ''; |
| 1722 |
if( isset($attributes['time']) ) { |
| 1723 |
$pos = $attributes['time']; |
| 1724 |
} else if (isset($attributes['timestamp'])) { |
| 1725 |
$pos = $attributes['timestamp']; |
| 1726 |
} else if (isset($attributes['ts'])) { |
| 1727 |
$pos = $attributes['ts']; |
| 1728 |
} |
| 1729 |
|
| 1730 |
// only allow digits, periods (for floats) and colons to prevent XSS |
| 1731 |
if (!preg_match('/^[\d:.]+$/', $pos)) { |
| 1732 |
$pos = ''; |
| 1733 |
} |
| 1734 |
|
| 1735 |
if( empty($pos) ) { |
| 1736 |
return $content; |
| 1737 |
} |
| 1738 |
|
| 1739 |
// Prepare data |
| 1740 |
$timeInSeconds = powerpress_raw_duration($pos); |
| 1741 |
$readableTime = $pos; |
| 1742 |
if( strpos($readableTime, ':') === false ) // If the time they entered is not in colon format, lets use a readable format with the colons... |
| 1743 |
$readableTime = powerpress_readable_duration($timeInSeconds); |
| 1744 |
if( empty($content) ) |
| 1745 |
$content = $readableTime; |
| 1746 |
|
| 1747 |
// We can't add players to feeds |
| 1748 |
if( is_feed() ) { |
| 1749 |
if( empty($content) ) // If no custom label is set, lets use this timestamp in a readable format with colons |
| 1750 |
return $readableTime; |
| 1751 |
return $content; |
| 1752 |
} |
| 1753 |
|
| 1754 |
$feedSlug = 'podcast'; |
| 1755 |
if( !empty($attributes['channel']) ) |
| 1756 |
$feedSlug = $attributes['channel']; |
| 1757 |
|
| 1758 |
if( empty($GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ]) ) { |
| 1759 |
if( function_exists('qed_stt_shortcode') ) { // If using the skip to timestamp plugin, we will fall back to it since we are not handling the player... |
| 1760 |
return qed_stt_shortcode($attributes, $content); |
| 1761 |
} |
| 1762 |
|
| 1763 |
return $content; |
| 1764 |
} |
| 1765 |
|
| 1766 |
$playerID = $GLOBALS['powerpress_skipto_player'][ get_the_ID() ][ $feedSlug ]; |
| 1767 |
return '<a title="'. esc_attr(sprintf(__('Skip to %s', 'powerpress'), $readableTime)) .'" href="'. get_permalink() .'#" onclick="return powerpress_stp(event);" class="powerpress-skip-a" data-pp-stp="'. $timeInSeconds .'" data-pp-player="'. $playerID .'">'. $content .'</a>'; |
| 1768 |
} |
| 1769 |
|
| 1770 |
|
| 1771 |
|