Compare commits
17 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d6c23c086e | |||
| 7b7c5e7251 | |||
| afa02ef721 | |||
| d4cfc5cbf3 | |||
| 9ef317e3ac | |||
| 66ca7919a1 | |||
| 80838c3611 | |||
| 5d6e49e0b6 | |||
| c64e277fe6 | |||
| a16bd5e911 | |||
| 824e5a3324 | |||
| 2160c11c66 | |||
| bab8e406a2 | |||
| 2572ce610e | |||
| 7019c7731f | |||
| e55126c266 | |||
| cc6d7577ea |
16
README.md
16
README.md
@@ -20,7 +20,7 @@ Ein Spieler kann nicht einfach auf "Hochladen" klicken und Bilder laden. Er muss
|
||||
3. Er muss diesen Code auf dem Minecraft-Server im Chat eingeben (z.B. `/verify [Code]`).
|
||||
4. Erst dann wird der Upload freigeschaltet.
|
||||
|
||||
Dies stellt sicher, dass niemand unter dem Namen eines anderen Spieler Bilder hochlädt.
|
||||
Dies stellt sicher, dass niemand unter dem Namen eines anderen Spielers Bilder hochlädt.
|
||||
|
||||
---
|
||||
|
||||
@@ -111,7 +111,7 @@ Erstellt eine dedizierte Seite für einen spezifischen Spieler. Dies ist nützli
|
||||
|
||||
**Code:** `[mc_gallery_all_albums]`
|
||||
|
||||
Zeigt eine Übersicht aller ersterten Alben an (unabhängig von den einzelnen Bildern). Jedes Album wird als Karte mit einem Titel und einer Vorschau angezeigt. Ideal, um sich einen schnellen Überblick über die Sammlungen zu verschaffen.
|
||||
Zeigt eine Übersicht aller erstellten Alben an (unabhängig von den einzelnen Bildern). Jedes Album wird als Karte mit einem Titel und einer Vorschau angezeigt. Ideal, um sich einen schnellen Überblick über die Sammlungen zu verschaffen.
|
||||
|
||||
**Beispiel:**
|
||||
```
|
||||
@@ -128,10 +128,20 @@ Zeigt eine Übersicht aller ersterten Alben an (unabhängig von den einzelnen Bi
|
||||
|
||||
---
|
||||
|
||||
## 🔗 Voraussetzungen
|
||||
|
||||
Für die Verifizierungsfunktion wird die **StatusAPI** benötigt:
|
||||
|
||||
**[StatusAPI auf Git](https://git.viper.ipv64.net/M_Viper/StatusAPI)**
|
||||
|
||||
Die StatusAPI muss auf deinem Minecraft-Bungeecord laufen, um die Kommunikation zwischen dem Minecraft-Server und dem WordPress-Plugin zu ermöglichen.
|
||||
|
||||
---
|
||||
|
||||
## Häufige Fragen (FAQ)
|
||||
|
||||
**F: Warum können sich Spieler nicht verifizieren?**
|
||||
A: Du musst sicherstellen, dass auf deinem Minecraft-Server ein Plugin läuft, das mit diesem WordPress-Plugin kommunizieren kann. Der Server muss den Befehl `/verify` entgegennehmen und an deine WordPress-Website melden.
|
||||
A: Du musst sicherstellen, dass auf deinem Minecraft-Bungeecord die [StatusAPI](https://git.viper.ipv64.net/M_Viper/StatusAPI) läuft, die mit diesem WordPress-Plugin kommunizieren kann. Der Server muss den Befehl `/verify` entgegennehmen und an deine WordPress-Website melden.
|
||||
|
||||
**F: Wo finde ich die Server ID?**
|
||||
A: Gehe im WordPress Dashboard auf "MC Gallery PRO" > "MC Server". Die ID ist die Zahl, die in der URL steht, wenn du einen Server bearbeitest (z.B. `post.php?post=15&action=edit` → ID ist 15).
|
||||
@@ -1,54 +0,0 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.mviper</groupId>
|
||||
<artifactId>Verify</artifactId>
|
||||
<version>1.0</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Verify</name>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<spigot.version>1.20.1-R0.1-SNAPSHOT</spigot.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.11.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>de.mviper.verify.Verify</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
||||
@@ -1,146 +0,0 @@
|
||||
package de.mviper.verify;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import javax.crypto.Mac;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import java.net.*;
|
||||
import java.io.*;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class Verify extends JavaPlugin implements CommandExecutor {
|
||||
|
||||
private String wpVerifyUrl;
|
||||
private String sharedSecret;
|
||||
private int serverId;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
saveDefaultConfig();
|
||||
wpVerifyUrl = getConfig().getString("wp_verify_url", "http://deine-wp-domain.tld");
|
||||
sharedSecret = getConfig().getString("shared_secret", "ChangeMe");
|
||||
serverId = getConfig().getInt("server_id", 0);
|
||||
getCommand("verify").setExecutor(this);
|
||||
getLogger().info("Verify enabled for server ID: " + serverId + " | WP URL: " + wpVerifyUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
if (!(sender instanceof Player)) {
|
||||
sender.sendMessage(ChatColor.RED + "Nur Spieler können diesen Befehl benutzen.");
|
||||
return true;
|
||||
}
|
||||
Player p = (Player) sender;
|
||||
if (args.length != 1) {
|
||||
p.sendMessage(ChatColor.YELLOW + "Benutzung: /verify <token>");
|
||||
return true;
|
||||
}
|
||||
String token = args[0].trim();
|
||||
String playerName = p.getName();
|
||||
|
||||
HttpURLConnection conn = null;
|
||||
try {
|
||||
// FIX: Explizit UTF-8 für die Signatur
|
||||
Charset utf8 = Charset.forName("UTF-8");
|
||||
String signature = hmacSHA256(playerName + token, sharedSecret, utf8);
|
||||
|
||||
// FIX: Explizit UTF-8 für den Payload
|
||||
String payload = "{\"player\":\"" + escapeJson(playerName) + "\",\"token\":\"" + escapeJson(token) + "\",\"server_id\":" + serverId + ",\"signature\":\"" + signature + "\"}";
|
||||
|
||||
URL url = new URL(wpVerifyUrl + "/wp-json/mc-gallery/v1/verify");
|
||||
conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(7000);
|
||||
conn.setDoOutput(true);
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json; charset=utf-8");
|
||||
|
||||
try (OutputStream os = conn.getOutputStream()) {
|
||||
os.write(payload.getBytes(utf8));
|
||||
}
|
||||
|
||||
int code = conn.getResponseCode();
|
||||
String resp;
|
||||
|
||||
// FIX: Antwort immer als UTF-8 lesen, egal ob 200 oder 403
|
||||
if (code >= 200 && code < 300) {
|
||||
InputStream is = conn.getInputStream();
|
||||
resp = streamToString(is, utf8);
|
||||
} else {
|
||||
InputStream es = conn.getErrorStream();
|
||||
resp = streamToString(es, utf8);
|
||||
}
|
||||
|
||||
// Antwort parsen
|
||||
if (resp != null && !resp.isEmpty() && resp.trim().startsWith("{")) {
|
||||
// Erfolgreiche Übertragung, nun JSON parsen
|
||||
|
||||
// Checken ob success true ist
|
||||
boolean isSuccess = resp.contains("\"success\":true");
|
||||
|
||||
// Die message auslesen
|
||||
String message = "Ein unbekannter Fehler ist aufgetreten.";
|
||||
int keyIndex = resp.indexOf("\"message\":\"");
|
||||
if (keyIndex != -1) {
|
||||
int startIndex = keyIndex + 11;
|
||||
int endIndex = resp.indexOf("\"", startIndex);
|
||||
if (endIndex != -1) {
|
||||
message = resp.substring(startIndex, endIndex);
|
||||
}
|
||||
}
|
||||
|
||||
// Nachricht senden (mit Farbcodes)
|
||||
if (isSuccess) {
|
||||
p.sendMessage(ChatColor.GREEN + "✓ " + message);
|
||||
p.sendMessage(ChatColor.GRAY + "Du kannst nun Bilder hochladen!");
|
||||
} else {
|
||||
// Hier landen Fehler wie "Name stimmt nicht überein" oder 403
|
||||
// Durch die UTF-8 Lesung sollten Umlaute jetzt korrekt sein
|
||||
p.sendMessage(ChatColor.RED + "✗ " + message);
|
||||
}
|
||||
} else {
|
||||
p.sendMessage(ChatColor.RED + "✗ Fehler beim Verbinden mit der Webseite (Code: " + code + ")");
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
p.sendMessage(ChatColor.RED + "✗ Ein interner Fehler ist aufgetreten.");
|
||||
getLogger().warning("Verify error: " + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if (conn != null) {
|
||||
conn.disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// FIX: UTF-8 als Parameter übergeben
|
||||
private static String hmacSHA256(String data, String key, Charset charset) throws Exception {
|
||||
Mac mac = Mac.getInstance("HmacSHA256");
|
||||
mac.init(new SecretKeySpec(key.getBytes(charset), "HmacSHA256"));
|
||||
byte[] raw = mac.doFinal(data.getBytes(charset));
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (byte b : raw) sb.append(String.format("%02x", b));
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
// FIX: UTF-8 als Parameter übergeben
|
||||
private static String streamToString(InputStream in, Charset charset) throws IOException {
|
||||
if (in == null) return "";
|
||||
try (BufferedReader br = new BufferedReader(new InputStreamReader(in, charset))) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
String line;
|
||||
while ((line = br.readLine()) != null) sb.append(line);
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
private static String escapeJson(String s) {
|
||||
return s.replace("\\", "\\\\").replace("\"","\\\"").replace("\n","\\n").replace("\r","\\r");
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
# URL deiner WordPress-Seite (ohne Slash am Ende)
|
||||
wp_verify_url: "https://deine-wp-domain.tld"
|
||||
|
||||
# Shared Secret — muss identisch sein mit dem Secret im WordPress Server-CPT
|
||||
shared_secret: "TrageHierDasSecretEin"
|
||||
|
||||
# server_id: die Post-ID des mc_server-Posts in der jeweiligen WordPress-Installation
|
||||
server_id: 1
|
||||
@@ -1,7 +0,0 @@
|
||||
name: Verify
|
||||
main: de.mviper.verify.Verify
|
||||
version: 1.0
|
||||
api-version: 1.20
|
||||
commands:
|
||||
verify:
|
||||
description: Verifiziere ein Website-Token (Usage /verify <token>)
|
||||
199
mc-multiserver-gallery-pro.php
Normal file
199
mc-multiserver-gallery-pro.php
Normal file
@@ -0,0 +1,199 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: MC MultiServer Gallery PRO
|
||||
Description: Professionelle Minecraft-Galerie mit Ingame-Verification, modernem UI, Lightbox und AJAX-Upload (multi-server fähig).
|
||||
Version: 2.5.3
|
||||
Author: M_Viper
|
||||
Text Domain: mc-multiserver-gallery-pro
|
||||
Domain Path: /languages
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO:</strong> Dieses Plugin benötigt PHP 7.0 oder höher.</p></div>';
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined('MCGALLERY_PRO_VERSION')) { return; }
|
||||
|
||||
define('MCGALLERY_PRO_VERSION', '2.5.2');
|
||||
define('MCGALLERY_PRO_DIR', plugin_dir_path(__FILE__));
|
||||
define('MCGALLERY_PRO_URL', plugin_dir_url(__FILE__));
|
||||
define('MCGALLERY_TOKEN_TTL', 300);
|
||||
define('MCGALLERY_OPTION_KEY', 'mc_gallery_tokens_store');
|
||||
|
||||
function mc_gallery_pro_safe_require($path) {
|
||||
if (!file_exists($path)) {
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', function() use ($path) {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO Fehler:</strong> Datei nicht gefunden: <code>' . esc_html($path) . '</code>.</p></div>';
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
require_once $path;
|
||||
return true;
|
||||
}
|
||||
|
||||
function mc_gallery_pro_load_textdomain() {
|
||||
load_plugin_textdomain('mc-multiserver-gallery-pro', false, basename(dirname(__FILE__)) . '/languages');
|
||||
}
|
||||
add_action('plugins_loaded', 'mc_gallery_pro_load_textdomain');
|
||||
|
||||
$core_files = [
|
||||
'class-mc-gallery-helpers.php',
|
||||
'class-mc-gallery-core.php',
|
||||
'class-mc-gallery-shortcodes.php'
|
||||
];
|
||||
|
||||
if (!is_dir(MCGALLERY_PRO_DIR . 'includes')) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO Fehler:</strong> Der Ordner <code>includes/</code> fehlt.</p></div>';
|
||||
});
|
||||
} else {
|
||||
foreach ($core_files as $file) {
|
||||
if (!mc_gallery_pro_safe_require(MCGALLERY_PRO_DIR . 'includes/' . $file)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mc_gallery_pro_activate_callback() {
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
if (!get_option(MC_Gallery_Core::OPTION_THUMB_H)) {
|
||||
update_option(MC_Gallery_Core::OPTION_THUMB_H, 200);
|
||||
}
|
||||
}
|
||||
if (get_option(MCGALLERY_OPTION_KEY) === false) {
|
||||
update_option(MCGALLERY_OPTION_KEY, []);
|
||||
}
|
||||
}
|
||||
register_activation_hook(__FILE__, 'mc_gallery_pro_activate_callback');
|
||||
|
||||
function mc_gallery_pro_uninstall_callback() {
|
||||
delete_option(MCGALLERY_OPTION_KEY);
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
delete_option(MC_Gallery_Core::OPTION_THUMB_H);
|
||||
}
|
||||
}
|
||||
register_uninstall_hook(__FILE__, 'mc_gallery_pro_uninstall_callback');
|
||||
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
add_action('plugins_loaded', ['MC_Gallery_Core', 'init']);
|
||||
}
|
||||
if (class_exists('MC_Gallery_Shortcodes')) {
|
||||
add_action('plugins_loaded', ['MC_Gallery_Shortcodes', 'init']);
|
||||
}
|
||||
|
||||
/* ================= SIDEBAR WIDGET: BILD DES TAGES ================= */
|
||||
class MC_Daily_Image_Widget extends WP_Widget {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct(
|
||||
'mc_daily_image_widget',
|
||||
'MC Bild des Tages',
|
||||
array( 'description' => 'Zeigt jeden Tag ein anderes, zufälliges Bild aus allen MC Galerien an.' )
|
||||
);
|
||||
}
|
||||
|
||||
// Frontend-Ausgabe
|
||||
public function widget( $args, $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Bild des Tages';
|
||||
|
||||
echo $args['before_widget'];
|
||||
if ( ! empty( $title ) ) {
|
||||
echo $args['before_title'] . apply_filters( 'widget_title', $title ) . $args['after_title'];
|
||||
}
|
||||
|
||||
// 1. Eindeutiger Key für heute (z.B. mc_daily_image_2023-10-27)
|
||||
$today_key = 'mc_daily_image_' . date('Y-m-d');
|
||||
|
||||
// 2. Prüfen, ob wir heute schon ein Bild ausgewählt haben
|
||||
$image_id = get_transient( $today_key );
|
||||
|
||||
// Falls kein Bild für heute im Cache ist:
|
||||
if ( false === $image_id ) {
|
||||
|
||||
// Alle MC Galerien finden
|
||||
$galleries = get_posts([
|
||||
'post_type' => 'mc_gallery',
|
||||
'numberposts' => -1,
|
||||
'fields' => 'ids',
|
||||
'post_status' => 'publish'
|
||||
]);
|
||||
|
||||
if ( ! empty( $galleries ) ) {
|
||||
// Ein zufälliges Bild aus diesen Galerien holen
|
||||
$random_image = get_posts([
|
||||
'post_type' => 'attachment',
|
||||
'post_mime_type' => 'image',
|
||||
'post_parent__in'=> $galleries,
|
||||
'numberposts' => 1,
|
||||
'orderby' => 'rand', // Zufällig wählen
|
||||
'suppress_filters' => false
|
||||
]);
|
||||
|
||||
if ( ! empty( $random_image ) ) {
|
||||
$image_id = $random_image[0]->ID;
|
||||
// Das Bild für 24 Stunden (bis morgen) speichern
|
||||
set_transient( $today_key, $image_id, DAY_IN_SECONDS );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. Bild anzeigen (wird aus Cache oder neu geladen)
|
||||
if ( $image_id && wp_attachment_is_image( $image_id ) ) {
|
||||
|
||||
$img_src = wp_get_attachment_image_src( $image_id, 'medium' );
|
||||
$full_src = wp_get_attachment_image_src( $image_id, 'full' );
|
||||
|
||||
if ( $img_src ) {
|
||||
?>
|
||||
<div class="mc-daily-image-container" style="text-align: center;">
|
||||
<a href="<?php echo esc_url( $full_src[0] ); ?>" target="_blank" title="Vollbild anzeigen">
|
||||
<img src="<?php echo esc_url( $img_src[0] ); ?>" alt="MC Bild des Tages" style="max-width: 100%; height: auto; border-radius: 4px; box-shadow: 0 2px 5px rgba(0,0,0,0.1);" />
|
||||
</a>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
} else {
|
||||
echo '<p style="text-align:center; color:#888;">Keine Bilder verfügbar.</p>';
|
||||
}
|
||||
|
||||
echo $args['after_widget'];
|
||||
}
|
||||
|
||||
// Backend Formular
|
||||
public function form( $instance ) {
|
||||
$title = ! empty( $instance['title'] ) ? $instance['title'] : 'Bild des Tages';
|
||||
?>
|
||||
<p>
|
||||
<label for="<?php echo $this->get_field_id( 'title' ); ?>">Titel:</label>
|
||||
<input class="widefat" id="<?php echo $this->get_field_id( 'title' ); ?>"
|
||||
name="<?php echo $this->get_field_name( 'title' ); ?>" type="text"
|
||||
value="<?php echo esc_attr( $title ); ?>">
|
||||
</p>
|
||||
<p class="description" style="font-size: 0.9em; color: #666;">
|
||||
Dieses Widget wählt einmal pro Tag (um 00:00 Uhr) ein zufälliges Bild aus allen Spieler-Galerien aus und zeigt es an. Der Bildtext ist ausgeblendet.
|
||||
</p>
|
||||
<?php
|
||||
}
|
||||
|
||||
// Speichern der Einstellungen
|
||||
public function update( $new_instance, $old_instance ) {
|
||||
$instance = array();
|
||||
$instance['title'] = ( ! empty( $new_instance['title'] ) ) ? sanitize_text_field( $new_instance['title'] ) : 'Bild des Tages';
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
||||
// Widget registrieren
|
||||
function mc_register_daily_image_widget() {
|
||||
register_widget( 'MC_Daily_Image_Widget' );
|
||||
}
|
||||
add_action( 'widgets_init', 'mc_register_daily_image_widget' );
|
||||
@@ -1,91 +0,0 @@
|
||||
<?php
|
||||
/*
|
||||
Plugin Name: MC MultiServer Gallery PRO
|
||||
Description: Professionelle Minecraft-Galerie mit Ingame-Verification, modernem UI, Lightbox und AJAX-Upload (multi-server fähig).
|
||||
Version: 2.5.2
|
||||
Author: M_Viper
|
||||
Text Domain: mc-multiserver-gallery-pro
|
||||
Domain Path: /languages
|
||||
*/
|
||||
|
||||
if (!defined('ABSPATH')) exit;
|
||||
|
||||
if (version_compare(PHP_VERSION, '7.0', '<')) {
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO:</strong> Dieses Plugin benötigt PHP 7.0 oder höher.</p></div>';
|
||||
});
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (defined('MCGALLERY_PRO_VERSION')) { return; }
|
||||
|
||||
define('MCGALLERY_PRO_VERSION', '2.5.2');
|
||||
define('MCGALLERY_PRO_DIR', plugin_dir_path(__FILE__));
|
||||
define('MCGALLERY_PRO_URL', plugin_dir_url(__FILE__));
|
||||
define('MCGALLERY_TOKEN_TTL', 300);
|
||||
define('MCGALLERY_OPTION_KEY', 'mc_gallery_tokens_store');
|
||||
|
||||
function mc_gallery_pro_safe_require($path) {
|
||||
if (!file_exists($path)) {
|
||||
if (is_admin()) {
|
||||
add_action('admin_notices', function() use ($path) {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO Fehler:</strong> Datei nicht gefunden: <code>' . esc_html($path) . '</code>.</p></div>';
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
require_once $path;
|
||||
return true;
|
||||
}
|
||||
|
||||
function mc_gallery_pro_load_textdomain() {
|
||||
load_plugin_textdomain('mc-multiserver-gallery-pro', false, basename(dirname(__FILE__)) . '/languages');
|
||||
}
|
||||
add_action('plugins_loaded', 'mc_gallery_pro_load_textdomain');
|
||||
|
||||
$core_files = [
|
||||
'class-mc-gallery-helpers.php',
|
||||
'class-mc-gallery-core.php',
|
||||
'class-mc-gallery-shortcodes.php'
|
||||
];
|
||||
|
||||
if (!is_dir(MCGALLERY_PRO_DIR . 'includes')) {
|
||||
add_action('admin_notices', function() {
|
||||
echo '<div class="error"><p><strong>MC Gallery PRO Fehler:</strong> Der Ordner <code>includes/</code> fehlt.</p></div>';
|
||||
});
|
||||
} else {
|
||||
foreach ($core_files as $file) {
|
||||
if (!mc_gallery_pro_safe_require(MCGALLERY_PRO_DIR . 'includes/' . $file)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function mc_gallery_pro_activate_callback() {
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
if (!get_option(MC_Gallery_Core::OPTION_THUMB_H)) {
|
||||
update_option(MC_Gallery_Core::OPTION_THUMB_H, 200);
|
||||
}
|
||||
}
|
||||
if (get_option(MCGALLERY_OPTION_KEY) === false) {
|
||||
update_option(MCGALLERY_OPTION_KEY, []);
|
||||
}
|
||||
}
|
||||
register_activation_hook(__FILE__, 'mc_gallery_pro_activate_callback');
|
||||
|
||||
function mc_gallery_pro_uninstall_callback() {
|
||||
delete_option(MCGALLERY_OPTION_KEY);
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
delete_option(MC_Gallery_Core::OPTION_THUMB_H);
|
||||
}
|
||||
}
|
||||
register_uninstall_hook(__FILE__, 'mc_gallery_pro_uninstall_callback');
|
||||
|
||||
if (class_exists('MC_Gallery_Core')) {
|
||||
add_action('plugins_loaded', ['MC_Gallery_Core', 'init']);
|
||||
}
|
||||
if (class_exists('MC_Gallery_Shortcodes')) {
|
||||
add_action('plugins_loaded', ['MC_Gallery_Shortcodes', 'init']);
|
||||
}
|
||||
Reference in New Issue
Block a user