Skip to content

Instantly share code, notes, and snippets.

@drblue
Created September 4, 2014 11:41
Show Gist options
  • Save drblue/5008d8f079a9874ba0e9 to your computer and use it in GitHub Desktop.
Save drblue/5008d8f079a9874ba0e9 to your computer and use it in GitHub Desktop.
Wordpress subscribe2 plugin digest template patch
Index: classes/class-s2-core.php
===================================================================
--- classes/class-s2-core.php (revision 979098)
+++ classes/class-s2-core.php (working copy)
@@ -1365,7 +1365,8 @@
}
} else {
// we are sending a preview
- $posts = get_posts('numberposts=1');
+ $posts = get_posts('numberposts=3');
+ $posts = apply_filters('s2_cron_preview_posts', $posts, $this);
}
// Collect sticky posts if desired
@@ -1511,6 +1512,7 @@
}
// update post_meta data for sent ids but not sticky posts
+ $ids = apply_filters('s2_update_post_status', $ids);
foreach ( $ids as $id ) {
if ( !empty($sticky_ids) && !in_array($id, $sticky_ids) ) {
update_post_meta($id, '_s2_digest_post_status', 'done');
@@ -1518,7 +1520,8 @@
update_post_meta($id, '_s2_digest_post_status', 'done');
}
}
- $this->subscribe2_options['last_s2cron'] = implode(',', $digest_post_ids);
+ $last_s2cron_digest_post_ids = apply_filters('last_s2cron_digest_post_ids', $digest_post_ids, $this->subscribe2_options['last_s2cron']);
+ $this->subscribe2_options['last_s2cron'] = (is_array($last_s2cron_digest_post_ids)) ? implode(',', $last_s2cron_digest_post_ids) : $last_s2cron_digest_post_ids;
update_option('subscribe2_options', $this->subscribe2_options);
// we add a blank line after each post excerpt now trim white space that occurs for the last post
@@ -1564,16 +1567,17 @@
$mailtext = stripslashes($this->substitute($mailtext));
// prepare recipients
+ $mailtype = apply_filters('s2_digest_mailtype', 'text');
if ( $preview != '' ) {
$this->myemail = $preview;
$this->myname = __('Digest Preview', 'subscribe2');
- $this->mail(array($preview), $subject, $mailtext);
+ $this->mail(array($preview), $subject, $mailtext, $mailtype);
} else {
$public = $this->get_public();
$all_post_cats_string = implode(',', $all_post_cats);
$registered = $this->get_registered("cats=$all_post_cats_string");
$recipients = array_merge((array)$public, (array)$registered);
- $this->mail($recipients, $subject, $mailtext);
+ $this->mail($recipients, $subject, $mailtext, $mailtype);
}
} // end subscribe2_cron()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment