Version Description
- Set transient token for Marketing Campaign in database
Download this release
Release Info
Developer | team-rs |
Plugin | SendGrid |
Version | 1.10.4 |
Comparing to | |
See all releases |
Code changes from version 1.10.2 to 1.10.4
- lib/class-sendgrid-mc-optin.php +23 -23
- lib/class-sendgrid-tools.php +74 -0
- lib/sendgrid/sendgrid-wp-mail.php +6 -0
- readme.txt +12 -2
- wpsendgrid.php +1 -1
lib/class-sendgrid-mc-optin.php
CHANGED
@@ -60,7 +60,7 @@ class Sendgrid_OptIn_API_Endpoint{
|
|
60 |
exit();
|
61 |
}
|
62 |
|
63 |
-
$transient = ( is_multisite() ?
|
64 |
|
65 |
if ( ! $transient or
|
66 |
! is_array( $transient ) or
|
@@ -83,9 +83,9 @@ class Sendgrid_OptIn_API_Endpoint{
|
|
83 |
|
84 |
if ( $page == false ) {
|
85 |
if ( is_multisite() ) {
|
86 |
-
|
87 |
} else {
|
88 |
-
|
89 |
}
|
90 |
wp_redirect( 'sg-subscription-success' );
|
91 |
exit();
|
@@ -131,28 +131,28 @@ class Sendgrid_OptIn_API_Endpoint{
|
|
131 |
|
132 |
$token = Sendgrid_OptIn_API_Endpoint::generate_email_token( $email, $first_name, $last_name );
|
133 |
|
134 |
-
$transient = ( is_multisite() ?
|
135 |
|
136 |
if ( $transient and isset( $transient['email'] ) and ! $from_settings ) {
|
137 |
return false;
|
138 |
}
|
139 |
|
140 |
if ( is_multisite() ) {
|
141 |
-
if ( false ==
|
142 |
array(
|
143 |
'email' => $email,
|
144 |
'first_name' => $first_name,
|
145 |
'last_name' => $last_name ),
|
146 |
-
|
147 |
-
|
148 |
}
|
149 |
-
} elseif ( false ==
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
24 * 60 * 60 ) and ! $from_settings and $transient ) {
|
155 |
-
|
156 |
}
|
157 |
|
158 |
$confirmation_link = site_url() . '/?__sg_api=1&token=' . $token;
|
@@ -191,10 +191,10 @@ function register_shortcode_first_name($atts)
|
|
191 |
}
|
192 |
|
193 |
$token = $_GET['sg_token'];
|
194 |
-
$transient =
|
195 |
|
196 |
if ( is_multisite() ) {
|
197 |
-
$transient =
|
198 |
}
|
199 |
|
200 |
if ( ! $transient ||
|
@@ -221,10 +221,10 @@ function register_shortcode_last_name($atts)
|
|
221 |
}
|
222 |
|
223 |
$token = $_GET['sg_token'];
|
224 |
-
$transient =
|
225 |
|
226 |
if ( is_multisite() ) {
|
227 |
-
$transient =
|
228 |
}
|
229 |
|
230 |
if ( ! $transient or
|
@@ -251,10 +251,10 @@ function register_shortcode_email($atts)
|
|
251 |
}
|
252 |
|
253 |
$token = $_GET['sg_token'];
|
254 |
-
$transient =
|
255 |
|
256 |
if ( is_multisite() ) {
|
257 |
-
$transient =
|
258 |
}
|
259 |
|
260 |
if ( ! $transient or
|
@@ -285,17 +285,17 @@ function sg_invalidate_token() {
|
|
285 |
}
|
286 |
|
287 |
$token = $_GET['sg_token'];
|
288 |
-
$transient =
|
289 |
|
290 |
if ( is_multisite() ) {
|
291 |
-
$transient =
|
292 |
}
|
293 |
|
294 |
if ( $token and $transient ) {
|
295 |
if ( is_multisite() ) {
|
296 |
-
|
297 |
} else {
|
298 |
-
|
299 |
}
|
300 |
}
|
301 |
}
|
60 |
exit();
|
61 |
}
|
62 |
|
63 |
+
$transient = ( is_multisite() ? Sendgrid_Tools::get_site_transient_sendgrid( $token ) : Sendgrid_Tools::get_transient_sendgrid( $token ) );
|
64 |
|
65 |
if ( ! $transient or
|
66 |
! is_array( $transient ) or
|
83 |
|
84 |
if ( $page == false ) {
|
85 |
if ( is_multisite() ) {
|
86 |
+
Sendgrid_Tools::set_site_transient_sendgrid( $token, null );
|
87 |
} else {
|
88 |
+
Sendgrid_Tools::set_transient_sendgrid( $token, null );
|
89 |
}
|
90 |
wp_redirect( 'sg-subscription-success' );
|
91 |
exit();
|
131 |
|
132 |
$token = Sendgrid_OptIn_API_Endpoint::generate_email_token( $email, $first_name, $last_name );
|
133 |
|
134 |
+
$transient = ( is_multisite() ? Sendgrid_Tools::get_site_transient_sendgrid( $token ) : Sendgrid_Tools::get_transient_sendgrid( $token ) );
|
135 |
|
136 |
if ( $transient and isset( $transient['email'] ) and ! $from_settings ) {
|
137 |
return false;
|
138 |
}
|
139 |
|
140 |
if ( is_multisite() ) {
|
141 |
+
if ( false == Sendgrid_Tools::set_site_transient_sendgrid( $token,
|
142 |
array(
|
143 |
'email' => $email,
|
144 |
'first_name' => $first_name,
|
145 |
'last_name' => $last_name ),
|
146 |
+
24 * 60 * 60 ) and ! $from_settings and $transient ) {
|
147 |
+
return false;
|
148 |
}
|
149 |
+
} elseif ( false == Sendgrid_Tools::set_transient_sendgrid( $token,
|
150 |
+
array(
|
151 |
+
'email' => $email,
|
152 |
+
'first_name' => $first_name,
|
153 |
+
'last_name' => $last_name ),
|
154 |
24 * 60 * 60 ) and ! $from_settings and $transient ) {
|
155 |
+
return false;
|
156 |
}
|
157 |
|
158 |
$confirmation_link = site_url() . '/?__sg_api=1&token=' . $token;
|
191 |
}
|
192 |
|
193 |
$token = $_GET['sg_token'];
|
194 |
+
$transient = Sendgrid_Tools::get_transient_sendgrid( $token );
|
195 |
|
196 |
if ( is_multisite() ) {
|
197 |
+
$transient = Sendgrid_Tools::get_site_transient_sendgrid( $token );
|
198 |
}
|
199 |
|
200 |
if ( ! $transient ||
|
221 |
}
|
222 |
|
223 |
$token = $_GET['sg_token'];
|
224 |
+
$transient = Sendgrid_Tools::get_transient_sendgrid( $token );
|
225 |
|
226 |
if ( is_multisite() ) {
|
227 |
+
$transient = Sendgrid_Tools::get_site_transient_sendgrid( $token );
|
228 |
}
|
229 |
|
230 |
if ( ! $transient or
|
251 |
}
|
252 |
|
253 |
$token = $_GET['sg_token'];
|
254 |
+
$transient = Sendgrid_Tools::get_transient_sendgrid( $token );
|
255 |
|
256 |
if ( is_multisite() ) {
|
257 |
+
$transient = Sendgrid_Tools::get_site_transient_sendgrid( $token );
|
258 |
}
|
259 |
|
260 |
if ( ! $transient or
|
285 |
}
|
286 |
|
287 |
$token = $_GET['sg_token'];
|
288 |
+
$transient = Sendgrid_Tools::get_transient_sendgrid( $token );
|
289 |
|
290 |
if ( is_multisite() ) {
|
291 |
+
$transient = Sendgrid_Tools::get_site_transient_sendgrid( $token );
|
292 |
}
|
293 |
|
294 |
if ( $token and $transient ) {
|
295 |
if ( is_multisite() ) {
|
296 |
+
Sendgrid_Tools::set_site_transient_sendgrid( $token, null );
|
297 |
} else {
|
298 |
+
Sendgrid_Tools::set_transient_sendgrid( $token, null );
|
299 |
}
|
300 |
}
|
301 |
}
|
lib/class-sendgrid-tools.php
CHANGED
@@ -1634,6 +1634,80 @@ class Sendgrid_Tools
|
|
1634 |
{
|
1635 |
return preg_replace('/<(https?:\/\/[^>]*)>/im', '$1', $content);
|
1636 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1637 |
}
|
1638 |
|
1639 |
/**
|
1634 |
{
|
1635 |
return preg_replace('/<(https?:\/\/[^>]*)>/im', '$1', $content);
|
1636 |
}
|
1637 |
+
|
1638 |
+
/**
|
1639 |
+
* Set/update the value of a transient using database.
|
1640 |
+
*
|
1641 |
+
* @param string $transient Transient name. Expected to not be SQL-escaped. Must be
|
1642 |
+
* 172 characters or fewer in length.
|
1643 |
+
* @param mixed $value Transient value. Must be serializable if non-scalar.
|
1644 |
+
* Expected to not be SQL-escaped.
|
1645 |
+
* @param int $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
|
1646 |
+
* @return bool False if value was not set and true if value was set.
|
1647 |
+
*/
|
1648 |
+
public static function set_transient_sendgrid( $transient, $value, $expiration = 0 ) {
|
1649 |
+
$old_cache_value = wp_using_ext_object_cache();
|
1650 |
+
wp_using_ext_object_cache( false );
|
1651 |
+
$set_transient_result = set_transient( $transient, $value, $expiration );
|
1652 |
+
wp_using_ext_object_cache( $old_cache_value );
|
1653 |
+
|
1654 |
+
return $set_transient_result;
|
1655 |
+
}
|
1656 |
+
|
1657 |
+
/**
|
1658 |
+
* Set/update the value of a site transient using database.
|
1659 |
+
*
|
1660 |
+
* @param string $transient Transient name. Expected to not be SQL-escaped. Must be
|
1661 |
+
* 172 characters or fewer in length.
|
1662 |
+
* @param mixed $value Transient value. Must be serializable if non-scalar.
|
1663 |
+
* Expected to not be SQL-escaped.
|
1664 |
+
* @param int $expiration Optional. Time until expiration in seconds. Default 0 (no expiration).
|
1665 |
+
* @return bool False if value was not set and true if value was set.
|
1666 |
+
*/
|
1667 |
+
public static function set_site_transient_sendgrid( $transient, $value, $expiration = 0 ) {
|
1668 |
+
$old_cache_value = wp_using_ext_object_cache();
|
1669 |
+
wp_using_ext_object_cache( false );
|
1670 |
+
$set_transient_result = set_site_transient( $transient, $value, $expiration );
|
1671 |
+
wp_using_ext_object_cache( $old_cache_value );
|
1672 |
+
|
1673 |
+
return $set_transient_result;
|
1674 |
+
}
|
1675 |
+
|
1676 |
+
/**
|
1677 |
+
* Get the value of a transient from database.
|
1678 |
+
*
|
1679 |
+
* If the transient does not exist, does not have a value, or has expired,
|
1680 |
+
* then the return value will be false.
|
1681 |
+
*
|
1682 |
+
* @param string $transient Transient name. Expected to not be SQL-escaped.
|
1683 |
+
* @return mixed Value of transient.
|
1684 |
+
*/
|
1685 |
+
function get_transient_sendgrid( $transient ) {
|
1686 |
+
$old_cache_value = wp_using_ext_object_cache();
|
1687 |
+
wp_using_ext_object_cache( false );
|
1688 |
+
$value = get_transient( $transient );
|
1689 |
+
wp_using_ext_object_cache( $old_cache_value );
|
1690 |
+
|
1691 |
+
return $value;
|
1692 |
+
}
|
1693 |
+
|
1694 |
+
/**
|
1695 |
+
* Get the value of a site transient from database.
|
1696 |
+
*
|
1697 |
+
* If the transient does not exist, does not have a value, or has expired,
|
1698 |
+
* then the return value will be false.
|
1699 |
+
*
|
1700 |
+
* @param string $transient Transient name. Expected to not be SQL-escaped.
|
1701 |
+
* @return mixed Value of transient.
|
1702 |
+
*/
|
1703 |
+
function get_site_transient_sendgrid( $transient ) {
|
1704 |
+
$old_cache_value = wp_using_ext_object_cache();
|
1705 |
+
wp_using_ext_object_cache( false );
|
1706 |
+
$value = get_site_transient( $transient );
|
1707 |
+
wp_using_ext_object_cache( $old_cache_value );
|
1708 |
+
|
1709 |
+
return $value;
|
1710 |
+
}
|
1711 |
}
|
1712 |
|
1713 |
/**
|
lib/sendgrid/sendgrid-wp-mail.php
CHANGED
@@ -330,6 +330,12 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
|
|
330 |
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
|
331 |
|
332 |
$text_content = $message;
|
|
|
|
|
|
|
|
|
|
|
|
|
333 |
if ( array_key_exists( 'sendgrid_mail_text' , $GLOBALS['wp_filter'] ) ) {
|
334 |
$text_content = apply_filters( 'sendgrid_mail_text', $text_content );
|
335 |
}
|
330 |
$content_type = apply_filters( 'wp_mail_content_type', $content_type );
|
331 |
|
332 |
$text_content = $message;
|
333 |
+
// check if setText() is set in the header
|
334 |
+
$text_content_header = $mail->getText();
|
335 |
+
if ( isset( $text_content_header ) and false != $text_content_header ) {
|
336 |
+
$text_content = $text_content_header;
|
337 |
+
}
|
338 |
+
// check if filter sendgrid_mail_text is set
|
339 |
if ( array_key_exists( 'sendgrid_mail_text' , $GLOBALS['wp_filter'] ) ) {
|
340 |
$text_content = apply_filters( 'sendgrid_mail_text', $text_content );
|
341 |
}
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ Contributors: team-rs
|
|
3 |
Donate link: http://sendgrid.com/
|
4 |
Tags: email, email reliability, email templates, sendgrid, smtp, transactional email, wp_mail,email infrastructure, email marketing, marketing email, deliverability, email deliverability, email delivery, email server, mail server, email integration, cloud email
|
5 |
Requires at least: 4.2
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag: 1.10.
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
@@ -255,6 +255,11 @@ The settings for all sites in the network can be configured only by the Network
|
|
255 |
|
256 |
== Changelog ==
|
257 |
|
|
|
|
|
|
|
|
|
|
|
258 |
= 1.10.2 =
|
259 |
* Add options to configure subscription widget form (labels, padding)
|
260 |
= 1.10.1 =
|
@@ -387,6 +392,11 @@ The settings for all sites in the network can be configured only by the Network
|
|
387 |
|
388 |
== Upgrade notice ==
|
389 |
|
|
|
|
|
|
|
|
|
|
|
390 |
= 1.10.2 =
|
391 |
* Add options to configure subscription widget form (labels, padding)
|
392 |
= 1.10.1 =
|
3 |
Donate link: http://sendgrid.com/
|
4 |
Tags: email, email reliability, email templates, sendgrid, smtp, transactional email, wp_mail,email infrastructure, email marketing, marketing email, deliverability, email deliverability, email delivery, email server, mail server, email integration, cloud email
|
5 |
Requires at least: 4.2
|
6 |
+
Tested up to: 4.7
|
7 |
+
Stable tag: 1.10.4
|
8 |
License: GPLv2 or later
|
9 |
License URI: http://www.gnu.org/licenses/gpl-2.0.html
|
10 |
|
255 |
|
256 |
== Changelog ==
|
257 |
|
258 |
+
= 1.10.4 =
|
259 |
+
* Set transient token for Marketing Campaign in database
|
260 |
+
= 1.10.3 =
|
261 |
+
* Add option to configure text version using setText() function from the header
|
262 |
+
* Tested up to 4.7
|
263 |
= 1.10.2 =
|
264 |
* Add options to configure subscription widget form (labels, padding)
|
265 |
= 1.10.1 =
|
392 |
|
393 |
== Upgrade notice ==
|
394 |
|
395 |
+
= 1.10.4 =
|
396 |
+
* Set transient token for Marketing Campaign in database
|
397 |
+
= 1.10.3 =
|
398 |
+
* Add option to configure text version using setText() function from the header
|
399 |
+
* Tested up to 4.7
|
400 |
= 1.10.2 =
|
401 |
* Add options to configure subscription widget form (labels, padding)
|
402 |
= 1.10.1 =
|
wpsendgrid.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
Plugin Name: SendGrid
|
4 |
Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
|
5 |
Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
|
6 |
-
Version: 1.10.
|
7 |
Author: SendGrid
|
8 |
Author URI: http://sendgrid.com
|
9 |
Text Domain: sendgrid-email-delivery-simplified
|
3 |
Plugin Name: SendGrid
|
4 |
Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
|
5 |
Description: Email Delivery. Simplified. SendGrid's cloud-based email infrastructure relieves businesses of the cost and complexity of maintaining custom email systems. SendGrid provides reliable delivery, scalability and real-time analytics along with flexible APIs that make custom integration a breeze.
|
6 |
+
Version: 1.10.4
|
7 |
Author: SendGrid
|
8 |
Author URI: http://sendgrid.com
|
9 |
Text Domain: sendgrid-email-delivery-simplified
|