Title: [PATCH] REFERENCELINKS template parameter doesn&#039;t include links
Last modified: August 22, 2016

---

# [PATCH] REFERENCELINKS template parameter doesn't include links

 *  [sjmurdoch](https://wordpress.org/support/users/sjmurdoch/)
 * (@sjmurdoch)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/)
 * In plain text email, when using the {REFERENCELINKS} code, the numbers are appended
   to text which includes links but the table of links is not included at the bottom.
   The reason seems to be because {REFERENCELINKS} is removed prior to the check
   for its presence when adding the link table. See below for a patch on version
   10.18.3 which seems to fix the issue.
 *     ```
       diff -Naur subscribe2.orig/classes/class-s2-core.php subscribe2/classes/class-s2-core.php
       --- subscribe2/classes/class-s2-core.php        2015-02-04 22:27:55.000000000 +0000
       +++ /var/sites/secblog/wp-content/plugins/subscribe2/classes/class-s2-core.php  2015-02-09 17:42:09.949548744 +0000
       @@ -497,7 +497,6 @@
                       $excerpttext = $plaintext;
   
                       if ( strstr($mailtext, "{REFERENCELINKS}") ) {
       -                       $mailtext = str_replace("{REFERENCELINKS}", '', $mailtext);
                               $plaintext_links = '';
                               $i = 0;
                               while ( preg_match('|<a([^>]*)>(.*)<\/a>|Ui', $plaintext, $matches) ) {
       @@ -514,6 +513,7 @@
                       $plaintext = trim(strip_tags($plaintext));
   
                       if ( strstr($mailtext, "{REFERENCELINKS}") && $plaintext_links != '' ) {
       +                       $mailtext = str_replace("{REFERENCELINKS}", '', $mailtext);
                               $plaintext .= "\r\n\r\n" . trim($plaintext_links);
                       }
       ```
   
 * [https://wordpress.org/plugins/subscribe2/](https://wordpress.org/plugins/subscribe2/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776102)
 * [@sjmurdoch](https://wordpress.org/support/users/sjmurdoch/),
 * Thanks for spotting this, your fix looks reasonable however if there are no images
   in a particular post and therefore $plaintext_links is empty then I don’t think
   the {REFERENCELINKS} keyword will be removed.
 * A better fix might be to replaced the latter if statement:
    `if ( strstr($mailtext,"{
   REFERENCELINKS}") && $plaintext_links != '' ) {` with: `if ( isset( $plaintext_links)&&''!
   == $plaintext_links ) {`
 * Does that work for you?
 *  Thread Starter [sjmurdoch](https://wordpress.org/support/users/sjmurdoch/)
 * (@sjmurdoch)
 * [11 years, 4 months ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776111)
 * Good point. Here’s the patch I’m running with that seems to work (now on 10.18.4)
 *     ```
       --- class-s2-core.php	2015-02-10 00:44:36.000000000 +0000
       +++ class-s2-core.php	2015-02-11 17:25:00.828988178 +0000
       @@ -513,7 +513,7 @@
   
         		$plaintext = trim(strip_tags($plaintext));
   
       -		if ( strstr($mailtext, "{REFERENCELINKS}") && $plaintext_links != '' ) {
       +		if ( isset( $plaintext_links ) && '' !== $plaintext_links ) {
        			$plaintext .= "\r\n\r\n" . trim($plaintext_links);
        		}
       ```
   
 *  Thread Starter [sjmurdoch](https://wordpress.org/support/users/sjmurdoch/)
 * (@sjmurdoch)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776416)
 * Is this fix going to be rolled into the release? I noticed 10.18.5 came out but
   the problem still seems to be there.
 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776417)
 * [@sjmurdoch](https://wordpress.org/support/users/sjmurdoch/),
 * This is patched in Subscribe2 HTML but I no longer have commit privileges to 
   the free version. Maybe it’ll get picked up by the ReadyGraph folks at some point,
   perhaps email them direct:
    [info@readygraph.com](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/info@readygraph.com?output_format=md)
 *  [tanaylakhani](https://wordpress.org/support/users/tanaylakhani/)
 * (@tanaylakhani)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776418)
 * Yes this patch will be rolled out in next release.
 *  [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * (@mattyrob)
 * [11 years, 1 month ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776419)
 * [@tanaylakhani](https://wordpress.org/support/users/tanaylakhani/)
 * Thanks for the update – will you also be addressing some of the bug fixes and
   enhancements in the [trac](https://plugins.trac.wordpress.org/query?component=subscribe2&status=!closed&order=id)
   as some point in the future?

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘[PATCH] REFERENCELINKS template parameter doesn't include links’ is closed
to new replies.

 * ![](https://ps.w.org/subscribe2/assets/icon-256x256.png?rev=2318630)
 * [Subscribe2 - Form, Email Subscribers & Newsletters](https://wordpress.org/plugins/subscribe2/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/subscribe2/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/subscribe2/)
 * [Active Topics](https://wordpress.org/support/plugin/subscribe2/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/subscribe2/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/subscribe2/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [Matt Robinson](https://wordpress.org/support/users/mattyrob/)
 * Last activity: [11 years, 1 month ago](https://wordpress.org/support/topic/patch-referencelinks-template-parameter-doesnt-include-links/#post-5776419)
 * Status: not resolved