Skip to content

Commit

Permalink
Properly register scripts using wp_register_script prior to enqueuing
Browse files Browse the repository at this point in the history
  • Loading branch information
devin committed Jul 14, 2015
1 parent ab19fc1 commit 6a515f4
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions includes/scripts.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,20 +65,32 @@ function give_load_scripts() {
if ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ) {

if ( give_is_cc_verify_enabled() ) {
wp_enqueue_script( 'give-cc-validator', $js_plugins . 'jquery.creditCardValidator' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_register_script( 'give-cc-validator', $js_plugins . 'jquery.creditCardValidator' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-cc-validator' );
}

wp_enqueue_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-mask-money', $js_plugins . 'jquery.maskMoney' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-magnific', $js_plugins . 'give-magnific' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_register_script( 'give-blockui', $js_plugins . 'jquery.blockUI' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-blockui' );

wp_register_script( 'give-qtip', $js_plugins . 'jquery.qtip' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-qtip' );

wp_register_script( 'give-mask-money', $js_plugins . 'jquery.maskMoney' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-mask-money' );

wp_register_script( 'give-magnific', $js_plugins . 'give-magnific' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-magnific' );

wp_register_script( 'give-checkout-global', $js_dir . 'give-checkout-global' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-checkout-global' );

//General scripts
wp_enqueue_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_register_script( 'give-scripts', $js_dir . 'give' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-scripts' );

// Load AJAX scripts, if enabled
wp_enqueue_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_register_script( 'give-ajax', $js_dir . 'give-ajax' . $suffix . '.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give-ajax' );

//Localize / Pass AJAX vars from PHP
wp_localize_script( 'give-checkout-global', 'give_global_vars', $localize_give_checkout );
Expand All @@ -88,7 +100,8 @@ function give_load_scripts() {
} else {

//DEBUG is OFF (one JS file to rule them all!)
wp_enqueue_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION );
wp_register_script( 'give', $js_dir . 'give.all.min.js', array( 'jquery' ), GIVE_VERSION );
wp_enqueue_script( 'give' );

//Localize / Pass AJAX vars from PHP
wp_localize_script( 'give', 'give_global_vars', $localize_give_checkout );
Expand Down

0 comments on commit 6a515f4

Please sign in to comment.