← All changes
|
modules/atomic-widgets/elements/flexbox/flexbox.php
+14
-65
4.3.0-beta3
→
3.32.0-dev3
View file →
| @@ -1,23 +1,20 @@ | ||
| 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 | 9 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 13 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Html_Tag_Control; | |
| 14 | 10 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 11 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Select_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,45 +41,26 @@ | ||
| 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 | - 'newValue' => [ | |
| 76 | - '$$type' => 'string', | |
| 77 | - 'value' => 'a', | |
| 78 | - ], | |
| 79 | - ] )->get(); | |
| 50 | + ] ) | |
| 51 | + ->get(); | |
| 80 | 52 | |
| 81 | 53 | return [ |
| 82 | 54 | 'classes' => Classes_Prop_Type::make() |
| 83 | 55 | ->default( [] ), |
| 84 | 56 | 'tag' => String_Prop_Type::make() |
| 85 | - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button', 'main', 'nav' ] ) | |
| 57 | + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer' ] ) | |
| 86 | 58 | ->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 | 59 | ->set_dependencies( $tag_dependencies ), |
| 89 | 60 | 'link' => Link_Prop_Type::make(), |
| 90 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 61 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 91 | 62 | ]; |
| 92 | - | |
| 93 | - return $schema; | |
| 94 | 63 | } |
| 95 | 64 | |
| 96 | 65 | protected function define_atomic_controls(): array { |
| 97 | 66 | return [ |
| @@ -98,9 +67,9 @@ | ||
| 98 | 67 | Section::make() |
| 99 | 68 | ->set_label( __( 'Settings', 'elementor' ) ) |
| 100 | 69 | ->set_id( 'settings' ) |
| 101 | 70 | ->set_items( [ |
| 102 | - Html_Tag_Control::bind_to( 'tag' ) | |
| 71 | + Select_Control::bind_to( 'tag' ) | |
| 103 | 72 | ->set_options( [ |
| 104 | 73 | [ |
| 105 | 74 | 'value' => 'div', |
| 106 | 75 | 'label' => 'Div', |
| @@ -124,23 +93,11 @@ | ||
| 124 | 93 | [ |
| 125 | 94 | 'value' => 'footer', |
| 126 | 95 | 'label' => 'Footer', |
| 127 | 96 | ], |
| 128 | - [ | |
| 129 | - 'value' => 'main', | |
| 130 | - 'label' => 'Main', | |
| 131 | - ], | |
| 132 | - [ | |
| 133 | - 'value' => 'nav', | |
| 134 | - 'label' => 'Nav', | |
| 135 | - ], | |
| 136 | 97 | ]) |
| 137 | - ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ) | |
| 138 | - ->set_fallback_labels( [ | |
| 139 | - 'a' => 'a (link)', | |
| 140 | - ] ), | |
| 98 | + ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ), | |
| 141 | 99 | Link_Control::bind_to( 'link' ) |
| 142 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 143 | 100 | ->set_label( __( 'Link', 'elementor' ) ) |
| 144 | 101 | ->set_meta( [ |
| 145 | 102 | 'topDivider' => true, |
| 146 | 103 | ] ), |
| @@ -176,9 +133,8 @@ | ||
| 176 | 133 | protected function add_render_attributes() { |
| 177 | 134 | parent::add_render_attributes(); |
| 178 | 135 | $settings = $this->get_atomic_settings(); |
| 179 | 136 | $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ]; |
| 180 | - $initial_attributes = $this->define_initial_attributes(); | |
| 181 | 137 | |
| 182 | 138 | $attributes = [ |
| 183 | 139 | 'class' => [ |
| 184 | 140 | 'e-con', |
| @@ -192,17 +148,10 @@ | ||
| 192 | 148 | $attributes['id'] = esc_attr( $settings['_cssid'] ); |
| 193 | 149 | } |
| 194 | 150 | |
| 195 | 151 | if ( ! empty( $settings['link']['href'] ) ) { |
| 196 | - $link_attributes = $this->get_link_attributes( $settings['link'] ); | |
| 197 | - $attributes = array_merge( $attributes, $link_attributes ); | |
| 152 | + $attributes = array_merge( $attributes, $settings['link'] ); | |
| 198 | 153 | } |
| 199 | 154 | |
| 200 | - $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 | - ]; | |
| 155 | + $this->add_render_attribute( '_wrapper', $attributes ); | |
| 207 | 156 | } |
| 208 | 157 | } |