-
-
Save stephenharris/5dd78b70dd81e082dc169ec4ba5c51c2 to your computer and use it in GitHub Desktop.
37666 - masonry shim bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery(document).ready(function ($) { | |
var $container = $('.grid'); | |
$container.masonry({ | |
isAnimated: true,//this option is causing the error | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin demonstrating bug with Masonry v2 shim | |
* | |
* @see https://core.trac.wordpress.org/ticket/37666 | |
*/ | |
function register_scripts(){ | |
wp_register_script( 'init-masonry', plugin_dir_url( __FILE__ )."init-masonry.js", array( 'jquery', 'jquery-masonry' ) ); | |
} | |
add_action( 'init', 'register_scripts' ); | |
function insert_grid( $atts = array() ){ | |
wp_enqueue_script( 'init-masonry' ); | |
return '<div class="grid"> | |
<div class="grid-item">...</div> | |
<div class="grid-item">...</div> | |
<div class="grid-item">...</div> | |
</div>'; | |
} | |
add_filter( 'the_content', 'insert_grid' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment