| | |
| | | $business->setHasOfferCatalogField($this); |
| | | } |
| | | |
| | | public function registerPostFields():void |
| | | { |
| | | $postType = $this->registrar->getBased(); |
| | | add_meta_box( |
| | | $postType.'_fields', |
| | | 'Extra Fields', |
| | | [$this, 'renderMyMetaBox'], |
| | | $postType, |
| | | 'side', |
| | | 'high' |
| | | ); |
| | | } |
| | | public function renderMyMetaBox():void |
| | | { |
| | | $ID = get_the_ID(); |
| | | $meta = match ($this->type) { |
| | | 'post' => Meta::forPost($ID), |
| | | 'term' => Meta::forTerm($ID), |
| | | 'user' => Meta::forUser($ID), |
| | | }; |
| | | $defaults = array_keys(match($this->type) { |
| | | 'post' => $this->defaultPostFields(), |
| | | 'term' => $this->defaultTermFields(), |
| | | 'user' => $this->defaultUserFields() |
| | | }); |
| | | foreach ($this->fields as $fName => $field){ |
| | | if (!in_array($fName, $defaults)){ |
| | | echo Form::render($fName, $meta->get($fName),$field->getConfig()); |
| | | } |
| | | } |
| | | } |
| | | // public function registerPostFields():void |
| | | // { |
| | | // $postType = $this->registrar->getBased(); |
| | | // add_meta_box( |
| | | // $postType.'_fields', |
| | | // 'Extra Fields', |
| | | // [$this, 'renderMyMetaBox'], |
| | | // $postType, |
| | | // 'side', |
| | | // 'high' |
| | | // ); |
| | | // } |
| | | // public function renderMyMetaBox():void |
| | | // { |
| | | // $ID = get_the_ID(); |
| | | // $meta = match ($this->type) { |
| | | // 'post' => Meta::forPost($ID), |
| | | // 'term' => Meta::forTerm($ID), |
| | | // 'user' => Meta::forUser($ID), |
| | | // }; |
| | | // $defaults = array_keys(match($this->type) { |
| | | // 'post' => $this->defaultPostFields(), |
| | | // 'term' => $this->defaultTermFields(), |
| | | // 'user' => $this->defaultUserFields() |
| | | // }); |
| | | // foreach ($this->fields as $fName => $field){ |
| | | // if (!in_array($fName, $defaults)){ |
| | | // echo Form::render($fName, $meta->get($fName),$field->getConfig()); |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | public static function getUserFields():array |
| | | { |