-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpodcastindex.php
1578 lines (1186 loc) · 56.3 KB
/
podcastindex.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?PHP
/*
Plugin Name: Podcast Namespace
Plugin URI: https://github.com/Lehmancreations/Podcast-Namespace-Wordpress-Plugin
Description: A plugin to add the podcasting 2.0 namespace to your Powerpress feeds
Version: 1.7.3
Author: Lehmancreations
Author URI: https://lehmancreations.com
Requires at least: 3.6
/**
* Generated by the WordPress Option Page generator
* at http://jeremyhixon.com/wp-tools/option-page/
*/
class PodcastNamespace {
private $podcast_namespace_options;
public function __construct() {
add_action( 'admin_menu', array( $this, 'podcast_namespace_add_plugin_page' ) );
add_action( 'admin_init', array( $this, 'podcast_namespace_page_init' ) );
}
public function podcast_namespace_add_plugin_page() {
add_options_page(
'Podcast Namespace', // page_title
'Podcast Namespace', // menu_title
'manage_options', // capability
'podcast-namespace', // menu_slug
array( $this, 'podcast_namespace_create_admin_page' ) // function
);
}
public function podcast_namespace_create_admin_page() {
$this->podcast_namespace_options = get_option( 'podcast_namespace_option_name' ); ?>
<div class="wrap">
<h2>Podcast Namespace</h2>
<p><b>Set these options for the podcast namespace at the channel level</b></p>
<?php settings_errors(); ?>
<form method="post" action="options.php">
<?php
settings_fields( 'podcast_namespace_option_group' );
do_settings_sections( 'podcast-namespace-admin' );
submit_button();
?>
</form>
</div>
<div>
<p>
<b>To use the item level namespace place the following each in a custom field on the post:</b><br><br>
transcript is the name and value is a URL to the srt transcript file, you can have more than one of these but currently we only support srt<br><br>
chapters is the name and value is a URL to a json encoded chapter file<br><br>
person: use the custom person box on the post <br><br>
soundbite: use the custom soundbite box on the post
</p>
</div>
<div>
<p>
<hr>
Do you like this plugin? <a href="https://dudesanddadspodcast.com/paypal"> Consider a paypal donation to the podcast I host/produce </a>
</p>
</div>
<?php }
public function podcast_namespace_page_init() {
register_setting(
'podcast_namespace_option_group', // option_group
'podcast_namespace_option_name', // option_name
array( $this, 'podcast_namespace_sanitize' ) // sanitize_callback
);
add_settings_section(
'podcast_namespace_setting_section', // id
'Settings', // title
array( $this, 'podcast_namespace_section_info' ), // callback
'podcast-namespace-admin' // page
);
add_settings_field(
'locked_0', // id
'Locked', // title
array( $this, 'locked_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'locked_owner_1', // id
'Locked Owner Email', // title
array( $this, 'locked_owner_1_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'feedback_contact_email_2', // id
'Feedback Contact Email', // title
array( $this, 'feedback_contact_email_2_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'abuse_contact_email_3', // id
'Abuse Contact Email', // title
array( $this, 'abuse_contact_email_3_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'advertising_contact_email_3', // id
'Advertising Contact Email', // title
array( $this, 'advertising_contact_email_3_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'funding_url_4', // id
'Funding Url', // title
array( $this, 'funding_url_4_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'funding_description_0', // id
'Funding Description', // title
array( $this, 'funding_description_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'location_description_0', // id
'Location Description', // title
array( $this, 'location_description_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'location_geo_description_0', // id
'Location Coordinates', // title
array( $this, 'location_geo_description_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'location_osm_description_0', // id
'Location OSMID', // title
array( $this, 'location_osm_description_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'podcast_guid_0', // id
'Podcast GUID', // title
array( $this, 'podcast_guid_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'podcast_value_0', // id
'Podcast Value Block', // title
array( $this, 'podcast_value_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'podcast_value_suggested_0', // id
'Podcast Value Suggested Ammount', // title
array( $this, 'podcast_value_suggested_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
add_settings_field(
'medium_0', // id
'Medium', // title
array( $this, 'medium_0_callback' ), // callback
'podcast-namespace-admin', // page
'podcast_namespace_setting_section' // section
);
}
public function podcast_namespace_sanitize($input) {
$sanitary_values = array();
if ( isset( $input['locked_0'] ) ) {
$sanitary_values['locked_0'] = $input['locked_0'];
}
if ( isset( $input['locked_owner_1'] ) ) {
$sanitary_values['locked_owner_1'] = sanitize_text_field( $input['locked_owner_1'] );
}
if ( isset( $input['feedback_contact_email_2'] ) ) {
$sanitary_values['feedback_contact_email_2'] = sanitize_text_field( $input['feedback_contact_email_2'] );
}
if ( isset( $input['abuse_contact_email_3'] ) ) {
$sanitary_values['abuse_contact_email_3'] = sanitize_text_field( $input['abuse_contact_email_3'] );
}
if ( isset( $input['advertising_contact_email_3'] ) ) {
$sanitary_values['advertising_contact_email_3'] = sanitize_text_field( $input['advertising_contact_email_3'] );
}
if ( isset( $input['funding_url_4'] ) ) {
$sanitary_values['funding_url_4'] = sanitize_text_field( $input['funding_url_4'] );
}
if ( isset( $input['funding_description_0'] ) ) {
$sanitary_values['funding_description_0'] = sanitize_text_field( $input['funding_description_0'] );
}
if ( isset( $input['location_description_0'] ) ) {
$sanitary_values['location_description_0'] = sanitize_text_field( $input['location_description_0'] );
}
if ( isset( $input['location_geo_description_0'] ) ) {
$sanitary_values['location_geo_description_0'] = sanitize_text_field( $input['location_geo_description_0'] );
}
if ( isset( $input['location_osm_description_0'] ) ) {
$sanitary_values['location_osm_description_0'] = sanitize_text_field( $input['location_osm_description_0'] );
}
if ( isset( $input['podcast_guid_0'] ) ) {
if ( isset( $_POST['generate_UUID'] ) ) {
//Make the request to an API endpoint
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,'https://www.uuidtools.com/api/generate/v5/namespace/ead4c236-bf58-58c6-a2c6-a6b28d128cb6/name/' . $input['podcast_guid_0']);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
//Collect and show the results
$response = curl_exec ($ch);
curl_close ($ch);
$responseObj = json_decode($response);
$sanitary_values['podcast_guid_0'] = sanitize_text_field( $responseObj[0] );
} else {
$sanitary_values['podcast_guid_0'] = sanitize_text_field( $input['podcast_guid_0'] );
}
}
if ( isset( $input['podcast_value_0'] ) ) {
$sanitary_values['podcast_value_0'] = $input['podcast_value_0'];
}
if ( isset( $input['podcast_value_suggested_0'] ) ) {
if ($input['podcast_value_suggested_0'] == '') {
$sanitary_values['podcast_value_suggested_0'] = '0.00000015000';
} else {
$sanitary_values['podcast_value_suggested_0'] = $input['podcast_value_suggested_0'];
}
}
if ( isset( $input['medium_0'] ) ) {
$sanitary_values['medium_0'] = $input['medium_0'];
}
return $sanitary_values;
}
public function podcast_namespace_section_info() {
}
public function locked_0_callback() {
?> <select name="podcast_namespace_option_name[locked_0]" id="locked_0">
<?php $selected = (isset( $this->podcast_namespace_options['locked_0'] ) && $this->podcast_namespace_options['locked_0'] === 'yes') ? 'selected' : '' ; ?>
<option value="yes" <?php echo $selected; ?>>Yes</option>
<?php $selected = (isset( $this->podcast_namespace_options['locked_0'] ) && $this->podcast_namespace_options['locked_0'] === 'no') ? 'selected' : '' ; ?>
<option value="no" <?php echo $selected; ?>>No</option>
</select> <?php
}
public function locked_owner_1_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[locked_owner_1]" id="locked_owner_1" value="%s">',
isset( $this->podcast_namespace_options['locked_owner_1'] ) ? esc_attr( $this->podcast_namespace_options['locked_owner_1']) : ''
);
}
public function feedback_contact_email_2_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[feedback_contact_email_2]" id="feedback_contact_email_2" value="%s">',
isset( $this->podcast_namespace_options['feedback_contact_email_2'] ) ? esc_attr( $this->podcast_namespace_options['feedback_contact_email_2']) : ''
);
}
public function abuse_contact_email_3_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[abuse_contact_email_3]" id="abuse_contact_email_3" value="%s">',
isset( $this->podcast_namespace_options['abuse_contact_email_3'] ) ? esc_attr( $this->podcast_namespace_options['abuse_contact_email_3']) : ''
);
}
public function advertising_contact_email_3_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[advertising_contact_email_3]" id="adertising_contact_email_3" value="%s">',
isset( $this->podcast_namespace_options['advertising_contact_email_3'] ) ? esc_attr( $this->podcast_namespace_options['advertising_contact_email_3']) : ''
);
}
public function funding_url_4_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[funding_url_4]" id="funding_url_4" value="%s">',
isset( $this->podcast_namespace_options['funding_url_4'] ) ? esc_attr( $this->podcast_namespace_options['funding_url_4']) : ''
);
}
public function funding_description_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[funding_description_0]" id="funding_description_0" value="%s">',
isset( $this->podcast_namespace_options['funding_description_0'] ) ? esc_attr( $this->podcast_namespace_options['funding_description_0']) : ''
);
}
public function location_description_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[location_description_0]" id="location_description_0" value="%s">',
isset( $this->podcast_namespace_options['location_description_0'] ) ? esc_attr( $this->podcast_namespace_options['location_description_0']) : ''
);
}
public function location_geo_description_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[location_geo_description_0]" id="location_geo_description_0" value="%s">',
isset( $this->podcast_namespace_options['location_geo_description_0'] ) ? esc_attr( $this->podcast_namespace_options['location_geo_description_0']) : ''
);
}
public function location_osm_description_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[location_osm_description_0]" id="location_osm_description_0" value="%s">',
isset( $this->podcast_namespace_options['location_osm_description_0'] ) ? esc_attr( $this->podcast_namespace_options['location_osm_description_0']) : ''
);
}
public function podcast_guid_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[podcast_guid_0]" id="podcast_guid_0" value="%s">',
isset( $this->podcast_namespace_options['podcast_guid_0'] ) ? esc_attr( $this->podcast_namespace_options['podcast_guid_0']) : ''
);
?> <input type="checkbox" id="generate_UUID" name="generate_UUID">
<label for="generate_UUID"> Generate UUID (Check this, and put your feed url in minus the https:// and the trailing slash)</label><br><br> <b>A guid is generated from the RSS feed url, with the protocol scheme and trailing slashes stripped off. A podcast gets assigned a podcast:guid once in it's lifetime using it's current feed url (at the time of assignment) as the seed value. That GUID is then meant to follow the podcast from then on, for the duration of it's life, even if the feed url changes. See <a href="https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#guid" target="pc">The Podcast Namespace documentation</a> for more information.</b><?php
}
public function podcast_value_0_callback() {
printf(
'<textarea rows="4" cols="35" name="podcast_namespace_option_name[podcast_value_0]" id="podcast_0">%s</textarea>',
isset( $this->podcast_namespace_options['podcast_value_0'] ) ? esc_attr( $this->podcast_namespace_options['podcast_value_0']) : ''
);
?> <br><b>Please input the tag you got from your lightning provider (i.e. LNpay.co or satoshis.stream) begining at"<podcast:valueRecipient" tag. <br>NOTE: Please do not enter the "<podcast:value type="lightning"" tag or the "</podcast:value>" tag, we will put that in your feed. Also note inputing the wrong thing in here can wreck your feed. This is an advanced setting. Also note that if you set your value block here we will add a 1% fee split for using our plugin</b> <?PHP
}
public function podcast_value_suggested_0_callback() {
printf(
'<input class="regular-text" type="text" name="podcast_namespace_option_name[podcast_value_suggested_0]" id="podcast_value_suggested_0" value="%s">',
isset( $this->podcast_namespace_options['podcast_value_suggested_0'] ) ? esc_attr( $this->podcast_namespace_options['podcast_value_suggested_0']) : ''
);
?> <br><b>if this field is left blank it will default to 0.00000015000</b><br><?PHP
}
public function medium_0_callback() {
?> <select name="podcast_namespace_option_name[medium_0]" id="medium_0">
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'podcast') ? 'selected' : '' ; ?>
<option value="podcast" <?php echo $selected; ?>>podcast</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'music') ? 'selected' : '' ; ?>
<option value="music" <?php echo $selected; ?>>music</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'video') ? 'selected' : '' ; ?>
<option value="video" <?php echo $selected; ?>>video</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'film') ? 'selected' : '' ; ?>
<option value="film" <?php echo $selected; ?>>film</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'audiobook') ? 'selected' : '' ; ?>
<option value="audiobook" <?php echo $selected; ?>>audiobook</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'newsletter') ? 'selected' : '' ; ?>
<option value="newsletter" <?php echo $selected; ?>>newsletter</option>
<?php $selected = (isset( $this->podcast_namespace_options['medium_0'] ) && $this->podcast_namespace_options['medium_0'] === 'blog') ? 'selected' : '' ; ?>
<option value="blog" <?php echo $selected; ?>>blog</option>
</select> <?php
}
}
if ( is_admin() )
$podcast_namespace = new PodcastNamespace();
/*
* Retrieve this value with:
* $podcast_namespace_options = get_option( 'podcast_namespace_option_name' ); // Array of All Options
* $locked_0 = $podcast_namespace_options['locked_0']; // Locked
* $locked_owner_1 = $podcast_namespace_options['locked_owner_1']; // Locked Owner
* $feedback_contact_email_2 = $podcast_namespace_options['feedback_contact_email_2']; // Feedback Contact Email
* $abuse_contact_email_3 = $podcast_namespace_options['abuse_contact_email_3']; // Abuse Contact Email
* $advertising_contact_email_3 = $podcast_namespace_options['advertising_contact_email_3']; // Advertising Contact Email
* $funding_url_4 = $podcast_namespace_options['funding_url_4']; // Funding Url
* $funding_description_0 = $podcast_namespace_options['funding_description_0']; // Funding Description
* $location_description_0 = $podcast_namespace_options['location_description_0']; // Location Description
* $location_geo_description_0 = $podcast_namespace_options['location_geo_description_0']; // Location Description Coordinates
* $location_osm_description_0 = $podcast_namespace_options['location_osm_description_0']; // OSMID of the podcast
* $podcast_guid_0 = $podcast_namespace_options['podcast_guid_0']; // Podcast GUID
* $podcast_namespace_options['podcast_guid_suggested_0'] //Suggested value
* * $podcast_namespace_options['medium_0'] //Medium
*/
function podcastindex_rss2_ns()
{
if( !powerpress_is_podcast_feed() )
return;
// Okay, lets add the namespace (commented out because powerpress already adds it)
//echo 'xmlns:podcast="https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md"'.PHP_EOL;
}
add_action('rss2_ns', 'podcastindex_rss2_ns');
add_action('rss2_ns_podcastindex', 'podcastindex_rss2_ns');
function podastindex_rss2_head()
{
if( !powerpress_is_podcast_feed() )
return;
$podcast_namespace_options = get_option( 'podcast_namespace_option_name' ); // Array of All Options
echo "<!-- Podcast Namespace Tags Added by LehmanCreations V1.7.3 -->".PHP_EOL;
if (!empty ( $podcast_namespace_options['locked_owner_1'] )) {
echo "\t".'<podcast:locked owner="' . $podcast_namespace_options['locked_owner_1'] .'">' . $podcast_namespace_options['locked_0'] . '</podcast:locked>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['feedback_contact_email_2'] )) {
echo "\t".'<podcast:contact type="feedback" method="email">'. $podcast_namespace_options['feedback_contact_email_2'] .'</podcast:contact>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['abuse_contact_email_3'] )) {
echo "\t".'<podcast:contact type="abuse" method="email">' . $podcast_namespace_options['abuse_contact_email_3'] . '</podcast:contact>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['advertising_contact_email_3'] )) {
echo "\t".'<podcast:contact type="advertising" method="email">' . $podcast_namespace_options['advertising_contact_email_3'] . '</podcast:contact>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['funding_url_4'] )) {
echo "\t".'<podcast:funding url="'. $podcast_namespace_options['funding_url_4'] . '">' .$podcast_namespace_options['funding_description_0']. '</podcast:funding>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['location_description_0'] )) {
echo "\t".'<podcast:location geo="geo:' . $podcast_namespace_options['location_geo_description_0'] . '" osm="' . $podcast_namespace_options['location_osm_description_0'] . '">' .$podcast_namespace_options['location_description_0']. '</podcast:location>'.PHP_EOL; }
if (!empty ( $podcast_namespace_options['podcast_guid_0'] )) {
echo apply_filters( 'namespace_guid_change',"\t".'<podcast:guid>' . $podcast_namespace_options['podcast_guid_0'] . '</podcast:guid>'.PHP_EOL, 0); }
if (!empty ( $podcast_namespace_options['podcast_value_0'] )) {
echo "\t". '<podcast:value type="lightning" method="keysend" suggested="' .$podcast_namespace_options['podcast_value_suggested_0'] .'">' .PHP_EOL;
echo "\t \t". $podcast_namespace_options['podcast_value_0'] .PHP_EOL;
$responseObj = json_decode( getv4vInfo() );
echo "\t \t". '<podcast:valueRecipient name="LehmanCreations PodcastNamespace Plugin" address="'. $responseObj->address . '" type="node"';
if(!empty ($responseObj->customkey)) {
echo ' customKey="' . $responseObj->customkey . '"'; }
if(!empty ($responseObj->customvalue)) {
echo ' custombvalue="' . $responseObj->customvalue . '"'; }
echo ' split="1" fee="true" />' .PHP_EOL;
echo "\t". '</podcast:value>' .PHP_EOL;
}
if (!empty ( $podcast_namespace_options['medium_0'] )) {
echo "\t".'<podcast:medium>' . $podcast_namespace_options['medium_0'] . '</podcast:medium>'.PHP_EOL; }
}
add_action('rss2_head', 'podastindex_rss2_head');
// Item level
//Chapters
function podcastindex_rss2_chapters( $content ) {
if( !powerpress_is_podcast_feed() )
return;
global $post;
$post_chapters = get_post_meta( $post->ID, 'chapters', TRUE );
// add chapters only if the Custom Field is set
if ( $post_chapters ) {
echo '<podcast:chapters url="'.$post_chapters .'" type="application/json"/>'.PHP_EOL;
} else {
return;
}
}
add_filter( 'rss2_item', 'podcastindex_rss2_chapters' );
//Transcripts
function podcastindex_rss2_transcript( $content ) {
if( !powerpress_is_podcast_feed() )
return;
global $post;
$post_transcripts = get_post_meta( $post->ID, 'transcript');
// add transcripts only if the Custom Field is set
if ( $post_transcripts ) {
foreach( $post_transcripts as $post_transcript ) {
echo "\t".'<podcast:transcript url="'.$post_transcript .'" type="text/srt" rel="captions"/>'.PHP_EOL;
}
} else {
return;
}
}
add_filter( 'rss2_item', 'podcastindex_rss2_transcript' );
//Person
//Person - Custom Meta box
// START CUSTOM META BOX PERSON
//Add metabox with dynamically added key-value (with more values possible) custom fields
//TO CUSTOMIZE FIND AND REPLACE ANYTHING WITH psn in it
// Caution, there're 2 set of options below
//Variables used in the following functions should be mentioned in the 'global' statement of each of them appropriately
//=======Options 1=======
$psn_post_type = 'post';
$psn_metabox_label = 'Podcast Person';
$psn_cf_name = 'person';
// Add actions, initialise functions
add_action( 'add_meta_boxes', 'psn_dynamic_add_custom_box' );
add_action( 'save_post', 'psn_dynamic_save_postdata' );
//Function to add a meta box
function psn_dynamic_add_custom_box() {
global $psn_post_type, $psn_metabox_label;
add_meta_box('psn_dynamic_sectionid', $psn_metabox_label, 'psn_dynamic_inner_custom_box', $psn_post_type);
}
//Function that defines metabox contents
function psn_dynamic_inner_custom_box() {
//=======Options 2=======
$psn_label_addnew = 'Add Person';
$psn_label_remove = 'Remove person';
$psn_key_name = 'name';
$psn_value_name = 'role';
$psn_value2_name = 'img';
$psn_value3_name = 'url';
$psn_key_label = 'Name';
$psn_value_label = 'Role (host/guest)';
$psn_value2_label = 'Image URL';
$psn_value3_label = 'URL';
global $post;
global $psn_cf_name;
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'psn_dynamicMeta_noncename' );
//OPTIONAL - if using a date field
//Load admin scripts & styles for JS datepicker via the class from Meta Box plugin. This requires Meta Box plugin by Rilwis installed http://x.co/1YgqA
// $loadJqUIfromMetaboxPlugin = new RWMB_Date_Field();
// $loadJqUIfromMetaboxPlugin->admin_enqueue_scripts();
?>
<div id="psn_dynamic_inner_custom_box">
<?php
$psn_items = get_post_meta($post->ID,$psn_cf_name,true);
$c = 0;
if ( is_array($psn_items) && count( $psn_items ) > 0 ) {
foreach( $psn_items as $psn_item ) {
if ( isset( $psn_item[$psn_key_name] ) || isset( $psn_item[$psn_value_name] ) ) {
printf( '<p class="psn_parent"><label for=""%6$s[%1$s][%4$s]">%8$s</label> <input type="text" name="%6$s[%1$s][%4$s]" id="%6$s[%1$s][%4$s]" value="%2$s"> <label for="%6$s[%1$s][%5$s]">%9$s</label> <input id="%6$s[%1$s][%5$s]" type="text" name="%6$s[%1$s][%5$s]" value="%3$s"><label for="%6$s[%1$s][%10$s]">%11$s</label> <input type="text" id="%6$s[%1$s][%10$s]" name="%6$s[%1$s][%10$s]" value="%12$s"><label for="%6$s[%1$s][%13$s]">%14$s</label> <input type="text" id="%6$s[%1$s][%13$s]" name="%6$s[%1$s][%13$s]" value="%15$s"> <a href="#" class="psn_remove">%7$s</a></p>',
/*1*/ $c,
/*2*/ $psn_item[$psn_key_name],
/*3*/ $psn_item[$psn_value_name],
/*4*/ $psn_key_name,
/*5*/ $psn_value_name,
/*6*/ $psn_cf_name,
/*7*/ $psn_label_remove,
/*8*/ $psn_key_label,
/*9*/ $psn_value_label,
/*10*/ $psn_value2_name,
/*11*/ $psn_value2_label,
/*12*/ $psn_item[$psn_value2_name],
/*13*/ $psn_value3_name,
/*14*/ $psn_value3_label,
/*15*/ $psn_item[$psn_value3_name]
);
$c = $c + 1;
}
}
}
?>
<span id="psn_here"></span>
<a href="#" class="psn_add button-secondary"><?php echo $psn_label_addnew; ?></a>
<style type="text/css">
.psn_parent {display: flex;}
.psn_parent > * {flex:1 1 auto;}
.psn_parent label {padding-right:5px; text-align: right;}
.psn_parent .psn_remove {padding-left: 5px;}
</style>
<script>
var $ =jQuery.noConflict();
$(document).ready(function() {
//OPTIONAL
//Add datepicker to an input
//$('body').on('focus',".choosedate", function(){ //Allows to init datepicker on non existing yet elements
// $(this).datepicker({ dateFormat: "dd.mm.yy" });
//});
var count = <?php echo $c; ?>;
$(".psn_add").on('click',function(e) {
e.preventDefault();
count = count + 1;
$('#psn_here').append('<p class="psn_parent"><label for="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_key_name; ?>]"><?php echo $psn_key_label; ?></label> <input type="text" id="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_key_name; ?>]" name="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_key_name; ?>]" value=""> <label for="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value_name; ?>]"><?php echo $psn_value_label; ?></label> <input type="text" name="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value_name; ?>]" id="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value_name; ?>]" value=""><label for="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value2_name; ?>]"><?php echo $psn_value2_label; ?></label> <input type="text" name="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value2_name; ?>]" id="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value2_name; ?>]" value=""><label for="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value3_name; ?>]"><?php echo $psn_value3_label; ?></label> <input type="text" name="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value3_name; ?>]" id="<?php echo $psn_cf_name; ?>['+count+'][<?php echo $psn_value3_name; ?>]" value=""><a href="#" class="psn_remove"><?php echo $psn_label_remove; ?></a></p>');
return false;
});
$("#psn_dynamic_inner_custom_box").on('click', '.psn_remove', function(e) {
e.preventDefault();
$(this).parent().remove();
});
});
</script>
</div><?php
}
/* When the post is saved, saves our custom data */
function psn_dynamic_save_postdata( $post_id ) {
global $psn_cf_name;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( !isset( $_POST['psn_dynamicMeta_noncename'] ) )
return;
if ( !wp_verify_nonce( $_POST['psn_dynamicMeta_noncename'], plugin_basename( __FILE__ ) ) )
return;
$data2post = $_POST[$psn_cf_name];
if (is_null($data2post)) {
$psn_items = get_post_meta($post->ID,$psn_cf_name,true);
delete_post_meta($post_id,$psn_cf_name, $psn_items);
} else {
update_post_meta($post_id,$psn_cf_name,$data2post);
}
}
// END CUSTOM META BOX
//Person RSS feed
function podcastindex_rss2_person( $content ) {
if( !powerpress_is_podcast_feed() )
return;
global $post;
$post_person = get_post_meta($post->ID, 'person',true); // get the value
// add person only if the Custom Field is set
if ( $post_person ) {
foreach( $post_person as $k => $v) {
echo "\t".'<podcast:person role="'. $v['role'] .'" img="' . $v['img'] . '" href="' . $v['url'] . '">' . $v['name'] .'</podcast:person>' .PHP_EOL;
}
} else {
return;
}
}
add_filter( 'rss2_item', 'podcastindex_rss2_person' );
// Soundbite
//Soundbite - custom metabox
//=======Options 1=======
$sbite_post_type = 'post';
$sbite_metabox_label = 'Podcast Soundbites';
$sbite_cf_name = 'soundbites';
// Add actions, initialise functions
add_action( 'add_meta_boxes', 'sbite_dynamic_add_custom_box' );
add_action( 'save_post', 'sbite_dynamic_save_postdata' );
//Function to add a meta box
function sbite_dynamic_add_custom_box() {
global $sbite_post_type, $sbite_metabox_label;
add_meta_box('sbite_dynamic_sectionid', $sbite_metabox_label, 'sbite_dynamic_inner_custom_box', $sbite_post_type);
}
//Function that defines metabox contents
function sbite_dynamic_inner_custom_box() {
//=======Options 2=======
$sbite_label_addnew = 'Add Soundbite';
$sbite_label_remove = 'Remove Soundbite';
$sbite_key_name = 'startTime';
$sbite_value_name = 'title';
$sbite_value2_name = 'duration';
$sbite_key_label = 'Start Time (seconds)';
$sbite_value_label = 'Title';
$sbite_value2_label = 'Duration (seconds)';
global $post;
global $sbite_cf_name;
// Use nonce for verification
wp_nonce_field( plugin_basename( __FILE__ ), 'sbite_dynamicMeta_noncename' );
//OPTIONAL - if using a date field
//Load admin scripts & styles for JS datepicker via the class from Meta Box plugin. This requires Meta Box plugin by Rilwis installed http://x.co/1YgqA
// $loadJqUIfromMetaboxPlugin = new RWMB_Date_Field();
// $loadJqUIfromMetaboxPlugin->admin_enqueue_scripts();
?>
<div id="sbite_dynamic_inner_custom_box">
<?php
$sbite_items = get_post_meta($post->ID,$sbite_cf_name,true);
$c = 0;
if ( is_array($sbite_items) && count( $sbite_items ) > 0 ) {
foreach( $sbite_items as $sbite_item ) {
if ( isset( $sbite_item[$sbite_key_name] ) || isset( $sbite_item[$sbite_value_name] ) ) {
printf( '<p class="sbite_parent"><label for=""%6$s[%1$s][%5$s]">%9$s</label> <input type="text" name="%6$s[%1$s][%5$s]" id="%6$s[%1$s][%5$s]" value="%3$s"> <label for="%6$s[%1$s][%4$s]">%8$s</label> <input id="%6$s[%1$s][%4$s]" type="text" name="%6$s[%1$s][%4$s]" value="%2$s"><label for="%6$s[%1$s][%10$s]">%11$s</label> <input type="text" id="%6$s[%1$s][%10$s]" name="%6$s[%1$s][%10$s]" value="%12$s"> <a href="#" class="sbite_remove">%7$s</a></p>',
/*1*/ $c,
/*2*/ $sbite_item[$sbite_key_name],
/*3*/ $sbite_item[$sbite_value_name],
/*4*/ $sbite_key_name,
/*5*/ $sbite_value_name,
/*6*/ $sbite_cf_name,
/*7*/ $sbite_label_remove,
/*8*/ $sbite_key_label,
/*9*/ $sbite_value_label,
/*10*/ $sbite_value2_name,
/*11*/ $sbite_value2_label,
/*12*/ $sbite_item[$sbite_value2_name]
);
$c = $c + 1;
}
}
}
?>
<span id="sbite_here"></span>
<a href="#" class="sbite_add button-secondary"><?php echo $sbite_label_addnew; ?></a>
<style type="text/css">
.sbite_parent {display: flex;}
.sbite_parent > * {flex:1 1 auto;}
.sbite_parent label {padding-right:5px; text-align: right;}
.sbite_parent .sbite_remove {padding-left: 5px;}
</style>
<script>
var $ =jQuery.noConflict();
$(document).ready(function() {
//OPTIONAL
//Add datepicker to an input
//$('body').on('focus',".choosedate", function(){ //Allows to init datepicker on non existing yet elements
// $(this).datepicker({ dateFormat: "dd.mm.yy" });
//});
var count = <?php echo $c; ?>;
$(".sbite_add").on('click',function(e) {
e.preventDefault();
count = count + 1;
$('#sbite_here').append('<p class="sbite_parent"><label for="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value_name; ?>]"><?php echo $sbite_value_label; ?></label> <input type="text" id="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value_name; ?>]" name="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value_name; ?>]" value=""> <label for="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_key_name; ?>]"><?php echo $sbite_key_label; ?></label> <input type="text" name="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_key_name; ?>]" id="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_key_name; ?>]" value=""><label for="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value2_name; ?>]"><?php echo $sbite_value2_label; ?></label> <input type="text" name="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value2_name; ?>]" id="<?php echo $sbite_cf_name; ?>['+count+'][<?php echo $sbite_value2_name; ?>]" value=""> <a href="#" class="sbite_remove"><?php echo $sbite_label_remove; ?></a></p>');
return false;
});
$("#sbite_dynamic_inner_custom_box").on('click', '.sbite_remove', function(e) {
e.preventDefault();
$(this).parent().remove();
});
});
</script>
</div><?php
}
/* When the post is saved, saves our custom data */
function sbite_dynamic_save_postdata( $post_id ) {
global $sbite_cf_name;
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
if ( !isset( $_POST['sbite_dynamicMeta_noncename'] ) )
return;
if ( !wp_verify_nonce( $_POST['sbite_dynamicMeta_noncename'], plugin_basename( __FILE__ ) ) )
return;
$data2post = $_POST[$sbite_cf_name];
if (is_null($data2post)) {
$sbite_items = get_post_meta($post->ID,$sbite_cf_name,true);
delete_post_meta($post_id,$sbite_cf_name, $sbite_items);
} else {
update_post_meta($post_id,$sbite_cf_name,$data2post);
}
}
// END CUSTOM META BOX
//Soundbite - rss function
function podcastindex_rss2_soundbite( $content ) {
if( !powerpress_is_podcast_feed() )
return;
global $post;
$post_soundbites = get_post_meta($post->ID, 'soundbites',true); // get the value
// add soundbite only if the Custom Field is set
if ( $post_soundbites ) {
foreach( $post_soundbites as $k => $v) {
echo "\t".'<podcast:soundbite startTime="'. $v['startTime'] .'" duration="' . $v['duration'] . '">' . $v['title'] . '</podcast:soundbite>'.PHP_EOL;
}
} else {
return;
}
}
add_filter( 'rss2_item', 'podcastindex_rss2_soundbite' );
// Podcast Season
//
// Add new meta box
function podcast_season_meta_box() {
add_meta_box('podcast_season','Podcast Season and Episode ','podcast_season_callback','post');
}
add_action('add_meta_boxes','podcast_season_meta_box');
function pdetails_callback( $post ) {
wp_nonce_field('podcast_season_save','podcast_season_meta_box_nonce');
$podcast_season = get_post_meta($post->ID,'_podcast_season_key',false);
}
// create three new fields inside the box
function podcast_season_callback( $post ) {
wp_nonce_field('podcast_season_save','podcast_season_meta_box_nonce');
$podcast_season = get_post_meta($post->ID,'_podcast_season_key',false);
?>
<table>
<th>Podcast Season</th>
<tr><td><label for="">Season Number</label></td>
<td> <input type="number" name="season_number_field" min="0" placeholder="Season Number" value="<?php echo $podcast_season[0]['season_number']; ?>"></td></tr>
<tr> <td><label for="">Season Name (optional)</label></td>
<td> <input type="text" name="season_name_field" placeholder="Enter Season Name" value="<?php echo $podcast_season[0]['season_name']; ?>"></td></tr>
<!-- </table>
<table> -->
<th>Podcast Episode</th>
<tr><td><label for="">Episode Number</label></td>
<td> <input type="number" name="episode_number_field" min="0" placeholder="Episode Number" value="<?php echo $podcast_season[0]['episode_number']; ?>"></td></tr>
<tr> <td><label for="">Episode Name (optional)</label></td>
<td> <input type="text" name="episode_name_field" placeholder="Enter Season Name" value="<?php echo $podcast_season[0]['episode_name']; ?>"></td></tr>
</table>
<?php
}
//save metabox field values in the database
function podcast_season_save( $post_id ) {
if( ! isset($_POST['podcast_season_meta_box_nonce'])) {
return;
}
if( ! wp_verify_nonce( $_POST['podcast_season_meta_box_nonce'], 'podcast_season_save') ) {
return;
}
if( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
return;
}
if( ! current_user_can('edit_post', $post_id)) {
return;
}
$podcast_season_details = [
'season_number' => $_POST['season_number_field'],
'season_name' => $_POST['season_name_field'],
'episode_number' => $_POST['episode_number_field'],
'episode_name' => $_POST['episode_name_field']
];
if ( $_POST['season_number_field'] == 0 AND $_POST['episode_number_field'] == 0) {
$podcast_season_items = get_post_meta($post->ID,'_podcast_season_key',true);
delete_post_meta($post_id,'_podcast_season_key', $podcast_season_items);