Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created August 15, 2016 11:00
Show Gist options
  • Save stephenharris/5dd78b70dd81e082dc169ec4ba5c51c2 to your computer and use it in GitHub Desktop.
Save stephenharris/5dd78b70dd81e082dc169ec4ba5c51c2 to your computer and use it in GitHub Desktop.
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