Skip to content

Commit

Permalink
Prevent the ss_player shortcode from rendering on the RSS feed
Browse files Browse the repository at this point in the history
Add the is_feed attribute to the wp_query object, for the RSS feed, if accessed via the old url structure
  • Loading branch information
jonathanbossenger committed Jul 22, 2019
1 parent a68bf2c commit 526ef3f
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 3 deletions.
8 changes: 8 additions & 0 deletions php/classes/controllers/class-admin-controller.php
Original file line number Diff line number Diff line change
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
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
9 changes: 9 additions & 0 deletions php/classes/shortcodes/class-player.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace SeriouslySimplePodcasting\ShortCodes;

// Exit if accessed directly.
use ParagonIE\Sodium\Core\Curve25519\Ge\P1p1;

if ( ! defined( 'ABSPATH' ) ) {
exit;
}
Expand All @@ -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();
Expand Down
3 changes: 1 addition & 2 deletions templates/feed-podcast.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -268,7 +268,6 @@

// 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/"
Expand Down

0 comments on commit 526ef3f

Please sign in to comment.