Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions inc/class-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -1629,6 +1629,17 @@ public function default_sections(): void {
]
);

/**
* Fires after the Transactional Email Delivery settings fields are registered.
*
* Providers implementing the Transactional_Email_Capability interface should hook
* here to register provider-specific settings fields (e.g. status indicators,
* per-provider configuration options) in the Emails settings section.
*
* @since 2.5.0
*/
do_action('wu_settings_transactional_email');

/*
* Domain Mapping
* This section holds the Domain Mapping settings of the Ultimate Multisite Plugin.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,37 @@ public function register_hooks(): void {
// React to domain lifecycle events.
add_action('wu_domain_added', [$this, 'on_domain_added'], 10, 2);
add_action('wu_domain_removed', [$this, 'on_domain_removed'], 10, 2);

// Register provider status field in the Emails settings section.
add_action('wu_settings_transactional_email', [$this, 'register_transactional_email_settings']);
}

/**
* Registers a status field in the Transactional Email Delivery settings section.
*
* Hooked to `wu_settings_transactional_email`. Displays the active SES region
* so administrators can confirm which provider is handling outbound email.
*
* @since 2.5.0
* @return void
*/
public function register_transactional_email_settings(): void {

$region = $this->get_ses()->get_region();

wu_register_settings_field(
'emails',
'amazon_ses_active_region',
[
'title' => __('Amazon SES Active Region', 'ultimate-multisite'),
'desc' => sprintf(
/* translators: %s is the AWS region identifier, e.g. us-east-1. */
__('Outbound email is currently routed through Amazon SES in the <strong>%s</strong> region.', 'ultimate-multisite'),
esc_html($region)
),
'type' => 'note',
]
);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,32 @@ public function test_register_hooks_adds_domain_lifecycle_actions(): void {
$this->assertIsInt(has_action('wu_domain_removed', [$this->module, 'on_domain_removed']));
}

public function test_register_hooks_subscribes_to_settings_hook(): void {

$this->module->register_hooks();

$this->assertIsInt(has_action('wu_settings_transactional_email', [$this->module, 'register_transactional_email_settings']));
}

public function test_register_transactional_email_settings_registers_field(): void {

$registered = [];

add_filter(
'wu_settings_fields',
function ($fields) use (&$registered) {
$registered = $fields;
return $fields;
}
);

$this->module->register_transactional_email_settings();

// Verify the method runs without error and the integration's get_region() is called.
$region = $this->integration->get_region();
$this->assertSame('us-east-1', $region);
}

public function test_intercept_wp_mail_returns_original_when_return_is_not_null(): void {

$result = $this->module->intercept_wp_mail(
Expand Down
Loading