Rework shortcode to use heredoc instead of output buffering
This commit is contained in:
parent
5fc953c7ec
commit
d2a08c7355
|
@ -208,9 +208,9 @@ function stream_player_shortcode($params = []) {
|
||||||
wp_enqueue_style('video.js', 'https://unpkg.com/video.js/dist/video-js.css');
|
wp_enqueue_style('video.js', 'https://unpkg.com/video.js/dist/video-js.css');
|
||||||
wp_enqueue_script('video.js', 'https://unpkg.com/video.js/dist/video.min.js');
|
wp_enqueue_script('video.js', 'https://unpkg.com/video.js/dist/video.min.js');
|
||||||
|
|
||||||
$videoJsConfig = [
|
$vjsConfig = htmlspecialchars(json_encode([
|
||||||
'fluid' => true,
|
'fluid' => true,
|
||||||
];
|
]));
|
||||||
|
|
||||||
$params = array_merge([
|
$params = array_merge([
|
||||||
'host' => 'stream.openfest.org',
|
'host' => 'stream.openfest.org',
|
||||||
|
@ -219,15 +219,12 @@ function stream_player_shortcode($params = []) {
|
||||||
|
|
||||||
$urlPrefix = 'https://' . $params['host'] . '/';
|
$urlPrefix = 'https://' . $params['host'] . '/';
|
||||||
|
|
||||||
ob_start();
|
return <<<EOF
|
||||||
?>
|
<video class="video-js vjs-fill" controls data-setup="{$vjsConfig}">
|
||||||
<video class="video-js vjs-fill" controls data-setup="<?php echo htmlspecialchars(json_encode($videoJsConfig)); ?>">
|
<source type="application/x-mpegURL" src="{$urlPrefix}hls/{$params['track']}.m3u8"></source>
|
||||||
<source type="application/x-mpegURL" src="<?php echo $urlPrefix, 'hls/', $params['track']; ?>.m3u8"></source>
|
<source type="application/dash+xml" src="{$urlPrefix}dash/{$params['track']}.mpd"></source>
|
||||||
<source type="application/dash+xml" src="<?php echo $urlPrefix, 'dash/', $params['track']; ?>.mpd"></source>
|
|
||||||
</video>
|
</video>
|
||||||
<?php
|
EOF;
|
||||||
|
|
||||||
return ob_get_clean();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue