• Resolved mjg2

    (@mjg2)


    I’m using the following to produce a listing page of the 20 most popular posts:

    <?php if (function_exists('wpp_get_mostpopular')) wpp_get_mostpopular("excerpt_by_words=1&stats_author=1&range=all&limit=20&stats_comments=0&post_type=post&thumbnail_width=100&thumbnail_height=100&excerpt_length=55&&stats_date=1&post_html='<div class=\"hentry\">{thumb}<div class=\"entry-head\"><h3 class=\"entry-title\"><a href="{url}" rel="bookmark">{text_title}</a></h3><div class=\"entry-meta\">by {author}</div></div><div class=\"entry-content entry-list-with-thumbnail\"><p>{summary}</p></div></div>'&cat=".$current); ?>

    When {summary} is displayed it appears it does not use the same function as WP uses for producing excerpts since I don’t see this issue on category index pages that use ‘the_excerpt’ function. Some of posts contain special javascript or style at the top of the post and are displayed in the {summary} output. The tags <style><script> are removed, but the contents of inside are not so the actual css or javascript is put in the summary of the post.

    Is there a way to filter this from WPP or is the only method to set an excerpt explicitly?

    https://www.ads-software.com/plugins/wordpress-popular-posts/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Indeed, WPP doesn’t filter out style/script tags from the excerpt. You’re, probably, the first person ever to ask about it. I never expected someone to use script/style tags directly in post content (and actually believed that WordPress stripped them out after saving/editing a post, but it seems I was wrong).

    Anyways, please try the following:

    1. Go to Plugins > Editor and pick WordPress Popular Posts from the dropdown.
    2. Find:
      // remove WP shortcodes
      $excerpt = strip_shortcodes( $excerpt );

      … and then add the following code after those two lines:

      // remove style/script tags
      $excerpt = preg_replace( '@<(script|style)[^>]*?>.*?</\\1>@si', '', $excerpt );
    3. Hit the Update file button to save changes.

    Let me know how it goes, ok?

    Thread Starter mjg2

    (@mjg2)

    Hi Hector,

    Thank you! It looks like that does the trick. Let me know if you plan on adding that to the next release so I can be on the lookout when updating in the future. Otherwise, I’ll be careful not to allow updates to remove this change we’ve added manually.

    Plugin Author Hector Cabrera

    (@hcabrera)

    I will include that on the next release, so don’t worry ??

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘{summary} includes tags (i.e. or’ is closed to new replies.