PluginProbe
PowerPress Podcasting plugin by Blubrry / trunk
PowerPress Podcasting plugin by Blubrry vtrunk
11.17.9 11.17.8 11.17.7 11.17.6 11.17.4 11.17.3 11.17.2 11.17.1 11.17 11.16.11 11.16.10 11.16.9 11.16.8 11.16.7 11.16.6 11.16.5 11.16.4 11.16.3 11.16.2 11.16.1 11.9.13 11.9.14 11.9.15 11.9.16 11.9.17 All 383 releases
powerpress / shortcodes / ShortCode.php

ShortCode.php in PowerPress Podcasting plugin by Blubrry trunk, at shortcodes/ShortCode.php

71 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class PowerPressNetworkShortCode
4 {
5 var $tag;
6 function __construct($tag)
7 {
8 $this->tag = $tag;
9 add_action('init', [$this, 'ppn_shortcode_init']);
10 add_action('wp_enqueue_scripts', [$this, 'ppn_enqueue_frontend_styles']);
11 }
12
13 /** enqueue network frontend css when shortcode is registered */
14 function ppn_enqueue_frontend_styles()
15 {
16 powerpress_enqueue_assets([
17 'ppn-frontend' => ['path' => 'css/ppn-frontend'],
18 'powerpress-blueprint' => ['path' => 'css/blueprint'],
19 'powerpress-subscribe-widget' => ['path' => 'css/subscribe-widget'],
20 'ppn-montserrat' => ['type' => 'style', 'url' => 'https://fonts.googleapis.com/css?family=Montserrat&display=swap'],
21 ]);
22 }
23
24 function ppn_shortcode_init()
25 {
26 add_shortcode($this->tag, [$this, 'ppn_shortcode']);
27 }
28
29 /**
30 * load network context: options, api url, network info
31 *
32 * @return array|string context array on success, error HTML on failure
33 */
34 protected function getNetworkContext()
35 {
36 $networkInfo = get_option('powerpress_network', []);
37 $networkInfo['network_id'] = get_option('powerpress_network_id');
38 $networkInfo['network_title'] = get_option('powerpress_network_title');
39
40 if (empty($networkInfo['network_id'])) {
41 return PowerPressNetwork::getHTML('invalid-network.php', [], null, null);
42 }
43
44 $apiArray = powerpress_get_api_array();
45 return [
46 'networkInfo' => $networkInfo,
47 'apiUrl' => $apiArray[0],
48 'creds' => ['post' => false],
49 'map' => get_option('powerpress_network_map', []),
50 'general' => get_option('network_general'),
51 ];
52 }
53
54 /**
55 * resolve page links for programs using the network map
56 */
57 protected function resolvePageLinks(array &$programs, array $map): void
58 {
59 foreach ($programs as &$program) {
60 $mapKey = "p-{$program['program_id']}";
61 $program['link'] = '#';
62 if (isset($map[$mapKey])) {
63 $postId = $map[$mapKey];
64 if (get_post_status($postId) === 'publish') {
65 $program['link'] = get_permalink($postId);
66 }
67 }
68 }
69 }
70 }
71