Permalink
Browse files

Activates noConflict mode for jQuery, and enqueues jQuery's Migrate p…

…lugin for backwards compatibility. Instantiates foundation.js to comply with jQuery noConflict mode.
  • Loading branch information...
1 parent 0987acd commit 07a51a9c4bdb3dc96350df2e28440f3c6dc811b4 @dalexisv83 dalexisv83 committed Mar 28, 2013
Showing with 15 additions and 1 deletion.
  1. +3 −1 footer.php
  2. +1 −0 js/jQuery-noConflict.js
  3. +11 −0 lib/clean.php
View
@@ -17,7 +17,9 @@
<?php wp_footer(); ?>
<script>
- $(document).foundation();
+ (function($) {
+ $(document).foundation();
+ })(jQuery);
</script>
</body>
@@ -0,0 +1 @@
+jQuery.noConflict();
View
@@ -120,6 +120,12 @@ function reverie_scripts_and_styles() {
wp_deregister_script('jquery');
// register Google jQuery
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js", false, null, true);
+
+ // register jQuery noConflict mode script
+ wp_register_script( 'jquery-noconflict', get_stylesheet_directory_uri() . '/js/jQuery-noConflict.js', array('jquery'), '1.0', true );
+
+ // register jQuery Migrate plugin (from code.jquery.com – "The minified production file is compressed and does not generate console warnings.")
+ wp_register_script( 'jquery-migrate', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://code.jquery.com/jquery-migrate-1.1.1.min.js", array('jquery'), '1.1.1', true );
// adding Foundation scripts file in the footer
wp_register_script( 'reverie-js', get_template_directory_uri() . '/js/foundation.min.js', array( 'jquery' ), '', true );
@@ -137,6 +143,11 @@ function reverie_scripts_and_styles() {
and your site will load faster.
*/
wp_enqueue_script( 'jquery' );
+
+ // enqueue jQuery noConflict mode script and Migrate plugin
+ wp_enqueue_script ('jquery-noconflict');
+ wp_enqueue_script ('jquery-migrate');
+
wp_enqueue_script( 'reverie-js' );
wp_enqueue_script( 'html5shiv' );

0 comments on commit 07a51a9

Please sign in to comment.