← All changes
|
modules/atomic-widgets/elements/base/has-atomic-base.php
+36
-1
4.0.9
→
4.1.0-beta1
View file →
| @@ -4,8 +4,10 @@ | ||
| 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; | |
| 8 | 10 | use Elementor\Modules\AtomicWidgets\PropsResolver\Render_Props_Resolver; |
| 9 | 11 | use Elementor\Modules\AtomicWidgets\PropTypes\Contracts\Prop_Type; |
| 10 | 12 | use Elementor\Modules\AtomicWidgets\Styles\Style_Schema; |
| 11 | 13 | use Elementor\Modules\AtomicWidgets\Parsers\Props_Parser; |
| @@ -248,8 +250,13 @@ | ||
| 248 | 250 | ); |
| 249 | 251 | $props['attributes'] = Attributes_Prop_Type::generate( $merged_attribute_values ); |
| 250 | 252 | |
| 251 | 253 | $parsed = Render_Props_Resolver::for_settings()->resolve( $schema, $props ); |
| 254 | + | |
| 255 | + return $this->transform_link_for_render( $parsed ); | |
| 256 | + } | |
| 257 | + | |
| 258 | + protected function transform_link_for_render( array $parsed ): array { | |
| 252 | 259 | $link_attributes = isset( $parsed['link'] ) ? $this->get_link_attributes_string( $parsed['link'] ) : ''; |
| 253 | 260 | |
| 254 | 261 | $parsed['link'] = ! empty( $link_attributes ) ? [ |
| 255 | 262 | 'tag' => $parsed['link']['tag'], |
| @@ -301,10 +308,13 @@ | ||
| 301 | 308 | } |
| 302 | 309 | |
| 303 | 310 | public static function get_props_schema(): array { |
| 304 | 311 | $schema = static::define_props_schema(); |
| 305 | - $schema['_cssid'] = String_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ); | |
| 306 | 312 | |
| 313 | + if ( ! isset( $schema['_cssid'] ) ) { | |
| 314 | + $schema['_cssid'] = String_Prop_Type::make()->meta( Overridable_Prop_Type::ignore() ); | |
| 315 | + } | |
| 316 | + | |
| 307 | 317 | return apply_filters( |
| 308 | 318 | 'elementor/atomic-widgets/props-schema', |
| 309 | 319 | $schema |
| 310 | 320 | ); |
| @@ -395,6 +405,31 @@ | ||
| 395 | 405 | $parts[] = sprintf( '%s="%s"', $key, esc_attr( $value ) ); |
| 396 | 406 | } |
| 397 | 407 | |
| 398 | 408 | return implode( ' ', $parts ); |
| 409 | + } | |
| 410 | + | |
| 411 | + public function has_action_link() { | |
| 412 | + if ( ! $this->get_id() ) { | |
| 413 | + return true; | |
| 414 | + } | |
| 415 | + | |
| 416 | + $link_settings = $this->get_atomic_setting( 'link' ) ?? null; | |
| 417 | + $attributes = $this->get_link_attributes( $link_settings ); | |
| 418 | + | |
| 419 | + return isset( $attributes['data-action-link'] ); | |
| 420 | + } | |
| 421 | + | |
| 422 | + public function get_script_depends() { | |
| 423 | + $depends = parent::get_script_depends(); | |
| 424 | + | |
| 425 | + if ( $this->has_action_link() ) { | |
| 426 | + $depends[] = Frontend_Assets_Loader::ACTION_LINK_HANDLERS_HANDLE; | |
| 427 | + } | |
| 428 | + | |
| 429 | + if ( Atomic_Form::is_instance_form( $this ) ) { | |
| 430 | + $depends[] = Frontend_Assets_Loader::FORM_HANDLERS_HANDLE; | |
| 431 | + } | |
| 432 | + | |
| 433 | + return $depends; | |
| 399 | 434 | } |
| 400 | 435 | } |