<?php
add_shortcode('public_certificate_viewer', function() {
if (!isset($_GET['cert_hash'])) {
return "<p style='text-align:center;'>Certificate ID not provided.</p>";
}
$cert_hash = sanitize_text_field($_GET['cert_hash']);
global $wpdb;
$table = $wpdb->prefix . 'tutor_certificates'; // تحقق من اسم الجدول الصحيح إذا كان مختلفًا
$cert = $wpdb->get_row("SELECT * FROM $table WHERE cert_hash = '$cert_hash'");
if (!$cert) {
return "<p style='text-align:center;'>Certificate not found.</p>";
}
ob_start();
?>
<div style="max-width:700px;margin:30px auto;text-align:center;padding:30px;border:1px solid #ccc;border-radius:10px;">
<h2>Certificate Verified ✅</h2>
<p><strong>Student Name:</strong> <?php echo esc_html($cert->student_name); ?></p>
<p><strong>Course:</strong> <?php echo esc_html($cert->course_name); ?></p>
<p><strong>Issued On:</strong> <?php echo esc_html($cert->date_issued); ?></p>
<p><strong>Certificate ID:</strong> <?php echo esc_html($cert_hash); ?></p>
</div>
<?php
return ob_get_clean();
});