HEX
Server: Apache/2.4.65 (Ubuntu)
System: Linux ielts-store-v2 6.8.0-1036-gcp #38~22.04.1-Ubuntu SMP Thu Aug 14 01:19:18 UTC 2025 x86_64
User: root (0)
PHP: 7.2.34-54+ubuntu20.04.1+deb.sury.org+1
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,
Upload Files
File: /var/www/html/ielts-store/wp-content/plugins/automatewoo/includes/Rules/Abstract_Meta.php
<?php

namespace AutomateWoo\Rules;

defined( 'ABSPATH' ) || exit;

/**
 * @class Abstract_Meta
 */
abstract class Abstract_Meta extends Rule {

	/** @var string */
	public $type = 'meta';

	/** @var bool */
	public $has_multiple_value_fields = true;

	/**
	 * Abstract_Meta constructor.
	 */
	public function __construct() {
		$this->compare_types = $this->get_string_compare_types() + $this->get_integer_compare_types();
		parent::__construct();
	}


	/**
	 * Validate a meta value.
	 *
	 * @param mixed  $actual_value
	 * @param string $compare_type
	 * @param mixed  $expected_value
	 * @return bool
	 */
	public function validate_meta( $actual_value, $compare_type, $expected_value ) {

		// Meta compares are a mix of string and number comparisons.
		// Validate as a number for numeric comparisons (greater/less/multiples) and for is/is not ONLY with numeric values
		if ( $this->is_numeric_meta_field( $compare_type, $expected_value ) ) {
			return $this->validate_number( $actual_value, $compare_type, $expected_value );
		} else {
			return $this->validate_string( $actual_value, $compare_type, $expected_value );
		}
	}

	/**
	 * Determine whether the meta field can reasonably be evaluated as a number, specifically for
	 * numeric comparisons (greater/less/multiples) and for numeric is/is not.
	 * This can facilitate better comparisons (for example, "5" = "5.0" in numeric comparisons,
	 * but not in string comparisons).
	 *
	 * @since 5.1.0
	 *
	 * @param string $compare_type
	 * @param mixed  $value
	 *
	 * @return bool True if the meta field is determined to be numeric.
	 */
	protected function is_numeric_meta_field( $compare_type, $value ) {
		$is_numeric_compare_type = ( $this->is_integer_compare_type( $compare_type ) && ! $this->is_is_or_is_not_compare_type( $compare_type ) );
		$is_numeric_is_is_not    = ( is_numeric( $value ) && $this->is_is_or_is_not_compare_type( $compare_type ) );

		return $is_numeric_compare_type || $is_numeric_is_is_not;
	}


	/**
	 * Return an associative array with 'key' and 'value' elements.
	 *
	 * @param mixed $value
	 * @return array|false
	 */
	public function prepare_value_data( $value ) {
		if ( ! is_array( $value ) ) {
			return false;
		}

		return [
			'key'   => trim( $value[0] ),
			'value' => isset( $value[1] ) ? $value[1] : false,
		];
	}

}