Update from Git Manager GUI
This commit is contained in:
32
includes/forum-statusapi.php
Normal file
32
includes/forum-statusapi.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
// Ingame-Benachrichtigung via StatusAPI
|
||||
if ( ! defined( 'ABSPATH' ) ) exit;
|
||||
|
||||
|
||||
|
||||
function wbf_notify_ingame($player, $message) {
|
||||
// Einstellungen laden
|
||||
$settings = function_exists('wbf_get_settings') ? wbf_get_settings() : [];
|
||||
$enabled = !empty($settings['mc_bridge_enabled']);
|
||||
$api_url = trim($settings['mc_bridge_api_url'] ?? '');
|
||||
$api_secret = trim($settings['mc_bridge_api_secret'] ?? '');
|
||||
if (!$enabled || !$api_url || !$api_secret) {
|
||||
return;
|
||||
}
|
||||
|
||||
$url = rtrim($api_url, '/') . '/notify-pn';
|
||||
$data = [
|
||||
'player' => $player,
|
||||
'message' => $message
|
||||
];
|
||||
$args = [
|
||||
'body' => json_encode($data),
|
||||
'headers' => [
|
||||
'Content-Type' => 'application/json',
|
||||
'X-API-Key' => $api_secret,
|
||||
],
|
||||
'timeout' => 2,
|
||||
'data_format' => 'body',
|
||||
];
|
||||
wp_remote_post($url, $args);
|
||||
}
|
||||
Reference in New Issue
Block a user