Skip to content

Commit

Permalink
Merge pull request #388 from TheCraigHewitt/release/1.20.6
Browse files Browse the repository at this point in the history
Release/1.20.6
  • Loading branch information
jonathanbossenger authored Jul 29, 2019
2 parents 4ae113e + b575f38 commit 549c2e6
Show file tree
Hide file tree
Showing 9 changed files with 139 additions and 59 deletions.
24 changes: 11 additions & 13 deletions php/classes/controllers/class-admin-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down Expand Up @@ -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';
Expand Down Expand Up @@ -1324,17 +1332,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 );
Expand Down
1 change: 0 additions & 1 deletion php/classes/controllers/class-frontend-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
16 changes: 10 additions & 6 deletions php/classes/handlers/class-series-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
23 changes: 17 additions & 6 deletions php/classes/handlers/class-settings-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' ), '<br/>' ),
'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',
Expand All @@ -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' ), '<br/>' ),
'type' => 'checkbox',
'default' => '',
'callback' => 'wp_strip_all_tags',
),
array(
'id' => 'new_feed_url',
'label' => __( 'New podcast feed URL', 'seriously-simple-podcasting' ),
Expand Down
30 changes: 30 additions & 0 deletions php/classes/handlers/class-upgrade-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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' );
}
}
7 changes: 7 additions & 0 deletions php/classes/shortcodes/class-player.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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();
Expand Down
11 changes: 10 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: podcast, audio, video, vodcast, rss, mp3, mp4, feed, itunes, podcasting, m
Requires at least: 4.4
Tested up to: 5.2
Requires PHP: 5.6
Stable tag: 1.20.5
Stable tag: 1.20.6
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -102,6 +102,15 @@ You can find complete user and developer documentation (along with the FAQs) on

== Changelog ==

= 1.20.6 =
* 2019-07-24
* UPDATE SUMMARY: Various bug fixes related to recent changes to the RSS Feed
* [NEW] Add a setting to control whether RSS feed episode description tags use the post content or the post excerpt
* [FIX] Fixes a bug where Turbocharge settings were enabled even when it is switched off
* [FIX] Fixes a bug when sending series data to a Castos connected podcast
* [FIX] Fixes a bug where the ss_player shortcode renders the media player in the RSS feed
* [FIX] Fixes a bug in the legacy RSS feed url

= 1.20.5 =
* 2019-07-10
* [NEW] Add the ability to turbo charge the load times of the RSS feed, by limiting certain fields
Expand Down
4 changes: 2 additions & 2 deletions seriously-simple-podcasting.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* Plugin Name: Seriously Simple Podcasting
* Version: 1.20.5
* Version: 1.20.6
* Plugin URI: https://www.castos.com/seriously-simple-podcasting
* Description: Podcasting the way it's meant to be. No mess, no fuss - just you and your content taking over the world.
* Author: Castos
Expand All @@ -26,7 +26,7 @@
use SeriouslySimplePodcasting\Controllers\Options_Controller;
use SeriouslySimplePodcasting\Rest\Rest_Api_Controller;

define( 'SSP_VERSION', '1.20.5' );
define( 'SSP_VERSION', '1.20.6' );
define( 'SSP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SSP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );

Expand Down
82 changes: 52 additions & 30 deletions templates/feed-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' );
Expand All @@ -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' );
Expand Down Expand Up @@ -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 {
Expand All @@ -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 = '';
Expand All @@ -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;
}
}
Expand All @@ -242,31 +242,43 @@
$category2 = ssp_get_feed_category_output( 2, $series_id );
$category3 = ssp_get_feed_category_output( 3, $series_id );

// 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 '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?>' . "\n";

// 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( '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 ) {
$episode_description = $series_episode_description;
}
}

<rss version="2.0"
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 do_action( 'rss2_ns' ); ?>
>
// 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 '<?xml version="1.0" encoding="' . get_option( 'blog_charset' ) . '"?>' . "\n";
?>
<rss version="2.0"
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 do_action( 'rss2_ns' ); ?>>
<channel>
<title><?php echo esc_html( $title ); ?></title>
<atom:link href="<?php esc_url( self_link() ); ?>" rel="self" type="application/rss+xml"/>
Expand Down Expand Up @@ -350,7 +362,7 @@
$qry = new WP_Query( $args );

if ( 'on' === $turbo ) {
$post_count = 0;
$turbo_post_count = 0;
}

if ( $qry->have_posts() ) {
Expand Down Expand Up @@ -450,8 +462,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
Expand Down Expand Up @@ -512,8 +534,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 ++;
}
?>
<item>
Expand All @@ -539,11 +561,11 @@
<?php if ( $itunes_season_number ): ?>
<itunes:season><?php echo $itunes_season_number; ?></itunes:season>
<?php endif; ?>
<?php if ( isset( $post_count ) && $post_count <= 10 ) { ?>
<?php if ( ! isset( $turbo_post_count ) || $turbo_post_count <= 10 ) { ?>
<content:encoded><![CDATA[<?php echo $content; ?>]]></content:encoded>
<?php } ?>
<enclosure url="<?php echo esc_url( $enclosure ); ?>" length="<?php echo esc_attr( $size ); ?>" type="<?php echo esc_attr( $mime_type ); ?>"></enclosure>
<?php if ( isset( $post_count ) && $post_count <= 10 ) { ?>
<?php if ( ! isset( $turbo_post_count ) || $turbo_post_count <= 10 ) { ?>
<itunes:summary><![CDATA[<?php echo $itunes_summary; ?>]]></itunes:summary>
<?php } ?>
<?php if ( $episode_image ) { ?>
Expand Down

0 comments on commit 549c2e6

Please sign in to comment.