Skip to content

Instantly share code, notes, and snippets.

@mwangepatrick
Created December 20, 2021 17:04
Show Gist options
  • Save mwangepatrick/5eaf1be6e85f48fb1267747993faa158 to your computer and use it in GitHub Desktop.
Save mwangepatrick/5eaf1be6e85f48fb1267747993faa158 to your computer and use it in GitHub Desktop.
(function($){
/**
* initializeBlock
*
* Adds custom JavaScript to the block HTML.
*
* @date 15/4/19
* @since 1.0.0
*
* @param object $block The block jQuery element.
* @param object attributes The block attributes (only available when editing).
* @return void
*/
var initializeBlock = function( $block ) {
}
// Initialize each block on page load (front end).
$(document).ready(function(){
$('.testimonial').each(function(){
initializeBlock( $(this) );
});
});
// Initialize dynamic block preview (editor).
if( window.acf ) {
window.acf.addAction( 'render_block_preview/type=testimonial', initializeBlock );
}
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment