PrettyPhoto dependency / dequeuing WPIS
-
Hi there,
Sorry for posting another question so soon, but wanted to get your take on another issue.
I noticed that JavaScript is crashing on my shop page because WPIS is trying to run PrettyPhoto. Maybe it is typically available by default on the shop page, I’m not sure. Either way it isn’t in my case, so the plugin’s JS crashes.
Here’s the enqueuing function in the plugin:
function wpis_enqueue_scripts() { if (!is_admin()) { wp_enqueue_script('wpis-slick-js', plugins_url('assets/js/slick.min.js', __FILE__),array('jquery'),'1.6.0', false); wp_enqueue_script('wpis-fancybox-js', plugins_url('assets/js/jquery.fancybox.js', __FILE__),array('jquery'),'1.0', true); wp_enqueue_script('wpis-front-js', plugins_url('assets/js/wpis.front.js', __FILE__),array('jquery'),'1.0', true); wp_enqueue_style('wpis-fancybox-css', plugins_url('assets/css/fancybox.css', __FILE__),'1.0', true); wp_enqueue_style('wpis-front-css', plugins_url('assets/css/wpis-front.css', __FILE__),'1.0', true); } } add_action( 'wp_enqueue_scripts', 'wpis_enqueue_scripts' );
This looks to me like the WPIS scripts are being loaded on every single (non-admin) page. Or am I missing something? If not, would you know of a good way to remove this action for all pages but the single product page?
I think this should do it:
if( !is_product() ) remove_action( 'wp_enqueue_scripts', 'wpis_enqueue_scripts' );
But I can’t find the right place to run this code, early enough that it’s before the scripts are loaded but not before the
is_product()
function is available.Any thoughts much appreciated.
Simon
EDIT: my current solution that feels very hacky and not very future proof is to explicitly dequeue each script inside the
wp_enqueue_scripts
action and callwpis_enqueue_scripts()
from my single product template.
- The topic ‘PrettyPhoto dependency / dequeuing WPIS’ is closed to new replies.