Skip to content

Commit

Permalink
Version 1.11.7
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Plesciuc committed Aug 28, 2017
1 parent 4d9d7af commit 998ba99
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 17 deletions.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* 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
* Requires at least: 4.6
* Tested up to: 4.8
* Stable tag: 1.11.6
* Stable tag: 1.11.7
* License: GPLv2 or later
* License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -99,6 +99,10 @@ SendGrid settings can optionally be defined as global variables (wp-config.php):
* Signup confirmation email content: define('SENDGRID_MC_SIGNUP_EMAIL_CONTENT', '<a href="%confirmation_link%">click here</a>');
* Signup confirmation page ID: define('SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE', 'page_id');

4. Other configuration options:
* Set a custom timeout for API requests to SendGrid in seconds: define('SENDGRID_REQUEST_TIMEOUT', 10);


### Filters

Use HTML content type for a single email:
Expand Down Expand Up @@ -265,6 +269,14 @@ wp_mail('[email protected]', 'Subject goes here', 'Message goes here', $email);

You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v4.0.2/README.md

### My server is slow. Can I increase the timeout for API requests?

Yes. You can define a constant in your wp-config.php file like this:

`define('SENDGRID_REQUEST_TIMEOUT', 10);`

The value is in seconds, this means that API requests will wait 10 seconds for a reponse from the SendGrid API server until timing out.

## Screenshots

1. Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to install also the 'Swift Mailer' plugin.
Expand Down Expand Up @@ -292,6 +304,10 @@ You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v

## Changelog

**1.11.7**
* Added a configuration parameter of API request timeout in seconds
* Fixed an issue that made the HTML subscription emails break links

**1.11.6**
* Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
* Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol
Expand Down Expand Up @@ -536,6 +552,10 @@ You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v

## Upgrade notice

**1.11.7**
* Added a configuration parameter of API request timeout in seconds
* Fixed an issue that made the HTML subscription emails break links

**1.11.6**
* Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
* Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol
Expand Down
6 changes: 3 additions & 3 deletions lib/class-sendgrid-mc-optin.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ public static function send_confirmation_email( $email, $first_name = '', $last_
return false;
}

$subject = htmlspecialchars_decode( $subject );
$content = htmlspecialchars_decode( $content );
$content_text = htmlspecialchars_decode( $content_text );
$subject = stripslashes( $subject );
$content = stripslashes( $content );
$content_text = stripslashes( $content_text );
$to = array( $email );

$token = Sendgrid_OptIn_API_Endpoint::generate_email_token( $email, $first_name, $last_name );
Expand Down
9 changes: 6 additions & 3 deletions lib/class-sendgrid-nlvx.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public static function get_all_lists()
'headers' => array(
'Authorization' => $auth
),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

$url = Sendgrid_NLVX::NLVX_API_URL . '/lists';
Expand Down Expand Up @@ -86,7 +87,8 @@ public static function add_recipient($email, $first_name = '', $last_name = '')
'headers' => array(
'Authorization' => $auth
),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

$url = Sendgrid_NLVX::NLVX_API_URL . '/recipients';
Expand Down Expand Up @@ -142,7 +144,8 @@ public static function add_recipient_to_list($recipient_id, $list_id)
'headers' => array(
'Authorization' => $auth
),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

$url = Sendgrid_NLVX::NLVX_API_URL . '/lists/'. $list_id . '/recipients/' . $recipient_id;
Expand Down
29 changes: 26 additions & 3 deletions lib/class-sendgrid-tools.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class Sendgrid_Tools
const CHECK_API_KEY_CACHE_KEY = "sendgrid_api_key_check";
const CHECK_API_KEY_STATS_CACHE_KEY = "sendgrid_api_key_stats_check";
const VALID_CREDENTIALS_STATUS = "valid";
const DEFAULT_TIMEOUT = 5;

// used static variable because php 5.3 doesn't support array as constant
public static $allowed_ports = array( Sendgrid_SMTP::TLS, Sendgrid_SMTP::TLS_ALTERNATIVE, Sendgrid_SMTP::SSL, Sendgrid_SMTP::TLS_ALTERNATIVE_2 );
Expand Down Expand Up @@ -78,7 +79,13 @@ public static function check_username_password( $username, $password, $clear_cac
$url = 'https://api.sendgrid.com/api/profile.get.json?';
$url .= "api_user=" . urlencode( $username ) . "&api_key=" . urlencode( $password );

$response = wp_remote_get( $url, array( 'decompress' => false ) );
$response = wp_remote_get(
$url,
array(
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
)
);

if ( ! is_array( $response ) or ! isset( $response['body'] ) ) {
return false;
Expand Down Expand Up @@ -113,7 +120,8 @@ public static function check_api_key_scopes( $apikey, $scopes )
$args = array(
'headers' => array(
'Authorization' => 'Bearer ' . $apikey ),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

$response = wp_remote_get( $url, $args );
Expand Down Expand Up @@ -223,7 +231,8 @@ public static function do_request( $api = 'v3/stats', $parameters = array() )
'headers' => array(
'Authorization' => 'Bearer ' . self::get_api_key()
),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

$data = urldecode( http_build_query( $parameters ) );
Expand Down Expand Up @@ -1424,6 +1433,20 @@ public static function get_multisite_pagination( $offset, $limit ) {

return $pagination;
}

/**
* Returns configured timeout for API requests
*
* @return integer timeout in seconds
*/
public static function get_request_timeout()
{
if ( defined( 'SENDGRID_REQUEST_TIMEOUT' ) ) {
return SENDGRID_REQUEST_TIMEOUT;
} else {
return self::DEFAULT_TIMEOUT;
}
}
}

/**
Expand Down
11 changes: 6 additions & 5 deletions lib/sendgrid/class-sendgrid-api.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,25 +25,26 @@ public function __construct( $username, $password_or_apikey ) {

public function send(SendGrid\Email $email) {
$data = array(
'headers' => array(
'headers' => array(
'Content-Type' => 'application/json',
'User-Agent' => 'sendgrid/wordpress;php',
'Authorization' => 'Bearer ' . $this->apikey
),
'body' => Sendgrid_Translator::to_api_v3( $email ),
'decompress' => false
'decompress' => false,
'timeout' => Sendgrid_Tools::get_request_timeout()
);

// Send the request
$response = wp_remote_post( self::URL, $data );

// Check that the response fields are set
if ( !is_array( $response ) or
!isset( $response['response'] ) or
if ( !is_array( $response ) or
!isset( $response['response'] ) or
!isset( $response['response']['code'] ) ) {
return false;
}

// Check for success code range (200-299)
$response_code = (int) $response['response']['code'];
if ( $response_code >= 200 and
Expand Down
19 changes: 18 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Donate link: http://sendgrid.com/
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
Requires at least: 4.6
Tested up to: 4.8
Stable tag: 1.11.6
Stable tag: 1.11.7
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down Expand Up @@ -100,6 +100,9 @@ SendGrid settings can optionally be defined as global variables (wp-config.php):
* Signup confirmation email content: define('SENDGRID_MC_SIGNUP_EMAIL_CONTENT', '<a href="%confirmation_link%">click here</a>');
* Signup confirmation page ID: define('SENDGRID_MC_SIGNUP_CONFIRMATION_PAGE', 'page_id');

4. Other configuration options:
* Set a custom timeout for API requests to SendGrid in seconds: define('SENDGRID_REQUEST_TIMEOUT', 10);

= Filters =

Use HTML content type for a single email:
Expand Down Expand Up @@ -276,6 +279,14 @@ wp_mail('[email protected]', 'Subject goes here', 'Message goes here', $email);

You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v4.0.2/README.md

= My server is slow. Can I increase the timeout for API requests? =

Yes. You can define a constant in your wp-config.php file like this:

`define('SENDGRID_REQUEST_TIMEOUT', 10);`

The value is in seconds, this means that API requests will wait 10 seconds for a reponse from the SendGrid API server until timing out.

== Screenshots ==

1. Go to Admin Panel, section Plugins and activate the SendGrid plugin. If you want to send emails through SMTP you need to install also the 'Swift Mailer' plugin.
Expand All @@ -292,6 +303,9 @@ You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v

== Changelog ==

= 1.11.7 =
* Added a configuration parameter of API request timeout in seconds
* Fixed an issue that made the HTML subscription emails break links
= 1.11.6 =
* Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
* Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol
Expand Down Expand Up @@ -472,6 +486,9 @@ You can find more examples here: https://github.com/sendgrid/sendgrid-php/blob/v

== Upgrade notice ==

= 1.11.7 =
* Added a configuration parameter of API request timeout in seconds
* Fixed an issue that made the HTML subscription emails break links
= 1.11.6 =
* Added a feature flag to disable whitespace normalization in BuddyPress plaintext emails
* Fixed an issue where the from name and email subjects would incorrectly display the ampersand symbol
Expand Down
2 changes: 1 addition & 1 deletion wpsendgrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: SendGrid
Plugin URI: http://wordpress.org/plugins/sendgrid-email-delivery-simplified/
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.
Version: 1.11.6
Version: 1.11.7
Author: SendGrid
Author URI: http://sendgrid.com
Text Domain: sendgrid-email-delivery-simplified
Expand Down

0 comments on commit 998ba99

Please sign in to comment.