| Server IP : 165.22.154.248 / Your IP : 216.73.217.0 [ Web Server : Apache/2.4.29 (Ubuntu) System : Linux droplet-integra 4.15.0-197-generic #208-Ubuntu SMP Tue Nov 1 17:23:37 UTC 2022 x86_64 User : www-data ( 33) PHP Version : 7.2.24-0ubuntu0.18.04.15 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, Domains : 1 Domains MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /var/www/web-integra/wp-content/plugins/elementor/includes/ |
Upload File : |
<?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 false !== array_search( $left_value, $right_value );
case '!in':
return false === array_search( $left_value, $right_value );
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;
}
}