← All changes
|
modules/atomic-widgets/elements/flexbox/flexbox.php
+13
-49
4.1.3
→
3.32.0-dev3
View file →
| @@ -1,22 +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\PropDependencies\Manager as Dependency_Manager; | |
| 4 | +use Elementor\Modules\AtomicWidgets\Elements\Atomic_Element_Base; | |
| 7 | 5 | use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\String_Prop_Type; |
| 8 | 6 | use Elementor\Modules\AtomicWidgets\PropTypes\Size_Prop_Type; |
| 9 | 7 | use Elementor\Modules\AtomicWidgets\Styles\Style_Definition; |
| 10 | 8 | use Elementor\Modules\AtomicWidgets\Styles\Style_Variant; |
| 11 | 9 | use Elementor\Modules\AtomicWidgets\Controls\Section; |
| 12 | -use Elementor\Modules\AtomicWidgets\Controls\Types\Html_Tag_Control; | |
| 13 | 10 | use Elementor\Modules\AtomicWidgets\Controls\Types\Link_Control; |
| 11 | +use Elementor\Modules\AtomicWidgets\Controls\Types\Select_Control; | |
| 14 | 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; | |
| 15 | 15 | use Elementor\Modules\AtomicWidgets\PropTypes\Attributes_Prop_Type; |
| 16 | -use Elementor\Modules\AtomicWidgets\PropTypes\Classes_Prop_Type; | |
| 17 | 16 | use Elementor\Modules\AtomicWidgets\PropTypes\Link_Prop_Type; |
| 18 | -use Elementor\Modules\Components\PropTypes\Overridable_Prop_Type; | |
| 19 | 17 | |
| 20 | 18 | if ( ! defined( 'ABSPATH' ) ) { |
| 21 | 19 | exit; // Exit if accessed directly. |
| 22 | 20 | } |
| @@ -21,17 +19,10 @@ | ||
| 21 | 19 | exit; // Exit if accessed directly. |
| 22 | 20 | } |
| 23 | 21 | |
| 24 | 22 | class Flexbox extends Atomic_Element_Base { |
| 25 | - use Has_Element_Template; | |
| 26 | - | |
| 27 | 23 | const BASE_STYLE_KEY = 'base'; |
| 28 | 24 | |
| 29 | - public function __construct( $data = [], $args = null ) { | |
| 30 | - parent::__construct( $data, $args ); | |
| 31 | - $this->meta( 'is_container', true ); | |
| 32 | - } | |
| 33 | - | |
| 34 | 25 | public static function get_type() { |
| 35 | 26 | return 'e-flexbox'; |
| 36 | 27 | } |
| 37 | 28 | |
| @@ -51,40 +42,25 @@ | ||
| 51 | 42 | return 'eicon-flexbox'; |
| 52 | 43 | } |
| 53 | 44 | |
| 54 | 45 | protected static function define_props_schema(): array { |
| 55 | - $tag_dependencies = Dependency_Manager::make( Dependency_Manager::RELATION_AND ) | |
| 46 | + $tag_dependencies = Dependency_Manager::make() | |
| 56 | 47 | ->where( [ |
| 57 | - 'operator' => 'ne', | |
| 58 | - 'path' => [ 'link', 'destination' ], | |
| 59 | - 'nestedPath' => [ 'group' ], | |
| 60 | - 'value' => 'action', | |
| 61 | - 'newValue' => [ | |
| 62 | - '$$type' => 'string', | |
| 63 | - 'value' => 'button', | |
| 64 | - ], | |
| 65 | - ] )->where( [ | |
| 66 | 48 | 'operator' => 'not_exist', |
| 67 | 49 | 'path' => [ 'link', 'destination' ], |
| 68 | - 'newValue' => [ | |
| 69 | - '$$type' => 'string', | |
| 70 | - 'value' => 'a', | |
| 71 | - ], | |
| 72 | - ] )->get(); | |
| 50 | + ] ) | |
| 51 | + ->get(); | |
| 73 | 52 | |
| 74 | 53 | return [ |
| 75 | 54 | 'classes' => Classes_Prop_Type::make() |
| 76 | 55 | ->default( [] ), |
| 77 | 56 | 'tag' => String_Prop_Type::make() |
| 78 | - ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer', 'a', 'button' ] ) | |
| 57 | + ->enum( [ 'div', 'header', 'section', 'article', 'aside', 'footer' ] ) | |
| 79 | 58 | ->default( 'div' ) |
| 80 | - ->description( 'The HTML tag for the flexbox container. Could be div, header, section, article, aside, footer, or a (link).' ) | |
| 81 | 59 | ->set_dependencies( $tag_dependencies ), |
| 82 | 60 | 'link' => Link_Prop_Type::make(), |
| 83 | - 'attributes' => Attributes_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ), | |
| 61 | + 'attributes' => Attributes_Prop_Type::make(), | |
| 84 | 62 | ]; |
| 85 | - | |
| 86 | - return $schema; | |
| 87 | 63 | } |
| 88 | 64 | |
| 89 | 65 | protected function define_atomic_controls(): array { |
| 90 | 66 | return [ |
| @@ -91,9 +67,9 @@ | ||
| 91 | 67 | Section::make() |
| 92 | 68 | ->set_label( __( 'Settings', 'elementor' ) ) |
| 93 | 69 | ->set_id( 'settings' ) |
| 94 | 70 | ->set_items( [ |
| 95 | - Html_Tag_Control::bind_to( 'tag' ) | |
| 71 | + Select_Control::bind_to( 'tag' ) | |
| 96 | 72 | ->set_options( [ |
| 97 | 73 | [ |
| 98 | 74 | 'value' => 'div', |
| 99 | 75 | 'label' => 'Div', |
| @@ -118,14 +94,10 @@ | ||
| 118 | 94 | 'value' => 'footer', |
| 119 | 95 | 'label' => 'Footer', |
| 120 | 96 | ], |
| 121 | 97 | ]) |
| 122 | - ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ) | |
| 123 | - ->set_fallback_labels( [ | |
| 124 | - 'a' => 'a (link)', | |
| 125 | - ] ), | |
| 98 | + ->set_label( esc_html__( 'HTML Tag', 'elementor' ) ), | |
| 126 | 99 | Link_Control::bind_to( 'link' ) |
| 127 | - ->set_placeholder( __( 'Type or paste your URL', 'elementor' ) ) | |
| 128 | 100 | ->set_label( __( 'Link', 'elementor' ) ) |
| 129 | 101 | ->set_meta( [ |
| 130 | 102 | 'topDivider' => true, |
| 131 | 103 | ] ), |
| @@ -161,9 +133,8 @@ | ||
| 161 | 133 | protected function add_render_attributes() { |
| 162 | 134 | parent::add_render_attributes(); |
| 163 | 135 | $settings = $this->get_atomic_settings(); |
| 164 | 136 | $base_style_class = $this->get_base_styles_dictionary()[ static::BASE_STYLE_KEY ]; |
| 165 | - $initial_attributes = $this->define_initial_attributes(); | |
| 166 | 137 | |
| 167 | 138 | $attributes = [ |
| 168 | 139 | 'class' => [ |
| 169 | 140 | 'e-con', |
| @@ -177,17 +148,10 @@ | ||
| 177 | 148 | $attributes['id'] = esc_attr( $settings['_cssid'] ); |
| 178 | 149 | } |
| 179 | 150 | |
| 180 | 151 | if ( ! empty( $settings['link']['href'] ) ) { |
| 181 | - $link_attributes = $this->get_link_attributes( $settings['link'] ); | |
| 182 | - $attributes = array_merge( $attributes, $link_attributes ); | |
| 152 | + $attributes = array_merge( $attributes, $settings['link'] ); | |
| 183 | 153 | } |
| 184 | 154 | |
| 185 | - $this->add_render_attribute( '_wrapper', array_merge( $initial_attributes, $attributes ) ); | |
| 186 | - } | |
| 187 | - | |
| 188 | - protected function get_templates(): array { | |
| 189 | - return [ | |
| 190 | - 'elementor/elements/flexbox' => __DIR__ . '/flexbox.html.twig', | |
| 191 | - ]; | |
| 155 | + $this->add_render_attribute( '_wrapper', $attributes ); | |
| 192 | 156 | } |
| 193 | 157 | } |