@@ -235,6 +235,13 @@ function email_add_menu_page_callback() {
+
|
@@ -327,6 +334,12 @@ function email_add_menu_page_callback() {
[post_modified_date]
The date the post was modified. This is the timestamp of current action.
+ [post_title]
+ The title of the post.
+
+ [post_content]
+ The content of the post. This will likely be in HTML format, so make sure to set your format accordingly.
+
@@ -338,19 +351,20 @@ function email_add_menu_page_callback() {
function email_insert_post() {
// variables for the field and option names
- $email_action = (isset($_POST['email_action']) ? $_POST['email_action'] : '');
- $email_type = (isset($_POST['email_type']) ? $_POST['email_type'] : '');
- $email_from = (isset($_POST['email_from']) ? $_POST['email_from'] : '');
- $email_from_name = (isset($_POST['email_from_name']) ? $_POST['email_from_name'] : '');
- $email_to = (isset($_POST['email_to']) ? $_POST['email_to'] : '');
- $email_to_role = (isset($_POST['email_to_role']) ? $_POST['email_to_role'] : '');
- $email_cc = (isset($_POST['email_cc']) ? $_POST['email_cc'] : '');
- $email_cc_role = (isset($_POST['email_cc_role']) ? $_POST['email_cc_role'] : '');
- $email_bcc = (isset($_POST['email_bcc']) ? $_POST['email_bcc'] : '');
- $email_bcc_role = (isset($_POST['email_bcc_role']) ? $_POST['email_bcc_role'] : '');
- $email_subject = (isset($_POST['email_subject']) ? $_POST['email_subject'] : '');
- $email_message = (isset($_POST['email_message']) ? $_POST['email_message'] : '');
- $email_hidden = (isset($_POST['email_hidden']) ? $_POST['email_hidden'] : '');
+ $email_action = (isset($_POST['email_action']) ? $_POST['email_action'] : '');
+ $email_type = (isset($_POST['email_type']) ? $_POST['email_type'] : '');
+ $email_from = (isset($_POST['email_from']) ? $_POST['email_from'] : '');
+ $email_from_name = (isset($_POST['email_from_name']) ? $_POST['email_from_name'] : '');
+ $email_to = (isset($_POST['email_to']) ? $_POST['email_to'] : '');
+ $email_to_role = (isset($_POST['email_to_role']) ? $_POST['email_to_role'] : '');
+ $email_cc = (isset($_POST['email_cc']) ? $_POST['email_cc'] : '');
+ $email_cc_role = (isset($_POST['email_cc_role']) ? $_POST['email_cc_role'] : '');
+ $email_bcc = (isset($_POST['email_bcc']) ? $_POST['email_bcc'] : '');
+ $email_bcc_role = (isset($_POST['email_bcc_role']) ? $_POST['email_bcc_role'] : '');
+ $email_subject = (isset($_POST['email_subject']) ? $_POST['email_subject'] : '');
+ $email_message = (isset($_POST['email_message']) ? $_POST['email_message'] : '');
+ $email_hidden = (isset($_POST['email_hidden']) ? $_POST['email_hidden'] : '');
+ $email_html_formatted = (isset($_POST['email_html_formatted']) ? $_POST['email_html_formatted'] : '');
if( isset($email_hidden) && ( $email_hidden == 'Y' ) ) {
@@ -432,6 +446,10 @@ function email_insert_post() {
array(
'key' => 'email_message',
'value' => $email_message
+ ),
+ array(
+ 'key' => 'email_html_formatted',
+ 'value' => $email_html_formatted
)
)
);
@@ -511,7 +529,7 @@ function email_insert_post() {
$success[] = $email_bcc;
}
if ( !empty( $email_bcc_role ) ) {
- update_post_meta( $post_id, 'email_bcc_role',$email_bcc_role );
+ update_post_meta( $post_id, 'email_bcc_role', $email_bcc_role );
$success[] = $email_bcc_role;
}
if ( !empty( $email_subject ) ) {
@@ -519,6 +537,9 @@ function email_insert_post() {
$success[] = $email_subject;
}
+ update_post_meta( $post_id, 'email_html_formatted', $email_html_formatted );
+ $success[] = $email_html_formatted;
+
$success[] = 'Edit '. get_the_title( $post_id ) .'';
if( !empty( $post_id ) ) {
diff --git a/parser.php b/parser.php
index 89dc0a1..21699a2 100644
--- a/parser.php
+++ b/parser.php
@@ -31,6 +31,7 @@ function email_parser( $post_id, $email_id, $old_status, $new_status, $string =
'[post_modified_date]',
'[post_modified_time]',
'[post_title]',
+ '[post_content]',
'[permalink]',
'[old_status]',
'[new_status]',
@@ -65,6 +66,7 @@ function email_parser( $post_id, $email_id, $old_status, $new_status, $string =
get_the_modified_date( '', $post_id ),
get_the_modified_time( '', $post_id ),
get_the_title( $post_id ),
+ get_post_field('post_content', $post_id ),
get_permalink( $post_id ),
$old_status,
$new_status,
diff --git a/router.php b/router.php
index be95870..430a845 100644
--- a/router.php
+++ b/router.php
@@ -38,23 +38,28 @@ function email_action_router( $new_status, $old_status, $post ) {
}
}
+function set_html_content_type() {
+ return 'text/html';
+}
+
function email_action( $action, $post_id, $email_id, $old_status, $new_status ) {
$post = get_post( $post_id );
- $email_action = get_post_meta( $email_id, 'email_action', true );
- $email_type = get_post_meta( $email_id, 'email_type', true );
- $email_from = get_post_meta( $email_id, 'email_from', true );
- $email_from_name = get_post_meta( $email_id, 'email_from_name', true );
- $email_to = get_post_meta( $email_id, 'email_to', true );
- $email_to_role = get_post_meta( $email_id, 'email_to_role', true );
- $email_cc = get_post_meta( $email_id, 'email_cc', true );
- $email_cc_role = get_post_meta( $email_id, 'email_cc_role', true );
- $email_bcc = get_post_meta( $email_id, 'email_bcc', true );
- $email_bcc_role = get_post_meta( $email_id, 'email_bcc_role', true );
- $email_subject = get_post_meta( $email_id, 'email_subject', true );
- $email_message = get_post_meta( $email_id, 'email_message', true );
- $email_hidden = get_post_meta( $email_id, 'email_hidden', true );
+ $email_action = get_post_meta( $email_id, 'email_action', true );
+ $email_type = get_post_meta( $email_id, 'email_type', true );
+ $email_from = get_post_meta( $email_id, 'email_from', true );
+ $email_from_name = get_post_meta( $email_id, 'email_from_name', true );
+ $email_to = get_post_meta( $email_id, 'email_to', true );
+ $email_to_role = get_post_meta( $email_id, 'email_to_role', true );
+ $email_cc = get_post_meta( $email_id, 'email_cc', true );
+ $email_cc_role = get_post_meta( $email_id, 'email_cc_role', true );
+ $email_bcc = get_post_meta( $email_id, 'email_bcc', true );
+ $email_bcc_role = get_post_meta( $email_id, 'email_bcc_role', true );
+ $email_subject = get_post_meta( $email_id, 'email_subject', true );
+ $email_message = get_post_meta( $email_id, 'email_message', true );
+ $email_hidden = get_post_meta( $email_id, 'email_hidden', true );
+ $email_html_formatted = get_post_meta( $email_id, 'email_html_formatted', true ) === 'true'? true: false;
// Build the comma separated list of email address for the TO field
$users_to_list = '';
@@ -104,7 +109,15 @@ function email_action( $action, $post_id, $email_id, $old_status, $new_status )
$parsed_message = email_parser( $post_id, $email_id, $old_status, $new_status );
$parsed_subject = email_parser( $post_id, $email_id, $old_status, $new_status, $email_subject );
+ if ( $email_html_formatted )
+ add_filter( 'wp_mail_content_type', 'set_html_content_type' );
+
$mail = wp_mail( $users_to_list, $parsed_subject, $parsed_message, $headers );
+
+
+ if ( $email_html_formatted )
+ // Reset content-type to avoid conflicts -- http://core.trac.wordpress.org/ticket/23578
+ remove_filter( 'wp_mail_content_type', 'set_html_content_type' );
// Log successful email
if( $mail ) {
|