Exemple #1
0
 /**
  * Get taxonomy field
  *
  * @return AbstractField
  * @throws WpException
  */
 public function get_field()
 {
     if ($this->_field == null) {
         if ($this->_field_init == null) {
             $this->_field = new Text();
         } elseif (is_string($this->_field_init)) {
             $this->_field = FieldFactory::build($this->_field_init);
         } elseif (Action::is_callable($this->_field_init)) {
             $this->_field = Action::execute($this->_field_init);
             if (!$this->_field instanceof AbstractField) {
                 throw new WpException("Option \"{$this->_title}\" init function must return a Field.");
             }
         } else {
             throw new WpException("Invalid field type.");
         }
         $this->_field->set_name($this->_key);
         $this->_field->set_label($this->_title);
     }
     return $this->_field;
 }