'meetings',
'key' => $key,
]);
tsml_email(TSML_MEETING_GUIDE_APP_NOTIFY, 'Sharing Key', $message, $current_user->user_email);
}
}
// remove a sharing key
if (!empty($_POST['tsml_remove_sharing_key']) && $valid_nonce) {
$key = sanitize_text_field($_POST['tsml_remove_sharing_key']);
if (array_key_exists($key, $tsml_sharing_keys)) {
unset($tsml_sharing_keys[$key]);
if (empty($tsml_sharing_keys)) {
delete_option('tsml_sharing_keys');
} else {
update_option('tsml_sharing_keys', $tsml_sharing_keys);
}
tsml_alert(__('Sharing key removed.', '12-step-meeting-list'));
} else {
// theoretically should never get here, because user is choosing from a list
tsml_alert(sprintf(
// translators: %s is the key that was not found
esc_html__('%s was not found in the list of sharing keys. Please try again.', '12-step-meeting-list'),
$key
), 'error');
}
}
// add a feedback email
if (!empty($_POST['tsml_add_feedback_address']) && $valid_nonce) {
$email = sanitize_text_field($_POST['tsml_add_feedback_address']);
if (!is_email($email)) {
// theoretically should never get here, because WordPress checks entry first
tsml_alert(sprintf(
// translators: %s is the email address that was not valid
esc_html__('%s is not a valid email address. Please try again.', '12-step-meeting-list'),
$email
), 'error');
} else {
$tsml_feedback_addresses[] = $email;
$tsml_feedback_addresses = array_unique($tsml_feedback_addresses);
sort($tsml_feedback_addresses);
update_option('tsml_feedback_addresses', $tsml_feedback_addresses);
tsml_alert(__('Feedback address added.', '12-step-meeting-list'));
tsml_cache_rebuild(); // these values affect what's in the cache
}
}
// remove a feedback email
if (!empty($_POST['tsml_remove_feedback_address']) && $valid_nonce) {
$email = sanitize_text_field($_POST['tsml_remove_feedback_address']);
if (($key = array_search($email, $tsml_feedback_addresses)) !== false) {
unset($tsml_feedback_addresses[$key]);
if (empty($tsml_feedback_addresses)) {
delete_option('tsml_feedback_addresses');
} else {
update_option('tsml_feedback_addresses', $tsml_feedback_addresses);
}
tsml_alert(__('Feedback address removed.', '12-step-meeting-list'));
tsml_cache_rebuild(); // these values affect what's in the cache
} else {
// theoretically should never get here, because user is choosing from a list
tsml_alert(sprintf(
// translators: %s is the email address that was not found
esc_html__('%s was not found in the list of addresses. Please try again.', '12-step-meeting-list'),
$email
), 'error');
}
}
// add a notification email
if (!empty($_POST['tsml_add_notification_address']) && $valid_nonce) {
$email = sanitize_text_field($_POST['tsml_add_notification_address']);
if (!is_email($email)) {
// theoretically should never get here, because WordPress checks entry first
tsml_alert(sprintf(
// translators: %s is the email address that was not valid
esc_html__('%s is not a valid email address. Please try again.', '12-step-meeting-list'),
$email
), 'error');
} else {
$tsml_notification_addresses[] = $email;
$tsml_notification_addresses = array_unique($tsml_notification_addresses);
sort($tsml_notification_addresses);
update_option('tsml_notification_addresses', $tsml_notification_addresses);
tsml_alert(__('Notification address added.', '12-step-meeting-list'));
}
}
// remove a notification email
if (!empty($_POST['tsml_remove_notification_address']) && $valid_nonce) {
$email = sanitize_text_field($_POST['tsml_remove_notification_address']);
if (($key = array_search($email, $tsml_notification_addresses)) !== false) {
unset($tsml_notification_addresses[$key]);
if (empty($tsml_notification_addresses)) {
delete_option('tsml_notification_addresses');
} else {
update_option('tsml_notification_addresses', $tsml_notification_addresses);
}
tsml_alert(__('Notification address removed.', '12-step-meeting-list'));
} else {
// theoretically should never get here, because user is choosing from a list
tsml_alert(sprintf(
// translators: %s is the email address that was not found
esc_html__('%s was not found in the list of addresses. Please try again.', '12-step-meeting-list'),
$email
), 'error');
}
}
// change user interface
if (!empty($_POST['tsml_user_interface']) && $valid_nonce) {
$tsml_user_interface = sanitize_text_field($_POST['tsml_user_interface']);
update_option('tsml_user_interface', $tsml_user_interface);
if ($tsml_user_interface == 'tsml_ui') {
$tsml_ui = "TSML UI";
} else {
$tsml_ui = "LEGACY UI";
}
tsml_alert(sprintf(
// translators: %s is the user interface that was selected
__('User interface is now set to %s', '12-step-meeting-list'),
$tsml_ui
));
}
// change timezone
if (isset($_POST['timezone']) && $valid_nonce) {
if (empty($_POST['timezone']) || tsml_timezone_is_valid($_POST['timezone'])) {
$tsml_timezone = sanitize_text_field($_POST['timezone']);
update_option('tsml_timezone', $tsml_timezone);
tsml_alert(__('Timezone updated.', '12-step-meeting-list'));
} else {
tsml_alert(__('Invalid timezone selected.', '12-step-meeting-list'), 'error');
}
}
// save entity fields
if (isset($_POST['tsml_entity']) && $valid_nonce) {
$current_tsml_entity = tsml_get_option_array('tsml_entity');
$tsml_entity = [];
global $tsml_entity_fields;
foreach ($tsml_entity_fields as $field) {
$tsml_entity[$field] = isset($current_tsml_entity[$field]) ? $current_tsml_entity[$field] : '';
if (isset($_POST["tsml_$field"])) {
$tsml_entity[$field] = substr(trim(strval($_POST["tsml_$field"])), 0, 100);
}
}
update_option('tsml_entity', $tsml_entity);
tsml_cache_rebuild(); // these values affects what's in the cache
tsml_alert(__('Entity details saved.', '12-step-meeting-list'));
}
?>