73 lines
2.1 KiB
PHP
73 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* DEBUG: Gutscheine prüfen
|
|
* Aufruf: /wp-content/plugins/skrift-konfigurator/debug-vouchers.php
|
|
*/
|
|
|
|
// WordPress laden
|
|
require_once('../../../wp-load.php');
|
|
|
|
// Sicherheit: Nur für Admins
|
|
if (!current_user_can('manage_options')) {
|
|
die('Keine Berechtigung');
|
|
}
|
|
|
|
echo '<h1>Gutschein Debug</h1>';
|
|
echo '<style>pre { background: #f5f5f5; padding: 15px; border: 1px solid #ddd; }</style>';
|
|
|
|
// 1. Direkt aus Datenbank lesen
|
|
$vouchers_db = get_option('skrift_konfigurator_vouchers', []);
|
|
echo '<h2>1. Direkt aus Datenbank (get_option)</h2>';
|
|
echo '<pre>';
|
|
print_r($vouchers_db);
|
|
echo '</pre>';
|
|
|
|
// 2. Über die Klasse
|
|
require_once plugin_dir_path(__FILE__) . 'includes/admin-vouchers.php';
|
|
$vouchers_class = Skrift_Konfigurator_Vouchers::get_vouchers();
|
|
echo '<h2>2. Über Klassen-Methode get_vouchers()</h2>';
|
|
echo '<pre>';
|
|
print_r($vouchers_class);
|
|
echo '</pre>';
|
|
|
|
// 3. JSON-Encoding prüfen (wie wp_localize_script es macht)
|
|
$vouchers_json = json_encode($vouchers_class);
|
|
echo '<h2>3. JSON-Encoded (wie wp_localize_script)</h2>';
|
|
echo '<pre>';
|
|
echo htmlspecialchars($vouchers_json);
|
|
echo '</pre>';
|
|
|
|
// 4. Zurück decodiert
|
|
$vouchers_decoded = json_decode($vouchers_json, true);
|
|
echo '<h2>4. JSON wieder decodiert</h2>';
|
|
echo '<pre>';
|
|
print_r($vouchers_decoded);
|
|
echo '</pre>';
|
|
|
|
// 5. Test: Ist es ein assoziatives Array oder Objekt?
|
|
echo '<h2>5. Datentyp-Analyse</h2>';
|
|
echo '<pre>';
|
|
echo 'is_array: ' . (is_array($vouchers_class) ? 'JA' : 'NEIN') . "\n";
|
|
echo 'count: ' . count($vouchers_class) . "\n";
|
|
echo 'empty: ' . (empty($vouchers_class) ? 'JA' : 'NEIN') . "\n";
|
|
echo 'Keys: ' . print_r(array_keys($vouchers_class), true) . "\n";
|
|
echo '</pre>';
|
|
|
|
// 6. Simuliere wp_localize_script
|
|
echo '<h2>6. Simuliertes wp_localize_script Output</h2>';
|
|
echo '<script>';
|
|
echo "\n";
|
|
echo 'var SkriftConfigurator = {';
|
|
echo "\n";
|
|
echo ' "version": "0.3.0",';
|
|
echo "\n";
|
|
echo ' "vouchers": ' . json_encode($vouchers_class);
|
|
echo "\n";
|
|
echo '};';
|
|
echo "\n";
|
|
echo 'console.log("Vouchers from simulated wp_localize_script:", SkriftConfigurator.vouchers);';
|
|
echo "\n";
|
|
echo '</script>';
|
|
|
|
echo '<p><strong>Öffnen Sie die Browser-Console, um das simulierte Output zu sehen!</strong></p>';
|