Added Basic Elementor widget logic.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ const __dirname = path.dirname(__filename);
|
||||
|
||||
const {modulesPath, projectPath} = getConfigs();
|
||||
|
||||
export async function buildWordPress(blockName, isBlock = false) {
|
||||
export async function buildWordPress(blockName, isBlock = false, isElementor = false) {
|
||||
const distPath = path.join(projectPath, 'exports', 'wordpress');
|
||||
// await mkdir(distPath, {recursive: true})
|
||||
await mkdir(path.join(distPath, 'templates'), {recursive: true})
|
||||
@@ -38,6 +38,7 @@ export async function buildWordPress(blockName, isBlock = false) {
|
||||
include_native_gutenberg_block: false,
|
||||
include_script: true,
|
||||
include_elementor_widget: false,
|
||||
isElementor,
|
||||
});
|
||||
|
||||
const backPath = modulesPath ? modulesPath.split('/').map(() => '..').join('/') : '';
|
||||
@@ -73,6 +74,16 @@ export async function buildWordPress(blockName, isBlock = false) {
|
||||
generatorsPath: path.join(__dirname),
|
||||
});
|
||||
|
||||
if(isElementor){
|
||||
await createFiles(data, [{
|
||||
from: `templates/helpers/Template_Elementor_Widget.php`,
|
||||
to: `helpers/${data.blockClassModel}_Elementor_Widget.php`,
|
||||
}], {
|
||||
pathDist: distPath,
|
||||
generatorsPath: path.join(__dirname)
|
||||
});
|
||||
}
|
||||
|
||||
if (isBlock) {
|
||||
await createFiles(data, [{
|
||||
from: `templates/Template_Component.php`,
|
||||
|
||||
Reference in New Issue
Block a user