<?php
namespace Elementor;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
/**
* Elementor conditions.
*
* Elementor conditions handler class introduce the compare conditions and the
* check conditions methods.
*
* @since 1.0.0
*/
class Conditions {
/**
* Compare conditions.
*
* Whether the two values comply the comparison operator.
*
* @since 1.0.0
* @access public
* @static
*
* @param mixed $left_value First value to compare.
* @param mixed $right_value Second value to compare.
* @param string $operator Comparison operator.
*
* @return bool Whether the two values complies the comparison operator.
*/
public static function compare( $left_value, $right_value, $operator ) {
switch ( $operator ) {
case '==':
return $left_value == $right_value;
case '!=':
return $left_value != $right_value;
case '!==':
return $left_value !== $right_value;
case 'in':
return in_array( $left_value, $right_value, true );
case '!in':
return ! in_array( $left_value, $right_value, true );
case 'contains':
return in_array( $right_value, $left_value, true );
case '!contains':
return ! in_array( $right_value, $left_value, true );
case '<':
return $left_value < $right_value;
case '<=':
return $left_value <= $right_value;
case '>':
return $left_value > $right_value;
case '>=':
return $left_value >= $right_value;
default:
return $left_value === $right_value;
}
}
/**
* Check conditions.
*
* Whether the comparison conditions comply.
*
* @since 1.0.0
* @access public
* @static
*
* @param array $conditions The conditions to check.
* @param array $comparison The comparison parameter.
*
* @return bool Whether the comparison conditions comply.
*/
public static function check( array $conditions, array $comparison ) {
$is_or_condition = isset( $conditions['relation'] ) && 'or' === $conditions['relation'];
$condition_succeed = ! $is_or_condition;
foreach ( $conditions['terms'] as $term ) {
if ( ! empty( $term['terms'] ) ) {
$comparison_result = self::check( $term, $comparison );
} else {
preg_match( '/(\w+)(?:\[(\w+)])?/', $term['name'], $parsed_name );
$value = $comparison[ $parsed_name[1] ];
if ( ! empty( $parsed_name[2] ) ) {
$value = $value[ $parsed_name[2] ];
}
$operator = null;
if ( ! empty( $term['operator'] ) ) {
$operator = $term['operator'];
}
$comparison_result = self::compare( $value, $term['value'], $operator );
}
if ( $is_or_condition ) {
if ( $comparison_result ) {
return true;
}
} elseif ( ! $comparison_result ) {
return false;
}
}
return $condition_succeed;
}
}
| nama | waktu | ukuran | owner | perm | aksi |
|---|---|---|---|---|---|
| .. | |||||
| admin-templates/ | 2026-11-25 08:10 | 10.11 KB | 76129f60960:kunden | dxwrx-rx-r | |
| base/ | 2026-11-25 08:10 | 153.85 KB | 76129f60960:kunden | dxwrx-rx-r | |
| controls/ | 2026-11-25 08:10 | 260.89 KB | 76129f60960:kunden | dxwrx-rx-r | |
| editor-templates/ | 2026-11-25 08:10 | 98.46 KB | 76129f60960:kunden | dxwrx-rx-r | |
| elements/ | 2026-11-25 08:10 | 117.77 KB | 76129f60960:kunden | dxwrx-rx-r | |
| interfaces/ | 2026-11-25 08:10 | 730 B | 76129f60960:kunden | dxwrx-rx-r | |
| libraries/ | 2026-11-25 08:10 | 24.14 KB | 76129f60960:kunden | dxwrx-rx-r | |
| managers/ | 2026-11-25 08:10 | 91.38 KB | 76129f60960:kunden | dxwrx-rx-r | |
| settings/ | 2026-11-25 08:10 | 54.34 KB | 76129f60960:kunden | dxwrx-rx-r | |
| template-library/ | 2026-11-25 08:10 | 154.16 KB | 76129f60960:kunden | dxwrx-rx-r | |
| widgets/ | 2026-11-25 08:10 | 510.64 KB | 76129f60960:kunden | dxwrx-rx-r | |
| api.php | 2026-11-25 08:10 | 8.82 KB | 76129f60960:kunden | -xw-x--x-- | |
| autoloader.php | 2026-11-25 08:10 | 9.79 KB | 76129f60960:kunden | -xw-x--x-- | |
| beta-testers.php | 2026-11-25 08:10 | 3.17 KB | 76129f60960:kunden | -xw-x--x-- | |
| compatibility.php | 2026-11-25 08:10 | 10.96 KB | 76129f60960:kunden | -xw-x--x-- | |
| conditions.php | 2026-11-25 08:10 | 2.7 KB | 76129f60960:kunden | -xw-x--x-- | |
| db.php | 2026-11-25 08:10 | 15.89 KB | 76129f60960:kunden | -xw-x--x-- | |
| editor-assets-api.php | 2026-11-25 08:10 | 4.5 KB | 76129f60960:kunden | -xw-x--x-- | |
| embed.php | 2026-11-25 08:10 | 9.57 KB | 76129f60960:kunden | -xw-x--x-- | |
| fonts.php | 2026-11-25 08:10 | 62.53 KB | 76129f60960:kunden | -xw-x--x-- | |
| frontend.php | 2026-11-25 08:10 | 40.02 KB | 76129f60960:kunden | -xw-x--x-- | |
| heartbeat.php | 2026-11-25 08:10 | 3.34 KB | 76129f60960:kunden | -xw-x--x-- | |
| maintenance-mode.php | 2026-11-25 08:10 | 11.16 KB | 76129f60960:kunden | -xw-x--x-- | |
| maintenance.php | 2026-11-25 08:10 | 2.99 KB | 76129f60960:kunden | -xw-x--x-- | |
| plugin.php | 2026-11-25 08:10 | 15.67 KB | 76129f60960:kunden | -xw-x--x-- | |
| preview.php | 2026-11-25 08:10 | 8.21 KB | 76129f60960:kunden | -xw-x--x-- | |
| rollback.php | 2026-11-25 08:10 | 4.16 KB | 76129f60960:kunden | -xw-x--x-- | |
| shapes.php | 2026-11-25 08:10 | 7.81 KB | 76129f60960:kunden | -xw-x--x-- | |
| stylesheet.php | 2026-11-25 08:10 | 8.91 KB | 76129f60960:kunden | -xw-x--x-- | |
| tracker.php | 2026-11-25 08:10 | 17 KB | 76129f60960:kunden | -xw-x--x-- | |
| user-data.php | 2026-11-25 08:10 | 3.67 KB | 76129f60960:kunden | -xw-x--x-- | |
| user.php | 2026-11-25 08:10 | 10.11 KB | 76129f60960:kunden | -xw-x--x-- | |
| utils.php | 2026-11-25 08:10 | 30.51 KB | 76129f60960:kunden | -xw-x--x-- | |