Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.7.0-alpha #814

Merged
merged 4 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion php/classes/controllers/class-episode-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function get_episode_download_link( $episode_id, $referrer = '' ) {
* @deprecated Use Episode_Repository::get_episode_player_link()
*/
public function get_episode_player_link( $episode_id ) {
return $this->episode_repository->get_episode_player_link( $episode_id );
return $this->episode_repository->get_passthrough_url( $episode_id );
}

/**
Expand Down
4 changes: 2 additions & 2 deletions php/classes/controllers/class-feed-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ public function get_podcast_feed( $series_id = null ) {
*
* @return string
*/
public function fetch_feed_item( $qry, $args ) {
public function fetch_feed_item( $qry, $args, $series_id = 0 ) {

$author = isset( $args['author'] ) ? $args['author'] : '';
$is_excerpt_mode = isset( $args['is_excerpt_mode'] ) ? $args['is_excerpt_mode'] : '';
Expand All @@ -282,7 +282,7 @@ public function fetch_feed_item( $qry, $args ) {
// Audio file
$audio_file = $ss_podcasting->get_enclosure( $post_id );

if ( get_option( 'permalink_structure' ) ) {
if ( ssp_series_passthrough_required( $series_id ) && get_option( 'permalink_structure' ) ) {
$enclosure = $ss_podcasting->get_episode_download_link( $post_id );
} else {
$enclosure = $audio_file;
Expand Down
21 changes: 13 additions & 8 deletions php/classes/repositories/class-episode-repository.php
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,10 @@ public function get_player_data( $id, $current_post = null, $skip_empty_audio =
$current_post = $current_post ?: $episode;
$episode_duration = get_post_meta( $id, 'duration', true );
$current_url = get_post_permalink( $current_post->ID );
$audio_file = $this->get_episode_player_link( $id );

if ( ssp_episode_passthrough_required( $id ) ) {
$audio_file = $this->get_passthrough_url( $id );
}
$album_art = $this->get_album_art( $id, 'thumbnail' );
$podcast_title = $this->get_podcast_title( $id );
$feed_url = $this->get_feed_url( $id );
Expand Down Expand Up @@ -657,7 +660,7 @@ protected function format_post_date( $post_date, $format = 'M j, Y' ) {
*
* @return string
*/
public function get_episode_player_link( $episode_id ) {
public function get_passthrough_url( $episode_id ) {
$file = $this->get_episode_download_link( $episode_id );

// Switch to podcast player URL
Expand Down Expand Up @@ -686,17 +689,19 @@ public function get_episode_download_link( $episode_id, $referrer = '' ) {
// Get download link based on permalink structure
if ( get_option( 'permalink_structure' ) ) {
$episode = get_post( $episode_id );
// Get file extension - default to MP3 to prevent empty extension strings
$ext = pathinfo( $file, PATHINFO_EXTENSION );
if ( ! $ext ) {
$ext = 'mp3';
// Get file extension - default to MP3 to prevent empty extension strings.
$link = $this->home_url . 'podcast-download/' . $episode_id . '/' . $episode->post_name;

// Avoid extensions if possible because the new NGINX version can't handle it properly.
if ( ssp_episode_passthrough_required( $episode_id ) ) {
$ext = pathinfo( $file, PATHINFO_EXTENSION );
$link .= $ext ? '.' . $ext : '.mp3';
}
$link = $this->home_url . 'podcast-download/' . $episode_id . '/' . $episode->post_name . '.' . $ext;
} else {
$link = add_query_arg( array( 'podcast_episode' => $episode_id ), $this->home_url );
}

// Allow for dyamic referrer
// Allow for dynamic referrer
$referrer = apply_filters( 'ssp_download_referrer', $referrer, $episode_id );

// Add referrer flag if supplied
Expand Down
6 changes: 3 additions & 3 deletions php/classes/rest/class-rest-api-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public function update_rest_podcast() {
*/
public function get_episode_audio_player() {
$podcast_id = ( isset( $_GET['ssp_podcast_id'] ) ? filter_var( $_GET['ssp_podcast_id'], FILTER_DEFAULT ) : '' );
$file = $this->episode_repository->get_episode_player_link( $podcast_id );
$file = $this->episode_repository->get_passthrough_url( $podcast_id );
$params = array( 'src' => $file, 'preload' => 'none' );

return array(
Expand Down Expand Up @@ -481,7 +481,7 @@ public function get_rest_audio_download_link( $object, $field_name, $request ) {
*/
public function get_rest_audio_player_link( $object, $field_name, $request ) {
if ( ! empty( $object['meta']['audio_file'] ) ) {
return $this->episode_repository->get_episode_player_link( $object['id'] );
return $this->episode_repository->get_passthrough_url( $object['id'] );
}

return '';
Expand All @@ -506,7 +506,7 @@ public function get_rest_audio_player( $object, $field_name, $request ) {
if ( 'standard' !== $player_style ) {
return;
}
$file = $this->episode_repository->get_episode_player_link( $object['id'] );
$file = $this->episode_repository->get_passthrough_url( $object['id'] );
$params = array( 'src' => $file, 'preload' => 'none' );
return wp_audio_shortcode( $params );
}
Expand Down
45 changes: 45 additions & 0 deletions php/includes/ssp-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -1880,3 +1880,48 @@ function ssp_episode_sync_status( $episode_id ) {
return $episode_repository->get_episode_sync_status( $episode_id );
}
}

if ( ! function_exists( 'ssp_episode_passthrough_required' ) ) {
/**
* Checks if episode requires the passthrough file URL ( /podcast-download/22/my-episode.mp3 ).
*
* @since 3.7.0
*
* @param int $episode_id
*
* @return bool
*/
function ssp_episode_passthrough_required( $episode_id ) {
$series = wp_get_post_terms( $episode_id, ssp_series_taxonomy() );

$needs_passthrough = false;

// Mark passthrough as needed if Ads enabled in any of the episode series.
if ( is_array( $series ) ) {
foreach ( $series as $term ) {
$needs_passthrough = $needs_passthrough || ssp_series_passthrough_required( $term->term_id );
}
}

return apply_filters( 'ssp_episode_passthrough_required', $needs_passthrough, $episode_id );
}
}

if ( ! function_exists( 'ssp_series_passthrough_required' ) ) {
/**
* Checks if series requires the passthrough file URL ( /podcast-download/22/my-episode.mp3 )
*
* @since 3.7.0
*
* @param int $series_id
*
* @return bool
*/
function ssp_series_passthrough_required( $series_id ) {

$needs_passthrough = 'on' === ssp_get_option( 'enable_ads', 'off', $series_id );


return apply_filters( 'ssp_series_passthrough_required', $needs_passthrough, $series_id );
}
}
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: 3.6.1
* Version: 3.7.0-alpha
* Plugin URI: https://castos.com/seriously-simple-podcasting/?utm_medium=sspodcasting&utm_source=wordpress&utm_campaign=wpplugin_08_2019
* 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 @@ -22,7 +22,7 @@
exit;
}

define( 'SSP_VERSION', '3.6.1' );
define( 'SSP_VERSION', '3.7.0-alpha' );
define( 'SSP_PLUGIN_FILE', __FILE__ );
define( 'SSP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SSP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
Expand Down
6 changes: 6 additions & 0 deletions src/components/EpisodeMetaSidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ const EpisodeMetaSidebar = () => {
const [isMetaSectionOpen, setMetaSectionOpen] = useState(true);
const [isItunesSectionOpen, setItunesSectionOpen] = useState(true);

// Render additional content using the filter
const additionalContent = wp.hooks.applyFilters('ssp.episodeMetaSidebarEnd', null);

// Use `useDispatch` to update post meta
const { editPost } = useDispatch('core/editor');

Expand Down Expand Up @@ -429,6 +432,9 @@ const EpisodeMetaSidebar = () => {
</h2>
{ isSyncSectionOpen && <SyncStatus syncStatus={ syncStatus }/> }
</PanelBody>) }

{ additionalContent }

</PluginSidebar>
);
};
Expand Down
2 changes: 1 addition & 1 deletion templates/feed-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@
while ( $qry->have_posts() ) {
$turbo_post_count = isset( $turbo_post_count ) ? $turbo_post_count + 1 : null;
$args = compact( 'author', 'is_excerpt_mode', 'pub_date_type', 'turbo_post_count', 'media_prefix' );
echo $feed_controller->fetch_feed_item( $qry, $args );
echo $feed_controller->fetch_feed_item( $qry, $args, $series_id );
}
} ?>
</channel>
Expand Down
6 changes: 0 additions & 6 deletions templates/feed-stylesheet.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,6 @@
</p>
</xsl:if>
<p class="episode_meta">
<a>
<xsl:attribute name="href">
<xsl:value-of select="enclosure/@url"/>?ref=download
</xsl:attribute>
Download episode
</a> |
<a>
<xsl:attribute name="href">
<xsl:value-of select="enclosure/@url"/>?ref=new_window
Expand Down
2 changes: 1 addition & 1 deletion tests/acceptance/3_main-feed.feature
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Feature: Login
And I can see in source "<description><![CDATA[Episode3 content]]></description>"
And I can see in source "<itunes:subtitle><![CDATA[Episode3 content]]></itunes:subtitle>"
And I can see in source "<content:encoded><![CDATA[Episode3 content]]></content:encoded>"
And I can see in source "<enclosure url=\"{{base_url}}/podcast-download"
And I can see in source "<enclosure url=\"https://episodes.castos.com/podcasthacker/d21a1b7a-531f-48f1-b4c0-8b8add2bccfe-file-example.mp3\" length=\"1087849\" type=\"audio/mpeg\"></enclosure>"
And I can see in source "type=\"audio/mpeg\"></enclosure>"
And I can see in source "<itunes:summary><![CDATA[Episode3 content]]></itunes:summary>"
And I can see in source "<itunes:explicit>false</itunes:explicit>"
Expand Down
Loading