Skip to content

Commit

Permalink
Deploying version 1.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmjones committed Jan 24, 2025
1 parent 9984004 commit 100e681
Show file tree
Hide file tree
Showing 8 changed files with 96 additions and 62 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
**Contributors:** wpengine, deliciousbrains, ianmjones, eriktorsner, kevinwhoffman, mattshaw, bradt, SylvainDeaure \
**Tags:** amazon ses,smtp,email delivery,gmail smtp,newsletter \
**Requires at least:** 5.3 \
**Tested up to:** 6.6 \
**Tested up to:** 6.7 \
**Requires PHP:** 7.4 \
**Stable tag:** 1.7.1
**Stable tag:** 1.7.1 \
**License:** GPLv2

Fix your email delivery problems by sending your WordPress emails through Amazon SES's powerful email sending infrastructure.

Expand Down
8 changes: 4 additions & 4 deletions classes/Autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* Autoloader for WP Offload SES.
*
* @author Delicious Brains
* @author Delicious Brains
* @package WP Offload SES
*/

Expand Down Expand Up @@ -46,7 +46,7 @@ class Autoloader {
*/
public function __construct( $prefix, $abspath ) {
$this->prefix = $prefix;
$this->abspath = $abspath;
$this->abspath = trailingslashit( $abspath );

$this->register_autoloader();
}
Expand Down Expand Up @@ -125,7 +125,7 @@ protected function get_class_path( $class_name ) {
*/
protected function get_classes_directory( $vendor = false ) {
$dir = $vendor ? 'vendor' : 'classes';
return $this->abspath . DIRECTORY_SEPARATOR . $dir . DIRECTORY_SEPARATOR;
}

return trailingslashit( $this->abspath . $dir );
}
}
10 changes: 6 additions & 4 deletions classes/Plugin-Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function get_plugin_page_url( $args = array(), $url_method = 'network', $
if ( isset( $args['hash'] ) ) {
$hash = $args['hash'];
unset( $args['hash'] );
} else if ( $this->default_tab ) {
} elseif ( $this->default_tab ) {
$hash = $this->default_tab;
}

Expand Down Expand Up @@ -265,7 +265,7 @@ public function enqueue_style( $handle, $path, $deps = array() ) {
* @return string
*/
public function plugins_url( $path ) {
return plugins_url( $path, $this->plugin_dir_path . '/wp-offload-ses.php' );
return plugins_url( $path, $this->plugin_dir_path . 'wp-offload-ses.php' );
}

/**
Expand Down Expand Up @@ -294,7 +294,7 @@ public function get_asset_suffix() {
*/
public function render_view( $view, $args = array() ) {
extract( $args ); // phpcs:ignore
include $this->plugin_dir_path . '/view/' . $view . '.php';
include $this->plugin_dir_path . 'view/' . $view . '.php';
}

/**
Expand Down Expand Up @@ -441,7 +441,9 @@ public function filter_update_footer( $content ) {
__( 'Documentation', 'wp-offload-ses' )
);

$links[] = '<a href="' . static::get_plugin_page_url( array( 'hash' => 'support' ) ) . '">' . __( 'Support', 'wp-offload-ses' ) . '</a>';
$links[] = '<a href="' . static::get_plugin_page_url(
array( 'hash' => 'support' )
) . '">' . __( 'Support', 'wp-offload-ses' ) . '</a>';

$links[] = Utils::dbrains_link(
static::dbrains_url(
Expand Down
44 changes: 27 additions & 17 deletions classes/Plugin-Updater.php → ext/Plugin-Updater.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
/**
* The PluginUpdater class which can be used to pull plugin updates from a new location.
*
* @package wp-offload-ses
*/

Expand All @@ -19,33 +20,38 @@
class Plugin_Updater {
/**
* The URL where the api is located.
* @var ApiUrl
*
* @var string
*/
private $api_url;

/**
* The amount of time to wait before checking for new updates.
* @var CacheTime
*
* @var int
*/
private $cache_time;

/**
* These properties are passed in when instantiating to identify the plugin and it's update location.
* @var Properties
*
* @var array
*/
private $properties;

/**
* Get the class constructed.
*
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
* @param array $properties These properties are passed in when instantiating to identify the plugin and it's update location.
*/
public function __construct( $properties ) {
if (
empty( $properties['plugin_slug'] ) ||
empty( $properties['plugin_basename'] )
) {
// phpcs:ignore WordPress.PHP.DevelopmentFunctions.error_log_error_log
error_log( 'WPE Secure Plugin Updater received a malformed request.' );

return;
}

Expand All @@ -65,8 +71,10 @@ public function __construct( $properties ) {
/**
* Get the full plugin properties, including the directory name, version, basename, and add a transient name.
*
* @param Properties $properties These properties are passed in when instantiating to identify the plugin and it's update location.
* @param ApiUrl $api_url The URL where the api is located.
* @param array $properties These properties are passed in when instantiating to identify the plugin and it's update location.
* @param string $api_url The URL where the api is located.
*
* @return array|null
*/
public function get_full_plugin_properties( $properties, $api_url ) {
$plugins = \get_plugins();
Expand Down Expand Up @@ -103,30 +111,33 @@ public function register() {
/**
* Filter the plugin update transient to take over update notifications.
*
* @param object $transient The site_transient_update_plugins transient.
* @param ?object $transient_value The value of the `site_transient_update_plugins` transient.
*
* @handles site_transient_update_plugins
* @return object
* @return object|null
*/
public function filter_plugin_update_transient( $transient ) {
public function filter_plugin_update_transient( $transient_value ) {
// No update object exists. Return early.
if ( empty( $transient ) ) {
return $transient;
if ( empty( $transient_value ) ) {
return $transient_value;
}

$result = $this->fetch_plugin_info();

if ( false === $result ) {
return $transient;
return $transient_value;
}

$res = $this->parse_plugin_info( $result );

if ( version_compare( $this->properties['plugin_version'], $result->version, '<' ) ) {
$res = $this->parse_plugin_info( $result );
$transient->response[ $res->plugin ] = $res;
$transient->checked[ $res->plugin ] = $result->version;
$transient_value->response[ $res->plugin ] = $res;
$transient_value->checked[ $res->plugin ] = $result->version;
} else {
$transient_value->no_update[ $res->plugin ] = $res;
}

return $transient;
return $transient_value;
}

/**
Expand Down Expand Up @@ -213,7 +224,6 @@ private function fetch_plugin_info() {
* @return stdClass
*/
private function parse_plugin_info( $response ) {

global $wp_version;

$res = new stdClass();
Expand Down
18 changes: 18 additions & 0 deletions ext/wposes-ext-functions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

if ( ! function_exists( 'wposes_check_for_upgrades' ) ) {
/**
* Initialize the checking for plugin updates.
*/
function wposes_check_for_upgrades() {
$properties = array(
'plugin_slug' => 'wp-ses',
'plugin_basename' => plugin_basename( WPOSESLITE_FILE ),
);

require_once WPOSESLITE_PATH . 'ext/Plugin-Updater.php';
new DeliciousBrains\WP_Offload_SES\Plugin_Updater( $properties );
}

add_action( 'admin_init', 'wposes_check_for_upgrades' );
}
8 changes: 4 additions & 4 deletions languages/wp-ses-en.pot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2024 Delicious Brains
# Copyright (C) 2025 Delicious Brains
# This file is distributed under the same license as the WP Offload SES Lite plugin.
msgid ""
msgstr ""
Expand All @@ -9,7 +9,7 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2024-10-04T12:19:56+00:00\n"
"POT-Creation-Date: 2025-01-24T15:02:36+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.11.0\n"
"X-Domain: wp-offload-ses\n"
Expand Down Expand Up @@ -304,11 +304,11 @@ msgstr ""
msgid "Documentation"
msgstr ""

#: classes/Plugin-Base.php:444
#: classes/Plugin-Base.php:446
msgid "Support"
msgstr ""

#: classes/Plugin-Base.php:451
#: classes/Plugin-Base.php:453
msgid "Feedback"
msgstr ""

Expand Down
3 changes: 2 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
Contributors: wpengine, deliciousbrains, ianmjones, eriktorsner, kevinwhoffman, mattshaw, bradt, SylvainDeaure
Tags: amazon ses,smtp,email delivery,gmail smtp,newsletter
Requires at least: 5.3
Tested up to: 6.6
Tested up to: 6.7
Requires PHP: 7.4
Stable tag: 1.7.1
License: GPLv2

Fix your email delivery problems by sending your WordPress emails through Amazon SES's powerful email sending infrastructure.

Expand Down
62 changes: 32 additions & 30 deletions wp-ses.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,23 @@

$GLOBALS['wposes_meta']['wp-ses']['version'] = '1.7.1';

if ( ! defined( 'WPOSESLITE_FILE' ) ) {
// Defines the path to the main plugin file.
define( 'WPOSESLITE_FILE', __FILE__ );

// Defines the path to be used for includes.
define( 'WPOSESLITE_PATH', wposes_lite_get_plugin_dir_path() );
}

if ( ! class_exists( 'DeliciousBrains\WP_Offload_SES\Compatibility_Check' ) ) {
require_once wposes_lite_get_plugin_dir_path() . '/classes/Compatibility-Check.php';
require_once WPOSESLITE_PATH . 'classes/Compatibility-Check.php';
}

global $wposes_compat_check;
$wposes_compat_check = new DeliciousBrains\WP_Offload_SES\Compatibility_Check(
'WP Offload SES Lite',
'wp-offload-ses-lite',
__FILE__
'wp-ses',
WPOSESLITE_FILE
);

add_action( 'activated_plugin', array( $wposes_compat_check, 'deactivate_other_instances' ) );
Expand Down Expand Up @@ -70,23 +78,21 @@ function wp_offload_ses_lite_init() {
return;
}

$abspath = wposes_lite_get_plugin_dir_path();

// Prevent error in Guzzle when PHP doesn't have the intl extension.
if ( ! function_exists( 'idn_to_ascii' ) && ! defined( 'IDNA_DEFAULT' ) ) {
define( 'IDNA_DEFAULT', 0 );
}

// Load autoloaders.
require_once $abspath . '/vendor/Aws3/aws-autoloader.php';
require_once $abspath . '/classes/Autoloader.php';
new DeliciousBrains\WP_Offload_SES\Autoloader( 'WP_Offload_SES', $abspath );
require_once WPOSESLITE_PATH . 'vendor/Aws3/aws-autoloader.php';
require_once WPOSESLITE_PATH . 'classes/Autoloader.php';
new DeliciousBrains\WP_Offload_SES\Autoloader( 'WP_Offload_SES', WPOSESLITE_PATH );

// Load compatibility functions for older PHP (< 8.0) and WordPress (< 5.9).
require_once $abspath . '/includes/compat.php';
require_once WPOSESLITE_PATH . 'includes/compat.php';

// Kick off the plugin.
$wp_offload_ses = new DeliciousBrains\WP_Offload_SES\WP_Offload_SES( __FILE__ );
$wp_offload_ses = new DeliciousBrains\WP_Offload_SES\WP_Offload_SES( WPOSESLITE_FILE );

return $wp_offload_ses;
}
Expand All @@ -99,14 +105,14 @@ function wp_offload_ses_lite_init() {
* @return string
*/
function wposes_lite_get_plugin_dir_path() {
$abspath = wp_normalize_path( dirname( __FILE__ ) );
$abspath = wp_normalize_path( dirname( WPOSESLITE_FILE ) );
$mu_path = wp_normalize_path( WPMU_PLUGIN_DIR );

if ( $mu_path === $abspath ) {
$abspath = $abspath . '/wp-ses/';
}

return $abspath;
return trailingslashit( $abspath );
}

/**
Expand All @@ -116,7 +122,7 @@ function wposes_lite_get_plugin_dir_path() {
*/
function wposes_lite_sending_enabled() {
if ( defined( 'WPOSES_SETTINGS' ) ) {
require_once dirname( __FILE__ ) . '/classes/Utils.php';
require_once WPOSESLITE_PATH . 'classes/Utils.php';
$defined_settings = Utils::maybe_unserialize( constant( 'WPOSES_SETTINGS' ) );

if ( isset( $defined_settings['send-via-ses'] ) ) {
Expand All @@ -143,9 +149,7 @@ function wposes_lite_sending_enabled() {
return false;
}

/*
* Override wp_mail if SES enabled
*/
// Override `wp_mail()` if sending via SES is enabled.
if ( ! function_exists( 'wp_mail' ) ) {
if ( wposes_lite_sending_enabled() ) {
/**
Expand All @@ -167,28 +171,26 @@ function wp_mail( $to, $subject, $message, $headers = '', $attachments = array()
$wp_offload_ses = wp_offload_ses_lite_init();
}

// Could not initialize plugin.
if ( is_null( $wp_offload_ses ) ) {
return false;
}

return $wp_offload_ses->mail_handler( $to, $subject, $message, $headers, $attachments );
}
}
} else {
global $pagenow;

if ( ! in_array( $pagenow, array( 'plugins.php', 'update-core.php' ), true ) ) {
require_once dirname( __FILE__ ) . '/classes/Error.php';
new DeliciousBrains\WP_Offload_SES\Error( DeliciousBrains\WP_Offload_SES\Error::$mail_function_exists, 'Mail function already overridden.' );
require_once WPOSESLITE_PATH . 'classes/Error.php';
new DeliciousBrains\WP_Offload_SES\Error(
DeliciousBrains\WP_Offload_SES\Error::$mail_function_exists,
'Mail function already overridden.'
);
}
}

/**
* Initialize the checking for plugin updates.
*/
function wposes_check_for_upgrades() {
$properties = array(
'plugin_slug' => 'wp-ses',
'plugin_basename' => plugin_basename( __FILE__ ),
);

require_once __DIR__ . '/classes/Plugin-Updater.php';
new DeliciousBrains\WP_Offload_SES\Plugin_Updater( $properties );
if ( file_exists( WPOSESLITE_PATH . 'ext/wposes-ext-functions.php' ) ) {
require_once WPOSESLITE_PATH . 'ext/wposes-ext-functions.php';
}
add_action( 'admin_init', 'wposes_check_for_upgrades' );

0 comments on commit 100e681

Please sign in to comment.