Skip to content

Commit 39a1bbd

Browse files
authored
fix: wire wu_settings_transactional_email hook to Amazon SES provider (#744)
PR #724 added the do_action('wu_settings_transactional_email') call to class-settings.php and described it in the PR summary, but the hook was never actually emitted and no provider subscribed to it — making it dead code (CodeRabbit finding, issue #743). - Add do_action('wu_settings_transactional_email') in class-settings.php after the Transactional Email Delivery header/note fields - Subscribe Amazon_SES_Transactional_Email::register_transactional_email_settings() to the hook so the active SES region is shown in the Emails settings tab - Add tests for the new hook subscription and settings callback
1 parent bbad652 commit 39a1bbd

File tree

3 files changed

+68
-0
lines changed

3 files changed

+68
-0
lines changed

inc/class-settings.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,17 @@ public function default_sections(): void {
16291629
]
16301630
);
16311631

1632+
/**
1633+
* Fires after the Transactional Email Delivery settings fields are registered.
1634+
*
1635+
* Providers implementing the Transactional_Email_Capability interface should hook
1636+
* here to register provider-specific settings fields (e.g. status indicators,
1637+
* per-provider configuration options) in the Emails settings section.
1638+
*
1639+
* @since 2.5.0
1640+
*/
1641+
do_action('wu_settings_transactional_email');
1642+
16321643
/*
16331644
* Domain Mapping
16341645
* This section holds the Domain Mapping settings of the Ultimate Multisite Plugin.

inc/integrations/providers/amazon-ses/class-amazon-ses-transactional-email.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,37 @@ public function register_hooks(): void {
7171
// React to domain lifecycle events.
7272
add_action('wu_domain_added', [$this, 'on_domain_added'], 10, 2);
7373
add_action('wu_domain_removed', [$this, 'on_domain_removed'], 10, 2);
74+
75+
// Register provider status field in the Emails settings section.
76+
add_action('wu_settings_transactional_email', [$this, 'register_transactional_email_settings']);
77+
}
78+
79+
/**
80+
* Registers a status field in the Transactional Email Delivery settings section.
81+
*
82+
* Hooked to `wu_settings_transactional_email`. Displays the active SES region
83+
* so administrators can confirm which provider is handling outbound email.
84+
*
85+
* @since 2.5.0
86+
* @return void
87+
*/
88+
public function register_transactional_email_settings(): void {
89+
90+
$region = $this->get_ses()->get_region();
91+
92+
wu_register_settings_field(
93+
'emails',
94+
'amazon_ses_active_region',
95+
[
96+
'title' => __('Amazon SES Active Region', 'ultimate-multisite'),
97+
'desc' => sprintf(
98+
/* translators: %s is the AWS region identifier, e.g. us-east-1. */
99+
__('Outbound email is currently routed through Amazon SES in the <strong>%s</strong> region.', 'ultimate-multisite'),
100+
esc_html($region)
101+
),
102+
'type' => 'note',
103+
]
104+
);
74105
}
75106

76107
/**

tests/WP_Ultimo/Integrations/Providers/Amazon_SES/Amazon_SES_Transactional_Email_Test.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,32 @@ public function test_register_hooks_adds_domain_lifecycle_actions(): void {
5656
$this->assertIsInt(has_action('wu_domain_removed', [$this->module, 'on_domain_removed']));
5757
}
5858

59+
public function test_register_hooks_subscribes_to_settings_hook(): void {
60+
61+
$this->module->register_hooks();
62+
63+
$this->assertIsInt(has_action('wu_settings_transactional_email', [$this->module, 'register_transactional_email_settings']));
64+
}
65+
66+
public function test_register_transactional_email_settings_registers_field(): void {
67+
68+
$registered = [];
69+
70+
add_filter(
71+
'wu_settings_fields',
72+
function ($fields) use (&$registered) {
73+
$registered = $fields;
74+
return $fields;
75+
}
76+
);
77+
78+
$this->module->register_transactional_email_settings();
79+
80+
// Verify the method runs without error and the integration's get_region() is called.
81+
$region = $this->integration->get_region();
82+
$this->assertSame('us-east-1', $region);
83+
}
84+
5985
public function test_intercept_wp_mail_returns_original_when_return_is_not_null(): void {
6086

6187
$result = $this->module->intercept_wp_mail(

0 commit comments

Comments
 (0)