From df7866b8b5ea7dac82fae3571eadec4a40798081 Mon Sep 17 00:00:00 2001 From: Roman Axelrod Date: Mon, 2 Jan 2023 14:23:11 +0200 Subject: [PATCH] Updated Build Template of Elementor block. --- .../templates/Template_Basic_Component.php | 3 ++- .../helpers/Template_Elementor_Widget.php | 22 ++++--------------- 2 files changed, 6 insertions(+), 19 deletions(-) diff --git a/platforms/wordpress/templates/Template_Basic_Component.php b/platforms/wordpress/templates/Template_Basic_Component.php index 2c57538..6c297f6 100644 --- a/platforms/wordpress/templates/Template_Basic_Component.php +++ b/platforms/wordpress/templates/Template_Basic_Component.php @@ -7,7 +7,8 @@ class <%= blockClassModel %>_Component <% if (isComponentManager || isElementor) public $hook_prefix = 'axeweb_blocks/<%= ownerFilename %>/<%= blockFilename %>';<% } %> <% if (!isComponentManager) { %>public function __construct() { - // add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] ); + <% if (isElementor) { %>parent::__construct(); + <% } %>// add_action( 'wp_enqueue_scripts', [ $this, 'register_assets' ] ); add_action( 'after_setup_theme', [ $this, 'register_assets' ] ); } diff --git a/platforms/wordpress/templates/helpers/Template_Elementor_Widget.php b/platforms/wordpress/templates/helpers/Template_Elementor_Widget.php index 098bfb7..74ef4ef 100644 --- a/platforms/wordpress/templates/helpers/Template_Elementor_Widget.php +++ b/platforms/wordpress/templates/helpers/Template_Elementor_Widget.php @@ -18,30 +18,16 @@ class <%= blockClassModel %>_Elementor_Widget extends \Elementor\Widget_Base { } protected function _register_controls() { - $this->start_controls_section( 'section_content', [ 'label' => 'Content' ] ); - - $repeater = new \Elementor\Repeater(); - - // $repeater->add_control( - // 'video_url', [ - // 'label' => 'YouTube URL', - // 'type' => \Elementor\Controls_Manager::URL, - // 'label_block' => true, - // 'condition' => [ - // 'type' => 'video', - // ], - // ] - // ); - - $this->end_controls_section(); + $block_data = \Core\Block::get_block_data( __DIR__ . '/../<%= blockFilename %>.block.json' ); + \Core\Elementor_Block::register_groups( $block_data, $this ); } function get_style_depends() { - return [ '<%= blockFilename %>' ]; + return [ 'block-<%= blockFilename %>' ]; } function get_script_depends() { - return [ 'script-<%= blockFilename %>' ]; + return [ 'block-<%= blockFilename %>' ]; } protected function render() {