Added option to insert javascript in footer using wordpress standard wp_register option (requires dependencies in theme also be registered)

This commit is contained in:
Joe Black 2011-12-01 23:24:52 -08:00
parent 326bdd400f
commit d2e525519f
2 changed files with 17 additions and 7 deletions

View File

@ -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' ),

View File

@ -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';
$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' );
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' );
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 );