HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: 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,pcntl_unshare,
Upload Files
File: /var/www/lipovac/wp-content/plugins/the-events-calendar/common/src/Tribe/Field_Conditional.php
<?php

/**
 * Class Tribe__Field_Conditional
 *
 * A work-around for PHP 5.2 lack of closure support to wrap
 *
 * Example usage: in the context of the definition of a list of fields to be fed to the Tribe__Settings class:
 *
 *      $fields = array(
 *          'foo' => array(
 *              'type' => 'checkbox_bool',
 *              // ...
 *          ),
 *          'bar' => array(
 *              'type' => 'text'
 *              'validate_if' => new Tribe__Field_Conditional( 'foo', 'tribe_is_truthy' )
 *              'conditional' => tribe_is_truthy( tribe_get_option( 'foo' ) ),
 *              // ...
 *          ),
 *      );
 *
 * The above will modify the validation logic to make it so that the field will not be validated if
 * the parent (`foo` in the example) is not "truthy".
 * If you need to hide/show the field conditionally use the `conditional` attribute of the field.
 *
 * @since 4.7.7
 */
class Tribe__Field_Conditional {

	/**
	 * @var string The slug of the field the condition
	 */
	protected $depends_on;
	/**
	 * @var bool
	 */
	protected $condition;

	/**
	 * Tribe__Field_Conditional constructor.
	 *
	 * @since 4.7.7
	 *
	 * @param      string    $depends_on_field The slug or identifier of the parent field.
	 * @param mixed|callable $condition        Either a valid callable function or method or a
	 *                                         value that will be used for a shallow comparison.
	 */
	public function __construct( $depends_on_field, $condition = true ) {
		$this->depends_on = $depends_on_field;
		$this->condition  = $condition;
	}

	/**
	 * @param       mixed $value  The value to check, typically the parent field value.
	 * @param array       $fields An array of all the current fields; this will be passed to
	 *                            the condition callback function for context if the condition
	 *                            is a callable function or method.
	 *
	 * @return bool Whether the check was successful (the parent field does have the required
	 *              value) or not.
	 */
	public function check( $value, array $fields ) {
		return is_callable( $this->condition )
			? call_user_func( $this->condition, $value, $fields )
			: $value == $this->condition;
	}

	/**
	 * Return the id/slug of the field this condition depends on.
	 *
	 * @since 4.7.7
	 *
	 * @return string
	 */
	public function depends_on() {
		return $this->depends_on;
	}
}