PluginProbe
StreamCast – bring live radio to your site with a sleek player / 2.4.0
StreamCast – bring live radio to your site with a sleek player v2.4.0
2.4.5 2.4.4 trunk 1.0 1.1 2.0.0 2.1.10 2.1.2 2.1.4 2.1.5 2.1.8 2.2.1 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 All 29 releases
← All changes | build/render.php +35 -34 trunk2.4.0 View file →
@@ -2,22 +2,22 @@
2 2 if ( ! defined( 'ABSPATH' ) ) exit;
3 3
4 4 $id = wp_unique_id( 'streamcast-' );
5 5
6 -$streamcast_stream_url = $attributes['radioPlayer']['streamURL'];
7 -$streamcast_stream_port = $attributes['radioPlayer']['streamPort'];
8 -$streamcast_player_type = $attributes['radioPlayer']['playerType'];
9 -$streamcast_welcome_message = $attributes['radioPlayer']['welcomeMessage'];
10 -$streamcast_skin = $attributes['radioPlayer']['skin']['name'];
11 -$streamcast_width = $attributes['radioPlayer']['skin']['width'];
12 -$streamcast_height = $attributes['radioPlayer']['skin']['height'];
13 -$streamcast_auto_play = $attributes['radioPlayer']['autoPlay'];
14 -$streamcast_volume = $attributes['radioPlayer']['initialVolume'];
15 -$streamcast_player_position = $attributes['radioPlayer']['playerPosition'];
16 -$streamcast_nonce = wp_create_nonce( 'streamcast_fetch_nonce' );
6 +$streamUrl = $attributes['radioPlayer']['streamURL'];
7 +$streamPort = $attributes['radioPlayer']['streamPort'];
8 +$playerType = $attributes['radioPlayer']['playerType'];
9 +$welcomeMessage = $attributes['radioPlayer']['welcomeMessage'];
10 +$skin = $attributes['radioPlayer']['skin']['name'];
11 +$width = $attributes['radioPlayer']['skin']['width'];
12 +$height = $attributes['radioPlayer']['skin']['height'];
13 +$autoPlay = $attributes['radioPlayer']['autoPlay'];
14 +$volume = $attributes['radioPlayer']['initialVolume'];
15 +$playerPosition = $attributes['radioPlayer']['playerPosition'];
16 +$nonce = wp_create_nonce( 'stp_fetch_nonce' );
17 17
18 -if ( ! function_exists( 'streamcast_get_player_position_styles' ) ) {
19 - function streamcast_get_player_position_styles( $id, $playerPosition ) {
18 +if ( ! function_exists( 'stp_get_player_position_styles' ) ) {
19 + function stp_get_player_position_styles( $id, $playerPosition ) {
20 20 $styles = '';
21 21 if ( $playerPosition === 'center' ) {
22 22 $styles = 'margin: auto; display: block;';
23 23 } elseif ( $playerPosition === 'left' ) {
@@ -29,47 +29,47 @@
29 29 return '#' . esc_attr( $id ) . ' .musesStyleReset { ' . $styles . ' }';
30 30 }
31 31 }
32 32
33 -$streamcast_dynamic_player_styles = streamcast_get_player_position_styles( $id, $streamcast_player_position );
33 +$dynamicPlayerStyles = stp_get_player_position_styles( $id, $playerPosition );
34 34
35 -if ( $streamcast_skin !== 'b_circle' && $streamcast_player_type === 'standard' ) {
36 - $streamcast_station_name = $attributes['radioPlayer']['stationName'];
37 - $streamcast_fetch_name_from_url = $attributes['radioPlayer']['fetchNameFromUrl'];
35 +if ( $skin !== 'b_circle' && $playerType === 'standard' ) {
36 + $stationName = $attributes['radioPlayer']['stationName'];
37 + $fetchNameFromUrl = $attributes['radioPlayer']['fetchNameFromUrl'];
38 38
39 39 ?>
40 40 <div id='<?php echo esc_attr( $id ); ?>'>
41 41 <style>
42 - <?php echo esc_html( wp_strip_all_tags( $streamcast_dynamic_player_styles ) ); ?>
42 + <?php echo esc_html( wp_strip_all_tags( $dynamicPlayerStyles ) ); ?>
43 43 </style>
44 44 <script type="text/javascript">
45 45 window.MRP?.insert({
46 - url: <?php echo wp_json_encode( $streamcast_stream_url ); ?>,
46 + url: <?php echo wp_json_encode( $streamUrl ); ?>,
47 47 lang: "en",
48 48 codec: "mp3",
49 - volume: <?php echo (int) $streamcast_volume; ?>,
50 - autoplay: <?php echo $streamcast_auto_play ? 'true' : 'false'; ?>,
49 + volume: <?php echo (int) $volume; ?>,
50 + autoplay: <?php echo $autoPlay ? 'true' : 'false'; ?>,
51 51 forceHTML5: true,
52 - welcome: <?php echo wp_json_encode( $streamcast_welcome_message ); ?>,
52 + welcome: <?php echo wp_json_encode( $welcomeMessage ); ?>,
53 53 jsevents: true,
54 54 buffering: 0,
55 55 wmode: "transparent",
56 - skin: <?php echo wp_json_encode( $streamcast_skin ); ?>,
57 - width: <?php echo (int) $streamcast_width; ?>,
58 - height: <?php echo (int) $streamcast_height; ?>,
56 + skin: <?php echo wp_json_encode( $skin ); ?>,
57 + width: <?php echo (int) $width; ?>,
58 + height: <?php echo (int) $height; ?>,
59 59 metadataMode: "shoutcast",
60 60 metadataInterval: 15
61 61 });
62 62
63 - var title = <?php echo wp_json_encode( $streamcast_station_name ); ?>;
63 + var title = <?php echo wp_json_encode( $stationName ); ?>;
64 64
65 65 async function fetchData() {
66 66 try {
67 - const fetchUrl = <?php echo wp_json_encode( esc_url( $streamcast_stream_url ) . '/currentsong?sid=1' ); ?>;
67 + const fetchUrl = <?php echo wp_json_encode( esc_url( $streamUrl ) . '/currentsong?sid=1' ); ?>;
68 68 const formData = new FormData();
69 - formData.append('action', 'streamcast_fetch_stream');
69 + formData.append('action', 'stp_fetch_stream');
70 70 formData.append("url", fetchUrl);
71 - formData.append("nonce", <?php echo wp_json_encode( $streamcast_nonce ); ?>);
71 + formData.append("nonce", <?php echo wp_json_encode( $nonce ); ?>);
72 72
73 73 const response = await fetch(<?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>, {
74 74 method: "POST",
75 75 body: formData,
@@ -87,13 +87,13 @@
87 87 }
88 88
89 89 async function fetchIceCastData() {
90 90 try {
91 - const fetchUrl = <?php echo wp_json_encode( esc_url( $streamcast_stream_url ) . '/status-json.xsl' ); ?>;
91 + const fetchUrl = <?php echo wp_json_encode( esc_url( $streamUrl ) . '/status-json.xsl' ); ?>;
92 92 const formData = new FormData();
93 - formData.append('action', 'streamcast_fetch_stream');
93 + formData.append('action', 'stp_fetch_stream');
94 94 formData.append("url", fetchUrl);
95 - formData.append("nonce", <?php echo wp_json_encode( $streamcast_nonce ); ?>);
95 + formData.append("nonce", <?php echo wp_json_encode( $nonce ); ?>);
96 96
97 97 const response = await fetch(<?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>, {
98 98 method: "POST",
99 99 body: formData,
@@ -117,11 +117,11 @@
117 117 }
118 118 }
119 119
120 120 async function updateTitle() {
121 - let title = <?php echo wp_json_encode( $streamcast_station_name ); ?>;
121 + let title = <?php echo wp_json_encode( $stationName ); ?>;
122 122
123 - <?php if ( $streamcast_fetch_name_from_url ) { ?>
123 + <?php if ( $fetchNameFromUrl ) { ?>
124 124 let fetchedTitle = await fetchData();
125 125 if (!fetchedTitle) {
126 126 fetchedTitle = await fetchIceCastData();
127 127 }
@@ -141,4 +141,5 @@
141 141 } else {
142 142 ?>
143 143 <div <?php echo wp_kses_post( get_block_wrapper_attributes() ); ?> id='<?php echo esc_attr( $id ); ?>' data-attributes='<?php echo esc_attr( wp_json_encode( $attributes ) ); ?>'></div>
144 144 <?php }
145 +