Fix JS enqueue. Closes #1365.

This commit is contained in:
Mike Jolley 2012-08-12 13:15:27 +01:00
parent d5163c5638
commit 402799c0eb
3 changed files with 133 additions and 130 deletions

View File

@ -154,6 +154,8 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Fix - Missing grouped product cart buttons
* Fix - Notice in invoice template with number_format
* Fix - Made variation get_image() return instead of echo
* Fix - Remove is_product check so variation JS can register itself for use. Same for the single product JS
* Fix - Above fix also fixes single product shortcodes
= 1.6.3 - 10/08/2012 =
* Feature - Option to register using the email address as the username instead of entering a username

View File

@ -514,7 +514,7 @@ function woocommerce_product_page_shortcode( $atts ) {
ob_start();
while ( $single_product->have_posts() ) : $single_product->the_post(); ?>
while ( $single_product->have_posts() ) : $single_product->the_post(); wp_enqueue_script( 'wc-single-product' ); ?>
<div class="single-product">

View File

@ -953,6 +953,8 @@ class Woocommerce {
* Register/queue frontend scripts
*/
function frontend_scripts() {
global $post;
$suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
$lightbox_en = get_option('woocommerce_enable_lightbox') == 'yes' ? true : false;
$chosen_en = get_option( 'woocommerce_enable_chosen' ) == 'yes' ? true : false;
@ -962,9 +964,8 @@ class Woocommerce {
wp_register_script( 'chosen', $this->plugin_url() . '/assets/js/chosen/chosen.jquery' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_register_script( 'jquery-ui', $this->plugin_url() . '/assets/js/jquery-ui' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_register_script( 'jquery-plugins', $this->plugin_url() . '/assets/js/jquery-plugins' . $suffix . '.js', array( 'jquery' ), '1.6', true );
if ( is_product() )
wp_register_script( 'wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_register_script( 'wc-add-to-cart-variation', $frontend_script_path . 'add-to-cart-variation' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_register_script( 'wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array( 'jquery' ), '1.6', true );
// Queue frontend scripts conditionally
if ( get_option( 'woocommerce_enable_ajax_add_to_cart' ) == 'yes' )
@ -977,9 +978,9 @@ class Woocommerce {
wp_enqueue_script( 'wc-checkout', $frontend_script_path . 'checkout' . $suffix . '.js', array( 'jquery' ), '1.6', true );
if ( is_product() )
wp_enqueue_script( 'wc-single-product', $frontend_script_path . 'single-product' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_enqueue_script( 'wc-single-product' );
if ( $lightbox_en && is_product() ) {
if ( $lightbox_en && ( is_product() || ( ! empty( $post->post_content ) && strstr( $post->post_content, '[product_page' ) ) ) ) {
wp_enqueue_script( 'fancybox', $this->plugin_url() . '/assets/js/fancybox/fancybox' . $suffix . '.js', array( 'jquery' ), '1.6', true );
wp_enqueue_style( 'woocommerce_fancybox_styles', $this->plugin_url() . '/assets/css/fancybox.css' );
}