111 lines
3.7 KiB
PHP
111 lines
3.7 KiB
PHP
<?php
|
|
/**
|
|
* Schnelle Datenbank-Prüfung
|
|
* Aufruf: /wp-content/plugins/skrift-konfigurator/check-db.php
|
|
*/
|
|
|
|
// WordPress laden
|
|
require_once('../../../wp-load.php');
|
|
|
|
// Sicherheit
|
|
if (!current_user_can('manage_options')) {
|
|
die('Keine Berechtigung');
|
|
}
|
|
|
|
header('Content-Type: text/html; charset=utf-8');
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Gutschein DB Check</title>
|
|
<style>
|
|
body { font-family: monospace; padding: 20px; background: #f5f5f5; }
|
|
.box { background: white; padding: 20px; margin: 10px 0; border: 2px solid #333; }
|
|
.error { background: #ffebee; border-color: #c62828; }
|
|
.success { background: #e8f5e9; border-color: #2e7d32; }
|
|
pre { background: #f5f5f5; padding: 10px; overflow-x: auto; }
|
|
h2 { margin-top: 0; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<h1>🔍 Gutschein Datenbank Check</h1>
|
|
|
|
<?php
|
|
// 1. Direkt aus DB
|
|
$vouchers = get_option('skrift_konfigurator_vouchers', []);
|
|
$count = count($vouchers);
|
|
?>
|
|
|
|
<div class="box <?php echo $count > 0 ? 'success' : 'error'; ?>">
|
|
<h2>1. Datenbank Status</h2>
|
|
<p><strong>Anzahl Gutscheine:</strong> <?php echo $count; ?></p>
|
|
<?php if ($count === 0): ?>
|
|
<p style="color: #c62828;">⚠️ <strong>KEINE GUTSCHEINE IN DER DATENBANK!</strong></p>
|
|
<?php else: ?>
|
|
<p style="color: #2e7d32;">✅ Gutscheine gefunden!</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<h2>2. Rohe Daten (PHP)</h2>
|
|
<pre><?php var_dump($vouchers); ?></pre>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<h2>3. JSON Encoding (wie im Frontend)</h2>
|
|
<pre><?php echo wp_json_encode($vouchers, JSON_PRETTY_PRINT); ?></pre>
|
|
</div>
|
|
|
|
<div class="box">
|
|
<h2>4. JavaScript Test</h2>
|
|
<script>
|
|
const vouchers = <?php echo wp_json_encode($vouchers); ?>;
|
|
console.log('Vouchers:', vouchers);
|
|
console.log('Type:', Array.isArray(vouchers) ? 'ARRAY ❌' : 'OBJECT ✅');
|
|
console.log('Keys:', Object.keys(vouchers));
|
|
console.log('Count:', Object.keys(vouchers).length);
|
|
</script>
|
|
<p>Öffnen Sie die Browser Console (F12) für JavaScript-Output</p>
|
|
</div>
|
|
|
|
<?php if ($count === 0): ?>
|
|
<div class="box error">
|
|
<h2>⚠️ Lösung: Gutscheine erstellen</h2>
|
|
<p>Es sind keine Gutscheine in der Datenbank. Bitte:</p>
|
|
<ol>
|
|
<li>Gehen Sie zu: <a href="<?php echo admin_url('options-general.php?page=skrift-vouchers'); ?>">Gutschein-Verwaltung</a></li>
|
|
<li>Erstellen Sie einen Test-Gutschein (z.B. Code: TEST10, Typ: Prozent, Wert: 10)</li>
|
|
<li>Oder führen Sie <code>create-test-voucher.php</code> aus</li>
|
|
</ol>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="box">
|
|
<h2>5. Schnell-Fix: Test-Gutschein erstellen</h2>
|
|
<form method="post">
|
|
<button type="submit" name="create_test" style="padding: 10px 20px; font-size: 16px; cursor: pointer;">
|
|
🚀 Test-Gutschein "TEST10" jetzt erstellen
|
|
</button>
|
|
</form>
|
|
|
|
<?php
|
|
if (isset($_POST['create_test'])) {
|
|
$vouchers['TEST10'] = [
|
|
'code' => 'TEST10',
|
|
'type' => 'percent',
|
|
'value' => 10,
|
|
'expiry_date' => '',
|
|
'usage_limit' => 0,
|
|
'usage_count' => 0,
|
|
];
|
|
update_option('skrift_konfigurator_vouchers', $vouchers);
|
|
echo '<p style="color: #2e7d32; font-weight: bold;">✅ Gutschein TEST10 wurde erstellt! Seite neu laden...</p>';
|
|
echo '<script>setTimeout(() => location.reload(), 1500);</script>';
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|