Hi Nayeem,
I’m not looking for custom coding, just trying to understand how the [doc_preview] shortcode works, specifically wanting to understand how to pass a package ID to it. I don’t see any documents on it.
As for what’s not working on your site:
https://try.wpdownloadmanager.com/download/password-protected-pdf-file/
They’re both throwing 401 and 500 errors.
Kind regards,
-Scott
For what it is worth, it seems the PDF Viewer is broken on the WPDM demo site, I was trying to see if I can find answers to my question. None of the demo PDFs are working.
Thanks!
-Scott
Hi Nayeem,
That server just recently got shutdown to outside addresses. The errors are above though. I’m working on getting the environment setup so you can look at it.
In a related note, is it possible to pass the package ID into the [doc_preview] shortcode? I am working on a solution with JavaScript that would help me prevent loading all of these PDFs on the page, multiple modals, etc. it’s just really inefficient and a massive resource hog.
I would like to have a single modal, have a grid of PDf documents on the screen (like my policies page), and when they click the button that fires the modal, I can then pass the document ID into the modal where [doc_preview] is which will load the document on demand when needed. How can I pass the package ID into [doc_preview]?
Thanks!
-Scott
Hi Nayeem, in addition to the errors posted above, I am also now seeing this issue that breaks closing the modal when popped up, unless a user clicks outside of the modal. This seems to be related to accessibility.
Blocked aria-hidden on an element because its descendant retained focus. The focus must not be hidden from assistive technology users. Avoid using aria-hidden on a focused element or its ancestor. Consider using the inert attribute instead, which will also prevent focus. For more details, see the aria-hidden section of the WAI-ARIA specification at https://w3c.github.io/aria/#aria-hidden.
Element with focus: div
Ancestor with aria-hidden: <div class=โ”modal fade modal-lg” id=โ”exampleModal-37550″ tabindex=โ”-1″ aria-labelledby=โ”exampleModalLabel” style=โ”display:โ none;โ” aria-hidden=โ”true”>โ<!– aria-modal=”true” aria-hidden=”true” –><div class=โ”modal-dialog” role=โ”document” style=โ”width:โ 1040px;โmax-width:โ 100%;โ”>โ<div class=โ”modal-content”>โflex<div class=โ”modal-header”>โflex<h5>โNEOnet Fee Scheduleโ</h5>โ<button type=โ”button” class=โ”close” data-dismiss=โ”modal” aria-label=โ”Close”>โ<span>โรโ</span>โ<!– aria-hidden=”true” –></button>โ</div>โ<div class=โ”modal-body”>โ<iframe id=โ”viewer-37550″ class=โ”thumbnail” src=โ”https:โ/โ/โneonet.org/โ?__wpdm_pdf_viewer=37550|1726755538027″ style=โ”width:โ 100%;โheight:โ 700px;โmargin-bottom:โ 15px;โborder:โ 1px solid #dddddd;โpadding:โ 0;โbackground:โ #f9f9fa”>โโฆโ</iframe>โ</div>โ<!– div class=”modal-footer”>
<button type=”button” class=”btn btn-secondary” data-dismiss=”modal”>Close</button>
</div –></div>โ</div>โ</div>โ
Hi Nayeem,
I am testing now. It does look like the 404 error is gone but there are numerous other errors posting:
I also have an issue with aria-hidden throwing an error and preventing the use of a close button I am trying to address.
https://dev.neonet.org/policies
Thanks!
-Scott
Hello Nayeem,
Thank you for confirming, please let me know when an update to the plugin is ready.
Kind regards,
-Scott
Hi Nayeem,
In 6.7.0 your company removed bootstrap from your plugin. You have not removed the calls to bootstrap from, I presume, the PDF Viewer add-on.
I’ve had to hide the actual modal “close” button, which end users likely expect to have access to, because it would not work.
Given this, it doesn’t actually work as it should, and spitting out numerous 404 errors on pages is really unhelpful. Will this be fixed?
Thanks!
-Scott
Hello Again,
I see in 6.7.0 you did remove bootstrap, which is fine and dandy, but the packages by category combined with the PDFviewer modal still seems to require it and is throwing errors. I don’t have anything explicitly calling for bootstrap, so how do I fix this issue?
Kind regards,
-Scott
Hi Nayeem,
Thanks for this, I’ll let you know how it goes once we get to the load balancing steps.
Be well!
-Scott
Hi Nayeem,
I see this: Update! Enhanced System Optimization and Compatibility Assurance Update, but I’m curious what was optimized?
In my situation, to avoid loading the same styles and JS files over and over for every package on a page, I have to find a way to only call [doc_preview] when I’m actually wanting to display the PDF Viewer.
For example on this page: https://dev.neonet.org/policies/
Every time the “view Policy” button is displayed, it calls all.css, viewer.css, viewer.js, etc. etc. etc. It’s causing issues with our overall site performance and we must find a better solution. Those files only need to be present on the page one time, and they only need to be present on pages that use this feature.
They seem to be pulled into the page through the inclusion of the [doc_preview] shortcode. If I can modify my modal buttons so that they call a separate php file that does 2 simple things… passes the package ID on the URL, and loads the [doc_preview] shortcode, I should be able to resolve this issue.
Thanks!
-Scott
Hi Nayeem,
This continues to be a problem, so I’ve been researching some alternate ways to prevent loading all of the repeating files causing unnecessary server calls, on just one page we have 300+ that can be eliminated if I can simply load those styles and JS files once.
Currently I am exploring a link template that I can apply to my Packages by category Elementor widget whereby instead of including [doc_preview] in the link template, which then causes all of the repeating files to load for every package in the category, I would like to make it so that the modal button calls another script/page and passes in the package ID where that new page/script loads [doc_preview]. This will ensure that regardless of how many packages are in the category and displayed on a single page, none of the other resources will be called until you click the modal button.
However, in my new page/script, even though I can confirm that WPDM and the WPDM PDF Viewer plugins are active, the [doc_preview] shortcode is not registered. Can you provide any guidance on how to ensure that shortcode is registered?
Also, I see WPDM PDF Viewer 3.1.0 just released, are there any details to the changelog available?
Thanks!
-Scott
Hi Nayeem,
Can you clarify what it is you think I’m wishing to have embedded? Based on what I pasted above, I just want to not link to the CSS and JS resources and instead enqueue them whereby the WordPress engine will insure they only load once regardless of how many packages exist on the page.
Change these links:
<link rel=”stylesheet” href=”<?= plugins_url(‘wpdm-pdf-viewer/pdfjs/web/viewer.css’) ?>”>
<link rel=”stylesheet” href=”<?= WPDM_ASSET_URL ?>bootstrap/css/bootstrap.min.css”>
<link rel=”stylesheet” href=”<?= WPDM_ASSET_URL ?>css/front.min.css”>
<link rel=”stylesheet” href=”<?= WPDM_FONTAWESOME_URL ?>”>
To enqueue:
wp_enqueue_script(‘pdf-js’, ‘path/to/pdf.js’, array(), ‘version’, true);
wp_enqueue_script(‘pdf-worker-js’, ‘path/to/pdf.worker.js’, array(‘pdf-js’), ‘version’, true);
wp_enqueue_script(‘viewer-js’, ‘path/to/viewer.js’, array(‘pdf-js’), ‘version’, true);
I believe once it is enqueued it won’t call it again, correct?
Thanks!
-Scott
Hi Nayeem,
It actually is an issue, under light load, it can appear to load up quickly. But try viewing one of the PDF modals as soon as the page loads. It sits and spins waiting for the rest of the page content to load, which happens to the be the 5+ linked resources the packages by category template is loading repeatedly for every package.
I have other pages, behind the login screen, that are significantly worse because they have 20 or so linked PDFs. Again, 20 packages and 5+ files per package being called from the server. It drives up memory and CPU usage and makes for a poor customer experience overall.
Unless I’m mistaken, it’s actually a pretty easy fix if the code simply enqueues the files once and doesn’t reference them by links.
Thanks,
-Scott
Hi Nayeem,
The way it works, as a midday pop-up, iframe, etc is actually fine.
What I would like to see dev fix is to not directly link to the individual JS and CSS files but rather enqueue them the way WordPress expects. With this change you can enqueue them once and they went repeat for every package. They only need to be loaded once on the page regardless of the number of packages. You’ll see significant performance impact with this fix.
Does that help?
Thanks!
Scott
Thanks, this wasn’t looking like it was posting for some reason, you can close this one and we can work in the other thread. ๐
Hi Nayeem,
I’m using [doc_preview] in the templates, thanks!
-Scott
Hi Nayeem,
Checking on this issue as well, thanks so much!
-Scott
Hi Nayeem,
Is the full URL that was attached captured and identified by a variable I could pull into my template so I can embed that YouTube link? Right now I am using the title and so my users have to fix the title with the full URL for this to work. If the URL exists in another field and I can use that, that would suffice.
Thanks!
-Scott
Awesome, thank you so much!
-Scott
Hi Nayeem,
Here are two screenshots:
This is the page where we’ve used multiple packages by category:
This is the dev-tools output (a sample) where there are 700+ server requests and you can see all of the repeating resources:
Here is the header of /wp-content/plugins/wpdm-pdf-viewer/tpls/pdf-viewer.php showing resource links as opposed to enqueuing the scripts just once. With the links used, they are getting repeated:
<?php
/**
* User: shahnuralam
* Date: 9/17/17
* Time: 2:14 AM
*/
if(!defined('ABSPATH')) die();
$pdf = isset($_GET['__wpdm_pdf_viewer'])?esc_attr($_GET['__wpdm_pdf_viewer']):'';
$_GET['file'] = $pdf;
?>
<!DOCTYPE html>
<html dir="ltr" mozdisallowselectionprint moznomarginboxes>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>PDF Viewer</title>
<link rel="stylesheet" href="<?php echo plugins_url('wpdm-pdf-viewer/assets/css/viewer.css'); ?>">
<link rel="stylesheet" href="<?php echo WPDM_BASE_URL; ?>assets/bootstrap3/css/bootstrap.css">
<link rel="stylesheet" href="<?php echo WPDM_BASE_URL; ?>assets/css/front3.css">
<script src="<?php echo plugins_url('wpdm-pdf-viewer/assets/pdfjs/pdf.js'); ?>"></script>
<script src="<?php echo plugins_url('wpdm-pdf-viewer/assets/js/viewer.js'); ?>"></script>
<style>
Here’s the header of viewer.php – wp-content/plugins/wpdm-pdf-viewer/tpls/viewer.php
<?php
$file_info = explode("|", $_GET['__wpdm_pdf_viewer']);
$pid = wpdm_valueof($file_info, 0);
$fileid = wpdm_valueof($file_info, 1, '');
do_action("wpdm_before_render_pdf_viewer", $pid, $fileid);
?><!DOCTYPE html>
<!--
Copyright 2012 Mozilla Foundation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Adobe CMap resources are covered by their own copyright but the same license:
Copyright 1990-2015 Adobe Systems Incorporated.
See https://github.com/adobe-type-tools/cmap-resources
-->
<html dir="ltr" mozdisallowselectionprint>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="google" content="notranslate">
<meta name="robots" content="noindex">
<meta name="robots" content="nofollow">
<title>PDF.js viewer</title>
<?php \WPDM\__\Apply::uiColors(); ?>
<link rel="stylesheet" href="<?= plugins_url('wpdm-pdf-viewer/pdfjs/web/viewer.css') ?>">
<link rel="stylesheet" href="<?= WPDM_ASSET_URL ?>bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="<?= WPDM_ASSET_URL ?>css/front.min.css">
<link rel="stylesheet" href="<?= WPDM_FONTAWESOME_URL ?>">
<script>
Does that help? You can see this here: https://dev.neonet.org/policies/
Thanks!
-Scott
I’m curious if there is an option to use hooks or theme templates or similar option to over ride the default repetitive loading of styles and js files?
Thanks!
-Scott
One option might be to enqueue the scripts and CSS so they only load once?
function my_custom_enqueue_scripts() {
wp_enqueue_script('pdf-js', 'path/to/pdf.js', array(), 'version', true);
wp_enqueue_script('pdf-worker-js', 'path/to/pdf.worker.js', array('pdf-js'), 'version', true);
wp_enqueue_script('viewer-js', 'path/to/viewer.js', array('pdf-js'), 'version', true);
}
add_action('wp_enqueue_scripts', 'my_custom_enqueue_scripts');
Since that post seemed to take, here’s the issue.
Hello,
When using the PDF Viewer Add-On in a template used in Packages by Category (Elementor), the following files get repeated for every button presented. It seems the code could be written to enqueue the scripts and CSS once which would have a significant impact on page performance. Is this something we can do on our own, or would this fix need done on your end?
wp-content/plugins/wpdm-pdf-viewer/pdfjs/web/viewer.css
wp-content/plugins/download-manager/assets/bootstrap/css/bootstrap.min.css
wp-content/plugins/download-manager/assets/css/front.min.css
https://use.fontawesome.com/releases/v6.2.0/css/all.css
wp-content/plugins/wpdm-pdf-viewer/pdfjs/build/pdf.js
wp-content/plugins/wpdm-pdf-viewer/pdfjs/web/viewer.js
wp-includes/js/jquery/jquery.js
wp-includes/js/jquery/jquery.form.js
wp-content/plugins/wpdm-pdf-viewer/pdfjs/web/locale/locale.properties
Have 20 packages in a category and then call those files for all 20 packages is quite taxing.
Perhaps one option would be to enqueue the scripts as opposed to link to them within the HTML attributes in the code?
Look forward to your suggestions.
Apologies if this is a dupe, I’m not seeing it post to the forum.
Kind regards,
-Scott
Hello, I’m trying to post a support request and it’s not making it into the forum. It has to do with this thread and the PDF Viewer Add on.
Hello, just checking on this issue. Thanks!
-Scott