belongsTo = $belongsTo; $this->exclude = $exclude; } /** * @return array * @throws \Exception */ public function execute(): array { $result = []; if ($this->belongsTo === MetaTypes::CUSTOM_POST_TYPE) { $cpts = CustomPostTypeRepository::get([ 'exclude' => $this->exclude ]); foreach ($cpts as $cpt) { $result[] = [ 'label' => $cpt->getName(), 'value' => $cpt->getName() ]; } } if ($this->belongsTo === MetaTypes::TAXONOMY) { $taxs = TaxonomyRepository::get([ 'exclude' => $this->exclude ]); foreach ($taxs as $tax) { $result[] = [ 'label' => $tax->getSlug(), 'value' => $tax->getSlug() ]; } } return $result; } }