Plaintext excerpts do not seem to work for "more" cases
-
Great plug-in!
I have been reconfiguring my site to send an excerpt of the post to subscribers by putting {POST} into the template for email notifications.
In testing I noticed that if the post had an explicit Excerpt then everything worked fine. However if the post had no explicit Excerpt but a <!–more–> in the main body then HTML Excerpt recipients would get the text before the tag (correct) but Plain Excerpt recipients would get around 55 words – perhaps extending beyond the <!–more–> tag (incorrect).
On investigation the problem seems to be that around line 565 in class-s2-core.php in generating the plain excerpt there is a test for “<!–more–>” in $plaintext, but around 20 lines earlier there has been a strip_tags() applied to $plaintext which now removes HTML comments. The test fails and drops through to the 55 word case.
With the rough patch below applied (note that the “$excerpt = strip_tags($excerpt);” is in the original) the plain excerpt behaves in line with the HTML version, handling the “more” case correctly. This patch however may not hand shortcodes correctly.
I am v9.0 of subscribe2 and WordPress 3.7.1
—————————————————————-
--- class-s2-core.php 2013-12-03 19:10:10.672474300 +0000 +++ class-s2-core-patched.php 2013-12-03 19:45:28.198589900 +0000 @@ -562,8 +562,8 @@ $excerpt = $post->post_excerpt; if ( '' == $excerpt ) { // no excerpt, is there a <!--more--> ? - if ( false !== strpos($plaintext, '<!--more-->') ) { - list($excerpt, $more) = explode('<!--more-->', $plaintext, 2); + if ( false !== strpos($content, '<!--more-->') ) { + list($excerpt, $more) = explode('<!--more-->', $content, 2); // strip leading and trailing whitespace $excerpt = strip_tags($excerpt); $excerpt = trim($excerpt);
- The topic ‘Plaintext excerpts do not seem to work for "more" cases’ is closed to new replies.