| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\Interactions\Validators; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class String_Value { |
| 10 |
public static function is_valid( $prop_value, $allowed_values = null ) { |
| 11 |
if ( ! is_array( $prop_value ) ) { |
| 12 |
return false; |
| 13 |
} |
| 14 |
|
| 15 |
if ( ! isset( $prop_value['$$type'] ) || 'string' !== $prop_value['$$type'] ) { |
| 16 |
return false; |
| 17 |
} |
| 18 |
|
| 19 |
if ( ! isset( $prop_value['value'] ) || ! is_string( $prop_value['value'] ) ) { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
if ( null !== $allowed_values && ! in_array( $prop_value['value'], $allowed_values, true ) ) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
|
| 27 |
return true; |
| 28 |
} |
| 29 |
} |
| 30 |
|