Skip to content

Commit

Permalink
Merge pull request #374 from TheCraigHewitt/release/1.20.4
Browse files Browse the repository at this point in the history
Release/1.20.4
  • Loading branch information
jonathanbossenger authored Jul 4, 2019
2 parents 31946cd + 655f4f6 commit c700a48
Show file tree
Hide file tree
Showing 5 changed files with 96 additions and 92 deletions.
48 changes: 0 additions & 48 deletions php/classes/controllers/class-settings-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -612,54 +612,6 @@ public function validate_slug( $slug ) {
return $slug;
}

/**
* Encode feed password
*
* @param string $password User input
*
* @return string Encoded password
*/
public function encode_password( $password ) {

if ( $password && strlen( $password ) > 0 && '' !== $password ) {
$password = md5( $password );
} else {
$option = get_option( 'ss_podcasting_protection_password' );
$password = $option;
}

return $password;
}

/**
* Validate protectino message
*
* @param string $message User input
*
* @return string Validated message
*/
public function validate_message( $message ) {

if ( $message ) {

$allowed = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'p' => array(),
);

$message = wp_kses( $message, $allowed );
}

return $message;
}

/**
* Mark redirect date for feed
*
Expand Down
48 changes: 48 additions & 0 deletions php/classes/handlers/class-settings-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,54 @@ public function settings_fields() {
return $settings;
}

/**
* Encode feed password
*
* @param string $password User input
*
* @return string Encoded password
*/
public function encode_password( $password ) {

if ( $password && strlen( $password ) > 0 && '' !== $password ) {
$password = md5( $password );
} else {
$option = get_option( 'ss_podcasting_protection_password' );
$password = $option;
}

return $password;
}

/**
* Validate protectino message
*
* @param string $message User input
*
* @return string Validated message
*/
public function validate_message( $message ) {

if ( $message ) {

$allowed = array(
'a' => array(
'href' => array(),
'title' => array(),
'target' => array(),
),
'br' => array(),
'em' => array(),
'strong' => array(),
'p' => array(),
);

$message = wp_kses( $message, $allowed );
}

return $message;
}

/**
* Builds the array of field settings for the subscribe links, based on the options stored in the options table.
*
Expand Down
6 changes: 5 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.3
Stable tag: 1.20.4
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

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

== Changelog ==

= 1.20.4=
* 2019-07-01
* [FIX] Fixes a bug introduced by 1.20.0 which breaks password protecting a feed

= 1.20.3 =
* 2019-06-13
* [FIX] Fixes a bug introduced by 1.20.0 where using link_title in the ss_podcast shortcode does not work
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.3
* Version: 1.20.4
* 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.3' );
define( 'SSP_VERSION', '1.20.4' );
define( 'SSP_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'SSP_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );

Expand Down
82 changes: 41 additions & 41 deletions templates/feed-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@
$protection = get_option( 'ss_podcasting_protect', '' );

// Handle feed protection if required
if ( $protection && $protection == 'on' ) {
if ( $protection && 'on' === $protection ) {

$give_access = false;

// Request password and give access if correct
if ( ! isset( $_SERVER['PHP_AUTH_USER'] ) && ! isset( $_SERVER['PHP_AUTH_PW'] ) ) {
$give_access = false;
} else {
$username = get_option( 'ss_podcasting_protection_username' );
$password = get_option( 'ss_podcasting_protection_password' );
if ( $_SERVER['PHP_AUTH_USER'] == $username ) {
if ( md5( $_SERVER['PHP_AUTH_PW'] ) == $password ) {

if ( $_SERVER['PHP_AUTH_USER'] === $username ) {
if ( md5( $_SERVER['PHP_AUTH_PW'] ) === $password ) {
$give_access = true;
}
}
Expand All @@ -62,39 +62,39 @@

// Send 401 status and display no access message if access has been denied
if ( ! $give_access ) {

// Set default message
$message = __( 'You are not permitted to view this podcast feed.', 'seriously-simple-podcasting' );

// Check message option from plugin settings
$message_option = get_option( 'ss_podcasting_protection_no_access_message' );
if ( $message_option ) {
$message = $message_option;
}

// Allow message to be filtered dynamically
$message = apply_filters( 'ssp_feed_no_access_message', $message );

$no_access_message = '<div style="text-align:center;font-family:sans-serif;border:1px solid red;background:pink;padding:20px 0;color:red;">' . $message . '</div>';

header( 'WWW-Authenticate: Basic realm="Podcast Feed"' );
header( 'HTTP/1.0 401 Unauthorized' );

die( $no_access_message );
}

// 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' ) {

$new_feed_url = get_option( 'ss_podcasting_new_feed_url' );
$update_date = get_option( 'ss_podcasting_redirect_feed_date' );

if ( $new_feed_url && $update_date ) {
$redirect_date = strtotime( '+2 days', $update_date );
$current_date = time();

// Redirect with 301 if it is more than 2 days since redirect was saved
if ( $current_date > $redirect_date ) {
header( 'HTTP/1.1 301 Moved Permanently' );
Expand Down Expand Up @@ -271,7 +271,7 @@
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 @@ -335,39 +335,39 @@
<?php if ( $new_feed_url ) { ?>
<itunes:new-feed-url><?php echo esc_url( $new_feed_url ); ?></itunes:new-feed-url>
<?php }

// Prevent WP core from outputting an <image> element
remove_action( 'rss2_head', 'rss2_site_icon' );

// Add RSS2 headers
do_action( 'rss2_head' );

// Get post IDs of all podcast episodes
$num_posts = intval( apply_filters( 'ssp_feed_number_of_posts', get_option( 'posts_per_rss', 10 ) ) );

$args = ssp_episodes( $num_posts, $podcast_series, true, 'feed' );

$qry = new WP_Query( $args );

if ( $qry->have_posts() ) {
while ( $qry->have_posts() ) {
$qry->the_post();

// Audio file
$audio_file = $ss_podcasting->get_enclosure( get_the_ID() );
if ( get_option( 'permalink_structure' ) ) {
$enclosure = $ss_podcasting->get_episode_download_link( get_the_ID() );
} else {
$enclosure = $audio_file;
}

$enclosure = apply_filters( 'ssp_feed_item_enclosure', $enclosure, get_the_ID() );

// If there is no enclosure then go no further
if ( ! isset( $enclosure ) || ! $enclosure ) {
continue;
}

// Get episode image from post featured image
$episode_image = '';
$image_id = get_post_thumbnail_id( get_the_ID() );
Expand All @@ -378,17 +378,17 @@
}
}
$episode_image = apply_filters( 'ssp_feed_item_image', $episode_image, get_the_ID() );

// Episode duration (default to 0:00 to ensure there is always a value for this)
$duration = get_post_meta( get_the_ID(), 'duration', true );
if ( ! $duration ) {
$duration = '0:00';
}
$duration = apply_filters( 'ssp_feed_item_duration', $duration, get_the_ID() );

// File size
$size = get_post_meta( get_the_ID(), 'filesize_raw', true );

if ( ! $size ) {
if ( ssp_is_connected_to_podcastmotor() ) {
$formatted_size = get_post_meta( get_the_ID(), 'filesize', true );
Expand All @@ -398,12 +398,12 @@
}
}
$size = apply_filters( 'ssp_feed_item_size', $size, get_the_ID() );


// File MIME type (default to MP3/MP4 to ensure there is always a value for this)
$mime_type = $ss_podcasting->get_attachment_mimetype( $audio_file );
if ( ! $mime_type ) {

// Get the episode type (audio or video) to determine the appropriate default MIME type
$episode_type = $ss_podcasting->get_episode_type( get_the_ID() );
switch ( $episode_type ) {
Expand All @@ -416,7 +416,7 @@
}
}
$mime_type = apply_filters( 'ssp_feed_item_mime_type', $mime_type, get_the_ID() );

// Episode explicit flag
$ep_explicit = get_post_meta( get_the_ID(), 'explicit', true );
$ep_explicit = apply_filters( 'ssp_feed_item_explicit', $ep_explicit, get_the_ID() );
Expand All @@ -427,7 +427,7 @@
$itunes_explicit_flag = 'clean';
$googleplay_explicit_flag = 'No';
}

// Episode block flag
$ep_block = get_post_meta( get_the_ID(), 'block', true );
$ep_block = apply_filters( 'ssp_feed_item_block', $ep_block, get_the_ID() );
Expand All @@ -436,27 +436,27 @@
} else {
$block_flag = 'no';
}

// Episode author
$author = esc_html( get_the_author() );
$author = apply_filters( 'ssp_feed_item_author', $author, get_the_ID() );

// Episode content (with iframes removed)
$content = get_the_content_feed( 'rss2' );
$content = preg_replace( '/<\/?iframe(.|\s)*?>/', '', $content );
$content = apply_filters( 'ssp_feed_item_content', $content, get_the_ID() );

// iTunes summary is the full episode content, but must be shorter than 4000 characters
$itunes_summary = mb_substr( $content, 0, 3999 );
$itunes_summary = apply_filters( 'ssp_feed_item_itunes_summary', $itunes_summary, get_the_ID() );
$gp_description = apply_filters( 'ssp_feed_item_gp_description', $itunes_summary, get_the_ID() );

// Episode description
ob_start();
the_excerpt_rss();
$description = ob_get_clean();
$description = apply_filters( 'ssp_feed_item_description', $description, get_the_ID() );

// iTunes subtitle does not allow any HTML and must be shorter than 255 characters
$itunes_subtitle = strip_tags( strip_shortcodes( $description ) );
$itunes_subtitle = str_replace( array(
Expand All @@ -471,7 +471,7 @@
), array( '', '', '', '', '', '', '', '' ), $itunes_subtitle );
$itunes_subtitle = mb_substr( $itunes_subtitle, 0, 254 );
$itunes_subtitle = apply_filters( 'ssp_feed_item_itunes_subtitle', $itunes_subtitle, get_the_ID() );

// Date recorded
$pubDateType = get_option( 'ss_podcasting_publish_date', 'published' );
if ( $pubDateType === 'published' ) {
Expand Down Expand Up @@ -544,4 +544,4 @@
<?php }
} ?>
</channel>
</rss>
</rss>

0 comments on commit c700a48

Please sign in to comment.