WordPress.org

Forums

mPress Custom Feed Excerpts
Bug in your use of preg_split (2 posts)

  1. Justin Watt
    Member
    Posted 2 years ago #

    I'm using a modified version of your plugin, and I realized that your use of preg_split will almost always evaluate to true (because a non-empty array evals to true), resulting in balanceTags being run on all content again.

    It would be more correct if you did something like this:

    $split = preg_split( '#<p><span id=\"more-\d+\"><\/span></p>#', $content, 2 );
    if ( count( $split ) == 2 ) {

    Also note: I added the paragraph-tags to your regex pattern, because WordPress adds those in. Otherwise, you get an empty paragraph left behind.

    The reason I modified your plugin is I wanted some indication in the feed that there was more content to read on the site. So in that if statement I added the following line:

    $content .= "<p>Continue Reading <a href='" . get_permalink() . "'>" . get_the_title_rss() . "</a> ยป</p>";

    http://wordpress.org/extend/plugins/mpress-custom-feed-excerpts/

  2. Micah Wood
    Member
    Plugin Author

    Posted 2 years ago #

    @justincwatt,

    Thanks for the feedback. I just released a new version of the plugin with a continue reading link and noticed your comment. Apparently I hadn't configured support messages to go to my email.

    As I said, I just released a new version. I have updated my code to use the correct logic to detect whether a split has or has not taken place, but that will be in the next release. I will give it a little time before my next release to see what feedback I get on how the continue reading link was implemented.

    I am not seeing WordPress add in an extra p tag around the 'more' span. Using your exact code on my test content resulted in no split at all. I wonder if your theme or another plugin is adding that extra markup?

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • mPress Custom Feed Excerpts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.