$certificate_id, 'code' => $verification_code ), $atts); if (empty($atts['id'])) { return '
Certificate ID is required
'; } $verification = ACCEVE_Certificate_Verification::get_instance(); $certificate = $verification->verify_certificate($atts['id'], $atts['code']); $resolved = ACCEVE_Certificate_Verification::resolve_certificate_template_for_display($certificate); $certificate_template = $resolved['certificate_template']; ob_start(); if ($certificate && ($certificate !== 'expired') && ($certificate !== 'inactive')) { wp_enqueue_script('cert-verification-frontend'); if ($certificate_template === 'custom_template' && $resolved['certificate_custom_template'] > 0) { $template_id = intval($resolved['certificate_custom_template']); if (class_exists('Certificate_Verification_Pro_Template')) { $pro_template = Certificate_Verification_Pro_Template::get_instance(); if (method_exists($pro_template, 'display_custom_template')) { $pro_template->display_custom_template($certificate, $template_id); } else { include ACCEVE_PATH . 'templates/certificate-template.php'; } } else { include ACCEVE_PATH . 'templates/certificate-template.php'; } } elseif ($certificate_template === 'template_two') { if (class_exists('Certificate_Verification_Pro_Template')) { $pro_template = Certificate_Verification_Pro_Template::get_instance(); $pro_template->verify_template_two($certificate); } else { include ACCEVE_PATH . 'templates/certificate-template.php'; } } else { include ACCEVE_PATH . 'templates/certificate-template.php'; } /** * Fires on the verify-certificate page after the certificate is displayed * and before the share section (e.g. PDF download button). * * @param object $certificate Verified certificate object. * @param array $atts Shortcode attributes. */ do_action('acceve_before_certificate_share', $certificate, $atts); if (class_exists('Certificate_Verification_Pro_Template')) { $options = get_option('acceve_certificate_verification_options'); $enabled = ! empty($options['enable_certificate_share']); if ($enabled){ $page_base = get_permalink(); if (!$page_base) { $page_base = home_url('/'); } $share_args = array('id' => $atts['id']); if (!empty($atts['code'])) { $share_args['code'] = $atts['code']; } $share_url = add_query_arg($share_args, $page_base); $share_title = sprintf( /* translators: %s: certificate ID */ __('Verified certificate: %s', 'academic-certificate-verification'), $atts['id'] ); $student_name = (is_object($certificate) && !empty($certificate->student_name)) ? $certificate->student_name : ''; if ($student_name) { $share_text = sprintf( /* translators: 1: student name, 2: site name */ __('Certificate for %1$s — verified on %2$s.', 'academic-certificate-verification'), $student_name, get_bloginfo('name') ); } else { $share_text = sprintf( /* translators: %s: site name */ __('View this verified certificate on %s.', 'academic-certificate-verification'), get_bloginfo('name') ); } include ACCEVE_PATH . 'templates/certificate-share-bar.php'; } } } else { include ACCEVE_PATH . 'templates/verification-result.php'; } return ob_get_clean(); } /** * Enqueue frontend assets. * * @return void * @since 1.0.0 */ public function load_frontend_assets() { wp_register_style( 'cert-verification-frontend', ACCEVE_URL . 'assets/css/frontend.css', array(), ACCEVE_VERSION ); wp_register_script( 'cert-verification-frontend', ACCEVE_URL . 'assets/js/frontend.js', array('jquery'), ACCEVE_VERSION, true ); wp_localize_script( 'cert-verification-frontend', 'certificate_verification', array( 'ajax_url' => admin_url('admin-ajax.php'), 'nonce' => wp_create_nonce('certificate_verification_nonce'), 'copy_failed' => __('Could not copy link.', 'academic-certificate-verification'), ) ); } }