From 87f67350955a818c55446aa551c0df2e7b5dda22 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Thu, 1 Aug 2019 14:46:27 +0200 Subject: [PATCH 1/9] Summary RSS Feed refactoring and adding Podtrac support Added a setting for the Podtrac prefix url Moved all feed related logic from the Admin_Controller to a new Feed_Controller Added a function which parses the audio_file url and returns it with the podtrac_prefix --- .../controllers/class-admin-controller.php | 65 ----------- php/classes/controllers/class-controller.php | 2 + .../controllers/class-feed-controller.php | 110 ++++++++++++++++++ .../handlers/class-settings-handler.php | 12 ++ php/includes/ssp-functions.php | 22 ++++ seriously-simple-podcasting.php | 4 +- templates/feed-podcast.php | 14 +++ vendor/composer/autoload_classmap.php | 1 + vendor/composer/autoload_static.php | 1 + 9 files changed, 165 insertions(+), 66 deletions(-) create mode 100644 php/classes/controllers/class-feed-controller.php diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index 4cc707bc..f0ef6c38 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -56,12 +56,6 @@ public function bootstrap() { // Regsiter podcast post type, taxonomies and meta fields. add_action( 'init', array( $this, 'register_post_type' ), 11 ); - // Register podcast feed. - add_action( 'init', array( $this, 'add_feed' ), 11 ); - - // Handle v1.x feed URL as well as feed URLs for default permalinks. - add_action( 'init', array( $this, 'redirect_old_feed' ), 11 ); - // Setup custom permalink structures. add_action( 'init', array( $this, 'setup_permastruct' ), 10 ); @@ -1233,15 +1227,6 @@ public function load_plugin_textdomain() { load_plugin_textdomain( $domain, false, dirname( plugin_basename( $this->file ) ) . '/lang/' ); } - /** - * Register podcast feed - * @return void - */ - public function add_feed() { - $feed_slug = apply_filters( 'ssp_feed_slug', $this->token ); - add_feed( $feed_slug, array( $this, 'feed_template' ) ); - } - /** * Hide RSS footer created by WordPress SEO from podcast RSS feed * @@ -1258,56 +1243,6 @@ public function hide_wp_seo_rss_footer( $include_footer = true ) { return $include_footer; } - /** - * Load feed template - * @return void - */ - public function feed_template() { - global $wp_query; - - // Prevent 404 on feed - $wp_query->is_404 = false; - - /** - * Fix the is_feed attribute on the old feed url structure - */ - if ( ! $wp_query->is_feed ) { - $wp_query->is_feed = true; - } - - status_header( 200 ); - - $file_name = 'feed-podcast.php'; - - $user_template_file = apply_filters( 'ssp_feed_template_file', trailingslashit( get_stylesheet_directory() ) . $file_name ); - - // Any functions hooked in here must NOT output any data or else feed will break - do_action( 'ssp_before_feed' ); - - // Load user feed template if it exists, otherwise use plugin template - if ( file_exists( $user_template_file ) ) { - require( $user_template_file ); - } else { - require( $this->template_path . $file_name ); - } - - // Any functions hooked in here must NOT output any data or else feed will break - do_action( 'ssp_after_feed' ); - - exit; - } - - /** - * Redirect feed URLs created prior to v1.8 to ensure backwards compatibility - * @return void - */ - public function redirect_old_feed() { - if ( isset( $_GET['feed'] ) && in_array( $_GET['feed'], array( $this->token, 'itunes' ) ) ) { - $this->feed_template(); - exit; - } - } - /** * Flush rewrite rules on plugin acivation * @return void diff --git a/php/classes/controllers/class-controller.php b/php/classes/controllers/class-controller.php index 9030a23e..2482ef69 100644 --- a/php/classes/controllers/class-controller.php +++ b/php/classes/controllers/class-controller.php @@ -7,6 +7,8 @@ exit; } +// @todo maybe this should be a trait ? + /** * Main controller class * diff --git a/php/classes/controllers/class-feed-controller.php b/php/classes/controllers/class-feed-controller.php new file mode 100644 index 00000000..245dffab --- /dev/null +++ b/php/classes/controllers/class-feed-controller.php @@ -0,0 +1,110 @@ +bootstrap(); + } + + /** + * Set up all hooks and filters for this class + */ + public function bootstrap() { + // Register podcast feed. + add_action( 'init', array( $this, 'add_feed' ), 11 ); + + // Handle v1.x feed URL as well as feed URLs for default permalinks. + add_action( 'init', array( $this, 'redirect_old_feed' ), 11 ); + } + + /** + * Register podcast feed + * @return void + */ + public function add_feed() { + $feed_slug = apply_filters( 'ssp_feed_slug', $this->token ); + add_feed( $feed_slug, array( $this, 'render_podcast_feed' ) ); + } + + /** + * Redirect feed URLs created prior to v1.8 to ensure backwards compatibility + * @return void + */ + public function redirect_old_feed() { + if ( isset( $_GET['feed'] ) && in_array( $_GET['feed'], array( $this->token, 'itunes' ) ) ) { + $this->render_podcast_feed(); + exit; + } + } + + /** + * Render the podcast feed + * // @todo move all logic from feed template file to this method, at the very least + * @return void + */ + public function render_podcast_feed() { + global $wp_query; + + // Prevent 404 on feed + $wp_query->is_404 = false; + + /** + * Fix the is_feed attribute on the old feed url structure + */ + if ( ! $wp_query->is_feed ) { + $wp_query->is_feed = true; + } + + $this->load_feed_template(); + + exit; + + } + + /** + * Loads the feed template file + */ + public function load_feed_template() { + status_header( 200 ); + + $user_template_file = apply_filters( 'ssp_feed_template_file', trailingslashit( get_stylesheet_directory() ) . $this->feed_file_name ); + + // Any functions hooked in here must NOT output any data or else feed will break + do_action( 'ssp_before_feed' ); + + // Load user feed template if it exists, otherwise use plugin template + if ( file_exists( $user_template_file ) ) { + require $user_template_file; + } else { + require $this->template_path . $this->feed_file_name; + } + + // Any functions hooked in here must NOT output any data or else feed will break + do_action( 'ssp_after_feed' ); + } +} diff --git a/php/classes/handlers/class-settings-handler.php b/php/classes/handlers/class-settings-handler.php index c85f3726..9f9d53bd 100644 --- a/php/classes/handlers/class-settings-handler.php +++ b/php/classes/handlers/class-settings-handler.php @@ -723,6 +723,18 @@ public function settings_fields() { ), 'default' => '', ), + + array( + 'id' => 'podtrac_prefix', + 'label' => __( 'Podtrac Prefix', 'seriously-simple-podcasting' ), + 'description' => __( 'Enter your Podtrac Prefix to use Podtrac\'s Measurement service. Be sure to include correct protocol and trailing slash.', 'seriously-simple-podcasting' ), + 'type' => 'text', + 'default' => '', + 'placeholder' => __( 'https://dts.podtrac.com/redirect/mp3/', 'seriously-simple-podcasting' ), + 'callback' => 'esc_url_raw', + 'class' => 'regular-text', + ), + array( 'id' => 'episode_description', 'label' => __( 'Episode description', 'seriously-simple-podcasting' ), diff --git a/php/includes/ssp-functions.php b/php/includes/ssp-functions.php index ef02519c..d6e61829 100644 --- a/php/includes/ssp-functions.php +++ b/php/includes/ssp-functions.php @@ -1051,3 +1051,25 @@ function get_series_data_for_castos( $series_id ) { } } + +if ( ! function_exists( 'parse_episode_url_for_podtrac' ) ) { + /** + * Takes an episode url and appends the podtrac prefix in front of it + * + * @param string $audio_file_url + * @param string $podtrac_url + * + * @return string + */ + function parse_episode_url_for_podtrac( $audio_file_url = '', $podtrac_url = '' ) { + if ( empty( $podtrac_url ) ) { + return $audio_file_url; + } + if ( empty( $audio_file_url ) ) { + return $audio_file_url; + } + $url_parts = wp_parse_url( $audio_file_url ); + + return $podtrac_url . $url_parts['host'] . $url_parts['path']; + } +} diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 9e9670b0..04e03016 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -22,6 +22,7 @@ use SeriouslySimplePodcasting\Controllers\Admin_Controller; use SeriouslySimplePodcasting\Controllers\Frontend_Controller; +use SeriouslySimplePodcasting\Controllers\Feed_Controller; use SeriouslySimplePodcasting\Controllers\Settings_Controller; use SeriouslySimplePodcasting\Controllers\Options_Controller; use SeriouslySimplePodcasting\Rest\Rest_Api_Controller; @@ -49,9 +50,10 @@ * @todo the admin_controller should really be renamed, as it's not really 'admin' specific * @todo alternatively the non admin specific functionality should be moved into it's own 'foundation' controller, perhaps even the parent controller */ -global $ssp_admin, $ss_podcasting; +global $ssp_admin, $ss_podcasting, $ssp_feed; $ssp_admin = new Admin_Controller( __FILE__, SSP_VERSION ); $ss_podcasting = new Frontend_Controller( __FILE__, SSP_VERSION ); +$ssp_feed = new Feed_Controller( __FILE__, SSP_VERSION ); /** * Only load the settings if we're in the admin dashboard */ diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index e8cfa376..7296632e 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -11,6 +11,7 @@ exit; } +// @todo move all of this logic into the Feed_Controller render_podcast_feed method, at the very least global $ss_podcasting, $wp_query; // Hide all errors @@ -254,6 +255,15 @@ } } +// Get podract prefix setting +$podtrac_prefix = get_option( 'ss_podcasting_podtrac_prefix', '' ); +if ( $series_id && $series_id > 0 ) { + $series_podtrac_prefix = get_option( 'ss_podcasting_episode_description_' . $series_id ); + if ( false !== $series_podtrac_prefix ) { + $podtrac_prefix = $series_podtrac_prefix; + } +} + // Get episode description setting $episode_description = get_option( 'ss_podcasting_episode_description', 'excerpt' ); if ( $series_id && $series_id > 0 ) { @@ -391,6 +401,10 @@ $enclosure = apply_filters( 'ssp_feed_item_enclosure', $enclosure, get_the_ID() ); + if ( ! empty( $podtrac_prefix ) ) { + $enclosure = parse_episode_url_for_podtrac( $enclosure, $podtrac_prefix ); + } + // If there is no enclosure then go no further if ( ! isset( $enclosure ) || ! $enclosure ) { continue; diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 8d51210f..9326a967 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -11,6 +11,7 @@ 'SeriouslySimplePodcasting\\Controllers\\Controller' => $baseDir . '/php/classes/controllers/class-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Episode_Controller' => $baseDir . '/php/classes/controllers/class-episode-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Extensions_Controller' => $baseDir . '/php/classes/controllers/class-extensions-controller.php', + 'SeriouslySimplePodcasting\\Controllers\\Feed_Controller' => $baseDir . '/php/classes/controllers/class-feed-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Frontend_Controller' => $baseDir . '/php/classes/controllers/class-frontend-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Import_Controller' => $baseDir . '/php/classes/controllers/class-import-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Options_Controller' => $baseDir . '/php/classes/controllers/class-options-controller.php', diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 561fa380..0dcbca58 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -12,6 +12,7 @@ class ComposerStaticInit34e210bfa8d7151620d7fa4510f053c5 'SeriouslySimplePodcasting\\Controllers\\Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Episode_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-episode-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Extensions_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-extensions-controller.php', + 'SeriouslySimplePodcasting\\Controllers\\Feed_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-feed-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Frontend_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-frontend-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Import_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-import-controller.php', 'SeriouslySimplePodcasting\\Controllers\\Options_Controller' => __DIR__ . '/../..' . '/php/classes/controllers/class-options-controller.php', From aa502e84bc422068e2f586c57a0585a13cb86b5a Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Thu, 1 Aug 2019 14:49:18 +0200 Subject: [PATCH 2/9] Updated version and changelog --- readme.txt | 4 ++++ seriously-simple-podcasting.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index 6381d6dc..7066407f 100644 --- a/readme.txt +++ b/readme.txt @@ -102,6 +102,10 @@ You can find complete user and developer documentation (along with the FAQs) on == Changelog == += 1.20.8-alpha = +* 2019-08-01 +* [NEW] Added support for Podtrac Measuring service + = 1.20.7 = * 2019-07-31 * [UPDATE] Updated podcast categories to reflect Apple's [podcast category changes](https://podnews.net/press-release/apple-wwdc-2019-anno) diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 04e03016..24acab1c 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -1,7 +1,7 @@ Date: Fri, 2 Aug 2019 08:40:35 +0200 Subject: [PATCH 3/9] Moved add_feed method call on activation hook to Feed_Controller --- php/classes/controllers/class-admin-controller.php | 1 - php/classes/controllers/class-feed-controller.php | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index f0ef6c38..fb877831 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -1251,7 +1251,6 @@ public function activate() { // Setup all custom URL rules $this->register_post_type(); - $this->add_feed(); $this->setup_permastruct(); // Flush permalinks diff --git a/php/classes/controllers/class-feed-controller.php b/php/classes/controllers/class-feed-controller.php index 245dffab..43581ed3 100644 --- a/php/classes/controllers/class-feed-controller.php +++ b/php/classes/controllers/class-feed-controller.php @@ -40,6 +40,8 @@ public function bootstrap() { // Handle v1.x feed URL as well as feed URLs for default permalinks. add_action( 'init', array( $this, 'redirect_old_feed' ), 11 ); + + register_activation_hook( $this->file, array( $this, 'add_feed' ) ); } /** From 2226825528f2b24a1e936d06a713c296641ff347 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 2 Aug 2019 09:11:49 +0200 Subject: [PATCH 4/9] Adds Feed_Controller dependancy on Admin Controller to be able to register add_feed method on plugin activation --- .../controllers/class-admin-controller.php | 23 ++++++++++++++----- .../controllers/class-feed-controller.php | 2 -- seriously-simple-podcasting.php | 4 +--- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index fb877831..eee21c1f 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -26,13 +26,21 @@ class Admin_Controller extends Controller { */ protected $ajax_handler; + /** + * @var object instance of Upgrade_Handler + */ protected $upgrade_handler; + /** + * @var object instance of Feed_Controller + */ + protected $feed_controller; + /** * Admin_Controller constructor. * - * @param $file main plugin file - * @param $version plugin version + * @param $file string main plugin file + * @param $version string plugin version */ public function __construct( $file, $version ) { parent::__construct( $file, $version ); @@ -48,6 +56,8 @@ public function bootstrap() { $this->upgrade_handler = new Upgrade_Handler(); + $this->feed_controller = new Feed_Controller(); + // Handle localisation. $this->load_plugin_textdomain(); @@ -1244,21 +1254,22 @@ public function hide_wp_seo_rss_footer( $include_footer = true ) { } /** - * Flush rewrite rules on plugin acivation + * All plugin activation functionality * @return void */ public function activate() { - // Setup all custom URL rules $this->register_post_type(); + // Setup feed + $this->feed_controller->add_feed(); + // Setup permalink structure $this->setup_permastruct(); - // Flush permalinks flush_rewrite_rules( true ); } /** - * Flush rewrite rules on plugin deacivation + * All plugin deactivation functionality * @return void */ public function deactivate() { diff --git a/php/classes/controllers/class-feed-controller.php b/php/classes/controllers/class-feed-controller.php index 43581ed3..245dffab 100644 --- a/php/classes/controllers/class-feed-controller.php +++ b/php/classes/controllers/class-feed-controller.php @@ -40,8 +40,6 @@ public function bootstrap() { // Handle v1.x feed URL as well as feed URLs for default permalinks. add_action( 'init', array( $this, 'redirect_old_feed' ), 11 ); - - register_activation_hook( $this->file, array( $this, 'add_feed' ) ); } /** diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 24acab1c..726221ca 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -22,7 +22,6 @@ use SeriouslySimplePodcasting\Controllers\Admin_Controller; use SeriouslySimplePodcasting\Controllers\Frontend_Controller; -use SeriouslySimplePodcasting\Controllers\Feed_Controller; use SeriouslySimplePodcasting\Controllers\Settings_Controller; use SeriouslySimplePodcasting\Controllers\Options_Controller; use SeriouslySimplePodcasting\Rest\Rest_Api_Controller; @@ -50,10 +49,9 @@ * @todo the admin_controller should really be renamed, as it's not really 'admin' specific * @todo alternatively the non admin specific functionality should be moved into it's own 'foundation' controller, perhaps even the parent controller */ -global $ssp_admin, $ss_podcasting, $ssp_feed; +global $ssp_admin, $ss_podcasting; $ssp_admin = new Admin_Controller( __FILE__, SSP_VERSION ); $ss_podcasting = new Frontend_Controller( __FILE__, SSP_VERSION ); -$ssp_feed = new Feed_Controller( __FILE__, SSP_VERSION ); /** * Only load the settings if we're in the admin dashboard */ From fa54c85e502a9beabe1d1497a0598dab1f1dc470 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 2 Aug 2019 09:22:30 +0200 Subject: [PATCH 5/9] Passing correct parameters to Feed_Controller constructor --- php/classes/controllers/class-admin-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index eee21c1f..b9535dcf 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -56,7 +56,7 @@ public function bootstrap() { $this->upgrade_handler = new Upgrade_Handler(); - $this->feed_controller = new Feed_Controller(); + $this->feed_controller = new Feed_Controller( $this->file, $this->version ); // Handle localisation. $this->load_plugin_textdomain(); From 61d2b23bd99db217e3369438106c3a34a1ef83ff Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 2 Aug 2019 09:26:12 +0200 Subject: [PATCH 6/9] Added a comment for later refactoring --- seriously-simple-podcasting.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 726221ca..61766877 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -47,7 +47,7 @@ /** * @todo refactor these globals * @todo the admin_controller should really be renamed, as it's not really 'admin' specific - * @todo alternatively the non admin specific functionality should be moved into it's own 'foundation' controller, perhaps even the parent controller + * @todo alternatively the non admin specific functionality should be moved into it's own 'foundation' controller, perhaps even the parent controller, or a trait */ global $ssp_admin, $ss_podcasting; $ssp_admin = new Admin_Controller( __FILE__, SSP_VERSION ); From acdca15e22d73cd41dec9c6f9083a8ec4d4403e8 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 2 Aug 2019 10:52:48 +0200 Subject: [PATCH 7/9] Moved terminology from podtrac only to media file prefx Updated all relevant logic Added link to setting --- php/classes/handlers/class-settings-handler.php | 12 ++++++------ php/includes/ssp-functions.php | 12 ++++++------ templates/feed-podcast.php | 14 +++++++------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/php/classes/handlers/class-settings-handler.php b/php/classes/handlers/class-settings-handler.php index 9f9d53bd..a2b7b19f 100644 --- a/php/classes/handlers/class-settings-handler.php +++ b/php/classes/handlers/class-settings-handler.php @@ -714,27 +714,27 @@ public function settings_fields() { array( 'id' => 'consume_order', 'label' => __( 'Show Type', 'seriously-simple-podcasting' ), + // translators: placeholders are for help document link 'description' => sprintf( __( 'The order your podcast episodes will be listed. %1$sMore details here.%2$s', 'seriously-simple-podcasting' ), '', '' ), 'type' => 'select', 'options' => array( '' => __( 'Please Select', 'seriously-simple-podcasting' ), 'episodic' => __( 'Episodic', 'seriously-simple-podcasting' ), - 'serial' => __( 'Serial', 'seriously-simple-podcasting' ) + 'serial' => __( 'Serial', 'seriously-simple-podcasting' ), ), 'default' => '', ), - array( - 'id' => 'podtrac_prefix', - 'label' => __( 'Podtrac Prefix', 'seriously-simple-podcasting' ), - 'description' => __( 'Enter your Podtrac Prefix to use Podtrac\'s Measurement service. Be sure to include correct protocol and trailing slash.', 'seriously-simple-podcasting' ), + 'id' => 'media_prefix', + 'label' => __( 'Media File Prefix', 'seriously-simple-podcasting' ), + // translators: placeholders are for help document link + 'description' => sprintf( __( 'Enter your Podtrac, Chartable, or other media file prefix here. %1$sMore details here.%2$s', 'seriously-simple-podcasting' ), '', '' ), 'type' => 'text', 'default' => '', 'placeholder' => __( 'https://dts.podtrac.com/redirect/mp3/', 'seriously-simple-podcasting' ), 'callback' => 'esc_url_raw', 'class' => 'regular-text', ), - array( 'id' => 'episode_description', 'label' => __( 'Episode description', 'seriously-simple-podcasting' ), diff --git a/php/includes/ssp-functions.php b/php/includes/ssp-functions.php index d6e61829..d890e512 100644 --- a/php/includes/ssp-functions.php +++ b/php/includes/ssp-functions.php @@ -1052,17 +1052,17 @@ function get_series_data_for_castos( $series_id ) { } } -if ( ! function_exists( 'parse_episode_url_for_podtrac' ) ) { +if ( ! function_exists( 'parse_episode_url_with_media_prefix' ) ) { /** - * Takes an episode url and appends the podtrac prefix in front of it + * Takes an episode url and appends the media prefix in front of it * * @param string $audio_file_url - * @param string $podtrac_url + * @param string $media_prefix * * @return string */ - function parse_episode_url_for_podtrac( $audio_file_url = '', $podtrac_url = '' ) { - if ( empty( $podtrac_url ) ) { + function parse_episode_url_with_media_prefix( $audio_file_url = '', $media_prefix = '' ) { + if ( empty( $media_prefix ) ) { return $audio_file_url; } if ( empty( $audio_file_url ) ) { @@ -1070,6 +1070,6 @@ function parse_episode_url_for_podtrac( $audio_file_url = '', $podtrac_url = '' } $url_parts = wp_parse_url( $audio_file_url ); - return $podtrac_url . $url_parts['host'] . $url_parts['path']; + return $media_prefix . $url_parts['host'] . $url_parts['path']; } } diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index 7296632e..0ea97530 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -255,12 +255,12 @@ } } -// Get podract prefix setting -$podtrac_prefix = get_option( 'ss_podcasting_podtrac_prefix', '' ); +// Get media prefix setting +$media_prefix = get_option( 'ss_podcasting_media_prefix', '' ); if ( $series_id && $series_id > 0 ) { - $series_podtrac_prefix = get_option( 'ss_podcasting_episode_description_' . $series_id ); - if ( false !== $series_podtrac_prefix ) { - $podtrac_prefix = $series_podtrac_prefix; + $series_media_prefix = get_option( 'ss_podcasting_media_prefix_' . $series_id ); + if ( false !== $series_media_prefix ) { + $media_prefix = $series_media_prefix; } } @@ -401,8 +401,8 @@ $enclosure = apply_filters( 'ssp_feed_item_enclosure', $enclosure, get_the_ID() ); - if ( ! empty( $podtrac_prefix ) ) { - $enclosure = parse_episode_url_for_podtrac( $enclosure, $podtrac_prefix ); + if ( ! empty( $media_prefix ) ) { + $enclosure = parse_episode_url_with_media_prefix( $enclosure, $media_prefix ); } // If there is no enclosure then go no further From 346757d54624c61826f976afb0cf5b96285c6b80 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 2 Aug 2019 10:53:43 +0200 Subject: [PATCH 8/9] Updated version number --- seriously-simple-podcasting.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 61766877..1160c0bf 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -1,7 +1,7 @@ Date: Tue, 13 Aug 2019 09:55:01 +0200 Subject: [PATCH 9/9] Version bump and changelog update --- readme.txt | 10 +++++----- seriously-simple-podcasting.php | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/readme.txt b/readme.txt index 7066407f..e4fb7eca 100644 --- a/readme.txt +++ b/readme.txt @@ -2,9 +2,9 @@ Contributors: PodcastMotor, psykro, simondowdles, hlashbrooke, whyisjake Tags: podcast, audio, video, vodcast, rss, mp3, mp4, feed, itunes, podcasting, media, stitcher, google play, playlist Requires at least: 4.4 -Tested up to: 5.2 +Tested up to: 5.2.2 Requires PHP: 5.6 -Stable tag: 1.20.7 +Stable tag: 1.20.8 License: GPLv2 or later License URI: http://www.gnu.org/licenses/gpl-2.0.html @@ -102,9 +102,9 @@ You can find complete user and developer documentation (along with the FAQs) on == Changelog == -= 1.20.8-alpha = -* 2019-08-01 -* [NEW] Added support for Podtrac Measuring service += 1.20.8 = +* 2019-08-13 +* [NEW] Added support for RSS Feed media file prefixing, to enable measuring services like Podtrac and Chartable = 1.20.7 = * 2019-07-31 diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 1160c0bf..1a3b8f01 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -1,14 +1,14 @@