From 54e79a8e2e7428666996616bdc2982412bb23a4b Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 19 Jul 2019 12:51:05 +0200 Subject: [PATCH 1/9] Adding Episode content setting Updating RSS to apply Episode content setting and update Turbocharge application Adding Stylesheet back to RSS feed --- .../handlers/class-settings-handler.php | 23 +++-- templates/feed-podcast.php | 88 +++++++++++++------ 2 files changed, 76 insertions(+), 35 deletions(-) diff --git a/php/classes/handlers/class-settings-handler.php b/php/classes/handlers/class-settings-handler.php index c36fed34..5d934377 100644 --- a/php/classes/handlers/class-settings-handler.php +++ b/php/classes/handlers/class-settings-handler.php @@ -569,12 +569,15 @@ public function settings_fields() { 'default' => '', ), array( - 'id' => 'redirect_feed', - 'label' => __( 'Redirect this feed to new URL', 'seriously-simple-podcasting' ), - 'description' => sprintf( __( 'Redirect your feed to a new URL (specified below).', 'seriously-simple-podcasting' ), '
' ), - 'type' => 'checkbox', - 'default' => '', - 'callback' => 'wp_strip_all_tags', + 'id' => 'episode_description', + 'label' => __( 'Episode description', 'seriously-simple-podcasting' ), + 'description' => __( 'Use the excerpt or the post content in the description tag for episodes', 'seriously-simple-podcasting' ), + 'type' => 'radio', + 'options' => array( + 'excerpt' => __( 'Post Excerpt', 'seriously-simple-podcasting' ), + 'content' => __( 'Post Content', 'seriously-simple-podcasting' ), + ), + 'default' => 'excerpt', ), array( 'id' => 'turbocharge_feed', @@ -584,6 +587,14 @@ public function settings_fields() { 'default' => '', 'callback' => 'wp_strip_all_tags', ), + array( + 'id' => 'redirect_feed', + 'label' => __( 'Redirect this feed to new URL', 'seriously-simple-podcasting' ), + 'description' => sprintf( __( 'Redirect your feed to a new URL (specified below).', 'seriously-simple-podcasting' ), '
' ), + 'type' => 'checkbox', + 'default' => '', + 'callback' => 'wp_strip_all_tags', + ), array( 'id' => 'new_feed_url', 'label' => __( 'New podcast feed URL', 'seriously-simple-podcasting' ), diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index 39fb5f40..d246b477 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -86,7 +86,7 @@ // If redirect is on, get new feed URL and redirect if setting was changed more than 48 hours ago $redirect = get_option( 'ss_podcasting_redirect_feed' ); $new_feed_url = false; -if ( $redirect && $redirect == 'on' ) { +if ( $redirect && 'on' === $redirect ) { $new_feed_url = get_option( 'ss_podcasting_new_feed_url' ); $update_date = get_option( 'ss_podcasting_redirect_feed_date' ); @@ -108,7 +108,7 @@ if ( $series_id ) { $redirect = get_option( 'ss_podcasting_redirect_feed_' . $series_id ); $new_feed_url = false; - if ( $redirect && $redirect == 'on' ) { + if ( $redirect && 'on' === $redirect ) { $new_feed_url = get_option( 'ss_podcasting_new_feed_url_' . $series_id ); if ( $new_feed_url ) { header( 'HTTP/1.1 301 Moved Permanently' ); @@ -206,7 +206,7 @@ $explicit_option = $series_explicit_option; } $explicit_option = apply_filters( 'ssp_feed_explicit', $explicit_option, $series_id ); -if ( $explicit_option && 'on' == $explicit_option ) { +if ( $explicit_option && 'on' === $explicit_option ) { $itunes_explicit = 'yes'; $googleplay_explicit = 'Yes'; } else { @@ -221,7 +221,7 @@ $complete_option = $series_complete_option; } $complete_option = apply_filters( 'ssp_feed_complete', $complete_option, $series_id ); -if ( $complete_option && 'on' == $complete_option ) { +if ( $complete_option && 'on' === $complete_option ) { $complete = 'yes'; } else { $complete = ''; @@ -231,7 +231,7 @@ $image = get_option( 'ss_podcasting_data_image', '' ); if ( $podcast_series ) { $series_image = get_option( 'ss_podcasting_data_image_' . $series_id, 'no-image' ); - if ( 'no-image' != $series_image ) { + if ( 'no-image' !== $series_image ) { $image = $series_image; } } @@ -242,31 +242,51 @@ $category2 = ssp_get_feed_category_output( 2, $series_id ); $category3 = ssp_get_feed_category_output( 3, $series_id ); +// Get iTunes Type +$itunes_type = get_option( 'ss_podcasting_consume_order' . ( $series_id > 0 ? '_' . $series_id : null ) ); + +// Get turbo setting +$turbo = get_option( 'ss_podcasting_turbocharge_feed', 'off' ); +if ( $series_id && $series_id > 0 ) { + $series_turbo = get_option( 'ss_podcasting_turbocharge_feed_' . $series_id ); + if ( false !== $series_turbo ) { + $turbo = $series_turbo; + } +} + +// Get episode description setting +$episode_description = get_option( 'episode_description', 'excerpt' ); +if ( $series_id && $series_id > 0 ) { + $series_episode_description = get_option( 'episode_description_' . $series_id ); + if ( false !== $series_episode_description ) { + $episode_description = $series_episode_description; + } +} + +// Get stylesheet URL (filterable to allow custom RSS stylesheets) +$stylehseet_url = apply_filters( 'ssp_rss_stylesheet', $ss_podcasting->template_url . 'feed-stylesheet.xsl' ); + // Set RSS content type and charset headers header( 'Content-Type: ' . feed_content_type( 'podcast' ) . '; charset=' . get_option( 'blog_charset' ), true ); // Use `echo` for first line to prevent any extra characters at start of document echo '' . "\n"; -// Get iTunes Type -$itunes_type = get_option( 'ss_podcasting_consume_order' . ( $series_id > 0 ? '_' . $series_id : null ) ); - -$turbo = get_option( 'ss_podcasting_turbocharge_feed', 'off' ); - +// Include RSS stylesheet +if ( $stylehseet_url ) { + echo ''; +} ?> - -> - +xmlns:content="http://purl.org/rss/1.0/modules/content/" +xmlns:wfw="http://wellformedweb.org/CommentAPI/" +xmlns:dc="http://purl.org/dc/elements/1.1/" +xmlns:atom="http://www.w3.org/2005/Atom" +xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" +xmlns:slash="http://purl.org/rss/1.0/modules/slash/" +xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" +xmlns:googleplay="http://www.google.com/schemas/play-podcasts/1.0" + > <?php echo esc_html( $title ); ?> @@ -350,7 +370,7 @@ $qry = new WP_Query( $args ); if ( 'on' === $turbo ) { - $post_count = 0; + $turbo_post_count = 0; } if ( $qry->have_posts() ) { @@ -450,8 +470,18 @@ $content = preg_replace( '/<\/?iframe(.|\s)*?>/', '', $content ); $content = apply_filters( 'ssp_feed_item_content', $content, get_the_ID() ); - // Description is the full episode content, includes HTML, but must be shorter than 4000 characters - $description = mb_substr( $content, 0, 3999 ); + // Description is set based on feed setting + if ( 'excerpt' === $episode_description ) { + ob_start(); + the_excerpt_rss(); + $description = ob_get_clean(); + } else { + $description = $content; + if ( isset( $turbo_post_count ) && $turbo_post_count > 10 ) { + // If turbo is on, limit the full html description to 4000 chars + $description = mb_substr( $description, 0, 3999 ); + } + } $description = apply_filters( 'ssp_feed_item_description', $description, get_the_ID() ); // iTunes summary excludes HTML and must be shorter than 4000 characters @@ -512,8 +542,8 @@ $itunes_episode_number = get_post_meta( get_the_ID(), 'itunes_episode_number', true ); $itunes_season_number = get_post_meta( get_the_ID(), 'itunes_season_number', true ); } - if ( isset( $post_count ) ) { - $post_count ++; + if ( isset( $turbo_post_count ) ) { + $turbo_post_count ++; } ?> @@ -539,11 +569,11 @@ - + ]]> - + ]]> From cbf41535589c71e87ef7892630bd21465a3078da Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Fri, 19 Jul 2019 13:21:39 +0200 Subject: [PATCH 2/9] Fixed a bug with pushing series data to Castos, on the default feed Settings page --- php/classes/handlers/class-series-handler.php | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/php/classes/handlers/class-series-handler.php b/php/classes/handlers/class-series-handler.php index 82d616b5..6415b8cd 100644 --- a/php/classes/handlers/class-series-handler.php +++ b/php/classes/handlers/class-series-handler.php @@ -24,18 +24,22 @@ public function maybe_save_series() { if ( ! isset( $_GET['settings-updated'] ) || 'true' !== $_GET['settings-updated'] ) { return false; } - - if ( isset( $_GET['feed-series'] ) ) { - $feed_series_slug = ( isset( $_GET['feed-series'] ) ? filter_var( $_GET['feed-series'], FILTER_SANITIZE_STRING ) : '' ); + if ( ! isset( $_GET['feed-series'] ) ) { + $feed_series_slug = 'default'; + } else { + $feed_series_slug = sanitize_text_field( $_GET['feed-series'] ); if ( empty( $feed_series_slug ) ) { return false; } + } + + if ( 'default' === $feed_series_slug ) { + $series_data = get_series_data_for_castos( 0 ); + $series_data['series_id'] = 0; + } else { $series = get_term_by( 'slug', $feed_series_slug, 'series' ); $series_data = get_series_data_for_castos( $series->term_id ); $series_data['series_id'] = $series->term_id; - } else { - $series_data = get_series_data_for_castos( 0 ); - $series_data['series_id'] = 0; } $castos_handler = new Castos_Handler(); From b1f7c142fe7b6feb7101f646595e015b67c19487 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Mon, 22 Jul 2019 10:27:35 +0200 Subject: [PATCH 3/9] Fixing a few bugs with the Episode description setting --- templates/feed-podcast.php | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index d246b477..df3264f8 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -255,7 +255,7 @@ } // Get episode description setting -$episode_description = get_option( 'episode_description', 'excerpt' ); +$episode_description = get_option( 'ss_podcasting_episode_description', 'excerpt' ); if ( $series_id && $series_id > 0 ) { $series_episode_description = get_option( 'episode_description_' . $series_id ); if ( false !== $series_episode_description ) { @@ -263,19 +263,12 @@ } } -// Get stylesheet URL (filterable to allow custom RSS stylesheets) -$stylehseet_url = apply_filters( 'ssp_rss_stylesheet', $ss_podcasting->template_url . 'feed-stylesheet.xsl' ); - // Set RSS content type and charset headers header( 'Content-Type: ' . feed_content_type( 'podcast' ) . '; charset=' . get_option( 'blog_charset' ), true ); // Use `echo` for first line to prevent any extra characters at start of document echo '' . "\n"; -// Include RSS stylesheet -if ( $stylehseet_url ) { - echo ''; -} ?> > +> <?php echo esc_html( $title ); ?> @@ -569,11 +562,11 @@ - + ]]> - + ]]> From 1ca7b304bebf9b4a002b1f05e27815a9fe0afcf4 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Mon, 22 Jul 2019 10:36:10 +0200 Subject: [PATCH 4/9] Version bump to 1.20.6-beta --- readme.txt | 5 +++++ seriously-simple-podcasting.php | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/readme.txt b/readme.txt index a216ef65..f014bae2 100644 --- a/readme.txt +++ b/readme.txt @@ -102,6 +102,11 @@ You can find complete user and developer documentation (along with the FAQs) on == Changelog == += 1.20.6-beta = +* 2019-07-22 +* [NEW] Adds a setting to control how the RSS feed episode description is selected, either post excerpt or full post content +* [FIX] Fixes a bug where Turbocharge settings were enabled even when it is switched off + = 1.20.5 = * 2019-07-10 * [NEW] Add the ability to turbo charge the load times of the RSS feed, by limiting certain fields diff --git a/seriously-simple-podcasting.php b/seriously-simple-podcasting.php index 9077178c..ed4d3172 100644 --- a/seriously-simple-podcasting.php +++ b/seriously-simple-podcasting.php @@ -1,7 +1,7 @@ Date: Mon, 22 Jul 2019 11:21:50 +0200 Subject: [PATCH 5/9] Adding upgrade step to add default episode_description field --- .../controllers/class-admin-controller.php | 12 +------- .../handlers/class-upgrade-handler.php | 30 +++++++++++++++++++ 2 files changed, 31 insertions(+), 11 deletions(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index 724480f5..36fc4ff9 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -1324,17 +1324,7 @@ public function update() { $previous_version = get_option( 'ssp_version', '1.0' ); - if ( version_compare( $previous_version, '1.13.1', '<' ) ) { - flush_rewrite_rules(); - } - - if ( version_compare( $previous_version, '1.19.20', '<=' ) ) { - $this->upgrade_handler->upgrade_subscribe_links_options(); - } - - if ( version_compare( $previous_version, '1.20.3', '<=' ) ) { - $this->upgrade_handler->upgrade_stitcher_subscribe_link_option(); - } + $this->upgrade_handler->run_upgrades( $previous_version ); // always just check if the directory is ok ssp_get_upload_directory( false ); diff --git a/php/classes/handlers/class-upgrade-handler.php b/php/classes/handlers/class-upgrade-handler.php index e39331bb..505b5e4b 100644 --- a/php/classes/handlers/class-upgrade-handler.php +++ b/php/classes/handlers/class-upgrade-handler.php @@ -4,6 +4,29 @@ class Upgrade_Handler { + /** + * Main upgrade method, called from admin controller + * + * @param $previous_version + */ + public function run_upgrades( $previous_version ) { + if ( version_compare( $previous_version, '1.13.1', '<' ) ) { + flush_rewrite_rules(); + } + + if ( version_compare( $previous_version, '1.19.20', '<=' ) ) { + $this->upgrade_subscribe_links_options(); + } + + if ( version_compare( $previous_version, '1.20.3', '<=' ) ) { + $this->upgrade_stitcher_subscribe_link_option(); + } + + if ( version_compare( $previous_version, '1.20.6', '<' ) ) { + $this->add_default_episode_description_option(); + } + } + /** * Adds the ss_podcasting_subscribe_options array to the options table */ @@ -27,4 +50,11 @@ public function upgrade_stitcher_subscribe_link_option() { } update_option( 'ss_podcasting_subscribe_options', $subscribe_links_options ); } + + /** + * Adds the default episode_description option + */ + public function add_default_episode_description_option() { + update_option( 'ss_podcasting_episode_description', 'excerpt' ); + } } From 526ef3fb8c6f67be6bbdac36547d58b290b3c1a3 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Mon, 22 Jul 2019 12:46:38 +0200 Subject: [PATCH 6/9] Prevent the ss_player shortcode from rendering on the RSS feed Add the is_feed attribute to the wp_query object, for the RSS feed, if accessed via the old url structure --- php/classes/controllers/class-admin-controller.php | 8 ++++++++ php/classes/controllers/class-frontend-controller.php | 1 - php/classes/shortcodes/class-player.php | 9 +++++++++ templates/feed-podcast.php | 3 +-- 4 files changed, 18 insertions(+), 3 deletions(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index 36fc4ff9..9efc23e2 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -1260,6 +1260,14 @@ public function feed_template() { // 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'; diff --git a/php/classes/controllers/class-frontend-controller.php b/php/classes/controllers/class-frontend-controller.php index 1b54cd7f..6f14079f 100644 --- a/php/classes/controllers/class-frontend-controller.php +++ b/php/classes/controllers/class-frontend-controller.php @@ -485,7 +485,6 @@ public function media_player( $src_file = '', $episode_id = 0, $player_size = "l * @return string Media player HTML on success, empty string on failure */ public function load_media_player($src_file = '', $episode_id = 0, $player_size){ - /** * Check if this player is being loaded via the AMP for WordPress plugin and if so, force the standard player * https://wordpress.org/plugins/amp/ diff --git a/php/classes/shortcodes/class-player.php b/php/classes/shortcodes/class-player.php index 35acd605..6a0f72a8 100644 --- a/php/classes/shortcodes/class-player.php +++ b/php/classes/shortcodes/class-player.php @@ -3,6 +3,8 @@ namespace SeriouslySimplePodcasting\ShortCodes; // Exit if accessed directly. +use ParagonIE\Sodium\Core\Curve25519\Ge\P1p1; + if ( ! defined( 'ABSPATH' ) ) { exit; } @@ -23,6 +25,13 @@ class Player { */ public function shortcode() { + /** + * If we're in an RSS feed, don't render this shortcode + */ + if ( is_feed() ) { + return; + } + global $ss_podcasting; $current_post = get_post(); diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index df3264f8..b2c58e2b 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -14,7 +14,7 @@ global $ss_podcasting, $wp_query; // Hide all errors -error_reporting( 0 ); +// error_reporting( 0 ); // Allow feed access by default $give_access = true; @@ -268,7 +268,6 @@ // Use `echo` for first line to prevent any extra characters at start of document echo '' . "\n"; - ?> Date: Mon, 22 Jul 2019 13:29:36 +0200 Subject: [PATCH 7/9] Fixes an error with the old RSS URL feed, because of an ealier change with the registration of post types being changed to a lower priority --- php/classes/controllers/class-admin-controller.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/php/classes/controllers/class-admin-controller.php b/php/classes/controllers/class-admin-controller.php index 9efc23e2..d0d30591 100644 --- a/php/classes/controllers/class-admin-controller.php +++ b/php/classes/controllers/class-admin-controller.php @@ -57,10 +57,10 @@ public function bootstrap() { add_action( 'init', array( $this, 'register_post_type' ), 11 ); // Register podcast feed. - add_action( 'init', array( $this, 'add_feed' ), 1 ); + 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' ) ); + add_action( 'init', array( $this, 'redirect_old_feed' ), 11 ); // Setup custom permalink structures. add_action( 'init', array( $this, 'setup_permastruct' ), 10 ); From a53b261bf1c58969ed1521910c6467dda3c23808 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Tue, 23 Jul 2019 15:55:20 +0200 Subject: [PATCH 8/9] Removing incorrect declaration --- php/classes/shortcodes/class-player.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/php/classes/shortcodes/class-player.php b/php/classes/shortcodes/class-player.php index 6a0f72a8..54515751 100644 --- a/php/classes/shortcodes/class-player.php +++ b/php/classes/shortcodes/class-player.php @@ -3,8 +3,6 @@ namespace SeriouslySimplePodcasting\ShortCodes; // Exit if accessed directly. -use ParagonIE\Sodium\Core\Curve25519\Ge\P1p1; - if ( ! defined( 'ABSPATH' ) ) { exit; } From 2be31c66c1325e7f7302bfd49563be3f31d3d4c6 Mon Sep 17 00:00:00 2001 From: Jonathan Bossenger Date: Tue, 23 Jul 2019 15:57:02 +0200 Subject: [PATCH 9/9] Turn error_reporting off in feed template --- templates/feed-podcast.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/feed-podcast.php b/templates/feed-podcast.php index b2c58e2b..0a504161 100644 --- a/templates/feed-podcast.php +++ b/templates/feed-podcast.php @@ -14,7 +14,7 @@ global $ss_podcasting, $wp_query; // Hide all errors -// error_reporting( 0 ); +error_reporting( 0 ); // Allow feed access by default $give_access = true;