| 1 |
<?php |
| 2 |
|
| 3 |
class PowerPressNetworkProgram extends PowerPressNetworkShortCode |
| 4 |
{ |
| 5 |
function __construct() |
| 6 |
{ |
| 7 |
parent::__construct('ppn-program'); |
| 8 |
} |
| 9 |
|
| 10 |
function ppn_shortcode($attr, $contents) |
| 11 |
{ |
| 12 |
require_once(WP_PLUGIN_DIR . '/powerpress/powerpressadmin.php'); |
| 13 |
|
| 14 |
$ctx = $this->getNetworkContext(); |
| 15 |
if (is_string($ctx)) return $ctx; |
| 16 |
|
| 17 |
$program_id = $attr['id']; |
| 18 |
$props = []; |
| 19 |
$props['program_id'] = $program_id; |
| 20 |
$props['style'] = $attr['style'] ?? 'full'; |
| 21 |
$props['ssb-style'] = $attr['ssb-style'] ?? 'modern'; |
| 22 |
$props['ssb-shape'] = $attr['ssb-shape'] ?? 'circle'; |
| 23 |
$props['limit'] = $attr['limit'] ?? '20'; |
| 24 |
$props['network_general'] = $ctx['general']; |
| 25 |
|
| 26 |
$networkInfo = $ctx['networkInfo']; |
| 27 |
$networkInfo['program_id'] = $program_id; |
| 28 |
|
| 29 |
$results = PowerpressNetworkDataBus::getSpecificProgramInNetwork($ctx['apiUrl'], false, $networkInfo, false); |
| 30 |
|
| 31 |
if ( !$results || !is_array($results) ) { |
| 32 |
return '<p>' . esc_html__('This show is currently unavailable.', 'powerpress') . '</p>'; |
| 33 |
} |
| 34 |
|
| 35 |
|
| 36 |
if (isset($results['error'])) { |
| 37 |
if ($results['error'] == 'Fail To Find Your Program In This Network') { |
| 38 |
return PowerPressNetwork::getHTML('no-program-results.php', $props, null, null); |
| 39 |
} else if ($results['error'] == 'Your account does not have the network with specified id') { |
| 40 |
return PowerPressNetwork::getHTML('invalid-network.php', $props, null, null); |
| 41 |
} |
| 42 |
return $results['error']; |
| 43 |
} |
| 44 |
|
| 45 |
$props['episodes'] = $results['episodes']; |
| 46 |
$props['artwork_url'] = $results['program_info']['artwork_url']; |
| 47 |
$props['program_title'] = $results['program_info']['program_title']; |
| 48 |
$props['program_desc'] = $results['program_info']['program_desc']; |
| 49 |
$props['talent_name'] = $results['program_info']['talent_name']; |
| 50 |
$props['program_url'] = $results['program_info']['program_htmlurl']; |
| 51 |
$props['program_rssurl'] = $results['program_info']['program_rssurl']; |
| 52 |
$props['program_itunesurl'] = $results['program_info']['program_itunesurl'] ?? false; |
| 53 |
|
| 54 |
// subscribe links |
| 55 |
$subscribeKeys = [ |
| 56 |
'subscribe_googleplay', 'subscribe_html', 'subscribe_tunein', |
| 57 |
'subscribe_itunes', 'subscribe_deezer', 'subscribe_iheart', |
| 58 |
'subscribe_pandora', 'subscribe_radio_com', 'subscribe_spotify', |
| 59 |
'subscribe_blubrry', 'subscribe_podchaser', 'subscribe_jiosaavn', |
| 60 |
'subscribe_gaana', 'subscribe_pcindex', 'subscribe_amazon_music', |
| 61 |
'subscribe_anghami', |
| 62 |
]; |
| 63 |
foreach ($subscribeKeys as $key) { |
| 64 |
$props[$key] = $results['program_info'][$key] ?? false; |
| 65 |
} |
| 66 |
|
| 67 |
return PowerPressNetwork::getHTML('program-result.php', $props, null, null); |
| 68 |
} |
| 69 |
} |
| 70 |
$GLOBALS['ppn_program'] = new PowerPressNetworkProgram(); |