Skip to content

Instantly share code, notes, and snippets.

@amberhinds
Created September 19, 2016 17:29
Show Gist options
  • Save amberhinds/01096e2a84959af5c91282429690247b to your computer and use it in GitHub Desktop.
Save amberhinds/01096e2a84959af5c91282429690247b to your computer and use it in GitHub Desktop.
Add Woocommerce lightbox scripts on other parts of the site (put on specific page templates or in functions.php)
<?php
add_action( 'wp_enqueue_scripts', 'frontend_scripts_include_lightbox' );
function frontend_scripts_include_lightbox() {
global $woocommerce;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$lightbox_en = get_option( 'woocommerce_enable_lightbox' ) == 'yes' ? true : false;
if ( $lightbox_en ) {
wp_enqueue_script( 'prettyPhoto', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto' . $suffix . '.js', array( 'jquery' ), '3.1.5', true );
wp_enqueue_script( 'prettyPhoto-init', $woocommerce->plugin_url() . '/assets/js/prettyPhoto/jquery.prettyPhoto.init' . $suffix . '.js', array( 'jquery' ), $woocommerce->version, true );
wp_enqueue_style( 'woocommerce_prettyPhoto_css', $woocommerce->plugin_url() . '/assets/css/prettyPhoto.css' );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment