| | |
| | | namespace JVBase\managers\SEO\render\Traits\_Properties; |
| | | |
| | | use JVBase\managers\SEO\render\Traits\_Helpers\arrayHelper; |
| | | use JVBase\meta\Meta; |
| | | use JVBase\registrar\Fields; |
| | | |
| | | if (!defined('ABSPATH')) { |
| | | exit; |
| | |
| | | } |
| | | $this->award = $award; |
| | | } |
| | | public function getAwardFieldConfig():array |
| | | |
| | | public function setAwardField(Fields $fields):void |
| | | { |
| | | return [ |
| | | 'type' => 'repeater', |
| | | 'label' => 'Award(s)', |
| | | 'hint' => 'List any awards won by this Thing.', |
| | | $fields->addField('awards', [ |
| | | 'type' => 'tagList', |
| | | 'label' => __('Award(s)', 'jvb'), |
| | | 'hint' => 'List any awards won by this Thing.', |
| | | 'fields' => [ |
| | | 'award' => [ |
| | | 'name' => [ |
| | | 'type' => 'text', |
| | | 'label' => 'Award', |
| | | 'hint' => 'Include the award name, year, and presenter (if any)' |
| | | 'label' => __('Award Name', 'jvb'), |
| | | 'required' => true, |
| | | ], |
| | | 'presenter' => [ |
| | | 'type' => 'text', |
| | | 'label' => __('Presenter', 'jvb'), |
| | | ], |
| | | 'year' => [ |
| | | 'type' => 'number', |
| | | 'label' => __('Year', 'jvb') |
| | | ] |
| | | ] |
| | | ]; |
| | | ]); |
| | | } |
| | | |
| | | public function formatAwardField(Meta $meta):void |
| | | { |
| | | $awards = $meta->get('awards'); |
| | | $out = []; |
| | | if (!empty($awards)) { |
| | | foreach ($awards as $a) { |
| | | $award = false; |
| | | if (!empty($a['name'])) { |
| | | $award = '"'.$a['name'].'"'; |
| | | }else { |
| | | continue; |
| | | } |
| | | if (!empty($a['presenter'])) { |
| | | $award .= ', presented by '.$a['presenter']; |
| | | } |
| | | if (!empty($a['year'])) { |
| | | $award .= ' - '.$a['year']; |
| | | } |
| | | if ($award) { |
| | | $out[] = $award; |
| | | } |
| | | } |
| | | } |
| | | if (!empty ($out)) { |
| | | $this->setAward($out); |
| | | } |
| | | } |
| | | } |