| @@ -56,8 +56,12 @@ | ||
| 56 | 56 | 'skip_confirmation' => '', 'url_to_storage_source' => '', |
| 57 | 57 | 'count_against_user' => '', 'check_user' => '', |
| 58 | 58 | 'get_streamer_json' => '', 'get_streamer_array' => ''), $attr); |
| 59 | 59 | |
| 60 | + //260811 Validate download key. | |
| 61 | + if(!in_array($attr['download_key'], array('ip-forever', 'universal'), true)) | |
| 62 | + $attr['download_key'] = filter_var($attr['download_key'], FILTER_VALIDATE_BOOLEAN) ? 'yes' : ''; | |
| 63 | + | |
| 60 | 64 | foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 61 | 65 | do_action('ws_plugin__s2member_before_sc_get_file_after_shortcode_atts', get_defined_vars()); |
| 62 | 66 | unset($__refs, $__v); // Housekeeping. |
| 63 | 67 | |
| @@ -128,9 +132,10 @@ | ||
| 128 | 132 | 'player_width' => '480', 'player_height' => '270', 'player_aspectratio' => '', |
| 129 | 133 | |
| 130 | 134 | // Playback |
| 131 | 135 | 'player_autostart' => 'no', 'player_fallback' => 'yes', 'player_mute' => 'no', |
| 132 | - 'player_primary' => (($attr['player'] === 'jw-player-v7' || $attr['player'] === 'jw-player-v6') ? 'html5' : 'flash'), | |
| 136 | + //260920.1835 Avoid reading the optional player attribute before shortcode defaults have been applied. | |
| 137 | + 'player_primary' => ((isset($attr['player']) && ($attr['player'] === 'jw-player-v7' || $attr['player'] === 'jw-player-v6')) ? 'html5' : 'flash'), | |
| 133 | 138 | 'player_repeat' => 'no', 'player_startparam' => '', // `startparam` seems to be JW Player v6 only. |
| 134 | 139 | |
| 135 | 140 | // Advanced Option Blocks |
| 136 | 141 | 'player_option_blocks' => ''), $attr); |
| @@ -136,8 +141,12 @@ | ||
| 136 | 141 | 'player_option_blocks' => ''), $attr); |
| 137 | 142 | |
| 138 | 143 | $attr['download'] = (!empty($attr['file_download'])) ? $attr['file_download'] : $attr['download']; |
| 139 | 144 | |
| 145 | + //260811 Validate download key. | |
| 146 | + if(!in_array($attr['download_key'], array('ip-forever', 'universal'), true)) | |
| 147 | + $attr['download_key'] = filter_var($attr['download_key'], FILTER_VALIDATE_BOOLEAN) ? 'yes' : ''; | |
| 148 | + | |
| 140 | 149 | foreach(array_keys(get_defined_vars()) as $__v) $__refs[$__v] =& $$__v; |
| 141 | 150 | do_action('ws_plugin__s2member_before_sc_get_stream_after_shortcode_atts', get_defined_vars()); |
| 142 | 151 | unset($__refs, $__v); // Housekeeping. |
| 143 | 152 | |
| @@ -166,9 +175,9 @@ | ||
| 166 | 175 | if(!preg_match('/^(?:[0-9]+|[0-9]+(?:\.[0-9]+)?%)$/D', (string)$attr['player_width'])) |
| 167 | 176 | $attr['player_width'] = '480'; |
| 168 | 177 | if(!preg_match('/^(?:[0-9]+|[0-9]+(?:\.[0-9]+)?%)$/D', (string)$attr['player_height'])) |
| 169 | 178 | $attr['player_height'] = '270'; |
| 170 | - if($attr['player_aspectratio'] && (!preg_match('/^([0-9]+):([0-9]+)$/D', (string)$attr['player_aspectratio'], $_player_aspectratio) || !(integer)$_player_aspectratio[1] || !(integer)$_player_aspectratio[2])) | |
| 179 | + if($attr['player_aspectratio'] && (!preg_match('/^([0-9]+):([0-9]+)$/D', (string)$attr['player_aspectratio'], $_player_aspectratio) || !(int)$_player_aspectratio[1] || !(int)$_player_aspectratio[2])) | |
| 171 | 180 | $attr['player_aspectratio'] = ''; |
| 172 | 181 | unset($_player_aspectratio); //260805 Housekeeping. |
| 173 | 182 | |
| 174 | 183 | //260805 Resolution tokens become filename suffixes and labels, so discard tokens outside the supported token format. |
| @@ -250,10 +259,10 @@ | ||
| 250 | 259 | $player_resolution_aspect_ratio_w = 16; // Default aspect ratio width. |
| 251 | 260 | $player_resolution_aspect_ratio_h = 9; // Default aspect ratio in height. |
| 252 | 261 | if($attr['player_aspectratio'] && preg_match('/^[0-9]+\:[0-9]+$/', $attr['player_aspectratio'])) |
| 253 | 262 | list($player_resolution_aspect_ratio_w, $player_resolution_aspect_ratio_h) = explode(':', $attr['player_aspectratio']); |
| 254 | - $player_resolution_aspect_ratio_w = (integer)$player_resolution_aspect_ratio_w; // Force integer value. | |
| 255 | - $player_resolution_aspect_ratio_h = (integer)$player_resolution_aspect_ratio_h; // Force integer value. | |
| 263 | + $player_resolution_aspect_ratio_w = (int)$player_resolution_aspect_ratio_w; // Force integer value. | |
| 264 | + $player_resolution_aspect_ratio_h = (int)$player_resolution_aspect_ratio_h; // Force integer value. | |
| 256 | 265 | |
| 257 | 266 | // See: <http://wsharks.com/1yzjAl6> and <http://wsharks.com/1yzkhea> regarging the SMIL bitrate hints given here. |
| 258 | 267 | $player_resolution_bitrates = array(2160 => '35000000', 1440 => '10000000', 1080 => '8000000', 720 => '5000000', 640 => '2500001', 480 => '2500000', 360 => '1000000', 320 => '999999', 240 => '500000', 180 => '300000'); |
| 259 | 268 | $player_resolution_bitrates = apply_filters('ws_plugin__s2member_sc_get_stream_resolution_bitrates', $player_resolution_bitrates, get_defined_vars()); |
| @@ -295,9 +304,9 @@ | ||
| 295 | 304 | $_player_source = array('file' => $player_resolution_sources_smil_file_url); |
| 296 | 305 | if($_is_first_file_download_url) $_player_source['default'] = 'true'; |
| 297 | 306 | $player_sources[] = $_player_source; |
| 298 | 307 | } |
| 299 | - $_file_download_url['smil']['height'] = (integer)$_file_download_url_label; // e.g., `720p-HD` becomes `720`. | |
| 308 | + $_file_download_url['smil']['height'] = (int)$_file_download_url_label; // e.g., `720p-HD` becomes `720`. | |
| 300 | 309 | if(!$_file_download_url['smil']['height']) $_file_download_url['smil']['height'] = 720; // Use a default height if invalid. |
| 301 | 310 | $_file_download_url['smil']['width'] = ceil(($_file_download_url['smil']['height'] / $player_resolution_aspect_ratio_h) * $player_resolution_aspect_ratio_w); |
| 302 | 311 | |
| 303 | 312 | $_file_download_url['smil']['system-bitrate'] = '1'; // Default value. |
| @@ -354,10 +363,10 @@ | ||
| 354 | 363 | |
| 355 | 364 | //260805 Parse flexible attributes as data and substitute only values encoded for their exact output contexts. |
| 356 | 365 | $_player_tracks = self::sc_get_stream_json_data($attr['player_tracks'], 'array'); |
| 357 | 366 | $_player_option_blocks = self::sc_get_stream_json_data($attr['player_option_blocks'], 'object-properties'); |
| 358 | - $_player_width = (strpos($attr['player_width'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_width']) : (string)(integer)$attr['player_width']; | |
| 359 | - $_player_height = $attr['player_aspectratio'] ? '""' : ((strpos($attr['player_height'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_height']) : (string)(integer)$attr['player_height']); | |
| 367 | + $_player_width = (strpos($attr['player_width'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_width']) : (string)(int)$attr['player_width']; | |
| 368 | + $_player_height = $attr['player_aspectratio'] ? '""' : ((strpos($attr['player_height'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_height']) : (string)(int)$attr['player_height']); | |
| 360 | 369 | if(!is_string($_player_width)) $_player_width = '480'; |
| 361 | 370 | if(!is_string($_player_height)) $_player_height = '270'; |
| 362 | 371 | |
| 363 | 372 | //260805 strtr() replaces literal placeholders without reprocessing placeholder-like text inside generated values. |
| @@ -400,10 +409,10 @@ | ||
| 400 | 409 | $player_resolution_aspect_ratio_w = 16; // Default aspect ratio width. |
| 401 | 410 | $player_resolution_aspect_ratio_h = 9; // Default aspect ratio in height. |
| 402 | 411 | if($attr['player_aspectratio'] && preg_match('/^[0-9]+\:[0-9]+$/', $attr['player_aspectratio'])) |
| 403 | 412 | list($player_resolution_aspect_ratio_w, $player_resolution_aspect_ratio_h) = explode(':', $attr['player_aspectratio']); |
| 404 | - $player_resolution_aspect_ratio_w = (integer)$player_resolution_aspect_ratio_w; // Force integer value. | |
| 405 | - $player_resolution_aspect_ratio_h = (integer)$player_resolution_aspect_ratio_h; // Force integer value. | |
| 413 | + $player_resolution_aspect_ratio_w = (int)$player_resolution_aspect_ratio_w; // Force integer value. | |
| 414 | + $player_resolution_aspect_ratio_h = (int)$player_resolution_aspect_ratio_h; // Force integer value. | |
| 406 | 415 | |
| 407 | 416 | // See: <http://wsharks.com/1yzjAl6> and <http://wsharks.com/1yzkhea> regarging the SMIL bitrate hints given here. |
| 408 | 417 | $player_resolution_bitrates = array(2160 => '35000000', 1440 => '10000000', 1080 => '8000000', 720 => '5000000', 640 => '2500001', 480 => '2500000', 360 => '1000000', 320 => '999999', 240 => '500000', 180 => '300000'); |
| 409 | 418 | $player_resolution_bitrates = apply_filters('ws_plugin__s2member_sc_get_stream_resolution_bitrates', $player_resolution_bitrates, get_defined_vars()); |
| @@ -445,9 +454,9 @@ | ||
| 445 | 454 | $_player_source = array('file' => $player_resolution_sources_smil_file_url); |
| 446 | 455 | if($_is_first_file_download_url) $_player_source['default'] = 'true'; |
| 447 | 456 | $player_sources[] = $_player_source; |
| 448 | 457 | } |
| 449 | - $_file_download_url['smil']['height'] = (integer)$_file_download_url_label; // e.g., `720p-HD` becomes `720`. | |
| 458 | + $_file_download_url['smil']['height'] = (int)$_file_download_url_label; // e.g., `720p-HD` becomes `720`. | |
| 450 | 459 | if(!$_file_download_url['smil']['height']) $_file_download_url['smil']['height'] = 720; // Use a default height if invalid. |
| 451 | 460 | $_file_download_url['smil']['width'] = ceil(($_file_download_url['smil']['height'] / $player_resolution_aspect_ratio_h) * $player_resolution_aspect_ratio_w); |
| 452 | 461 | |
| 453 | 462 | $_file_download_url['smil']['system-bitrate'] = '1'; // Default value. |
| @@ -504,10 +513,10 @@ | ||
| 504 | 513 | |
| 505 | 514 | //260805 Parse flexible attributes as data and substitute only values encoded for their exact output contexts. |
| 506 | 515 | $_player_captions = self::sc_get_stream_json_data($attr['player_captions'], 'array'); |
| 507 | 516 | $_player_option_blocks = self::sc_get_stream_json_data($attr['player_option_blocks'], 'object-properties'); |
| 508 | - $_player_width = (strpos($attr['player_width'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_width']) : (string)(integer)$attr['player_width']; | |
| 509 | - $_player_height = $attr['player_aspectratio'] ? '""' : ((strpos($attr['player_height'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_height']) : (string)(integer)$attr['player_height']); | |
| 517 | + $_player_width = (strpos($attr['player_width'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_width']) : (string)(int)$attr['player_width']; | |
| 518 | + $_player_height = $attr['player_aspectratio'] ? '""' : ((strpos($attr['player_height'], '%') !== FALSE) ? wp_json_encode((string)$attr['player_height']) : (string)(int)$attr['player_height']); | |
| 510 | 519 | if(!is_string($_player_width)) $_player_width = '480'; |
| 511 | 520 | if(!is_string($_player_height)) $_player_height = '270'; |
| 512 | 521 | |
| 513 | 522 | //260805 strtr() replaces literal placeholders without reprocessing placeholder-like text inside generated values. |