← All changes
|
modules/atomic-widgets/elements/flexbox/flexbox.php
+10
-52
4.3.0-beta3
→
3.33.0-beta1
View file →
| @@ -1,11 +1,8 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor\Modules\AtomicWidgets\Elements\Flexbox; |
| 3 | 3 | |
| 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; | |
| 7 | -use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; | |
| 4 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base; | |
| 8 | 5 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 9 | 6 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 10 | 7 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 11 | 8 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| @@ -12,12 +9,12 @@ | ||
| 12 | 9 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 13 | 10 | use Elementor\Modules\AtomicWidgets\Controls\Types\Html_Tag_Control; |
| 14 | 11 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 15 | 12 | use Elementor\Modules\AtomicWidgets\Controls\Types\Text_Control; |
| 13 | +use Elementor\Modules\AtomicWidgets\PropDependencies\Manager as Dependency_Manager; | |
| 14 | +use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; | |
| 16 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 17 | -use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; | |
| 18 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 19 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 20 | 17 | |
| 21 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 22 | 19 | exit; // Exit if accessed directly. |
| 23 | 20 | } |
| @@ -22,23 +19,14 @@ | ||
| 22 | 19 | exit; // Exit if accessed directly. |
| 23 | 20 | } |
| 24 | 21 | |
| 25 | 22 | class Flexbox extends Atomic_Element_Base { |
| 26 | - use Has_Element_Template; | |
| 27 | - | |
| 28 | 23 | const BASE_STYLE_KEY = 'base'; |
| 29 | 24 | |
| 30 | - public function __construct( $data = [], $args = null ) { | |
| 31 | - parent::__construct( $data, $args ); | |
| 32 | - $this->meta( 'is_container', true ); | |
| 33 | - } | |
| 34 | - | |
| 35 | 25 | public static function get_type() { |
| 36 | 26 | return 'e-flexbox'; |
| 37 | 27 | } |
| 38 | 28 | |
| 39 | - public static $widget_description = 'A container (div) with flex display and flex-direction row by default.'; | |
| 40 | - | |
| 41 | 29 | public static function get_element_type(): string { |
| 42 | 30 | return 'e-flexbox'; |
| 43 | 31 | } |
| 44 | 32 | |
| @@ -46,9 +34,9 @@ | ||
| 46 | 34 | return esc_html__( 'Flexbox', 'elementor' ); |
| 47 | 35 | } |
| 48 | 36 | |
| 49 | 37 | public function get_keywords() { |
| 50 | - return [ 'ato', 'atom', 'atoms', 'atomic', 'container', 'wrapper', 'section', 'row', 'column', 'flex', 'layout' ]; | |
| 38 | + return [ 'ato', 'atom', 'atoms', 'atomic' ]; | |
| 51 | 39 | } |
| 52 | 40 | |
| 53 | 41 | public function get_icon() { |
| 54 | 42 | return 'eicon-flexbox'; |
| @@ -53,24 +41,11 @@ | ||
| 53 | 41 | public function get_icon() { |
| 54 | 42 | return 'eicon-flexbox'; |
| 55 | 43 | } |
| 56 | 44 | |
| 57 | - public static function get_computed_html_tag( array $settings ): string { | |
| 58 | - return Html_Tag_Computer::compute( $settings, 'div' ); | |
| 59 | - } | |
| 60 | - | |
| 61 | 45 | protected static function define_props_schema(): array { |
| 62 | - $tag_dependencies = Dependency_Manager::make( Dependency_Manager::RELATION_AND ) | |
| 46 | + $tag_dependencies = Dependency_Manager::make() | |
| 63 | 47 | ->where( [ |
| 64 | - 'operator' => 'ne', | |
| 65 | - 'path' => [ 'link', 'destination' ], | |
| 66 | - 'nestedPath' => [ 'group' ], | |
| 67 | - 'value' => 'action', | |
| 68 | - 'newValue' => [ | |
| 69 | - '$$type' => 'string', | |
| 70 | - 'value' => 'button', | |
| 71 | - ], | |
| 72 | - ] )->where( [ | |
| 73 | 48 | 'operator' => 'not_exist', |
| 74 | 49 | 'path' => [ 'link', 'destination' ], |
| 75 | 50 | 'newValue' => [ |
| 76 | 51 | '$$type' => 'string', |
| @@ -75,23 +50,21 @@ | ||
| 75 | 50 | 'newValue' => [ |
| 76 | 51 | '$$type' => 'string', |
| 77 | 52 | 'value' => 'a', |
| 78 | 53 | ], |
| 79 | - ] )->get(); | |
| 54 | + ] ) | |
| 55 | + ->get(); | |
| 80 | 56 | |
| 81 | 57 | return [ |
| 82 | 58 | 'classes' => Classes_Prop_Type::make() |
| 83 | 59 | ->default( [] ), |
| 84 | 60 | 'tag' => String_Prop_Type::make() |
| 85 | - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button', 'main', 'nav' ] ) | |
| 61 | + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a' ] ) | |
| 86 | 62 | ->default( 'div' ) |
| 87 | - ->description( 'The HTML tag for the flexbox container. One of: div, header, section, article, aside, footer, main, nav, a (link), or button.' ) | |
| 88 | 63 | ->set_dependencies( $tag_dependencies ), |
| 89 | 64 | 'link' => Link_Prop_Type::make(), |
| 90 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 65 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 91 | 66 | ]; |
| 92 | - | |
| 93 | - return $schema; | |
| 94 | 67 | } |
| 95 | 68 | |
| 96 | 69 | protected function define_atomic_controls(): array { |
| 97 | 70 | return [ |
| @@ -124,16 +97,8 @@ | ||
| 124 | 97 | [ |
| 125 | 98 | 'value' => 'footer', |
| 126 | 99 | 'label' => 'Footer', |
| 127 | 100 | ], |
| 128 | - [ | |
| 129 | - 'value' => 'main', | |
| 130 | - 'label' => 'Main', | |
| 131 | - ], | |
| 132 | - [ | |
| 133 | - 'value' => 'nav', | |
| 134 | - 'label' => 'Nav', | |
| 135 | - ], | |
| 136 | 101 | ]) |
| 137 | 102 | ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ) |
| 138 | 103 | ->set_fallback_labels( [ |
| 139 | 104 | 'a' => 'a (link)', |
| @@ -192,17 +157,10 @@ | ||
| 192 | 157 | $attributes['id'] = esc_attr( $settings['_cssid'] ); |
| 193 | 158 | } |
| 194 | 159 | |
| 195 | 160 | if ( ! empty( $settings['link']['href'] ) ) { |
| 196 | - $link_attributes = $this->get_link_attributes( $settings['link'] ); | |
| 197 | - $attributes = array_merge( $attributes, $link_attributes ); | |
| 161 | + $attributes = array_merge( $attributes, $settings['link'] ); | |
| 198 | 162 | } |
| 199 | 163 | |
| 200 | 164 | $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) ); |
| 201 | - } | |
| 202 | - | |
| 203 | - protected function get_templates(): array { | |
| 204 | - return [ | |
| 205 | - 'elementor/elements/flexbox' => __DIR__ . '/flexbox.html.twig', | |
| 206 | - ]; | |
| 207 | 165 | } |
| 208 | 166 | } |