| 1 |
<?php |
| 2 |
namespace Elementor\Modules\Components\Widgets; |
| 3 |
|
| 4 |
use Elementor\Modules\AtomicWidgets\Elements\Atomic_Widget_Base; |
| 5 |
use Elementor\Modules\AtomicWidgets\Elements\Has_Template; |
| 6 |
use Elementor\Modules\Components\PropTypes\Component_Instance_Prop_Type; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; // Exit if accessed directly. |
| 10 |
} |
| 11 |
|
| 12 |
class Component_Instance extends Atomic_Widget_Base { |
| 13 |
use Has_Template; |
| 14 |
|
| 15 |
public static function get_element_type(): string { |
| 16 |
return 'e-component'; |
| 17 |
} |
| 18 |
|
| 19 |
public function show_in_panel() { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
public function get_title() { |
| 24 |
return esc_html__( 'Component', 'elementor' ); |
| 25 |
} |
| 26 |
|
| 27 |
public function get_keywords() { |
| 28 |
return [ 'component' ]; |
| 29 |
} |
| 30 |
|
| 31 |
public function get_icon() { |
| 32 |
return 'eicon-components'; |
| 33 |
} |
| 34 |
|
| 35 |
protected static function define_props_schema(): array { |
| 36 |
return [ |
| 37 |
'component_instance' => Component_Instance_Prop_Type::make()->required(), |
| 38 |
]; |
| 39 |
} |
| 40 |
|
| 41 |
protected function parse_editor_settings( array $data ): array { |
| 42 |
$editor_data = parent::parse_editor_settings( $data ); |
| 43 |
|
| 44 |
if ( isset( $data['component_uid'] ) && is_string( $data['component_uid'] ) ) { |
| 45 |
$editor_data['component_uid'] = sanitize_text_field( $data['component_uid'] ); |
| 46 |
} |
| 47 |
|
| 48 |
return $editor_data; |
| 49 |
} |
| 50 |
|
| 51 |
protected function define_atomic_controls(): array { |
| 52 |
return []; |
| 53 |
} |
| 54 |
|
| 55 |
protected function get_templates(): array { |
| 56 |
return [ |
| 57 |
'elementor/elements/component' => __DIR__ . '/component.html.twig', |
| 58 |
]; |
| 59 |
} |
| 60 |
} |
| 61 |
|