diff --git a/platforms/php/build.php b/platforms/php/build.php index 3126cc9..abb25b0 100644 --- a/platforms/php/build.php +++ b/platforms/php/build.php @@ -59,8 +59,8 @@ class Component_Builder { private string $dist_path = ''; function __construct( $args = [] ) { - if ( empty( $args['backPath'] ) || empty( $args['projectPath'] ) || empty( $args['blockName'] ) || empty( $args['platform'] ) ) { - die( 'Error: Missing arguments. Make sure all parameter passed.' ); + if ( ! isset( $args['backPath'] ) || ! isset( $args['projectPath'] ) || ! isset( $args['blockName'] ) || ! isset( $args['platform'] ) ) { + throw new \Exception( 'Error: Missing arguments. Make sure all parameter passed.' ); } $this->module_path = $args['backPath']; @@ -121,7 +121,7 @@ class Component_Builder { $t = file_put_contents( $file_path, '' ); if ( $t === false ) { - die( "Error: Can't generate HBS template to PHP file. Cache folder is not accessible." ); + throw new \Exception( "Error: Can't generate HBS template to PHP file. Cache folder is not accessible." ); } return $file_path; diff --git a/platforms/wordpress/templates/Template_Basic_Component.php b/platforms/wordpress/templates/Template_Basic_Component.php index c766331..2668222 100644 --- a/platforms/wordpress/templates/Template_Basic_Component.php +++ b/platforms/wordpress/templates/Template_Basic_Component.php @@ -44,8 +44,8 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) function register_elementor_widget( $widgets_manager ): void { require_once "helpers/<%= blockClassModel %>_Elementor_Widget.php"; $widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() ); - } - <% } %> + }<% } %> + } <% if (isComponentManager) { %><%= blockClassModel %>_Component::get_instance();<% } else { diff --git a/platforms/wordpress/templates/Template_Component.php b/platforms/wordpress/templates/Template_Component.php index 441f6d9..7abf665 100644 --- a/platforms/wordpress/templates/Template_Component.php +++ b/platforms/wordpress/templates/Template_Component.php @@ -24,15 +24,7 @@ class <%= blockClassModel %>_Component extends \Core\Component { wp_enqueue_script( 'script-block-<%= blockFilename %>' ); }<% } %> - <% if (include_elementor_widget) { %>function register_custom_logic(): void { - add_action( 'elementor/widgets/widgets_registered', [ $this, 'register_elementor_widget' ] ); - } - -<% } %><% if (include_elementor_widget) { %> function register_elementor_widget( $widgets_manager ) { - $widgets_manager->register_widget_type( new Helpers\<%= blockClassModel %>_Elementor_Widget() ); - } - -<% } %><% if (include_acf_block) { %> function register_acf_block() { + <% if (include_acf_block) { %> function register_acf_block() { $this->register_block( __DIR__ . "/<%= blockFilename %>.block.json", [ 'style_assets' => [ [