Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the sharing filters in e-mail too #6342

Merged
merged 2 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions modules/sharedaddy/sharedaddy.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ function sharing_email_send_post( $data ) {
$headers[] = sprintf( 'From: %1$s <%2$s>', $data['name'], $from_email );
$headers[] = sprintf( 'Reply-To: %1$s <%2$s>', $data['name'], $data['source'] );

wp_mail( $data['target'], '['.__( 'Shared Post', 'jetpack' ).'] '.$data['post']->post_title, $content, $headers );
// Make sure to pass the title through the normal sharing filters.
$title = $data['sharing_source']->get_share_title( $data['post']->ID );

wp_mail( $data['target'], '[' . __( 'Shared Post', 'jetpack' ) . '] ' . $title, $content, $headers );
}


Expand All @@ -39,7 +42,7 @@ function sharing_email_check_for_spam_via_akismet( $data ) {
// Prepare the body_request for akismet
$body_request = array(
'blog' => get_option( 'home' ),
'permalink' => get_permalink( $data['post']->ID ),
'permalink' => $data['sharing_source']->get_share_url( $data['post']->ID ),
'comment_type' => 'share',
'comment_author' => $data['name'],
'comment_author_email' => $data['source'],
Expand Down Expand Up @@ -67,8 +70,9 @@ function sharing_email_send_post_content( $data ) {
/* translators: included in email when post is shared via email. First item is sender's name. Second is sender's email address. */
$content = sprintf( __( '%1$s (%2$s) thinks you may be interested in the following post:', 'jetpack' ), $data['name'], $data['source'] );
$content .= "\n\n";
$content .= $data['post']->post_title."\n";
$content .= get_permalink( $data['post']->ID )."\n";
// Make sure to pass the title and URL through the normal sharing filters.
$content .= $data['sharing_source']->get_share_title( $data['post']->ID ) . "\n";
$content .= $data['sharing_source']->get_share_url( $data['post']->ID ) . "\n";
return $content;
}

Expand Down
9 changes: 5 additions & 4 deletions modules/sharedaddy/sharing-sources.php
Original file line number Diff line number Diff line change
Expand Up @@ -426,10 +426,11 @@ public function process_request( $post, array $post_data ) {
*/
if ( apply_filters( 'sharing_email_check', true, $post, $post_data ) ) {
$data = array(
'post' => $post,
'source' => $source_email,
'target' => $target_email,
'name' => $source_name,
'post' => $post,
'source' => $source_email,
'target' => $target_email,
'name' => $source_name,
'sharing_source' => $this,
);
// todo: implement an error message when email doesn't get sent.
/**
Expand Down