Skip to content

Instantly share code, notes, and snippets.

@stephenharris stephenharris/init-masonry.js Secret
Created Aug 15, 2016

Embed
What would you like to do?
37666 - masonry shim bug
jQuery(document).ready(function ($) {
var $container = $('.grid');
$container.masonry({
isAnimated: true,//this option is causing the error
});
});
<?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
You can’t perform that action at this time.