<?php
|
namespace JVBase\managers\SEO\render\Traits\_Properties;
|
|
use JVBase\managers\SEO\render\DataType\Date;
|
use JVBase\meta\Meta;
|
use JVBase\registrar\Fields;
|
|
if (!defined('ABSPATH')) {
|
exit;
|
}
|
trait dissolutionDateTrait {
|
/**
|
* @var Date The date that this organization was dissolved.
|
*/
|
protected Date $dissolutionDate;
|
|
public function getDissolutionDate():?Date
|
{
|
return $this->dissolutionDate??null;
|
}
|
public function setDissolutionDate(Date|string $dissolutionDate):void
|
{
|
if (is_string($dissolutionDate)){
|
$dissolutionDate = new Date($dissolutionDate);
|
}
|
$this->dissolutionDate = $dissolutionDate;
|
}
|
public function getDissolutionDateFieldConfig():array
|
{
|
return [
|
'type' => 'date',
|
'label' => 'Dissolution Date',
|
'hint' => 'IMPORTANT: Do not fill this out, unless your business has actually closed.'
|
];
|
}
|
public function setDissolutionDateField(Fields $fields):void
|
{
|
$fields->addField(
|
'permanently_close',
|
[
|
'type' => 'true_false',
|
'label' => __('Permanently Close', 'jvb'),
|
'hint' => '*IMPORTANT* This signals to search engines that this business is no longer in business. Use only if your shop is closing!',
|
]
|
);
|
$fields->addField(
|
'dissolution_date',
|
[
|
'type' => 'date',
|
'label' => __('Dissolution Date', 'jvb'),
|
'condition' => [
|
'field' => 'permanently_close',
|
'operator' => '==',
|
'value' => true,
|
]
|
]
|
);
|
}
|
|
public function formatDissolutionDateField(Meta $meta):void
|
{
|
[$closed, $dissolution] = $meta->getAll(['permanently_close', 'dissolution_date']);
|
if (!empty($closed) && $closed === true) {
|
if (!empty($dissolution)) {
|
$this->setDissolutionDate($dissolution);
|
}
|
}
|
}
|
}
|