post_content, 'pdf_viewer')) { wp_enqueue_script('pdfjs', 'https://cdnjs.cloudflare.com/ajax/libs/pdf.js/3.11.174/pdf.min.js', array(), '3.11.174', true); wp_enqueue_script('pdf-viewer-js', get_template_directory_uri() . '/js/pdf-viewer.js', array('pdfjs'), '1.0', true); wp_enqueue_style('pdf-viewer-css', get_template_directory_uri() . '/css/pdf-viewer.css', array(), '1.0'); } } add_action('wp_enqueue_scripts', 'pdf_viewer_enqueue_scripts'); // Create the shortcode function pdf_viewer_shortcode($atts) { // Set default attributes $atts = shortcode_atts(array( 'url' => 'https://theblock.ae/wp-content/uploads/2025/06/VARA_EN_293_VER20250519.pdf', 'title' => 'VARA Document EN 293 Ver 20250519', 'height' => '600px', 'id' => 'pdf-viewer-' . uniqid() ), $atts, 'pdf_viewer'); // Validate URL - should not be empty after defaults are applied if (empty($atts['url']) || $atts['url'] === '') { return '
Error: PDF URL is required
'; } // Create unique ID for multiple PDFs on same page $viewer_id = sanitize_html_class($atts['id']); $pdf_url = esc_url($atts['url']); $pdf_title = esc_html($atts['title']); $height = esc_attr($atts['height']); // Generate the HTML ob_start(); ?>
Page 1-2 of 0
Loading PDF...
post_content, 'pdf_viewer')) { ?> post_content, 'pdf_viewer')) { ?>