| 1 |
<?php //Lets register our shortcode |
| 2 |
function sc_radio_player_cb($atts) |
| 3 |
{ |
| 4 |
extract(shortcode_atts(array( |
| 5 |
|
| 6 |
'id' => null, |
| 7 |
'url' => null, |
| 8 |
'background' => null, |
| 9 |
|
| 10 |
), $atts)); |
| 11 |
|
| 12 |
$post_type = get_post_type($id); |
| 13 |
if ($post_type != 'streamcast') { |
| 14 |
return false; |
| 15 |
} |
| 16 |
|
| 17 |
$player_type = stp_get_meta($id, 'opt-radio', "minimal"); |
| 18 |
|
| 19 |
$stationName = stp_get_meta($id, 'station_name', "Station Name"); |
| 20 |
$welcomeMsg = stp_get_meta($id, 'welcome_msgs', "Welcome Message"); |
| 21 |
$streamURL = stp_get_meta($id, 'stream_url', "https://media-ssl.musicradio.com/HeartLondon"); |
| 22 |
$artWork = "https://templates.bplugins.com/wp-content/uploads/2025/02/streamcast-demo-ultimate-1.png"; |
| 23 |
$backgroundColor = stp_get_meta($id, 'background', "#f09f8b"); |
| 24 |
$playerWidth = stp_get_meta($id, 'playerWidth', "100%"); |
| 25 |
|
| 26 |
|
| 27 |
if ($player_type === "ultimate") { |
| 28 |
$stationName = stp_get_meta($id, "radioName", "Station Name"); |
| 29 |
$streamURL = esc_attr(stp_get_meta($id, "streamURL", "http://s5-webradio.antenne.de/antenne?icy=https")); |
| 30 |
$playerWidth = stp_get_meta($id, 'playerWidth', "100%"); |
| 31 |
} elseif (in_array($player_type, ["auroraPlay", "echoStream", "wooden"])) { |
| 32 |
$stationName = stp_get_meta($id, 'station_name_echoXauroraXwooden', "Hello London"); |
| 33 |
$welcomeMsg = stp_get_meta($id, 'welcomeMsg_echoXaurora', '106.2'); |
| 34 |
$streamURL = stp_get_meta($id, 'stream_url_echoXaurora', "https://media-ssl.musicradio.com/HeartLondon"); |
| 35 |
if ($player_type === "auroraPlay") { |
| 36 |
$artWork = "https://danialsabagh.com/singleaudioplayer/img/radio.jpg"; |
| 37 |
$playerWidth = stp_get_meta($id, 'widthXaurora', "100%"); |
| 38 |
$backgroundColor = stp_get_meta($id, 'bgXaurora', "#000000" ); |
| 39 |
}elseif ($player_type === "wooden") { |
| 40 |
$playerWidth = stp_get_meta($id, 'widthXaurora', "100%"); |
| 41 |
$backgroundColor = stp_get_meta($id, 'bgXwooden', "#693328"); |
| 42 |
} else { |
| 43 |
$playerWidth = stp_get_meta($id, 'widthXecho', "450px"); |
| 44 |
} |
| 45 |
} elseif ($player_type === "standard") { |
| 46 |
$welcomeMsg = stp_get_meta($id, 'welcome_msgs', "Welcome Message"); |
| 47 |
} else { |
| 48 |
$streamURL = esc_attr(stp_get_meta($id, 'stream_url', "https://media-ssl.musicradio.com/HeartLondon")); |
| 49 |
$backgroundColor = stp_get_meta($id, 'background', "#f09f8b"); |
| 50 |
} |
| 51 |
|
| 52 |
$block = [ |
| 53 |
"blockName" => "scb/streamcast-block", |
| 54 |
"attrs" => [ |
| 55 |
"radioPlayer" => [ |
| 56 |
"playerType" => $player_type === 'plyr' ? 'minimal' : $player_type, |
| 57 |
"streamURL" => $streamURL, |
| 58 |
"streamProvider" => esc_attr(stp_get_meta($id, 'streamProvider', 'shoutcast')), |
| 59 |
"streamPort" => esc_attr(stp_get_meta($id, 'streamPort', "8000")), |
| 60 |
"streamMountPoint" => esc_attr(stp_get_meta($id, 'streamMountPoint', "house.320k.mp3")), |
| 61 |
"fetchNameFromUrl" => false, |
| 62 |
"stationName" => $stationName, |
| 63 |
"welcomeMessage" => $welcomeMsg, |
| 64 |
"artWork" => ["url" => $artWork], |
| 65 |
"autoPlay" => false, |
| 66 |
"showTime" => 1, |
| 67 |
"playerPosition" => "center", |
| 68 |
"skin" => [ |
| 69 |
"name" => "mcclean", |
| 70 |
"width" => 180, |
| 71 |
"height" => 60 |
| 72 |
], |
| 73 |
"initialVolume" => 65 |
| 74 |
], |
| 75 |
"radioStyles" => [ |
| 76 |
"playerWidth" => $playerWidth, |
| 77 |
"ultimate" => [ |
| 78 |
"playerColors" => "theme", |
| 79 |
"playerTheme" => "dodgerBlue", |
| 80 |
"playerOverlayColor" => "rgba(15, 17, 21, 0.5)", |
| 81 |
"thumbnailBorderColor" => "rgba(255, 255, 255, 0.2)", |
| 82 |
"contentColor" => "#fff", |
| 83 |
"buttonHoverColor" => "orangered", |
| 84 |
"progressActiveColor" => "orangered", |
| 85 |
"visualizerColor" => "orangered", |
| 86 |
"playerBackgroundImg" => "", |
| 87 |
"posterImg" => [ |
| 88 |
"url" => "https://templates.bplugins.com/wp-content/uploads/2025/02/streamcast-demo-ultimate-1.png" |
| 89 |
] |
| 90 |
], |
| 91 |
"echoStream" => [ |
| 92 |
"bgImg" => [ |
| 93 |
"url" => "https://danialsabagh.com/singleaudioplayer/img/radio.jpg" |
| 94 |
], |
| 95 |
"blur" => 7 |
| 96 |
], |
| 97 |
"backgroundColor" => $backgroundColor, |
| 98 |
"stationName" => [ |
| 99 |
"color" => "white", |
| 100 |
"hoverColor" => "", |
| 101 |
"typo" => [ |
| 102 |
"fontSize" => [ |
| 103 |
"desktop" => 18 |
| 104 |
] |
| 105 |
], |
| 106 |
"bgColor" => "#50241b", |
| 107 |
"hoverBgColor" => "" |
| 108 |
], |
| 109 |
"artistFmName" => [ |
| 110 |
"color" => "white", |
| 111 |
"typo" => [ |
| 112 |
"fontSize" => [ |
| 113 |
"desktop" => 15 |
| 114 |
] |
| 115 |
] |
| 116 |
], |
| 117 |
"contentColor" => "white", |
| 118 |
"playBtnColor" => "red", |
| 119 |
"timeStamp" => [ |
| 120 |
"color" => "white", |
| 121 |
"hoverColor" => "", |
| 122 |
"typo" => [ |
| 123 |
"fontSize" => [ |
| 124 |
"desktop" => 18 |
| 125 |
] |
| 126 |
], |
| 127 |
"bgColor" => "#50241b", |
| 128 |
"hoverBgColor" => "" |
| 129 |
] |
| 130 |
], |
| 131 |
'css' => esc_html(stp_get_meta($id, 'custom_css', "/* Your Custom CSS here */")), |
| 132 |
], |
| 133 |
"innerBlocks" => [], |
| 134 |
"innerHTML" => "", |
| 135 |
"innerContent" => [] |
| 136 |
]; |
| 137 |
|
| 138 |
return render_block($block); |
| 139 |
|
| 140 |
} |
| 141 |
add_shortcode('radio_player', 'sc_radio_player_cb'); |
| 142 |
|
| 143 |
|