public function form($instance)
    {
        $fields = $this->getModel()->getFields();

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

        // Add Title field from default mode
        $new_title = [
            'special' => [
                'id' => 'title',
                'title' => Translate::t('widget.fields.title'),
            ],
        ];

        // Add Title field from `olympus-text-field` component
        if (class_exists('\\GetOlympus\\Field\\Text')) {
            $new_title = \GetOlympus\Field\Text::build('title', [
                'title' => Translate::t('widget.fields.title'),
            ]);
        }

        // Add title on 1st place
        array_unshift($fields, $new_title);
        unset($new_title);

        $vars = [];

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

            // Build contents
            if (is_array($field) && isset($field['special'])) {
                $ctn = (array) $field['special'];
                $hasId = true;
            } else {
                $ctn = (array) $field->getModel()->getContents();
                $hasId = (boolean) $field->getModel()->getHasId();
            }

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

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

            // Value
            $id = isset($ctn['id']) ? $ctn['id'] : '';
            $value = !empty($id) && isset($instance[$id]) ? $instance[$id] : '';

            // Id and name
            $ctn['id'] = $this->get_field_id($id);
            $ctn['name'] = $this->get_field_name($id);

            // Get render field
            $vars['fields'][] = $field->render($ctn, [
                'template' => 'widget',
                'widget_value' => $value
            ], false);
        }

        // Render view
        Render::view('widget.html.twig', $vars, 'widget');
    }
public function form($instance)
    {
        $fields = $this->getModel()->getFields();

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

        // Add Title field from default mode
        $new_title = [
            'special' => [
                'id' => 'title',
                'title' => Translate::t('widget.fields.title'),
            ],
        ];

        // Add Title field from `olympus-text-field` component
        if (class_exists('\\GetOlympus\\Field\\Text')) {
            $new_title = \GetOlympus\Field\Text::build('title', [
                'title' => Translate::t('widget.fields.title'),
            ]);
        }

        // Add title on 1st place
        array_unshift($fields, $new_title);
        unset($new_title);

        $vars = [];

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

            // Build contents
            if (is_array($field) && isset($field['special'])) {
                $ctn = (array) $field['special'];
                $hasId = true;
            } else {
                $ctn = (array) $field->getModel()->getContents();
                $hasId = (boolean) $field->getModel()->getHasId();
            }

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

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

            // Value
            $id = isset($ctn['id']) ? $ctn['id'] : '';
            $value = !empty($id) && isset($instance[$id]) ? $instance[$id] : '';

            // Id and name
            $ctn['id'] = $this->get_field_id($id);
            $ctn['name'] = $this->get_field_name($id);

            // Get render field
            $vars['fields'][] = $field->render($ctn, [
                'template' => 'widget',
                'widget_value' => $value
            ], false);
        }

        // Render view
        Render::view('widget.html.twig', $vars, 'widget');
    }
public function form ( $ instance ) { $ fields = $ this -> getModel ( ) -> getFields ( ) ; // Check fields if ( empty ( $ fields ) ) { return ; } // Add Title field from default mode $ new_title = [ 'special' => [ 'id' => 'title' , 'title' => Translate :: t ( 'widget.fields.title' ) , ] , ] ; // Add Title field from `olympus-text-field` component if ( class_exists ( '\\GetOlympus\\Field\\Text' ) ) { $ new_title = \ GetOlympus \ Field \ Text :: build ( 'title' , [ 'title' => Translate :: t ( 'widget.fields.title' ) , ] ) ; } // Add title on 1st place array_unshift ( $ fields , $ new_title ) ; unset ( $ new_title ) ; $ vars = [ ] ; // Get fields foreach ( $ fields as $ field ) { if ( ! $ field ) { continue ; } // Build contents if ( is_array ( $ field ) && isset ( $ field [ 'special' ] ) ) { $ ctn = ( array ) $ field [ 'special' ] ; $ hasId = true ; } else { $ ctn = ( array ) $ field -> getModel ( ) -> getContents ( ) ; $ hasId = ( boolean ) $ field -> getModel ( ) -> getHasId ( ) ; } // Check fields if ( empty ( $ ctn ) || ! $ hasId ) { continue ; } // Does the field have an ID if ( ! isset ( $ ctn [ 'id' ] ) || empty ( $ ctn [ 'id' ] ) ) { continue ; } // Value $ id = isset ( $ ctn [ 'id' ] ) ? $ ctn [ 'id' ] : '' ; $ value = ! empty ( $ id ) && isset ( $ instance [ $ id ] ) ? $ instance [ $ id ] : '' ; // Id and name $ ctn [ 'id' ] = $ this -> get_field_id ( $ id ) ; $ ctn [ 'name' ] = $ this -> get_field_name ( $ id ) ; // Get render field $ vars [ 'fields' ] [ ] = $ field -> render ( $ ctn , [ 'template' => 'widget' , 'widget_value' => $ value ] , false ) ; } // Render view Render :: view ( 'widget.html.twig' , $ vars , 'widget' ) ; }
Displays the form for this widget on the Widgets page of the WP Admin area.

@return void
Displays the form for this widget on the Widgets page of the WP Admin area .