| | |
| | | public array $config; |
| | | public bool $isDirty = false; |
| | | public bool $isValid = true; |
| | | public bool $isDefault = false; |
| | | public array $errors = []; |
| | | |
| | | public function __construct(string $name, mixed $value, array $config = []) |
| | |
| | | $this->value = $value; |
| | | $this->originalValue = $value; |
| | | $this->config = $config; |
| | | if (array_key_exists('wp', $config) && $config['wp'] === true) { |
| | | $this->isDefault = true; |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public function set(mixed $value): self |
| | | { |
| | | $this->value = $value; |
| | | $this->isDirty = ($value !== $this->originalValue); |
| | | error_log('Checking if value is the same as old value: '.print_r($value, true)); |
| | | if ($value !== $this->value) { |
| | | error_log('Saving new value: '.print_r($value, true)); |
| | | $this->value = $value; |
| | | $this->isDirty = true; |
| | | } |
| | | return $this; |
| | | } |
| | | |
| | |
| | | */ |
| | | public function isWpDefault(): bool |
| | | { |
| | | return $this->config['_wp_default'] ?? false; |
| | | return $this->isDefault ?? false; |
| | | } |
| | | |
| | | /** |
| | |
| | | */ |
| | | public function isTaxonomy(): bool |
| | | { |
| | | return $this->type() === 'taxonomy' && !isset($this->config['taxonomy_type']); |
| | | return ($this->type() === 'taxonomy' || ($this->type() === 'selector' && isset($this->config['subtype']) && $this->config['subtype'] === 'taxonomy')) && !isset($this->config['isReference']); |
| | | } |
| | | |
| | | /** |