| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\Elements; |
| 4 |
|
| 5 |
use Elementor\Element_Base; |
| 6 |
use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; |
| 7 |
use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type; |
| 8 |
use Elementor\Plugin; |
| 9 |
|
| 10 |
if ( ! defined( 'ABSPATH' ) ) { |
| 11 |
exit; // Exit if accessed directly. |
| 12 |
} |
| 13 |
|
| 14 |
abstract class Atomic_Element_Base extends Element_Base { |
| 15 |
|
| 16 |
use Has_Atomic_Base; |
| 17 |
|
| 18 |
protected $version = '0.0'; |
| 19 |
protected $styles = []; |
| 20 |
protected $editor_settings = []; |
| 21 |
|
| 22 |
public function __construct( $data = [], $args = null ) { |
| 23 |
parent::__construct( $data, $args ); |
| 24 |
|
| 25 |
$this->version = $data['version'] ?? '0.0'; |
| 26 |
$this->styles = $data['styles'] ?? []; |
| 27 |
$this->editor_settings = $data['editor_settings'] ?? []; |
| 28 |
} |
| 29 |
|
| 30 |
abstract protected function define_atomic_controls(): array; |
| 31 |
|
| 32 |
public function get_global_scripts() { |
| 33 |
return []; |
| 34 |
} |
| 35 |
|
| 36 |
final public function get_initial_config() { |
| 37 |
$config = parent::get_initial_config(); |
| 38 |
$props_schema = static::get_props_schema(); |
| 39 |
|
| 40 |
$config['atomic_controls'] = $this->get_atomic_controls(); |
| 41 |
$config['atomic_props_schema'] = $props_schema; |
| 42 |
$config['dependencies_per_target_mapping'] = Dependency_Manager::get_source_to_dependents( $props_schema ); |
| 43 |
$config['base_styles'] = $this->get_base_styles(); |
| 44 |
$config['version'] = $this->version; |
| 45 |
$config['show_in_panel'] = true; |
| 46 |
$config['categories'] = [ 'v4-elements' ]; |
| 47 |
$config['hide_on_search'] = false; |
| 48 |
$config['controls'] = []; |
| 49 |
$config['keywords'] = $this->get_keywords(); |
| 50 |
|
| 51 |
return $config; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* @return array<string, Prop_Type> |
| 56 |
*/ |
| 57 |
abstract protected static function define_props_schema(): array; |
| 58 |
|
| 59 |
/** |
| 60 |
* Get Element keywords. |
| 61 |
* |
| 62 |
* Retrieve the element keywords. |
| 63 |
* |
| 64 |
* @since 3.29 |
| 65 |
* @access public |
| 66 |
* |
| 67 |
* @return array Element keywords. |
| 68 |
*/ |
| 69 |
public function get_keywords() { |
| 70 |
return []; |
| 71 |
} |
| 72 |
} |
| 73 |
|