Skip to content

Commit 0e6a394

Browse files
authored
Merge pull request #84 from CallumKerson/main
feat: added `itunes:block` channel tag option
2 parents ded5430 + 4a8d507 commit 0e6a394

4 files changed

Lines changed: 35 additions & 0 deletions

File tree

dir2cast.ini

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@
105105
; Podcasts may reject your feed!
106106
;ITUNES_EXPLICIT = "no"
107107

108+
; Whether or not to include the podcast in the iTunes podcast directory.
109+
; See https://github.com/simplepie/simplepie-ng/wiki/Spec:-iTunes-Podcast-RSS
110+
; Valid values are "Yes" or "yes". Any other value will be ignored.
111+
;
112+
; Only set this if you want the feed to be private and completely excluded from
113+
; any podcast directory scanning.
114+
;ITUNES_BLOCK = "no"
115+
108116

109117
; *** INFORMATION ABOUT YOUR PODCAST - the following can be set using text files ***
110118

dir2cast.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,11 @@ public function appendToChannel(DOMElement $channel, DOMDocument $doc)
390390
->appendChild( new DOMText( $this->explicit ) );
391391
}
392392

393+
if(!empty($this->block))
394+
{
395+
$channel->appendChild( $doc->createElement('itunes:block') )
396+
->appendChild( new DOMText( $this->block ) );
397+
}
393398

394399
if(!empty($this->image_href))
395400
{
@@ -533,6 +538,11 @@ public function setExplicit($explicit)
533538
{
534539
$this->explicit = $explicit;
535540
}
541+
542+
public function setBlock($block)
543+
{
544+
$this->block = $block;
545+
}
536546
}
537547

538548
class RSS_Item extends GetterSetter {
@@ -1999,6 +2009,9 @@ public static function defaults(array $SERVER)
19992009
if(!defined('ITUNES_EXPLICIT'))
20002010
define('ITUNES_EXPLICIT', '');
20012011

2012+
if(!defined('ITUNES_BLOCK'))
2013+
define('ITUNES_BLOCK', '');
2014+
20022015
if(!defined('LONG_TITLES'))
20032016
define('LONG_TITLES', false);
20042017

@@ -2166,6 +2179,7 @@ public function init()
21662179
$itunes->setSummary(ITUNES_SUMMARY);
21672180
$itunes->setImage(ITUNES_IMAGE);
21682181
$itunes->setExplicit(ITUNES_EXPLICIT);
2182+
$itunes->setBlock(ITUNES_BLOCK);
21692183

21702184
$itunes->setOwnerName(ITUNES_OWNER_NAME);
21712185
$itunes->setOwnerEmail(ITUNES_OWNER_EMAIL);

test/SettingsHandlerTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ class SettingsHandlerTest extends TestCase
3434
'ITUNES_AUTHOR',
3535
'ITUNES_CATEGORIES',
3636
'ITUNES_EXPLICIT',
37+
'ITUNES_BLOCK',
3738
'LONG_TITLES',
3839
'ITUNES_SUBTITLE_SUFFIX',
3940
'ITUNES_TYPE',
@@ -510,6 +511,7 @@ public function test_sensible_defaults($argv0)
510511
$this->assertEquals(ITUNES_AUTHOR, '');
511512
$this->assertEquals(ITUNES_CATEGORIES, '');
512513
$this->assertEquals(ITUNES_EXPLICIT, '');
514+
$this->assertEquals(ITUNES_BLOCK, '');
513515
$this->assertEquals(LONG_TITLES, false);
514516
$this->assertEquals(ITUNES_SUBTITLE_SUFFIX, '');
515517
$this->assertEquals(ITUNES_TYPE, 'episodic');

test/iTunes_Podcast_HelperTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,17 @@ public function test_adds_explicit_to_podcast()
143143
$this->assertChannelHasElement('explicit', 'yes', $data->channel);
144144
}
145145

146+
public function test_adds_block_to_podcast()
147+
{
148+
$mp = new MyPodcast();
149+
$itunes = $mp->addHelper(new iTunes_Podcast_Helper());
150+
$itunes->setBlock('yes');
151+
$content = $mp->generate();
152+
153+
$data = simplexml_load_string($content, 'SimpleXMLElement');
154+
$this->assertChannelHasElement('block', 'yes', $data->channel);
155+
}
156+
146157
public function test_adds_image_to_podcast()
147158
{
148159
$mp = new MyPodcast();

0 commit comments

Comments
 (0)