Created
April 1, 2015 14:34
-
-
Save cdlewis/bceea428dc319e7009ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 254c80a2dd08512a546dffad06ede4ca21fd9ff3 Mon Sep 17 00:00:00 2001 | |
From: Adam Wojtonis <[email protected]> | |
Date: Tue, 20 Jan 2015 15:22:55 -0500 | |
Subject: [PATCH] Adding trigger email functionality. | |
--- | |
imge_gravity2mailjet.php | 43 ++++++++++++++++++++++++++++++++++++++++++ | |
includes/template.html | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ | |
2 files changed, 92 insertions(+) | |
create mode 100644 includes/template.html | |
diff --git a/imge_gravity2mailjet.php b/imge_gravity2mailjet.php | |
index 0ccab35..f01f824 100644 | |
--- a/imge_gravity2mailjet.php | |
+++ b/imge_gravity2mailjet.php | |
@@ -120,6 +120,32 @@ function post_content_to_mailjet($entry, $form){ | |
trigger_error( "gf2mj error - ".$mj->_response_code, E_WARNING ); | |
} | |
} | |
+ | |
+ ################################# | |
+ # Send trigger email if enabled # | |
+ ################################# | |
+ | |
+ //Check if trigger email is enabled and addition was a success. | |
+ | |
+ if ( $cur_form['g2mj_enable_trigger'] == "true" && $mj->_response_code == 201 ) { | |
+ | |
+ $html = file_get_contents( 'includes/template.html' ); | |
+ | |
+ $params = array( | |
+ "method" => "POST", | |
+ "from" => "Bubba Atkinson <[email protected]>", | |
+ "to" => $Email, | |
+ "subject" => "Thanks for signing up!", | |
+ "html" => $html | |
+ ); | |
+ | |
+ $result = $mj->sendEmail($params); | |
+ | |
+ if ($mj->_response_code != 201) { | |
+ trigger_error( "gf2mj error - ".$mj->_response_code, E_WARNING ); | |
+ } | |
+ | |
+ } | |
} | |
} | |
@@ -151,6 +177,22 @@ class gf2mj{ | |
'</tr>'; | |
+ // The checkbox to send template welcome email on this form. | |
+ if (!array_key_exists('g2mj_enable_trigger', $form)) { | |
+ $form['g2mj_enable_trigger'] = ""; | |
+ } | |
+ $settings['Gravity to Mailjet']['g2mj_fields'] .= | |
+ '<tr>' . | |
+ ' <td colspan="2">' . | |
+ ' <input type="checkbox" value="true" id="g2mj_enable_trigger" name="g2mj_enable_trigger" ' . checked($form['g2mj_enable_trigger'],"true",false) . ' />' . | |
+ ' ' . | |
+ ' <label for="g2mj_enable_trigger">' . | |
+ ' Enable Mailjet success trigger email on this form' . | |
+ ' </label>' . | |
+ ' </td>' . | |
+ '</tr>'; | |
+ | |
+ | |
// List Settings | |
if (!array_key_exists('g2mj_apikey', $form)) { | |
$form['g2mj_apikey'] = ""; | |
@@ -310,6 +352,7 @@ class gf2mj{ | |
public static function gf2mj_save_form_settings($form) { | |
$form['g2mj_enable'] = rgpost('g2mj_enable'); | |
+ $form['g2mj_enable_trigger'] = rgpost('g2mj_enable_trigger'); | |
$form['g2mj_apikey'] = rgpost('g2mj_apikey'); | |
$form['g2mj_secretkey'] = rgpost('g2mj_secretkey'); | |
$form['g2mj_source'] = rgpost('g2mj_source'); | |
diff --git a/includes/template.html b/includes/template.html | |
new file mode 100644 | |
index 0000000..cfcdf37 | |
--- /dev/null | |
+++ b/includes/template.html | |
@@ -0,0 +1,49 @@ | |
+<!DOCTYPE HTML> | |
+ <html lang="en"> | |
+ <head> | |
+ <meta content="text/html; charset=utf-8" http-equiv="Content-Type"> | |
+ <title> | |
+ Thanks for signing up! | |
+ </title> | |
+ </head> | |
+ <body> | |
+ <!--- Preview --> | |
+ <p style="font-size: 1px; color: #FFF">Welcome to I.J. Review! We're excited to share with you the best content from around the internet.</p> | |
+ <table style="border-collpase:collapse;width:100%;max-width:800px;margin-right:auto;margin-left:auto;"> | |
+ <tbody> | |
+ <tr> | |
+ <td colspan="2" style="padding:0"> | |
+ <a href="http://home.ijreview.com/?utm_source=autoresponder&utm_medium=email&utm_campaign=newemail"> | |
+ <img alt="Hey! You don't want to miss this message. Enable images to check it out!" src="http://www.ijreview.com/wp-content/uploads/2015/01/Email-Main.jpg" style="width:100%;max-width:800px"></a> | |
+ </td> | |
+ </tr> | |
+ <tr> | |
+ <td style="width:400px;padding:0;"> | |
+ <a href="https://www.facebook.com/IjReview"><img src="http://www.ijreview.com/wp-content/uploads/2015/01/IJEmail-2-3.jpg" style="width:400px;max-width:100%"></a> | |
+ </td> | |
+ <td style="width:400px;padding:0;"> | |
+ <a href="http://home.ijreview.com/?utm_source=autoresponder&utm_medium=email&utm_campaign=newemail"><img src="http://www.ijreview.com/wp-content/uploads/2015/01/IJEmail-3-5.jpg" style="width:400px;max-width:100%"></a> | |
+ </td> | |
+ </tr> | |
+ <tr> | |
+ <td cellpadding="0" border="0" align="center" cellspacing="0" colspan="2" bgcolor="#1e1e1e"> | |
+ <a href="[[UNSUB_LINK_EN]]"><img src="http://www.ijreview.com/wp-content/uploads/2015/01/IJEmail-4-1.jpg" style="width:100%;max-width:800px"></a> | |
+ </td> | |
+ </tr> | |
+ <tr> | |
+ <td cellpadding="0" border="0" align="center" cellspacing="0" colspan="2" style="padding:8px"> | |
+ <p style="color:#1e1e1e;font-size:11px"> | |
+ Independent Journal Review | 3524 Silverside Road, Suite 35B | Wilmington, DE 19810 | |
+ </p> | |
+ <p style="font-size:11px;"> | |
+ <a style="color:#1e1e1e;" href="[[UNSUB_LINK_EN]]"> | |
+ Unsubscribe | |
+ </a> | |
+ </p> | |
+ </td> | |
+ </tr> | |
+ | |
+ </tbody> | |
+ </table> | |
+ </body> | |
+ </html> | |
\ No newline at end of file | |
-- | |
2.1.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment