-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmedia-monarchy-player.php
47 lines (43 loc) · 1.47 KB
/
media-monarchy-player.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/*
Plugin Name: Media Monarchy 24/7 Radio Stream
Description: A streaming media player that supports 8 distinct streams: use 'onair' for live broadcasts, 'news' for all news content, 'stream' for all music content, and genre-specific streams including 'rock', 'techno', 'country', 'ecclectic', and 'pop'. Example shortcode: [media_monarchy stream="country"]
Version: 1.3.1
Author: Better Call Jason
*/
// Enqueue the player script
function media_monarchy_enqueue_scripts() {
wp_enqueue_script(
'media-monarchy-player',
plugins_url('js/media-monarchy-player.js', __FILE__),
array(),
'1.0',
true
);
}
add_action('wp_enqueue_scripts', 'media_monarchy_enqueue_scripts');
// Register shortcode
function media_monarchy_player_shortcode($atts) {
$atts = shortcode_atts(array(
'stream' => 'music',
'theme' => 'dark',
'width' => '99%',
'height' => '63%'
), $atts);
$id = 'mm-player-' . uniqid();
return sprintf(
'<div id="%s"></div>
<script>
document.addEventListener("DOMContentLoaded", function() {
MediaMonarchy.createPlayer("%s", {
stream: "%s",
theme: "%s",
width: "%s",
height: "%s"
});
});
</script>',
$id, $id, $atts['stream'], $atts['theme'], $atts['width'], $atts['height']
);
}
add_shortcode('media_monarchy', 'media_monarchy_player_shortcode');