Mail settings implemented
This commit is contained in:
@ -14,6 +14,16 @@ class SettingsPage
|
||||
['Bdp\Modules\KompassSettings\Controllers\SettingsPage', 'kompass_settings_page_new']
|
||||
);
|
||||
|
||||
|
||||
add_submenu_page('options-general.php',
|
||||
'Mail',
|
||||
'Mail',
|
||||
'manage_options',
|
||||
'kompass-mail-settings',
|
||||
['Bdp\Modules\Mail\Controllers\MailSettingsController', 'settings_form']
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
public function __construct()
|
||||
{
|
||||
@ -23,14 +33,6 @@ class SettingsPage
|
||||
'manage_options',
|
||||
BDP_LV_PLUGIN_SLUG . '-Kompass-settings',
|
||||
[$this, 'option_page'],2048);
|
||||
|
||||
|
||||
add_options_page(
|
||||
__('Mail', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
|
||||
__('Mail', BDP_LV_PLUGIN_SLUG) . ' - ' . __('Settings', BDP_LV_PLUGIN_SLUG),
|
||||
'manage_options',
|
||||
BDP_LV_PLUGIN_SLUG . '-Kompass-mail-settings',
|
||||
[$this, 'mail_option_page'],2048);
|
||||
}
|
||||
|
||||
|
||||
|
@ -18,16 +18,6 @@ class MailController
|
||||
'dashicons-email',
|
||||
4
|
||||
);
|
||||
|
||||
/*$mailCompose = new MailCompose();
|
||||
add_submenu_page(
|
||||
'kompass-mail',
|
||||
__('Templates', BDP_LV_PLUGIN_SLUG),
|
||||
__('Templates', BDP_LV_PLUGIN_SLUG),
|
||||
'send_mails',
|
||||
'kompass-mail-compose',
|
||||
[$mailCompose, '__construct'],
|
||||
1);*/
|
||||
}
|
||||
|
||||
public function router()
|
||||
|
71
modules/Mail/Controllers/class-mailsettingscontroller.php
Normal file
71
modules/Mail/Controllers/class-mailsettingscontroller.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* File: class-mailsettingscontroller.php
|
||||
*
|
||||
*
|
||||
* @since 2024-07-31
|
||||
* @license GPL-3.0-or-later
|
||||
*
|
||||
* @package mareike/
|
||||
*/
|
||||
|
||||
namespace Bdp\Modules\Mail\Controllers;
|
||||
|
||||
class MailSettingsController {
|
||||
public static function set_smtp_if_required() {
|
||||
|
||||
|
||||
$smtp_host = get_option('kompass_smtp_host', null); // SMTP-Host
|
||||
$smtp_port = get_option('kompass_smtp_port', null); // SMTP-Port
|
||||
$smtp_username = get_option('kompass_smtp_user', null); // SMTP-Benutzername
|
||||
$smtp_password = get_option('kompass_smtp_pass', null); // SMTP-Passwort
|
||||
$smtp_secure = 'tls'; // Verschlüsselung (tls oder ssl)
|
||||
|
||||
|
||||
if (false !== (bool)get_option('kompass_use_smtp', false) &&
|
||||
null !== $smtp_host &&
|
||||
null !== $smtp_port &&
|
||||
null !== $smtp_username &&
|
||||
null !== $smtp_password) {
|
||||
|
||||
add_action( 'phpmailer_init', function ( $phpmailer ) use ( $smtp_host, $smtp_port, $smtp_username, $smtp_password, $smtp_secure ) {
|
||||
$phpmailer->isSMTP();
|
||||
$phpmailer->Host = $smtp_host;
|
||||
$phpmailer->Port = $smtp_port;
|
||||
$phpmailer->SMTPAuth = true;
|
||||
$phpmailer->Username = $smtp_username;
|
||||
$phpmailer->Password = $smtp_password;
|
||||
|
||||
$sender = get_option('kompass_smtp_sender', null);
|
||||
$sender_name = get_option('kompass_smtp_sender-name', null);
|
||||
|
||||
if (null !== $sender && null !== $sender_name)
|
||||
$phpmailer->setFrom( $sender, $sender_name );
|
||||
#$phpmailer->SMTPSecure = $smtp_secure;
|
||||
} );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static function settings_form() {
|
||||
if (isset($_POST['save'])) {
|
||||
update_option('kompass_use_smtp', false);
|
||||
|
||||
if (isset($_POST['use_smtp'])) update_option('kompass_use_smtp', true);
|
||||
update_option('kompass_smtp_host', sanitize_text_field(wp_unslash($_POST['smtp-host'])));
|
||||
update_option('kompass_smtp_port', sanitize_text_field(wp_unslash($_POST['smtp-port'])));
|
||||
update_option('kompass_smtp_user', sanitize_text_field(wp_unslash($_POST['smtp-user'])));
|
||||
update_option('kompass_smtp_pass', sanitize_text_field(wp_unslash($_POST['smtp-pass'])));
|
||||
update_option('kompass_smtp_sender', sanitize_text_field(wp_unslash($_POST['smtp-sender'])));
|
||||
update_option('kompass_smtp_sender-name', sanitize_text_field(wp_unslash($_POST['smtp-sender-name'])));
|
||||
|
||||
kompass_print_message_box('Die Einstellungen wurden gespeichert.');
|
||||
}
|
||||
|
||||
|
||||
require BDP_LV_PLUGIN_DIR . '/settings/views/mail-settings.php';
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -36,7 +36,11 @@ class SaveRegistration {
|
||||
wp_mail($user->user_email, 'Bitte bestätige deine Anmeldung', 'Hallo, bitte bestätige deine Anmeldung über den folgenden Link: ' . $activation_link);
|
||||
|
||||
// Notify admin
|
||||
wp_mail(get_option('admin_email'), 'New User Registration', 'A new user has registered: ' . $user->user_login . PHP_EOL . 'First name:' . $user->first_name . PHP_EOL . 'Last name:' . $user->last_name );
|
||||
wp_mail(get_option('admin_email'), 'New User Registration', 'A new user has registered: ' . PHP_EOL .
|
||||
'Username: ' . $user->user_login . PHP_EOL .
|
||||
'First name: ' . $user->first_name . PHP_EOL .
|
||||
'Last name: ' . $user->last_name . PHP_EOL .
|
||||
'E-Mail: ' . $user->user_email);
|
||||
}
|
||||
|
||||
public static function activate_user() {
|
||||
@ -72,5 +76,19 @@ class SaveRegistration {
|
||||
<p style="font-size:16px; color:#00796b;">Vielen Dank für deine Registrierung. Bitte überprüfen deine E-Mails, um deine Registrierung zu bestätigen.</p>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if ((isset($_GET['action']) && $_GET['action'] === 'laostpassword') ||
|
||||
isset($_GET['checkemail']) && $_GET['checkemail'] === 'confirm'
|
||||
){
|
||||
echo '<div class="custom-message" style="text-align:center; margin:20px auto; padding:10px; background-color:#e0f7fa; border:1px solid #00796b; border-radius:5px; max-width:600px;">
|
||||
<p style="font-size:16px; color:#00796b;">Insofern der Account existiert, hast du soeben weitere Anweisungen per E-Mail erhalten.</p>
|
||||
</div>';
|
||||
}
|
||||
|
||||
if (isset($_GET['action']) && $_GET['action'] === 'resetpass') {
|
||||
echo '<div class="custom-message" style="text-align:center; margin:20px auto; padding:10px; background-color:#e0f7fa; border:1px solid #00796b; border-radius:5px; max-width:600px;">
|
||||
<p style="font-size:16px; color:#00796b;">Dein Passwort wurde erfolgreich geändert.</p>
|
||||
</div>';
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user