From 44255c155e1b45ea3633485d0d3acd798c8b8a1e Mon Sep 17 00:00:00 2001 From: Eric Teubert Date: Fri, 26 Apr 2024 10:41:40 +0200 Subject: [PATCH] fix: itunes:explicit RSS tag content Must have changed from yes/no/clean to the more sensible true/false at some point without us noticing. This updates it. --- includes/explicit_content.php | 2 +- lib/feeds/base.php | 2 +- lib/model/episode.php | 5 +++-- lib/model/podcast.php | 10 ++++++++++ lib/settings/podcast/tab/directory.php | 5 ++--- lib/template/episode.php | 2 +- lib/version.php | 12 +++++++++++- readme.txt | 1 + 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/includes/explicit_content.php b/includes/explicit_content.php index 9b8f5158e..5fa4d0d7f 100644 --- a/includes/explicit_content.php +++ b/includes/explicit_content.php @@ -13,7 +13,7 @@ 'type' => 'checkbox', 'html' => ['style' => 'width: 200px;'], 'default' => '-1', - 'options' => [0 => 'no', 1 => 'yes', 2 => 'clean'], + 'options' => [0 => 'false', 1 => 'true'], ], 'position' => 770, ]; diff --git a/lib/feeds/base.php b/lib/feeds/base.php index e6785e5e3..693d4a3f7 100644 --- a/lib/feeds/base.php +++ b/lib/feeds/base.php @@ -287,7 +287,7 @@ function override_feed_head($hook, $podcast, $feed, $format) echo "\t".apply_filters('podlove_feed_itunes_block', $block); echo PHP_EOL; - $explicit = sprintf('%s', ($podcast->explicit == 2) ? 'clean' : (($podcast->explicit) ? 'yes' : 'no')); + $explicit = sprintf('%s', $podcast->explicit_text()); echo "\t".apply_filters('podlove_feed_itunes_explicit', $explicit); echo PHP_EOL; diff --git a/lib/model/episode.php b/lib/model/episode.php index f9df278e3..12debb8e3 100644 --- a/lib/model/episode.php +++ b/lib/model/episode.php @@ -224,11 +224,12 @@ public function categories($args = []) public function explicit_text() { + // backwards compatibility if ($this->explicit == 2) { - return 'clean'; + return 'false'; } - return $this->explicit ? 'yes' : 'no'; + return $this->explicit ? 'true' : 'false'; } public function media_files($args = []) diff --git a/lib/model/podcast.php b/lib/model/podcast.php index f92677aa2..5161efecf 100644 --- a/lib/model/podcast.php +++ b/lib/model/podcast.php @@ -235,6 +235,16 @@ public function default_copyright_claim() return '© '.date('Y').' '.($this->author_name ?? $this->title); } + public function explicit_text() + { + // backwards compatibility + if ($this->explicit == 2) { + return 'false'; + } + + return $this->explicit ? 'true' : 'false'; + } + /** * Episodes. * diff --git a/lib/settings/podcast/tab/directory.php b/lib/settings/podcast/tab/directory.php index 04d75f1cc..ec44a48ba 100644 --- a/lib/settings/podcast/tab/directory.php +++ b/lib/settings/podcast/tab/directory.php @@ -124,9 +124,8 @@ public function register_page() $wrapper->select('explicit', [ 'label' => __('Explicit Content?', 'podlove-podcasting-plugin-for-wordpress'), - 'description' => __('', 'podlove-podcasting-plugin-for-wordpress'), - 'type' => 'checkbox', - 'options' => [0 => 'no', 1 => 'yes', 2 => 'clean'], + 'description' => __('True: If you specify true, indicating the presence of explicit content, directories may display an Explicit parental advisory graphic for your podcast. False: If you specify false, indicating that your podcast does not contain explicit language or adult content, directories may display a Clean parental advisory graphic for your podcast.', 'podlove-podcasting-plugin-for-wordpress'), + 'options' => [0 => 'false', 1 => 'true'], ]); $wrapper->checkbox('complete', [ diff --git a/lib/template/episode.php b/lib/template/episode.php index 2e85f14c7..ac026b38e 100644 --- a/lib/template/episode.php +++ b/lib/template/episode.php @@ -213,7 +213,7 @@ public function recordingDate($format = '') /** * Explicit status. * - * "yes", "no" or "clean" + * "true" or "false" * * @accessor */ diff --git a/lib/version.php b/lib/version.php index f013beaf4..428daed35 100644 --- a/lib/version.php +++ b/lib/version.php @@ -42,7 +42,7 @@ use Podlove\Jobs\CronJobRunner; -define('Podlove\DATABASE_VERSION', 156); +define('Podlove\DATABASE_VERSION', 157); add_action('admin_init', '\Podlove\maybe_run_database_migrations'); add_action('admin_init', '\Podlove\run_database_migrations', 5); @@ -1653,6 +1653,16 @@ function run_migrations_for_version($version) $podcast->feed_transcripts = 'generated'; $podcast->save(); + break; + case 157: + $podcast = Model\Podcast::get(); + + // update deprecated "clean" value to "false" + if ($podcast->explicit == 2) { + $podcast->explicit = 0; + $podcast->save(); + } + break; } } diff --git a/readme.txt b/readme.txt index 695d7774e..03719df3d 100644 --- a/readme.txt +++ b/readme.txt @@ -117,6 +117,7 @@ This product includes GeoLite2 data created by MaxMind, available from http://ww = 4.1.7 = +* fix `itunes:explicit` RSS tag. It now contains the valid values "true" or "false". * fix typo in API: `explicit` field was mistyped as `expicit` = 4.1.6 =