PluginProbe
Elementor Website Builder – more than just a page builder / 4.0.8
Elementor Website Builder – more than just a page builder v4.0.8
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
← All changes | modules/atomic-widgets/elements/base/has-atomic-base.php +3 -87 4.2.0-beta24.0.8 View file →
@@ -4,10 +4,8 @@
4 4
5 5 use Elementor\Element_Base;
6 6 use Elementor\Modules\AtomicWidgets\Controls\Base\Atomic_Control_Base;
7 7 use Elementor\Modules\AtomicWidgets\Controls\Section;
8 -use Elementor\Modules\AtomicWidgets\Elements\Atomic_Form\Atomic_Form;
9 -use Elementor\Modules\AtomicWidgets\Elements\Loader\Frontend_Assets_Loader;
10 8 use Elementor\Modules\AtomicWidgets\PropsResolver\Render_Props_Resolver;
11 9 use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type;
12 10 use Elementor\Modules\AtomicWidgets\Styles\Style_Schema;
13 11 use Elementor\Modules\AtomicWidgets\Parsers\Props_Parser;
@@ -28,9 +26,8 @@
28 26 * @mixin Element_Base
29 27 */
30 28 trait Has_Atomic_Base {
31 29 use Has_Base_Styles;
32 - use Has_Base_Settings;
33 30
34 31 public function has_widget_inner_wrapper(): bool {
35 32 return false;
36 33 }
@@ -93,11 +90,10 @@
93 90 foreach ( $styles as $style_id => $style ) {
94 91 $result = $style_parser->parse( $style );
95 92
96 93 if ( ! $result->is_valid() ) {
97 - throw new \Exception(
98 - esc_html( $this->format_styles_validation_error_message( $style_id, $data, $style, $result->errors()->to_string() ) )
99 - );
94 + $widget_id = $data['id'] ?? 'unknown';
95 + throw new \Exception( esc_html( "Styles validation failed for style `$style_id`. Widget ID: `$widget_id`. " . $result->errors()->to_string() ) );
100 96 }
101 97
102 98 $styles[ $style_id ] = $result->unwrap();
103 99 }
@@ -104,51 +100,8 @@
104 100
105 101 return $styles;
106 102 }
107 103
108 - private function format_styles_validation_error_message(
109 - string $style_id,
110 - array $data,
111 - array $style,
112 - string $validation_errors
113 - ): string {
114 - $widget_id = $data['id'] ?? 'unknown';
115 - $structure_label = $this->get_editor_structure_label( $data );
116 - $style_label = isset( $style['label'] ) && is_string( $style['label'] ) ? $style['label'] : null;
117 -
118 - $message_parts = [
119 - "Styles validation failed for style `$style_id` (widget `$widget_id`)",
120 - ];
121 -
122 - if ( $structure_label ) {
123 - $message_parts[] = "Structure label: `$structure_label`";
124 - } else {
125 - $element_name = $this->get_title();
126 -
127 - if ( '' === $element_name ) {
128 - $element_name = $this->get_name();
129 - }
130 -
131 - $message_parts[] = "Element: `$element_name`";
132 - }
133 -
134 - if ( $style_label ) {
135 - $message_parts[] = "Style label: `$style_label`";
136 - }
137 -
138 - return implode( '. ', $message_parts ) . '. ' . $validation_errors;
139 - }
140 -
141 - private function get_editor_structure_label( array $data ): ?string {
142 - $title = $data['editor_settings']['title'] ?? $this->editor_settings['title'] ?? null;
143 -
144 - if ( ! is_string( $title ) || '' === $title ) {
145 - return null;
146 - }
147 -
148 - return $title;
149 - }
150 -
151 104 private function parse_atomic_settings( array $settings ): array {
152 105 $schema = static::get_props_schema();
153 106 $props_parser = Props_Parser::make( $schema );
154 107
@@ -295,13 +248,8 @@
295 248 );
296 249 $props['attributes'] = Attributes_Prop_Type::generate( $merged_attribute_values );
297 250
298 251 $parsed = Render_Props_Resolver::for_settings()->resolve( $schema, $props );
299 -
300 - return $this->transform_link_for_render( $parsed );
301 - }
302 -
303 - protected function transform_link_for_render( array $parsed ): array {
304 252 $link_attributes = isset( $parsed['link'] ) ? $this->get_link_attributes_string( $parsed['link'] ) : '';
305 253
306 254 $parsed['link'] = ! empty( $link_attributes ) ? [
307 255 'tag' => $parsed['link']['tag'],
@@ -348,22 +296,15 @@
348 296 if ( isset( $data['title'] ) && is_string( $data['title'] ) ) {
349 297 $editor_data['title'] = sanitize_text_field( $data['title'] );
350 298 }
351 299
352 - if ( isset( $data['grid_outline'] ) && is_bool( $data['grid_outline'] ) ) {
353 - $editor_data['grid_outline'] = $data['grid_outline'];
354 - }
355 -
356 300 return $editor_data;
357 301 }
358 302
359 303 public static function get_props_schema(): array {
360 304 $schema = static::define_props_schema();
305 + $schema['_cssid'] = String_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() );
361 306
362 - if ( ! isset( $schema['_cssid'] ) ) {
363 - $schema['_cssid'] = String_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() );
364 - }
365 -
366 307 return apply_filters(
367 308 'elementor/atomic-widgets/props-schema',
368 309 $schema
369 310 );
@@ -454,31 +395,6 @@
454 395 $parts[] = sprintf( '%s="%s"', $key, esc_attr( $value ) );
455 396 }
456 397
457 398 return implode( ' ', $parts );
458 - }
459 -
460 - public function has_action_link() {
461 - if ( ! $this->get_id() ) {
462 - return true;
463 - }
464 -
465 - $link_settings = $this->get_atomic_setting( 'link' ) ?? null;
466 - $attributes = $this->get_link_attributes( $link_settings );
467 -
468 - return isset( $attributes['data-action-link'] );
469 - }
470 -
471 - public function get_script_depends() {
472 - $depends = parent::get_script_depends();
473 -
474 - if ( $this->has_action_link() ) {
475 - $depends[] = Frontend_Assets_Loader::ACTION_LINK_HANDLERS_HANDLE;
476 - }
477 -
478 - if ( Atomic_Form::is_instance_form( $this ) ) {
479 - $depends[] = Frontend_Assets_Loader::FORM_HANDLERS_HANDLE;
480 - }
481 -
482 - return $depends;
483 399 }
484 400 }