• Resolved chantireviews

    (@chantireviews)


    Polly registers the filter the_excerpt_rss for all rss feeds. The callback, filter_force_html_decode strips all of the html tags. Unfortunately for normal RSS feeds, people often insert html in the <description> tag so that images will show up in the RSS feeds. Mailchimp uses this feature for syndicating RSS feeds via email.

    Since the filter object is different from the template object, I ended up creating a static variable that is set to true at the beginning of the rss template and cleared at the end.

    In the filter, I simply check the variable and strip the tags if it is a polly feed. It seems like there should be a call that could be made inside of filter_force_html_decode that you could use instead of the static variable, but I didn’t dig into it.

    Thanks,

    Andy

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter chantireviews

    (@chantireviews)

    Just updated to 3.01 and this issue is still here. I’ve attached a patch file to show you how I fixed the issue.

    
    diff --git wp-content/plugins/amazon-polly/includes/class-amazonpolly-pollycast.php wp-content/plugins/ama
    zon-polly/includes/class-amazonpolly-pollycast.php
    index bb55dc3a..6d6ae569 100644
    --- wp-content/plugins/amazon-polly/includes/class-amazonpolly-pollycast.php
    +++ wp-content/plugins/amazon-polly/includes/class-amazonpolly-pollycast.php
    @@ -26,6 +26,7 @@ class Amazonpolly_PollyCast {
             * @var      string    $podcast_name    The slug of this podcast feed.
             */
            private $podcast_name = 'amazon-pollycast';
    +       static $podcast_rss = false;
    
            /**
             * Adds the custom feed endpoint.
    @@ -233,6 +234,25 @@ class Amazonpolly_PollyCast {
                    return $tags_list;
            }
    
    +       /**
    +        * Place at the begging of a Amazon polly feed
    +        *
    +        * @since    3.0.0
    +        */
    +       public function start_podcast_rss( ) {
    +               self::$podcast_rss = true;
    +       }
    +
    +       /**
    +        * Place at the begging of a Amazon polly feed
    +        *
    +        * @since    3.0.0
    +        */
    +       public function end_podcast_rss( ) {
    +               self::$podcast_rss = false;
    +       }
    +
    +
            /**
             * Returns a HTML decoded version of the provided input for use inside CDATA.
             *
    @@ -241,7 +261,9 @@ class Amazonpolly_PollyCast {
             * @return   string The HTML decoded version of the provided input for use inside CDATA.
             */
            public function filter_force_html_decode( $input ) {
    -               $input = wp_strip_all_tags( $input );
    +               if (self::$podcast_rss) {
    +                       $input = wp_strip_all_tags( $input );
    +               }
                    return html_entity_decode( $input, ENT_QUOTES, 'UTF-8' );
            }
    
    diff --git wp-content/plugins/amazon-polly/includes/template-amazon-pollycast.php wp-content/plugins/amazon-polly/includes/template-amazon-pollycast.php
    index b711df2f..aeb78e65 100644
    --- wp-content/plugins/amazon-polly/includes/template-amazon-pollycast.php
    +++ wp-content/plugins/amazon-polly/includes/template-amazon-pollycast.php
    @@ -34,6 +34,8 @@ $itunes_description = $amazon_pollycast->get_itunes_description();
     $common = new AmazonAI_Common();
     $itunes_author = $common->get_podcast_author();
    +$amazon_pollycast->start_podcast_rss();
    +
    
     ?>
     <rss version="2.0"
    @@ -135,3 +137,7 @@ $itunes_author = $common->get_podcast_author();
            <?php endwhile; ?>
     </channel>
     </rss>
    +
    +<?php
    +$amazon_pollycast->end_podcast_rss();
    +?>
    
    Plugin Contributor tstachlewski

    (@tstachlewski)

    I will introduce fix in next release. Thx

    Thread Starter chantireviews

    (@chantireviews)

    Thanks!

    Plugin Contributor tstachlewski

    (@tstachlewski)

    @chantireviews
    Could you send me this file? (or even do PR on github – https://github.com/awslabs/amazon-polly-wordpress-plugin ) It will be a bit easier for me to check this, that go through diff here.

    Contact to me: https://s3-eu-west-1.amazonaws.com/tomash-temp/contact.txt

    Cheers,
    Tomasz

    Plugin Contributor tstachlewski

    (@tstachlewski)

    Solved in 3.1.0

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Polly removes html from all RSS feeds’ is closed to new replies.