diff --git a/admin/admin-settings.php b/admin/admin-settings.php index 4f64ccf6bcc..595f31b9440 100644 --- a/admin/admin-settings.php +++ b/admin/admin-settings.php @@ -189,6 +189,14 @@ $woocommerce_settings['general'] = apply_filters('woocommerce_general_settings', 'checkboxgroup' => 'end' ), + array( + 'name' => __( 'Javascript', 'woothemes' ), + 'desc' => __( 'Enable Output of JavaScript in the footer?', 'woothemes' ), + 'id' => 'woocommerce_scripts_position', + 'std' => 'yes', + 'type' => 'checkbox' + ), + array( 'name' => __( 'Demo store notice', 'woothemes' ), 'desc' => __( 'Enable the "Demo Store" notice on your site', 'woothemes' ), diff --git a/woocommerce.php b/woocommerce.php index e08bfa287ac..957f69b7a76 100644 --- a/woocommerce.php +++ b/woocommerce.php @@ -133,7 +133,7 @@ function woocommerce_init() { } /** - * Init WooCommerce Tempalte Functions + * Init WooCommerce Template Functions * * This makes them pluggable by plugins and themes **/ @@ -234,15 +234,17 @@ function woocommerce_frontend_scripts() { global $woocommerce; $suffix = defined('SCRIPT_DEBUG') && SCRIPT_DEBUG ? '' : '.min'; - - wp_register_script( 'woocommerce', $woocommerce->plugin_url() . '/assets/js/woocommerce'.$suffix.'.js', 'jquery', '1.0' ); - wp_register_script( 'woocommerce_plugins', $woocommerce->plugin_url() . '/assets/js/woocommerce_plugins'.$suffix.'.js', 'jquery', '1.0' ); - wp_register_script( 'fancybox', $woocommerce->plugin_url() . '/assets/js/fancybox'.$suffix.'.js', 'jquery', '1.0' ); - + $lightbox_en = (get_option('woocommerce_enable_lightbox')=='yes') ? 0 : 1; + $scripts_position = (get_option('woocommerce_scripts_position') == 'yes') ? true : false; + + wp_register_script( 'woocommerce', $woocommerce->plugin_url() . '/assets/js/woocommerce'.$suffix.'.js', 'jquery', '1.0', $scripts_position ); + wp_register_script( 'woocommerce_plugins', $woocommerce->plugin_url() . '/assets/js/woocommerce_plugins'.$suffix.'.js', 'jquery', '1.0', $scripts_position ); + if $lightbox_en wp_register_script( 'fancybox', $woocommerce->plugin_url() . '/assets/js/fancybox'.$suffix.'.js', 'jquery', '1.0', $scripts_position ); + wp_enqueue_script('jquery'); wp_enqueue_script('woocommerce_plugins'); wp_enqueue_script('woocommerce'); - if (get_option('woocommerce_enable_lightbox')=='yes') wp_enqueue_script('fancybox'); + if $lightbox_en wp_enqueue_script('fancybox'); /* Script variables */ $states = json_encode( $woocommerce->countries->states );