public function addFields($term, $mode = 'edit')
    {
        // Check mode
        $mode = in_array($mode, ['add', 'edit']) ? $mode : 'edit';

        // Check fields
        if (empty($this->fields)) {
            return;
        }

        // Get current
        $term = is_object($term) ? $term : get_term($term);

        // Get fields
        foreach ($this->fields as $field) {
            if (!$field) {
                continue;
            }

            // Build contents
            $ctn = (array) $field->getModel()->getContents();
            $hasId = (boolean) $field->getModel()->getHasId();

            // Check fields
            if (empty($ctn)) {
                continue;
            }

            // Does the field have an ID
            if ($hasId && (!isset($ctn['id']) || empty($ctn['id']))) {
                continue;
            }

            // Display field
            $field->render($ctn, [
                'structure' => '%TERM%-%SLUG%',
                'template'  => 'term-'.$mode,
                'term'      => $term,
            ]);
        }
    }
public function addFields($term, $mode = 'edit')
    {
        // Check mode
        $mode = in_array($mode, ['add', 'edit']) ? $mode : 'edit';

        // Check fields
        if (empty($this->fields)) {
            return;
        }

        // Get current
        $term = is_object($term) ? $term : get_term($term);

        // Get fields
        foreach ($this->fields as $field) {
            if (!$field) {
                continue;
            }

            // Build contents
            $ctn = (array) $field->getModel()->getContents();
            $hasId = (boolean) $field->getModel()->getHasId();

            // Check fields
            if (empty($ctn)) {
                continue;
            }

            // Does the field have an ID
            if ($hasId && (!isset($ctn['id']) || empty($ctn['id']))) {
                continue;
            }

            // Display field
            $field->render($ctn, [
                'structure' => '%TERM%-%SLUG%',
                'template'  => 'term-'.$mode,
                'term'      => $term,
            ]);
        }
    }
public function addFields ( $ term , $ mode = 'edit' ) { // Check mode $ mode = in_array ( $ mode , [ 'add' , 'edit' ] ) ? $ mode : 'edit' ; // Check fields if ( empty ( $ this -> fields ) ) { return ; } // Get current $ term = is_object ( $ term ) ? $ term : get_term ( $ term ) ; // Get fields foreach ( $ this -> fields as $ field ) { if ( ! $ field ) { continue ; } // Build contents $ ctn = ( array ) $ field -> getModel ( ) -> getContents ( ) ; $ hasId = ( boolean ) $ field -> getModel ( ) -> getHasId ( ) ; // Check fields if ( empty ( $ ctn ) ) { continue ; } // Does the field have an ID if ( $ hasId && ( ! isset ( $ ctn [ 'id' ] ) || empty ( $ ctn [ 'id' ] ) ) ) { continue ; } // Display field $ field -> render ( $ ctn , [ 'structure' => '%TERM%-%SLUG%' , 'template' => 'term-' . $ mode , 'term' => $ term , ] ) ; } }
Hook building custom fields.

@param string|object $term
@param string        $mode
Hook building custom fields .