Added Basic Elementor widget logic.

This commit is contained in:
2022-11-25 19:42:28 +02:00
parent 00866a8115
commit 4d1d2337bf
4 changed files with 85 additions and 8 deletions
@@ -36,4 +36,11 @@ class <%= blockClassModel %>_Component {
echo apply_filters( 'the_content', wpautop( $output ) );
}
<% if (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() );
}<% } %>
}
// ( new <%= blockClassModel %>_Component() ); // Initialization
@@ -0,0 +1,60 @@
<?php
namespace AXEWEB_Blocks\Blocks\<%= ownerClass %>\<%= blockClassModel %>\Helpers;
class <%= blockClassModel %>_Elementor_Widget extends \Elementor\Widget_Base {
const PLUGIN_NAME = '<%= blockFilename %>';
public function get_name() {
return self::PLUGIN_NAME;
}
public function get_title() {
return '<%= blockClassModel %>';
}
public function get_icon() {
return 'eicon-plus-square-o';
}
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();
}
function get_style_depends() {
return [ '<%= blockFilename %>' ];
}
function get_script_depends() {
return [ 'script-<%= blockFilename %>' ];
}
protected function render() {
$settings = $this->get_settings_for_display();
$component = new \AXEWEB_Blocks\Blocks\Scytale\<%= blockClassModel %>\<%= blockClassModel %>_Component();
$args = self::prepare( $settings );
$component->render( $args );
}
public static function prepare( $args ): array {
// Prepare $args for render function.
return $args;
}
}