Jake Vanderwerf
2026-05-03 9bbeea742424837fb58207d88e10dbca0b2cae04
inc/managers/SEO/render/Traits/_Properties/dissolutionDateTrait.php
@@ -2,6 +2,8 @@
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;
@@ -31,4 +33,37 @@
         '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);
         }
      }
   }
}