database = $database;
// Changed Shortcode Name to be unique (tcvs_)
add_shortcode( 'tcvs_verification', array( $this, 'verification_form_shortcode' ) );
// Changed AJAX Handlers to tcvs_ prefix
add_action( 'wp_ajax_tcvs_verify_certificate', array( $this, 'ajax_verify_certificate' ) );
add_action( 'wp_ajax_nopriv_tcvs_verify_certificate', array( $this, 'ajax_verify_certificate' ) );
}
public function verification_form_shortcode( $atts ) {
wp_enqueue_style( 'tcvs-frontend-style' );
wp_enqueue_script( 'tcvs-frontend-script' );
ob_start();
?>
database->get_certificate_by_number( $certificate_number );
if ( ! $certificate ) {
wp_send_json_error( 'Certificate not found. Please check the number and try again.' );
}
$html = $this->display_certificate( $certificate );
wp_send_json_success( array( 'html' => $html ) );
}
public function display_certificate( $certificate ): string {
$settings = $this->database->get_institute_settings();
$inst_name = !empty($settings->institute_name) ? $settings->institute_name : 'Your Institute Name';
$inst_logo = $settings->institute_logo ?? '';
$inst_addr = $settings->institute_address ?? '';
$inst_phone = $settings->institute_phone ?? '';
$inst_email = $settings->institute_email ?? '';
$inst_sig = $settings->signature_image ?? '';
$verified_img = $settings->verified_by_image ?? '';
$date_source = '';
if ( ! empty( $certificate->issue_date ) && $certificate->issue_date !== '0000-00-00' ) {
$date_source = $certificate->issue_date;
} elseif ( ! empty( $certificate->created_at ) ) {
$date_source = $certificate->created_at;
} else {
$date_source = current_time( 'Y-m-d' );
}
$timestamp = strtotime( $date_source );
if ( $timestamp ) {
$formatted_date = date_i18n( get_option( 'date_format' ), $timestamp );
} else {
$formatted_date = date_i18n( get_option( 'date_format' ) );
}
ob_start();
?>
student_image)): ?>
Verify Your Certificate
THIS IS A VALID CERTIFICATE
student_image)): ?>
No Photo
student_name); ?>
Reg: certificate_number); ?>
Course Name
course_name); ?>
Batch No
batch_number); ?>
Issue Date
Institute
Phone: | Email:
Certificate of Completion
This is to certify that
student_name); ?>
Son/Daughter of father_name); ?>
has successfully completed the course
course_name); ?>
Registration No.
certificate_number); ?>
Batch No.
batch_number); ?>
Issue Date
Verified By
Principal Signature
