Skip to content

Commit

Permalink
feat: add an admin notice when ses email is disabled because of the v…
Browse files Browse the repository at this point in the history
…anity domain
  • Loading branch information
carlalexander committed Sep 5, 2024
1 parent 73016db commit 55d7703
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion pluggable.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
add_action('admin_notices', function () {
echo '<div class="notice notice-warning"><p><strong>Ymir:</strong> Sending emails using SES is disabled because the "wp_mail" function was already overridden by another plugin.</p></div>';
});
} elseif ($ymir->isSesEnabled() && !function_exists('wp_mail')) {
} elseif ($ymir->isSesEnabled() && $ymir->isUsingVanityDomain()) {
add_action('admin_notices', function () {
echo '<div class="notice notice-warning"><p><strong>Ymir:</strong> Sending emails using SES is disabled because the site is using a vanity domain. To learn how to map a domain to your environment, check out <a href="https://docs.ymirapp.com/guides/domain-mapping.html">this guide</a>.</p></div>';
});
} elseif ($ymir->isSesEnabled() && !$ymir->isUsingVanityDomain() && !function_exists('wp_mail')) {
/**
* Send email using the cloud provider email client.
*/
Expand Down
11 changes: 9 additions & 2 deletions src/Plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,18 @@ public function isLoaded(): bool
*/
public function isSesEnabled(): bool
{
return !$this->container['ymir_using_vanity_domain']
&& false === getenv('YMIR_DISABLE_SES')
return false === getenv('YMIR_DISABLE_SES')
&& (!defined('YMIR_DISABLE_SES') || !YMIR_DISABLE_SES);
}

/**
* Checks if the site is using a vanity domain.
*/
public function isUsingVanityDomain(): bool
{
return $this->container['ymir_using_vanity_domain'];
}

/**
* Loads the plugin into WordPress.
*/
Expand Down

0 comments on commit 55d7703

Please sign in to comment.