Skip to content

Instantly share code, notes, and snippets.

@robincornett

robincornett/functions-01.php Secret

Created Apr 12, 2016
Embed
What would you like to do?
Add a CTA (Call to Action) button to your MailChimp RSS emails.
<?php
// do not include the opening tag
// Disable the Read More link added by Send Images to RSS
add_filter( 'send_images_rss_excerpt_read_more', '__return_false' );
<?php
// do not include the opening tag
add_filter( 'send_images_rss_excerpt_read_more', 'leaven_change_read_more_cta', 10, 5 );
/**
* Modify the Send Images to RSS excerpt "read more" link output to be a button in MailChimp.
*
* @author Robin Cornett
*
* @param $output string final output for "read more" text
* @param $read_more string "read more" text set on plugin settings page
* @param $blog_name string the name of your site
* @param $post_name string the post name
* @param $permalink string URL for the post
*
* @return string
*/
function leaven_change_read_more_cta( $output, $read_more, $blog_name, $post_name, $permalink ) {
// set your colors here
$button_color = '#2a717a';
$link_color = '#ffffff';
// for a full width button using your Read More text, you shouldn't need to change this
$output = '<table border="0" cellpadding="0" cellspacing="0" style="background-color:' . $button_color . '; border-radius:5px;" width="100%">';
$output .= '<tbody>';
$output .= '<tr>';
$output .= '<td align="center" style="color:' . $link_color . '; font-weight:bold; line-height:1.5; padding-top:15px; padding-right:30px; padding-bottom:15px; padding-left:30px; margin: 24px auto;" valign="middle"><a href="' . $permalink . '" style="color:' . $link_color . '; text-decoration:none;" target="_blank">' . $read_more . '</a></td>';
$output .= '</tr>';
$output .= '</tbody>';
$output .= '</table>';
return $output;
}
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
*|RSSITEM:CONTENT|*
<table border="0" cellpadding="0" cellspacing="0" style="background-color:#2a717a; border-radius:5px;" width="100%">
<tbody>
<tr>
<td align="center" style="color:#FFFFFF; font-weight:bold; line-height:150%; padding-top:15px; padding-right:30px; padding-bottom:15px; padding-left:30px; margin: 24px auto;" valign="middle"><a href="*|RSSITEM:URL|*" style="color:#FFFFFF; text-decoration:none;" target="_blank">Read *|RSSITEM:TITLE|* on my site.</a></td>
</tr>
</tbody>
</table>
*|END:RSSITEMS|*
*|RSSITEMS:|*
<h2 class="mc-toc-title"><a href="*|RSSITEM:URL|*" target="_blank">*|RSSITEM:TITLE|*</a></h2>
*|RSSITEM:CONTENT|* *|END:RSSITEMS|*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment