| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Interactions\Validators; |
| 4 |
|
| 5 |
use Elementor\Modules\AtomicWidgets\Parsers\Props_Parser; |
| 6 |
use Elementor\Modules\Interactions\Props\Custom_Effect_Prop_Type; |
| 7 |
|
| 8 |
if ( ! defined( 'ABSPATH' ) ) { |
| 9 |
exit; |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* TODO: At least a value validator interface to enforce is_valid fxn for consistency |
| 14 |
*/ |
| 15 |
class Custom_Effect_Value { |
| 16 |
public static function is_valid( array $animation_value ): bool { |
| 17 |
$effect_value = $animation_value['effect']['value'] ?? null; |
| 18 |
|
| 19 |
if ( 'custom' !== $effect_value ) { |
| 20 |
return true; |
| 21 |
} |
| 22 |
|
| 23 |
if ( ! isset( $animation_value['custom_effect'] ) ) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
|
| 27 |
$props_parser = Props_Parser::make( [ |
| 28 |
'custom_effect' => Custom_Effect_Prop_Type::make(), |
| 29 |
] ); |
| 30 |
|
| 31 |
$result = $props_parser->parse( [ 'custom_effect' => $animation_value['custom_effect'] ] ); |
| 32 |
|
| 33 |
return $result->is_valid(); |
| 34 |
} |
| 35 |
} |
| 36 |
|