first commit

This commit is contained in:
2026-05-25 14:34:29 +02:00
commit 64f5e06629
4236 changed files with 1314148 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
<?php
namespace Elementor\Modules\Interactions\Validators;
use Elementor\Modules\Interactions\Validators\String_Value as StringValueValidator;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Breakpoints_Value {
public static function is_valid( $breakpoints_prop_value ) {
if ( ! is_array( $breakpoints_prop_value ) ) {
return false;
}
if ( ! isset( $breakpoints_prop_value['$$type'] ) || 'interaction-breakpoints' !== $breakpoints_prop_value['$$type'] ) {
return false;
}
if ( ! isset( $breakpoints_prop_value['value'] ) || ! is_array( $breakpoints_prop_value['value'] ) ) {
return false;
}
return self::validate_value( $breakpoints_prop_value['value'] );
}
private static function validate_value( $value ) {
if ( ! is_array( $value ) ) {
return false;
}
if ( ! isset( $value['excluded'] ) || ! is_array( $value['excluded'] ) ) {
return false;
}
return self::validate_excluded( $value['excluded'] );
}
private static function validate_excluded( $excluded ) {
if ( ! is_array( $excluded ) ) {
return false;
}
if ( ! isset( $excluded['$$type'] ) || 'excluded-breakpoints' !== $excluded['$$type'] ) {
return false;
}
if ( ! isset( $excluded['value'] ) || ! is_array( $excluded['value'] ) ) {
return false;
}
return self::validate_excluded_value( $excluded['value'] );
}
private static function validate_excluded_value( $value ) {
if ( ! is_array( $value ) ) {
return false;
}
foreach ( $value as $breakpoint_value ) {
if ( ! StringValueValidator::is_valid( $breakpoint_value ) ) {
return false;
}
}
return true;
}
}

View File

@@ -0,0 +1,35 @@
<?php
namespace Elementor\Modules\Interactions\Validators;
use Elementor\Modules\AtomicWidgets\Parsers\Props_Parser;
use Elementor\Modules\Interactions\Props\Custom_Effect_Prop_Type;
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* TODO: At least a value validator interface to enforce is_valid fxn for consistency
*/
class Custom_Effect_Value {
public static function is_valid( array $animation_value ): bool {
$effect_value = $animation_value['effect']['value'] ?? null;
if ( 'custom' !== $effect_value ) {
return true;
}
if ( ! isset( $animation_value['custom_effect'] ) ) {
return false;
}
$props_parser = Props_Parser::make( [
'custom_effect' => Custom_Effect_Prop_Type::make(),
] );
$result = $props_parser->parse( [ 'custom_effect' => $animation_value['custom_effect'] ] );
return $result->is_valid();
}
}

View File

@@ -0,0 +1,29 @@
<?php
namespace Elementor\Modules\Interactions\Validators;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class String_Value {
public static function is_valid( $prop_value, $allowed_values = null ) {
if ( ! is_array( $prop_value ) ) {
return false;
}
if ( ! isset( $prop_value['$$type'] ) || 'string' !== $prop_value['$$type'] ) {
return false;
}
if ( ! isset( $prop_value['value'] ) || ! is_string( $prop_value['value'] ) ) {
return false;
}
if ( null !== $allowed_values && ! in_array( $prop_value['value'], $allowed_values, true ) ) {
return false;
}
return true;
}
}

View File

@@ -0,0 +1,24 @@
<?php
namespace Elementor\Modules\Interactions\Validators;
use Elementor\Modules\Interactions\Validators\String_Value as StringValueValidator;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Trigger_Value {
private const VALID_TRIGGERS = [
'load',
'scrollIn',
'scrollOut',
'scrollOn',
'hover',
'click',
];
public static function is_valid( $trigger_prop_value ) {
return StringValueValidator::is_valid( $trigger_prop_value, static::VALID_TRIGGERS );
}
}