Update build of ACF blocks.
This commit is contained in:
@@ -8,20 +8,22 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
$args = array_merge( Helpers\<%= blockClassModel %>_Defaults::default_args(), $args );
|
$args = array_merge( Helpers\<%= blockClassModel %>_Defaults::default_args(), $args );
|
||||||
$args = Helpers\<%= blockClassModel %>_API::prepare_args( $args );
|
$args = Helpers\<%= blockClassModel %>_API::prepare_args( $args );
|
||||||
|
|
||||||
<% if (templateFormat === 'hbs') { %>return $this->get_component_template( __DIR__ . '/templates/<%= blockFilename %>.template.hbs', $args );<% } %>
|
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( array_merge( [], $args ), self::class );
|
||||||
<% if (templateFormat === 'php') { %>
|
return apply_filters( 'the_content', wpautop( $output ) );
|
||||||
$output = ( include( __DIR__ . '/templates/<%= blockFilename %>.template.php' ) )( array_merge( [], $args ), self::class );
|
|
||||||
echo apply_filters( 'the_content', wpautop( $output ) );
|
|
||||||
<% } %>
|
|
||||||
}
|
}
|
||||||
|
|
||||||
<% if (!include_acf_block && !include_native_gutenberg_block) { %>
|
<% if (!include_acf_block && !include_native_gutenberg_block) { %>function register_assets(): void {
|
||||||
public function register_assets() {
|
$version = get_plugin_data( __DIR__ . "/../../scytale-custom-blocks.php" )['Version']; // In Plugins
|
||||||
$this->add_style( __DIR__ . '/templates/styles/<%= blockFilename %>.min.css' );
|
// $version = \Core\Global_Functions::get_current_version_number(); // In Theme
|
||||||
<% if (include_script) { %>$this->add_script( __DIR__ . '/templates/scripts/<%= blockFilename %>.js' );<% } %>
|
|
||||||
}
|
|
||||||
|
|
||||||
<% } %><% if (include_elementor_widget) { %> function register_custom_logic(): void {
|
// $base_path = get_template_directory_uri() . '/components/partials/<%= blockFilename %>/';
|
||||||
|
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['wp-block-library'], get_blocks_version() );<% if (include_script) { %>
|
||||||
|
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version() );<% } %>
|
||||||
|
|
||||||
|
wp_enqueue_script( 'script-<%= blockFilename %>' );
|
||||||
|
}<% } %>
|
||||||
|
|
||||||
|
<% if (include_elementor_widget) { %>function register_custom_logic(): void {
|
||||||
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] );
|
add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,8 +34,8 @@ class <%= blockClassModel %>_Component extends \Core\Component {
|
|||||||
<% } %><% if (include_acf_block) { %> function register_acf_block() {
|
<% } %><% if (include_acf_block) { %> function register_acf_block() {
|
||||||
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
|
$this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [
|
||||||
'enqueue_assets' => function () {
|
'enqueue_assets' => function () {
|
||||||
wp_enqueue_style( '<%= blockFilename %>', \Core\Global_Functions::get_file_url( __DIR__ . '/templates/styles/<%= blockFilename %>.min.css', true ), [], get_blocks_version() );<% if (include_script) { %>
|
wp_enqueue_style( '<%= blockFilename %>', plugins_url( 'templates/styles/<%= blockFilename %>.min.css', __FILE__ ), ['wp-block-library'], get_blocks_version() );<% if (include_script) { %>
|
||||||
wp_enqueue_script( '<%= blockFilename %>', \Core\Global_Functions::get_file_url( __DIR__ . '/templates/scripts/<%= blockFilename %>.js', true ), ['assets-script'], get_blocks_version() );<% } %>
|
wp_enqueue_script( '<%= blockFilename %>', plugins_url( 'templates/scripts/<%= blockFilename %>.min.js', __FILE__ ), ['assets-script'], get_blocks_version() );<% } %>
|
||||||
},
|
},
|
||||||
'default' => Helpers\<%= blockClassModel %>_Defaults::default_args(),
|
'default' => Helpers\<%= blockClassModel %>_Defaults::default_args(),
|
||||||
'supports' => [
|
'supports' => [
|
||||||
|
|||||||
@@ -34,10 +34,10 @@ export async function buildWordPress(blockName, isBlock = false, isElementor = f
|
|||||||
ownerClass: owner.replace(/ /ig, '_'),
|
ownerClass: owner.replace(/ /ig, '_'),
|
||||||
ownerFilename: owner.toLowerCase().replace(/ /ig, '-'),
|
ownerFilename: owner.toLowerCase().replace(/ /ig, '-'),
|
||||||
templateFormat: 'php',
|
templateFormat: 'php',
|
||||||
include_acf_block: false,
|
include_acf_block: isBlock,
|
||||||
include_native_gutenberg_block: false,
|
include_native_gutenberg_block: false,
|
||||||
include_script: true,
|
include_script: true,
|
||||||
include_elementor_widget: false,
|
include_elementor_widget: isElementor,
|
||||||
isElementor,
|
isElementor,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user