Jake Vanderwerf
2026-05-03 9bbeea742424837fb58207d88e10dbca0b2cae04
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?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);
            }
        }
    }
}