wp-multi-ticket.php aktualisiert
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
* Plugin Name: WP Multi Ticket Pro
|
||||
* Plugin URI: https://git.viper.ipv64.net/M_Viper/wp-multi-ticket
|
||||
* Description: Leistungsstarkes Ticket- und Support-System für WordPress mit Gast-Tickets, Admin-Antworten, CSV-Export, Dashboard-Widgets und integriertem Update-Management über Gitea.
|
||||
* Version: 1.2
|
||||
* Version: 1.3
|
||||
* Author: M_Viper
|
||||
* Author URI: https://m-viper.de
|
||||
* Requires at least: 6.7.2
|
||||
@@ -17,8 +17,6 @@
|
||||
* Support: https://t.me/M_Viper04
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
class WP_Multi_Ticket_Pro {
|
||||
@@ -47,6 +45,11 @@ class WP_Multi_Ticket_Pro {
|
||||
// Hook für Update-Benachrichtigung
|
||||
add_action( 'admin_notices', array( $this, 'check_plugin_updates' ) );
|
||||
|
||||
// E-Mail-Konfiguration
|
||||
add_action( 'phpmailer_init', array( $this, 'configure_phpmailer' ) );
|
||||
add_filter( 'wp_mail_from', array( $this, 'custom_wp_mail_from' ) );
|
||||
add_filter( 'wp_mail_from_name', array( $this, 'custom_wp_mail_from_name' ) );
|
||||
|
||||
add_shortcode( 'wmt_form', array( $this, 'render_creation_form' ) );
|
||||
add_shortcode( 'wmt_view', array( $this, 'render_ticket_view' ) );
|
||||
add_shortcode( 'wmt_lookup', array( $this, 'render_lookup_form' ) );
|
||||
@@ -60,7 +63,137 @@ class WP_Multi_Ticket_Pro {
|
||||
add_action( 'admin_init', array( $this, 'handle_csv_export' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
/**
|
||||
* FIX: Verbesserte Konfiguration für PHPMailer mit Server-Check
|
||||
*/
|
||||
public function configure_phpmailer( $phpmailer ) {
|
||||
$smtp_enabled = get_option( 'wmt_smtp_enabled' );
|
||||
|
||||
if ( $smtp_enabled == '1' || $smtp_enabled === true ) {
|
||||
$encryption = get_option( 'wmt_smtp_encryption', '' );
|
||||
|
||||
// Prüfen, ob OpenSSL geladen ist, wenn Verschlüsselung gefordert ist
|
||||
if ( ( $encryption === 'tls' || $encryption === 'ssl' ) && ! extension_loaded('openssl') ) {
|
||||
// Wir können hier keine Notices werfen, also loggen wir es
|
||||
error_log('WMT SMTP Error: OpenSSL extension is missing, but encryption is set to ' . $encryption);
|
||||
return; // Abbrechen, sonst crasht es
|
||||
}
|
||||
|
||||
$phpmailer->isSMTP();
|
||||
$phpmailer->Host = get_option( 'wmt_smtp_host', 'localhost' );
|
||||
$phpmailer->Port = get_option( 'wmt_smtp_port', 25 );
|
||||
|
||||
$phpmailer->SMTPSecure = ( $encryption === 'tls' ) ? 'tls' : ( ( $encryption === 'ssl' ) ? 'ssl' : '' );
|
||||
|
||||
$smtp_auth = get_option( 'wmt_smtp_auth' );
|
||||
$phpmailer->SMTPAuth = ( $smtp_auth == '1' || $smtp_auth === true );
|
||||
|
||||
if ( $phpmailer->SMTPAuth ) {
|
||||
$phpmailer->Username = get_option( 'wmt_smtp_username', '' );
|
||||
$phpmailer->Password = get_option( 'wmt_smtp_password', '' );
|
||||
|
||||
// WICHTIG: Envelope Sender setzen (behebt "Sender address rejected")
|
||||
$phpmailer->Sender = $phpmailer->Username;
|
||||
}
|
||||
|
||||
if ( get_option( 'wmt_smtp_debug', false ) ) {
|
||||
$phpmailer->SMTPDebug = 3;
|
||||
$phpmailer->Debugoutput = function($str, $level) {
|
||||
error_log("SMTP Debug [Lvl $level]: $str");
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
$phpmailer->CharSet = 'UTF-8';
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt die Absender-E-Mail
|
||||
*/
|
||||
public function custom_wp_mail_from( $original_email_address ) {
|
||||
$custom_email = get_option( 'wmt_from_email', '' );
|
||||
return $custom_email ? $custom_email : $original_email_address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Absender-Namen
|
||||
*/
|
||||
public function custom_wp_mail_from_name( $original_email_from ) {
|
||||
$custom_name = get_option( 'wmt_from_name', '' );
|
||||
return $custom_name ? $custom_name : $original_email_from;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verbesserte E-Mail-Versand-Funktion mit Logging
|
||||
*/
|
||||
private function send_mail( $to, $subject, $message, $attachments = array() ) {
|
||||
$html_message = '
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<style>
|
||||
body { font-family: Arial, sans-serif; line-height: 1.6; color: #333; background-color: #f4f4f4; margin: 0; padding: 20px; }
|
||||
.container { max-width: 600px; margin: 0 auto; background: #fff; padding: 20px; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
|
||||
.header { background: #0073aa; color: white; padding: 20px; text-align: center; border-radius: 8px 8px 0 0; margin: -20px -20px 20px -20px; }
|
||||
.header h2 { margin: 0; color: white; }
|
||||
.content { padding: 0 10px; }
|
||||
.footer { text-align: center; padding: 20px; font-size: 12px; color: #666; border-top: 1px solid #eee; margin-top: 20px; }
|
||||
.button { background: #0073aa; color: white; padding: 12px 24px; text-decoration: none; border-radius: 4px; display: inline-block; margin: 10px 0; font-weight: bold; }
|
||||
.button:hover { background: #005177; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="container">
|
||||
<div class="header">
|
||||
<h2>' . get_bloginfo('name') . ' Support</h2>
|
||||
</div>
|
||||
<div class="content">
|
||||
' . wpautop( $message ) . '
|
||||
</div>
|
||||
<div class="footer">
|
||||
<p>Diese E-Mail wurde automatisch vom Support-System generiert.</p>
|
||||
<p><a href="' . home_url() . '">' . get_bloginfo('name') . '</a></p>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>';
|
||||
|
||||
$headers = array(
|
||||
'Content-Type: text/html; charset=UTF-8',
|
||||
);
|
||||
|
||||
if ( get_option( 'wmt_bcc_admin', false ) ) {
|
||||
$admin_email = get_option( 'wmt_admin_email', get_option('admin_email') );
|
||||
$headers[] = 'Bcc: ' . $admin_email;
|
||||
}
|
||||
|
||||
$result = wp_mail( $to, $subject, $html_message, $headers, $attachments );
|
||||
|
||||
if ( get_option( 'wmt_mail_logging', true ) ) {
|
||||
$log_entry = array(
|
||||
'timestamp' => current_time( 'mysql' ),
|
||||
'to' => $to,
|
||||
'subject' => $subject,
|
||||
'success' => $result ? 'YES' : 'NO',
|
||||
'error' => $result ? '' : 'Mail delivery failed (check SMTP settings or Spam folder)'
|
||||
);
|
||||
|
||||
$logs = get_option( 'wmt_mail_logs', array() );
|
||||
array_unshift( $logs, $log_entry );
|
||||
$logs = array_slice( $logs, 0, 50 );
|
||||
update_option( 'wmt_mail_logs', $logs );
|
||||
}
|
||||
|
||||
if ( ! $result ) {
|
||||
error_log( 'WMT Mail Error: Failed to send email to ' . $to . ' - Subject: ' . $subject );
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft auf Updates von der Git-URL und zeigt eine Admin-Notice an
|
||||
*/
|
||||
public function check_plugin_updates() {
|
||||
@@ -149,9 +282,7 @@ class WP_Multi_Ticket_Pro {
|
||||
}
|
||||
|
||||
|
||||
// *** HIER: korrigierter Hook-Name für die Analytics-Unterseite ***
|
||||
public function load_analytics_scripts( $hook ) {
|
||||
// Für Submenu: parent slug wmt_tickets -> Hook: wmt-tickets_page_wmt_analytics
|
||||
if ( 'wmt-tickets_page_wmt_analytics' !== $hook ) return;
|
||||
|
||||
$local_js = plugin_dir_path( __FILE__ ) . 'chart.js';
|
||||
@@ -163,14 +294,12 @@ class WP_Multi_Ticket_Pro {
|
||||
}
|
||||
|
||||
public function enqueue_styles() {
|
||||
// Hier wird die eingestellte Schriftfarbe geholt (Standard: #6b7280 = rgb(107, 114, 128))
|
||||
$custom_font_color = get_option( 'wmt_font_color', '#6b7280' );
|
||||
|
||||
?>
|
||||
<style>
|
||||
.wmt-box { max-width: 800px; margin: 20px auto; background: #fff; padding: 25px; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.08); font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Oxygen-Sans,Ubuntu,Cantarell,"Helvetica Neue",sans-serif; color: <?php echo esc_attr($custom_font_color); ?>; }
|
||||
|
||||
/* Überschriften explizit einfärben */
|
||||
.wmt-box h1, .wmt-box h2, .wmt-box h3 {
|
||||
color: <?php echo esc_attr($custom_font_color); ?>;
|
||||
}
|
||||
@@ -191,8 +320,9 @@ class WP_Multi_Ticket_Pro {
|
||||
.wmt-system-msg { text-align: center; margin: 20px 0; font-size: 12px; color: #666; background: #e9ecef; padding: 5px 10px; border-radius: 20px; display: inline-block; width: 100%; box-sizing: border-box; border: 1px solid #ced4da; }
|
||||
.wmt-internal-note { background: #eee; border-left: 4px solid #6c757d; padding: 10px; margin-bottom: 10px; font-size: 12px; color: #333; font-style: italic; display: block; }
|
||||
.wmt-internal-note strong { display: block; font-style: normal; color: #495057; margin-bottom: 3px; }
|
||||
.wmt-alert { padding: 15px; background: #fff3cd; color: #856404; border: 1px solid #ffeeba; margin-bottom: 20px; border-radius: 4px; }
|
||||
.wmt-alert { padding: 15px; background: #d4edda; color: #155724; border: 1px solid #c3e6cb; margin-bottom: 20px; border-radius: 4px; }
|
||||
.wmt-error { padding: 15px; background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; margin-bottom: 20px; border-radius: 4px; }
|
||||
.wmt-warning { padding: 15px; background: #fff3cd; color: #856404; border: 1px solid #ffeeba; margin-bottom: 20px; border-radius: 4px; }
|
||||
|
||||
.wmt-avatar { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: bold; font-size: 14px; margin-right: 10px; flex-shrink: 0; text-transform: uppercase; }
|
||||
.wmt-msg-row { display: flex; align-items: flex-start; margin-bottom: 15px; }
|
||||
@@ -239,6 +369,13 @@ class WP_Multi_Ticket_Pro {
|
||||
.wmt-css-bar-bg { flex-grow: 1; background: #f3f4f6; height: 24px; border-radius: 4px; overflow: hidden; position: relative; }
|
||||
.wmt-css-bar-fill { height: 100%; background: #3b82f6; display: flex; align-items: center; padding-left: 10px; color: #fff; font-size: 11px; white-space: nowrap; transition: width 0.5s ease; }
|
||||
.wmt-css-bar-val { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #6c757d; font-weight: bold; }
|
||||
|
||||
/* Mail Log Styles */
|
||||
.wmt-mail-log-table { width: 100%; border-collapse: collapse; margin-top: 20px; }
|
||||
.wmt-mail-log-table th, .wmt-mail-log-table td { padding: 10px; text-align: left; border-bottom: 1px solid #ddd; }
|
||||
.wmt-mail-log-table th { background: #f5f5f5; font-weight: bold; }
|
||||
.wmt-mail-success { color: #155724; font-weight: bold; }
|
||||
.wmt-mail-failed { color: #721c24; font-weight: bold; }
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
@@ -302,6 +439,7 @@ class WP_Multi_Ticket_Pro {
|
||||
add_submenu_page( 'wmt_tickets', 'Analytics', 'Analytics', 'manage_options', 'wmt_analytics', array( $this, 'render_analytics_page' ) );
|
||||
add_submenu_page( 'wmt_tickets', 'Einstellungen', 'Einstellungen', 'manage_options', 'wmt_settings', array( $this, 'render_settings_page' ) );
|
||||
add_submenu_page( 'wmt_tickets', 'Benachrichtigungen', 'Benachrichtigungen', 'manage_options', 'wmt_notifications', array( $this, 'render_notifications_page' ) );
|
||||
add_submenu_page( 'wmt_tickets', 'E-Mail Einstellungen', 'E-Mail Setup', 'manage_options', 'wmt_mail_settings', array( $this, 'render_mail_settings_page' ) );
|
||||
}
|
||||
|
||||
public function register_settings() {
|
||||
@@ -312,12 +450,245 @@ class WP_Multi_Ticket_Pro {
|
||||
register_setting( 'wmt_settings_group', 'wmt_admin_email' );
|
||||
register_setting( 'wmt_settings_group', 'wmt_templates' );
|
||||
register_setting( 'wmt_settings_group', 'wmt_allowed_filetypes' );
|
||||
register_setting( 'wmt_settings_group', 'wmt_font_color' ); // NEU: Schriftfarbe registrieren
|
||||
register_setting( 'wmt_settings_group', 'wmt_font_color' );
|
||||
|
||||
register_setting( 'wmt_notifications_group', 'wmt_discord_webhook' );
|
||||
register_setting( 'wmt_notifications_group', 'wmt_telegram_token' );
|
||||
register_setting( 'wmt_notifications_group', 'wmt_telegram_chat_id' );
|
||||
register_setting( 'wmt_notifications_group', 'wmt_new_ticket_notify_users' );
|
||||
|
||||
// SMTP Settings
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_enabled' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_host' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_port' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_auth' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_username' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_password' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_encryption' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_from_email' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_from_name' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_bcc_admin' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_mail_logging' );
|
||||
register_setting( 'wmt_mail_settings_group', 'wmt_smtp_debug' );
|
||||
}
|
||||
|
||||
public function render_mail_settings_page() {
|
||||
// Server-Diagnose Notice
|
||||
if ( get_option('wmt_smtp_enabled') && in_array(get_option('wmt_smtp_encryption'), array('ssl', 'tls')) ) {
|
||||
if ( ! extension_loaded('openssl') ) {
|
||||
echo '<div class="notice notice-error is-dismissible"><p><strong>Kritischer Fehler:</strong> Ihre PHP-Installation hat die <code>openssl</code> Erweiterung nicht geladen. SMTP mit SSL/TLS kann nicht funktionieren. Bitte wenden Sie sich an Ihren Hoster.</p></div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Test-Mail senden
|
||||
if ( isset( $_POST['wmt_send_test_mail'] ) && check_admin_referer( 'wmt_test_mail' ) ) {
|
||||
$test_email = sanitize_email( $_POST['test_email'] );
|
||||
$result = $this->send_mail(
|
||||
$test_email,
|
||||
'Test E-Mail von WP Multi Ticket Pro',
|
||||
'Wenn Sie diese E-Mail erhalten, funktioniert der E-Mail-Versand korrekt!'
|
||||
);
|
||||
|
||||
if ( $result ) {
|
||||
echo '<div class="wmt-alert">✓ Test-E-Mail erfolgreich an ' . esc_html($test_email) . ' gesendet!</div>';
|
||||
} else {
|
||||
echo '<div class="wmt-error">✗ Test-E-Mail konnte nicht gesendet werden. Bitte prüfen Sie die Einstellungen und Logs.</div>';
|
||||
}
|
||||
}
|
||||
|
||||
// Logs löschen
|
||||
if ( isset( $_POST['wmt_clear_logs'] ) && check_admin_referer( 'wmt_clear_logs' ) ) {
|
||||
delete_option( 'wmt_mail_logs' );
|
||||
echo '<div class="wmt-alert">Mail-Logs gelöscht.</div>';
|
||||
}
|
||||
|
||||
$logs = get_option( 'wmt_mail_logs', array() );
|
||||
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1>E-Mail Einstellungen</h1>
|
||||
|
||||
<div class="wmt-warning">
|
||||
<strong>⚠️ Wichtig:</strong> WordPress verwendet standardmäßig die PHP mail() Funktion, die oft nicht zuverlässig funktioniert.
|
||||
Für produktive Systeme empfehlen wir SMTP zu aktivieren.
|
||||
</div>
|
||||
|
||||
<form method="post" action="options.php">
|
||||
<?php settings_fields( 'wmt_mail_settings_group' ); ?>
|
||||
|
||||
<h2>Grundeinstellungen</h2>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>Absender E-Mail</th>
|
||||
<td>
|
||||
<input type="email" name="wmt_from_email" value="<?php echo esc_attr( get_option('wmt_from_email', get_option('admin_email')) ); ?>" class="regular-text">
|
||||
<p class="description">Die E-Mail-Adresse, von der Tickets versendet werden.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Absender Name</th>
|
||||
<td>
|
||||
<input type="text" name="wmt_from_name" value="<?php echo esc_attr( get_option('wmt_from_name', get_bloginfo('name') . ' Support') ); ?>" class="regular-text">
|
||||
<p class="description">Der Name, der als Absender angezeigt wird.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>BCC an Admin</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="wmt_bcc_admin" value="1" <?php checked( get_option('wmt_bcc_admin'), 1 ); ?>>
|
||||
Admin erhält BCC-Kopie aller E-Mails
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>E-Mail Logging</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="wmt_mail_logging" value="1" <?php checked( get_option('wmt_mail_logging', 1), 1 ); ?>>
|
||||
E-Mail-Versand protokollieren (empfohlen für Debugging)
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<h2>SMTP Einstellungen (empfohlen)</h2>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>SMTP aktivieren</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="wmt_smtp_enabled" value="1" <?php checked( get_option('wmt_smtp_enabled'), 1 ); ?>>
|
||||
SMTP für E-Mail-Versand verwenden
|
||||
</label>
|
||||
<p class="description">Empfohlen für zuverlässigen E-Mail-Versand.</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMTP Host</th>
|
||||
<td>
|
||||
<input type="text" name="wmt_smtp_host" value="<?php echo esc_attr( get_option('wmt_smtp_host', 'localhost') ); ?>" class="regular-text">
|
||||
<p class="description">z.B. smtp.gmail.com, smtp.ionos.de, mail.ihr-provider.de</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMTP Port</th>
|
||||
<td>
|
||||
<input type="number" name="wmt_smtp_port" value="<?php echo esc_attr( get_option('wmt_smtp_port', 587) ); ?>" class="small-text">
|
||||
<p class="description">Standard: 587 (TLS), 465 (SSL), 25 (keine Verschlüsselung)</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Verschlüsselung</th>
|
||||
<td>
|
||||
<select name="wmt_smtp_encryption">
|
||||
<option value="">Keine</option>
|
||||
<option value="tls" <?php selected( get_option('wmt_smtp_encryption'), 'tls' ); ?>>TLS (empfohlen)</option>
|
||||
<option value="ssl" <?php selected( get_option('wmt_smtp_encryption'), 'ssl' ); ?>>SSL</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMTP Authentifizierung</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="wmt_smtp_auth" value="1" <?php checked( get_option('wmt_smtp_auth', 1), 1 ); ?>>
|
||||
SMTP Authentifizierung verwenden
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMTP Benutzername</th>
|
||||
<td>
|
||||
<input type="text" name="wmt_smtp_username" value="<?php echo esc_attr( get_option('wmt_smtp_username') ); ?>" class="regular-text" autocomplete="off">
|
||||
<p class="description">Meist Ihre E-Mail-Adresse</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>SMTP Passwort</th>
|
||||
<td>
|
||||
<input type="password" name="wmt_smtp_password" value="<?php echo esc_attr( get_option('wmt_smtp_password') ); ?>" class="regular-text" autocomplete="new-password">
|
||||
<p class="description">⚠️ Wird unverschlüsselt in der Datenbank gespeichert!</p>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Debug-Modus</th>
|
||||
<td>
|
||||
<label>
|
||||
<input type="checkbox" name="wmt_smtp_debug" value="1" <?php checked( get_option('wmt_smtp_debug'), 1 ); ?>>
|
||||
SMTP Debug aktivieren (schreibt in PHP error_log)
|
||||
</label>
|
||||
<p class="description">Nur für Fehlersuche aktivieren!</p>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php submit_button( 'Einstellungen speichern' ); ?>
|
||||
</form>
|
||||
|
||||
<hr>
|
||||
|
||||
<h2>Test-E-Mail senden</h2>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field( 'wmt_test_mail' ); ?>
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th>Test-E-Mail an</th>
|
||||
<td>
|
||||
<input type="email" name="test_email" value="<?php echo esc_attr( get_option('wmt_admin_email', get_option('admin_email')) ); ?>" class="regular-text" required>
|
||||
<button type="submit" name="wmt_send_test_mail" class="button button-primary">Test-Mail senden</button>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<?php if ( ! empty( $logs ) ): ?>
|
||||
<hr>
|
||||
<h2>E-Mail Logs (letzte 50)</h2>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field( 'wmt_clear_logs' ); ?>
|
||||
<button type="submit" name="wmt_clear_logs" class="button">Logs löschen</button>
|
||||
</form>
|
||||
<table class="wmt-mail-log-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Zeit</th>
|
||||
<th>Empfänger</th>
|
||||
<th>Betreff</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ( $logs as $log ): ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html( $log['timestamp'] ); ?></td>
|
||||
<td><?php echo esc_html( $log['to'] ); ?></td>
|
||||
<td><?php echo esc_html( $log['subject'] ); ?></td>
|
||||
<td class="<?php echo $log['success'] === 'YES' ? 'wmt-mail-success' : 'wmt-mail-failed'; ?>">
|
||||
<?php echo $log['success'] === 'YES' ? '✓ Gesendet' : '✗ Fehler'; ?>
|
||||
<?php if ( ! empty( $log['error'] ) ): ?>
|
||||
<br><small><?php echo esc_html( $log['error'] ); ?></small>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
|
||||
<hr>
|
||||
<h2>Häufige Probleme & Lösungen</h2>
|
||||
<div style="background: #f9f9f9; padding: 20px; border-left: 4px solid #0073aa; margin-top: 20px;">
|
||||
<h3>E-Mails kommen nicht an?</h3>
|
||||
<ol>
|
||||
<li><strong>Logs prüfen:</strong> Aktivieren Sie Debug-Modus und schauen Sie in <code>wp-content/debug.log</code>.</li>
|
||||
<li><strong>Gmail Nutzer:</strong> Verwenden Sie ein <strong>App-Passwort</strong>, nicht Ihr normales Passwort. Port 587 + TLS.</li>
|
||||
<li><strong>OpenSSL Fehler:</strong> Wenn im Log steht "openssl extension missing", kontaktieren Sie Ihren Hoster.</li>
|
||||
<li><strong>Firewall:</strong> Manche Hoster blockieren Port 25 und 587.</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
|
||||
public function render_analytics_page() {
|
||||
@@ -414,12 +785,10 @@ class WP_Multi_Ticket_Pro {
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<!-- Chart.js Fallback CDN (für 100% Funktionalität) -->
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js@4.4.0/dist/chart.umd.min.js"></script>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
// Warten, bis Dokument und Skripte geladen sind
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
|
||||
const statusLabels = <?php echo json_encode(array_column($status_data, 'status'), JSON_UNESCAPED_UNICODE); ?>;
|
||||
@@ -431,7 +800,6 @@ class WP_Multi_Ticket_Pro {
|
||||
const timeLabels = <?php echo json_encode(array_column($timeline_data, 'date'), JSON_UNESCAPED_UNICODE); ?>;
|
||||
const timeCounts = <?php echo json_encode(array_column($timeline_data, 'count'), JSON_UNESCAPED_UNICODE); ?>;
|
||||
|
||||
// DEBUG: Ausgabe des Pfades in der Browser-Konsole (F12)
|
||||
const localUrl = "<?php echo plugins_url( 'chart.js', __FILE__ ); ?>";
|
||||
console.log("WMT DEBUG: Suche nach Chart.js auf: " + localUrl);
|
||||
|
||||
@@ -585,7 +953,7 @@ class WP_Multi_Ticket_Pro {
|
||||
}
|
||||
|
||||
public function render_settings_page() {
|
||||
$templates = get_option( 'wmt_templates', array() ); // FIX: Corrected array()
|
||||
$templates = get_option( 'wmt_templates', array() );
|
||||
if ( is_string($templates) ) $templates = array();
|
||||
?>
|
||||
<div class="wrap">
|
||||
@@ -599,7 +967,7 @@ class WP_Multi_Ticket_Pro {
|
||||
<tr><th>Status</th><td><input type="text" name="wmt_statuses" value="<?php echo esc_attr( get_option('wmt_statuses', 'Offen, In Bearbeitung, Wartet auf Antwort, Geschlossen') ); ?>" class="regular-text"></td></tr>
|
||||
<tr><th>Admin E-Mail</th><td><input type="email" name="wmt_admin_email" value="<?php echo esc_attr( get_option('wmt_admin_email', get_option('admin_email') ) ); ?>" class="regular-text"></td></tr>
|
||||
<tr><th>Erlaubte Dateiendungen</th><td><input type="text" name="wmt_allowed_filetypes" value="<?php echo esc_attr( get_option('wmt_allowed_filetypes', 'pdf, doc, docx, jpg, jpeg, png, txt') ); ?>" class="regular-text"><p class="description">Kommagetrennt (z.B. pdf, doc, png).</p></td></tr>
|
||||
<!-- NEU: Schriftfarbe Einstellung -->
|
||||
<!-- Schriftfarbe Einstellung -->
|
||||
<tr>
|
||||
<th>Schriftfarbe</th>
|
||||
<td>
|
||||
@@ -659,7 +1027,7 @@ class WP_Multi_Ticket_Pro {
|
||||
|
||||
public function render_notifications_page() {
|
||||
$all_users = get_users( array( 'orderby' => 'display_name' ) );
|
||||
$selected_users = get_option( 'wmt_new_ticket_notify_users', array() ); // FIX: Corrected array()
|
||||
$selected_users = get_option( 'wmt_new_ticket_notify_users', array() );
|
||||
if ( ! is_array( $selected_users ) ) $selected_users = array();
|
||||
?>
|
||||
<div class="wrap">
|
||||
@@ -1135,7 +1503,6 @@ class WP_Multi_Ticket_Pro {
|
||||
$tid = intval( $_POST['ticket_id'] );
|
||||
|
||||
// STATUS LOGIK:
|
||||
// Wenn nicht "Geschlossen" gewählt wurde, setzen wir es auf "In Bearbeitung"
|
||||
$status = sanitize_text_field( $_POST['status'] );
|
||||
if ( strtolower( $status ) !== 'geschlossen' ) {
|
||||
$status = 'In Bearbeitung';
|
||||
@@ -1147,9 +1514,7 @@ class WP_Multi_Ticket_Pro {
|
||||
$assigned = !empty($_POST['assigned_to']) ? intval( $_POST['assigned_to'] ) : null;
|
||||
|
||||
// Auto-Detection Logik
|
||||
// Wenn im Dropdown "Niemand" ausgewählt ist (NULL), ABER der User gerade antwortet...
|
||||
if ( empty($assigned) && (!empty($msg_content) || !empty($_FILES['ticket_file']['name'])) ) {
|
||||
// ...dann weisen wir es dem aktuellen User zu.
|
||||
$assigned = get_current_user_id();
|
||||
}
|
||||
|
||||
@@ -1171,13 +1536,15 @@ class WP_Multi_Ticket_Pro {
|
||||
));
|
||||
}
|
||||
|
||||
// Handover Benachrichtigung: Wenn sich der zugewiesene User ändert
|
||||
// Handover Benachrichtigung
|
||||
if ( $old_ticket->assigned_to != $assigned && $assigned ) {
|
||||
$user = get_userdata( $assigned );
|
||||
if ( $user ) {
|
||||
$subject = "Ticket #{$tid} wurde Ihnen zugewiesen";
|
||||
$body = "Hallo {$user->display_name},\n\nDas Ticket #{$tid} – „{$old_ticket->title}“ wurde Ihnen zur Bearbeitung zugewiesen.\n\nLink: " . admin_url( "admin.php?page=wmt_tickets&action=edit&id={$tid}" );
|
||||
wp_mail( $user->user_email, $subject, $body );
|
||||
|
||||
// HIER: Sendet HTML E-Mail mit Template
|
||||
$this->send_mail( $user->user_email, $subject, $body );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1192,7 +1559,9 @@ class WP_Multi_Ticket_Pro {
|
||||
$subject = "Neue Antwort zu Ihrem Ticket #{$tid}";
|
||||
$body = "Hallo {$old_ticket->guest_name},\n\nEs gibt eine neue Antwort:\n{$msg_content}\n\nLink zum Ticket:\n{$view_link}";
|
||||
if($file_url) $body .= "\n\nAnhang: {$file_url}";
|
||||
wp_mail( $old_ticket->guest_email, $subject, $body );
|
||||
|
||||
// HIER: Sendet HTML E-Mail mit Template
|
||||
$this->send_mail( $old_ticket->guest_email, $subject, $body );
|
||||
|
||||
} elseif ( ! empty( $internal_note ) ) {
|
||||
$current_user = wp_get_current_user();
|
||||
@@ -1384,24 +1753,31 @@ class WP_Multi_Ticket_Pro {
|
||||
$guest_link = add_query_arg( array( 'wmt_view' => $tid, 'hash' => $hash ), home_url() );
|
||||
|
||||
$admin_email = get_option( 'wmt_admin_email', get_option('admin_email') );
|
||||
wp_mail( $admin_email, "Neues Ticket #{$tid}: {$title}", "Von: {$name} ({$email})\nLink: {$admin_link}" );
|
||||
|
||||
// Admin Benachrichtigung (HTML)
|
||||
$admin_body = "Ein neues Ticket wurde erstellt.\n\nBetreff: {$title}\nVon: {$name} ({$email})\nPriorität: {$prio}\n\nLink: {$admin_link}";
|
||||
$this->send_mail( $admin_email, "Neues Ticket #{$tid}: {$title}", $admin_body );
|
||||
|
||||
$this->send_discord_notification( "Neues Ticket #{$tid}", "{$title}\nVon: {$name} ({$email})\nPriorität: {$prio}", $admin_link );
|
||||
$this->send_telegram_notification( "<b>Neues Ticket #{$tid}</b>\n<b>Betreff:</b> {$title}\n<b>Von:</b> {$name} ({$email})\n<b>Priorität:</b> {$prio}\nLink: {$admin_link}" );
|
||||
|
||||
$notify_user_ids = get_option( 'wmt_new_ticket_notify_users', array() ); // FIX: Corrected array()
|
||||
$notify_user_ids = get_option( 'wmt_new_ticket_notify_users', array() );
|
||||
if ( is_array( $notify_user_ids ) && ! empty( $notify_user_ids ) ) {
|
||||
foreach ( $notify_user_ids as $user_id ) {
|
||||
$user = get_userdata( $user_id );
|
||||
if ( $user ) {
|
||||
$subject = "Neues Ticket #{$tid}: {$title}";
|
||||
$body = "Hallo {$user->display_name},\n\nein neues Ticket wurde erstellt.\n\nBetreff: {$title}\nVon: {$name} ({$email})\nPriorität: {$prio}\n\nLink zum Ticket: {$admin_link}";
|
||||
wp_mail( $user->user_email, $subject, $body );
|
||||
|
||||
// HTML Benachrichtigung an zusätzliche User
|
||||
$this->send_mail( $user->user_email, $subject, $body );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wp_mail( $email, "Ihr Ticket #{$tid} wurde erstellt", "Hallo {$name},\n\nVielen Dank für Ihr Ticket.\nLink: {$guest_link}" );
|
||||
// Gast Bestätigung (HTML)
|
||||
$guest_body = "Hallo {$name},\n\nVielen Dank für Ihr Ticket #{$tid}.\nWir werden uns so schnell wie möglich bei Ihnen melden.\n\nLink zum Ticket:\n{$guest_link}";
|
||||
$this->send_mail( $email, "Ihr Ticket #{$tid} wurde erstellt", $guest_body );
|
||||
|
||||
wp_redirect( add_query_arg( 'wmt_success', '1', wp_get_referer() ) );
|
||||
exit;
|
||||
@@ -1425,7 +1801,10 @@ class WP_Multi_Ticket_Pro {
|
||||
|
||||
$admin_link = admin_url( "admin.php?page=wmt_tickets&action=edit&id={$tid}" );
|
||||
$admin_email = get_option( 'wmt_admin_email', get_option('admin_email') );
|
||||
wp_mail( $admin_email, "Neue Antwort zu Ticket #{$tid}", "Kunde hat geantwortet.\nLink: {$admin_link}" );
|
||||
|
||||
// Admin Benachrichtigung über Gast Antwort (HTML)
|
||||
$admin_body = "Der Kunde {$ticket->guest_name} hat auf Ticket #{$tid} geantwortet.\n\nLink: {$admin_link}";
|
||||
$this->send_mail( $admin_email, "Neue Antwort zu Ticket #{$tid}", $admin_body );
|
||||
|
||||
$this->send_discord_notification( "Neue Antwort in Ticket #{$tid}", "Kunde {$ticket->guest_name} hat geantwortet.", $admin_link );
|
||||
$this->send_telegram_notification( "<b>Neue Antwort in Ticket #{$tid}</b>\nKunde: {$ticket->guest_name}\nLink: {$admin_link}" );
|
||||
@@ -1446,7 +1825,8 @@ class WP_Multi_Ticket_Pro {
|
||||
$link = add_query_arg( array( 'wmt_view' => $t->id, 'hash' => $t->ticket_hash ), home_url() );
|
||||
$body .= "#{$t->id}: {$t->title}\n{$link}\n\n";
|
||||
}
|
||||
wp_mail( $email, "Ihre Tickets", $body );
|
||||
// HTML E-Mail senden
|
||||
$this->send_mail( $email, "Ihre Tickets", $body );
|
||||
}
|
||||
wp_redirect( add_query_arg( 'wmt_lookup_sent', '1', wp_get_referer() ) );
|
||||
exit;
|
||||
|
||||
Reference in New Issue
Block a user