Skip to content
PHP Filters

lzb_pro/block_script/template

Filters block script template path for custom JavaScript functionality of blocks.

This filter allows you to customize the template path used for block scripts in Lazy Blocks Pro.

Attributes

NameTypeDescription
$templateStringblock script template path
$template_nameStringtemplate name
$blockArrayblock data
$contextStringrendering context [editor, frontend]

Additional Filters

NameDescription
BLOCK_SLUG/frontend_script_templatespecific block in the frontend only
BLOCK_SLUG/editor_script_templatespecific block in the editor only
BLOCK_SLUG/script_templatespecific block only

Usage

PHP
function my_lzb_pro_block_script_template( $template, $template_name, $block, $context ) {
  // Custom script template for all blocks
  return '/YOUR_CUSTOM/SCRIPT/PATH.js';
}
 
add_filter( 'lzb_pro/block_script/template', 'my_lzb_pro_block_script_template', 10, 4 );
PHP
function my_lzb_pro_block_script_template( $template, $template_name, $block, $context ) {
  // Custom script template for specific block
  if ( $block['slug'] === 'my-custom-block' ) {
    return '/YOUR_CUSTOM/SCRIPT/PATH.js';
  }
  return $template;
}
 
add_filter( 'lzb_pro/block_script/template', 'my_lzb_pro_block_script_template', 10, 4 );
PHP
function my_lzb_pro_block_script_template( $template, $template_name, $block ) {
  // Custom script template for block "my-custom-block"
  return '/YOUR_CUSTOM/SCRIPT/PATH.js';
}
 
add_filter( 'my-custom-block/script_template', 'my_lzb_pro_block_script_template', 10, 3 );

Was this article helpful?