← All changes
|
modules/atomic-widgets/elements/div-block/div-block.php
+25
-2
4.0.9
→
4.3.2
View file →
| @@ -1,8 +1,10 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Div_Block; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Modules\AtomicWidgets\Elements\Base\Atomic_Element_Base; |
| 5 | +use Elementor\Modules\AtomicWidgets\Elements\Base\Has_Element_Template; | |
| 6 | +use Elementor\Modules\AtomicWidgets\Elements\Base\Html_Tag_Computer; | |
| 5 | 7 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 6 | 8 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 7 | 9 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 8 | 10 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| @@ -20,8 +22,10 @@ | ||
| 20 | 22 | exit; // Exit if accessed directly. |
| 21 | 23 | } |
| 22 | 24 | |
| 23 | 25 | class Div_Block extends Atomic_Element_Base { |
| 26 | + use Has_Element_Template; | |
| 27 | + | |
| 24 | 28 | const BASE_STYLE_KEY = 'base'; |
| 25 | 29 | |
| 26 | 30 | public function __construct( $data = [], $args = null ) { |
| 27 | 31 | parent::__construct( $data, $args ); |
| @@ -40,9 +44,9 @@ | ||
| 40 | 44 | return esc_html__( 'Div block', 'elementor' ); |
| 41 | 45 | } |
| 42 | 46 | |
| 43 | 47 | public function get_keywords() { |
| 44 | - return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 48 | + return [ 'ato', 'atom', 'atoms', 'atomic', 'container', 'wrapper', 'section', 'row', 'column', 'div', 'box', 'layout' ]; | |
| 45 | 49 | } |
| 46 | 50 | |
| 47 | 51 | public function get_icon() { |
| 48 | 52 | return 'eicon-div-block'; |
| @@ -47,8 +51,12 @@ | ||
| 47 | 51 | public function get_icon() { |
| 48 | 52 | return 'eicon-div-block'; |
| 49 | 53 | } |
| 50 | 54 | |
| 55 | + public static function get_computed_html_tag( array $settings ): string { | |
| 56 | + return Html_Tag_Computer::compute( $settings, 'div' ); | |
| 57 | + } | |
| 58 | + | |
| 51 | 59 | protected static function define_props_schema(): array { |
| 52 | 60 | $tag_dependencies = Dependency_Manager::make( Dependency_Manager::RELATION_AND ) |
| 53 | 61 | ->where( [ |
| 54 | 62 | 'operator' => 'ne', |
| @@ -71,10 +79,11 @@ | ||
| 71 | 79 | return [ |
| 72 | 80 | 'classes' => Classes_Prop_Type::make() |
| 73 | 81 | ->default( [] ), |
| 74 | 82 | 'tag' => String_Prop_Type::make() |
| 75 | - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button' ] ) | |
| 83 | + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button', 'main', 'nav' ] ) | |
| 76 | 84 | ->default( 'div' ) |
| 85 | + ->description( 'The HTML tag for the div block container. One of: div, header, section, article, aside, footer, main, nav, a (link), or button. Do not use heading or paragraph tags.' ) | |
| 77 | 86 | ->set_dependencies( $tag_dependencies ), |
| 78 | 87 | 'link' => Link_Prop_Type::make(), |
| 79 | 88 | 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), |
| 80 | 89 | ]; |
| @@ -111,8 +120,16 @@ | ||
| 111 | 120 | [ |
| 112 | 121 | 'value' => 'footer', |
| 113 | 122 | 'label' => 'Footer', |
| 114 | 123 | ], |
| 124 | + [ | |
| 125 | + 'value' => 'main', | |
| 126 | + 'label' => 'Main', | |
| 127 | + ], | |
| 128 | + [ | |
| 129 | + 'value' => 'nav', | |
| 130 | + 'label' => 'Nav', | |
| 131 | + ], | |
| 115 | 132 | ]) |
| 116 | 133 | ->set_fallback_labels( [ |
| 117 | 134 | 'a' => 'a (link)', |
| 118 | 135 | ] ) |
| @@ -182,6 +199,12 @@ | ||
| 182 | 199 | $attributes = array_merge( $attributes, $link_attributes ); |
| 183 | 200 | } |
| 184 | 201 | |
| 185 | 202 | $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) ); |
| 203 | + } | |
| 204 | + | |
| 205 | + protected function get_templates(): array { | |
| 206 | + return [ | |
| 207 | + 'elementor/elements/div-block' => __DIR__ . '/div-block.html.twig', | |
| 208 | + ]; | |
| 186 | 209 | } |
| 187 | 210 | } |