wp-multi-toolkit.php aktualisiert
This commit is contained in:
parent
959e458951
commit
e7fce1d49b
@ -19,6 +19,220 @@
|
||||
|
||||
defined('ABSPATH') or die('No direct access allowed.');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Gitea - Ticket - BUG - Report
|
||||
*/
|
||||
|
||||
// Funktion zur Erstellung eines Support-Tickets
|
||||
function send_support_ticket_to_server($plugin_name, $title, $description, $label = 'bug') {
|
||||
$server_url = 'https://m-viper.de/gitea-issue-creator-2.php';
|
||||
|
||||
$data = [
|
||||
'plugin' => $plugin_name,
|
||||
'title' => $title,
|
||||
'description' => $description,
|
||||
'label' => $label
|
||||
];
|
||||
|
||||
$args = [
|
||||
'method' => 'POST',
|
||||
'body' => json_encode($data),
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
],
|
||||
'timeout' => 45,
|
||||
];
|
||||
|
||||
$response = wp_remote_post($server_url, $args);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
$error_message = $response->get_error_message();
|
||||
return "<span class='error-message'>Es gab einen Fehler bei der Ticketübertragung: $error_message</span>";
|
||||
}
|
||||
|
||||
$response_body = wp_remote_retrieve_body($response);
|
||||
$response_data = json_decode($response_body, true);
|
||||
|
||||
if (isset($response_data['message']) && $response_data['message'] === 'Issues erfolgreich erstellt') {
|
||||
return '<span class="success-message">Issues erfolgreich erstellt</span>';
|
||||
} else {
|
||||
return '<span class="error-message">Es gab einen Fehler: ' . esc_html($response_body) . '</span>';
|
||||
}
|
||||
}
|
||||
|
||||
// Formular für das Support-Ticket mit Design
|
||||
function support_ticket_form() {
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1 class="wp-multi-support-title">WP-Multi Support</h1>
|
||||
<div class="support-form-container">
|
||||
<form method="post" class="wp-multi-support-form">
|
||||
<div class="form-group">
|
||||
<label for="plugin_name">Wählen Sie das Plugin</label>
|
||||
<select name="plugin_name" id="plugin_name" required>
|
||||
<option value="wp-multi">WP Multi</option>
|
||||
<option value="wp-multi-search">WP Multi Search</option>
|
||||
<option value="wp-multi-toolkit">WP Multi Toolkit</option>
|
||||
<option value="wp-multi-comment-notifications">WP Multi Comment Notifications</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ticket_title">Ticket-Titel</label>
|
||||
<input type="text" name="ticket_title" id="ticket_title" required placeholder="Geben Sie den Titel ein" />
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ticket_description">Ticket-Beschreibung</label>
|
||||
<textarea name="ticket_description" id="ticket_description" required placeholder="Beschreiben Sie Ihr Anliegen"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label for="ticket_label">Kategorie</label>
|
||||
<select name="ticket_label" id="ticket_label" required>
|
||||
<option value="bug">Bug (Etwas funktioniert nicht)</option>
|
||||
<option value="enhancement">Verbesserung (Neue Funktion)</option>
|
||||
<option value="question">Frage (Mehr Infos benötigt)</option>
|
||||
<option value="help wanted">Hilfe benötigt</option>
|
||||
<option value="invalid">Ungültig (Etwas ist falsch)</option>
|
||||
<option value="duplicate">Duplikat (Bereits vorhanden)</option>
|
||||
<option value="wontfix">Wird nicht behoben</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<input type="submit" name="submit_ticket" value="Ticket absenden" class="submit-button" />
|
||||
</form>
|
||||
|
||||
<?php
|
||||
if (isset($_POST['submit_ticket'])) {
|
||||
$plugin_name = sanitize_text_field($_POST['plugin_name']);
|
||||
$title = sanitize_text_field($_POST['ticket_title']);
|
||||
$description = sanitize_textarea_field($_POST['ticket_description']);
|
||||
$label = sanitize_text_field($_POST['ticket_label']);
|
||||
$result = send_support_ticket_to_server($plugin_name, $title, $description, $label);
|
||||
echo '<div class="response-message">' . $result . '</div>';
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
// CSS nur auf der Ticket-Seite (wp_multi_support) ausgeben
|
||||
if (isset($_GET['page']) && $_GET['page'] === 'wp_multi_support') {
|
||||
?>
|
||||
<style>
|
||||
.wp-multi-support-title {
|
||||
font-size: 28px;
|
||||
color: #23282d;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.support-form-container {
|
||||
background: #fff;
|
||||
padding: 20px;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
|
||||
max-width: 600px;
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.wp-multi-support-form .form-group {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.wp-multi-support-form label {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
margin-bottom: 5px;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
.wp-multi-support-form input[type="text"],
|
||||
.wp-multi-support-form textarea,
|
||||
.wp-multi-support-form select {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 4px;
|
||||
box-sizing: border-box;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.wp-multi-support-form textarea {
|
||||
height: 120px;
|
||||
resize: vertical;
|
||||
}
|
||||
|
||||
.wp-multi-support-form .submit-button {
|
||||
background-color: #0073aa;
|
||||
color: #fff;
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 4px;
|
||||
cursor: pointer;
|
||||
font-size: 16px;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
.wp-multi-support-form .submit-button:hover {
|
||||
background-color: #005d82;
|
||||
}
|
||||
|
||||
.response-message {
|
||||
margin-top: 20px;
|
||||
padding: 10px;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.success-message {
|
||||
color: #155724;
|
||||
background-color: #d4edda;
|
||||
border: 1px solid #c3e6cb;
|
||||
}
|
||||
|
||||
.error-message {
|
||||
color: #721c24;
|
||||
background-color: #f8d7da;
|
||||
border: 1px solid #f5c6cb;
|
||||
}
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Menüseite hinzufügen
|
||||
function add_support_ticket_page() {
|
||||
add_menu_page(
|
||||
'WP-Multi Support', // Seitentitel
|
||||
'WP-Multi Support', // Menüname
|
||||
'manage_options', // Berechtigung
|
||||
'wp_multi_support', // Slug (angepasst für Konsistenz)
|
||||
'support_ticket_form' // Funktion, die das Formular rendert
|
||||
);
|
||||
}
|
||||
|
||||
add_action('admin_menu', 'add_support_ticket_page');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
// ### Update Funktion ###
|
||||
*/
|
||||
|
||||
define('WPMT_PLUGIN_DIR', plugin_dir_path(__FILE__));
|
||||
|
||||
// Textdomain laden
|
||||
@ -50,16 +264,7 @@ function wpmt_enable_multi_callback() {
|
||||
echo '<input type="checkbox" name="wpmt_multi_settings[enable_multi]" value="1" ' . checked(1, $options['enable_multi'], false) . ' />';
|
||||
}
|
||||
|
||||
function wpmt_add_admin_menu() {
|
||||
add_options_page(
|
||||
__('WP Multi Toolkit Einstellungen', 'wp-multi-toolkit'),
|
||||
__('WP Multi Toolkit', 'wp-multi-toolkit'),
|
||||
'manage_options',
|
||||
'wpmt_settings',
|
||||
'wpmt_settings_page'
|
||||
);
|
||||
}
|
||||
add_action('admin_menu', 'wpmt_add_admin_menu');
|
||||
|
||||
|
||||
function wpmt_settings_page() {
|
||||
?>
|
||||
@ -413,4 +618,5 @@ function wpmt_uninstall() {
|
||||
delete_option('wpmt_multi_settings');
|
||||
wp_clear_scheduled_hook('wpmt_update_check_event');
|
||||
}
|
||||
register_uninstall_hook(__FILE__, 'wpmt_uninstall');
|
||||
register_uninstall_hook(__FILE__, 'wpmt_uninstall');
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user