wp-multi-ticket.php aktualisiert
This commit is contained in:
@@ -1,10 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: WP Multi Ticket Pro
|
||||
Description: Fix: Syntax Error in get_option + Chart.js Verbesserungen.
|
||||
Version: 1.0
|
||||
Author: M_Viper
|
||||
*/
|
||||
* 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.1
|
||||
* Author: M_Viper
|
||||
* Author URI: https://m-viper.de
|
||||
* Requires at least: 6.7.2
|
||||
* Tested up to: 6.7.2
|
||||
* Requires PHP: 7.4
|
||||
* License: GPL-2.0-or-later
|
||||
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
|
||||
* Text Domain: wp-multi-ticket
|
||||
* Domain Path: /languages
|
||||
* Tags: ticket, support, helpdesk, customer-support, guest-tickets, wp-multi
|
||||
* Support: https://t.me/M_Viper04
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
@@ -12,6 +25,7 @@ class WP_Multi_Ticket_Pro {
|
||||
|
||||
private $table_tickets;
|
||||
private $table_messages;
|
||||
private $update_url = 'https://git.viper.ipv64.net/M_Viper/wp-multi-ticket/releases';
|
||||
|
||||
public function __construct() {
|
||||
global $wpdb;
|
||||
@@ -30,6 +44,9 @@ class WP_Multi_Ticket_Pro {
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_styles' ) );
|
||||
add_action( 'admin_enqueue_scripts', array( $this, 'load_analytics_scripts' ) );
|
||||
|
||||
// Hook für Update-Benachrichtigung
|
||||
add_action( 'admin_notices', array( $this, 'check_plugin_updates' ) );
|
||||
|
||||
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' ) );
|
||||
@@ -43,6 +60,95 @@ class WP_Multi_Ticket_Pro {
|
||||
add_action( 'admin_init', array( $this, 'handle_csv_export' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Prüft auf Updates von der Git-URL und zeigt eine Admin-Notice an
|
||||
*/
|
||||
public function check_plugin_updates() {
|
||||
|
||||
if ( ! current_user_can( 'update_plugins' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ! function_exists( 'get_plugin_data' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/plugin.php';
|
||||
}
|
||||
|
||||
$plugin_data = get_plugin_data( __FILE__ );
|
||||
$current_version = $plugin_data['Version'];
|
||||
|
||||
$cache_key = 'wmt_ticket_update_check';
|
||||
$cached = get_transient( $cache_key );
|
||||
|
||||
if ( false === $cached ) {
|
||||
|
||||
$cached = array(
|
||||
'version' => $current_version,
|
||||
'url' => $this->update_url,
|
||||
);
|
||||
|
||||
// Gitea API – Releases
|
||||
$api_url = 'https://git.viper.ipv64.net/api/v1/repos/M_Viper/wp-multi-ticket/releases';
|
||||
|
||||
$response = wp_remote_get( $api_url, array(
|
||||
'timeout' => 10,
|
||||
'headers' => array(
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'WP-Multi-Ticket-Updater',
|
||||
),
|
||||
) );
|
||||
|
||||
if ( ! is_wp_error( $response ) && wp_remote_retrieve_response_code( $response ) === 200 ) {
|
||||
|
||||
$releases = json_decode( wp_remote_retrieve_body( $response ), true );
|
||||
|
||||
if ( is_array( $releases ) && ! empty( $releases ) ) {
|
||||
|
||||
// Neuestes Release (Gitea liefert neueste zuerst)
|
||||
$latest = $releases[0];
|
||||
|
||||
// Version (genau wie im Toolkit)
|
||||
if ( ! empty( $latest['tag_name'] ) ) {
|
||||
$cached['version'] = ltrim( $latest['tag_name'], 'vV' );
|
||||
} elseif ( ! empty( $latest['name'] ) ) {
|
||||
$cached['version'] = ltrim( $latest['name'], 'vV' );
|
||||
}
|
||||
|
||||
// Exaktes ZIP-Asset suchen
|
||||
if ( ! empty( $latest['assets'] ) && is_array( $latest['assets'] ) ) {
|
||||
foreach ( $latest['assets'] as $asset ) {
|
||||
if (
|
||||
! empty( $asset['name'] ) &&
|
||||
! empty( $asset['browser_download_url'] ) &&
|
||||
strtolower( $asset['name'] ) === 'wp-multi-ticket.zip'
|
||||
) {
|
||||
$cached['url'] = $asset['browser_download_url'];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Cache setzen
|
||||
set_transient( $cache_key, $cached, 12 * HOUR_IN_SECONDS );
|
||||
}
|
||||
|
||||
// Update-Hinweis anzeigen
|
||||
if ( version_compare( $cached['version'], $current_version, '>' ) ) {
|
||||
|
||||
echo '<div class="notice notice-warning is-dismissible">';
|
||||
echo '<p><strong>WP Multi Ticket Pro – Update verfügbar</strong></p>';
|
||||
echo '<p>Neue Version: <strong>' . esc_html( $cached['version'] ) . '</strong><br>';
|
||||
echo 'Installiert: <strong>' . esc_html( $current_version ) . '</strong></p>';
|
||||
echo '<p>';
|
||||
echo '<a href="' . esc_url( $this->update_url ) . '" target="_blank" class="button">Release ansehen</a> ';
|
||||
echo '<a href="' . esc_url( $cached['url'] ) . '" target="_blank" class="button button-primary">Direkter Download (ZIP)</a>';
|
||||
echo '</p>';
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// *** 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
|
||||
@@ -123,7 +229,7 @@ class WP_Multi_Ticket_Pro {
|
||||
.wmt-css-label { width: 120px; font-size: 13px; font-weight: 600; text-align: right; margin-right: 10px; }
|
||||
.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: #6b7280; font-weight: bold; }
|
||||
.wmt-css-bar-val { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); font-size: 11px; color: #6c757d; font-weight: bold; }
|
||||
</style>
|
||||
<?php
|
||||
}
|
||||
@@ -1328,4 +1434,4 @@ class WP_Multi_Ticket_Pro {
|
||||
exit;
|
||||
}
|
||||
}
|
||||
new WP_Multi_Ticket_Pro();
|
||||
new WP_Multi_Ticket_Pro();
|
||||
Reference in New Issue
Block a user