MySLP_Email_Settings
in package
Class MySLP_Email_Settings
Table of Contents
Constants
- DELIVERY_META_KEY : string = 'myslp_scheduled_email_last_sent'
- NOTICE_ABOUT_TO_EXPIRE : string = 'about_to_expire'
- NOTICE_RENEWING : string = 'renewing'
- SETTINGS_OPTION_NAME : string = 'myslp_email_options'
- DELIVERY_LOCK_PREFIX : string = '_myslp_scheduled_email_lock_'
- DELIVERY_LOCK_TTL : int = 900
- DUPLICATE_WINDOW : int = 30 * \DAY_IN_SECONDS
Properties
- $email_placeholders : array<string|int, mixed>
- $myslp_email_options : array<string|int, mixed>
Methods
- admin_script() : void
- Script and Styling enqueue
- get_instance() : MySLP_Email_Settings
- Return the shared email settings instance.
- get_scheduled_notice_defaults() : array<string, array<string, string>>
- Defaults shared by the sender and the settings interface.
- menu() : void
- Admin menu
- menu_page_content() : void
- Menu page settings
- new_account_notification() : void
- Send a new account notification to sysadmin.
- process_scheduled_email_account() : array<int, array<string, mixed>>
- Process every scheduled notice type for one network customer account.
- send_expired_action() : string
- Send expired account email function
- send_scheduled_email_notice() : array<string, mixed>
- Send one scheduled-email notice with safety, eligibility, locking, and deduplication.
- send_welcome_email() : string
- Send welcome email function
- __construct() : mixed
- Class constructor.
- acquire_delivery_lock() : false|int
- Attempts to acquire a delivery lock for a specific user and notice type.
- add_style() : string
- Add style to email.
- delivery_result() : array<string, mixed>
- Build a result without retaining recipient or message content.
- get_email_options() : void
- Get myslp_email_options.
- get_email_placeholders() : array<string, string>
- Get email placeholders.
- get_scheduled_email_context() : array<string, mixed>|WP_Error
- Resolve and validate the explicit account recipient context.
- get_scheduled_notice_template() : array<string, mixed>
- Return the canonical template for a scheduled notice.
- get_spam_allowlist() : string
- Retrieves the spam allowlist setting from the email options.
- maybe_migrate_legacy_reminder_options() : void
- Preserve the former reminder template as the new Renewing template, then retire its key.
- ok_to_spam() : bool
- Return true if OK to "spam" (send email from our dev and beta boxes for testing)
- parse_account_date() : int
- Interpret stored account dates in the configured WordPress timezone.
- replace_placeholders() : string
- Replace email placeholders.
- scheduled_notice_is_eligible() : bool
- send_the_email() : string
- Send The Email
Constants
DELIVERY_META_KEY
public
string
DELIVERY_META_KEY
= 'myslp_scheduled_email_last_sent'
NOTICE_ABOUT_TO_EXPIRE
public
string
NOTICE_ABOUT_TO_EXPIRE
= 'about_to_expire'
NOTICE_RENEWING
public
string
NOTICE_RENEWING
= 'renewing'
SETTINGS_OPTION_NAME
public
string
SETTINGS_OPTION_NAME
= 'myslp_email_options'
DELIVERY_LOCK_PREFIX
private
string
DELIVERY_LOCK_PREFIX
= '_myslp_scheduled_email_lock_'
DELIVERY_LOCK_TTL
private
int
DELIVERY_LOCK_TTL
= 900
DUPLICATE_WINDOW
private
int
DUPLICATE_WINDOW
= 30 * \DAY_IN_SECONDS
Properties
$email_placeholders
private
array<string|int, mixed>
$email_placeholders
= array()
$myslp_email_options
private
array<string|int, mixed>
$myslp_email_options
= array()
Methods
admin_script()
Script and Styling enqueue
public
admin_script(mixed $hook) : void
Parameters
- $hook : mixed
get_instance()
Return the shared email settings instance.
public
static get_instance() : MySLP_Email_Settings
Return values
MySLP_Email_Settingsget_scheduled_notice_defaults()
Defaults shared by the sender and the settings interface.
public
static get_scheduled_notice_defaults() : array<string, array<string, string>>
Return values
array<string, array<string, string>>menu()
Admin menu
public
menu() : void
Tags
menu_page_content()
Menu page settings
public
menu_page_content() : void
Tags
new_account_notification()
Send a new account notification to sysadmin.
public
new_account_notification() : void
process_scheduled_email_account()
Process every scheduled notice type for one network customer account.
public
process_scheduled_email_account(mixed $results, int $user_id, int $blog_id) : array<int, array<string, mixed>>
Parameters
- $results : mixed
-
Prior filter value.
- $user_id : int
-
Customer user ID.
- $blog_id : int
-
Customer primary blog ID.
Return values
array<int, array<string, mixed>>send_expired_action()
Send expired account email function
public
send_expired_action(int $user_id) : string
Parameters
- $user_id : int
Return values
stringsend_scheduled_email_notice()
Send one scheduled-email notice with safety, eligibility, locking, and deduplication.
public
send_scheduled_email_notice(int $user_id, string $notice_type[, array<string|int, mixed> $args = array() ]) : array<string, mixed>
Parameters
- $user_id : int
-
Customer user ID.
- $notice_type : string
-
Stable notice identifier.
- $args : array<string|int, mixed> = array()
-
Optional blog_id and manual mode.
Return values
array<string, mixed>send_welcome_email()
Send welcome email function
public
send_welcome_email(string $email) : string
Parameters
- $email : string
Return values
string__construct()
Class constructor.
private
__construct() : mixed
acquire_delivery_lock()
Attempts to acquire a delivery lock for a specific user and notice type.
private
acquire_delivery_lock(int $user_id, string $notice_type, int $now) : false|int
The lock prevents duplicate notifications by ensuring a time-based lock is set.
Parameters
- $user_id : int
-
The ID of the user for whom the delivery lock is being acquired.
- $notice_type : string
-
The type of notice for which the lock is being set.
- $now : int
-
The current timestamp used to establish the lock.
Return values
false|int —Returns the timestamp of the lock if successfully acquired, or false on failure.
add_style()
Add style to email.
private
add_style() : string
Return values
stringdelivery_result()
Build a result without retaining recipient or message content.
private
delivery_result(string $status, int $user_id, string $notice_type, bool $manual[, string $reason = '' ]) : array<string, mixed>
Parameters
- $status : string
- $user_id : int
- $notice_type : string
- $manual : bool
- $reason : string = ''
Return values
array<string, mixed>get_email_options()
Get myslp_email_options.
private
get_email_options() : void
Tags
get_email_placeholders()
Get email placeholders.
private
get_email_placeholders() : array<string, string>
Return values
array<string, string>get_scheduled_email_context()
Resolve and validate the explicit account recipient context.
private
get_scheduled_email_context(int $user_id, int $blog_id) : array<string, mixed>|WP_Error
Parameters
- $user_id : int
- $blog_id : int
Return values
array<string, mixed>|WP_Errorget_scheduled_notice_template()
Return the canonical template for a scheduled notice.
private
get_scheduled_notice_template(string $notice_type) : array<string, mixed>
Parameters
- $notice_type : string
Return values
array<string, mixed>get_spam_allowlist()
Retrieves the spam allowlist setting from the email options.
private
get_spam_allowlist() : string
Return values
string —The value of the spam allowlist setting, or an empty string if not set.
maybe_migrate_legacy_reminder_options()
Preserve the former reminder template as the new Renewing template, then retire its key.
private
maybe_migrate_legacy_reminder_options() : void
ok_to_spam()
Return true if OK to "spam" (send email from our dev and beta boxes for testing)
private
ok_to_spam(string $email) : bool
Parameters
- $email : string
Return values
boolparse_account_date()
Interpret stored account dates in the configured WordPress timezone.
private
parse_account_date(string $date_value) : int
Parameters
- $date_value : string
Return values
intreplace_placeholders()
Replace email placeholders.
private
replace_placeholders(string $message) : string
Parameters
- $message : string
Return values
stringscheduled_notice_is_eligible()
private
scheduled_notice_is_eligible(string $notice_type, int $expiration) : bool
Parameters
- $notice_type : string
- $expiration : int
Return values
boolsend_the_email()
Send The Email
private
send_the_email(string $email, string $subject, string $body) : string
Parameters
- $email : string
- $subject : string
- $body : string