nsrosenqvist/cmb2-widget

This package is abandoned and no longer maintained. No replacement package was suggested.

Installs: 63

Dependents: 1

Suggesters: 0

Security: 0

Stars: 3

Watchers: 1

Forks: 1

Open Issues: 0

Type:wordpress-plugin

1.0.1 2018-06-19 09:37 UTC

This package is auto-updated.

Last update: 2020-06-09 20:10:13 UTC


README

Lets you use CMB2 in widgets

Extend the abstract widget class.

use NSRosenqvist\CMB2\Widgets\CMB2_Widget;

class MyWidget extends CMB2_Widget
{
    protected $fields = [
        // You can set ID both as the key and in the array
        'title' => [
			'name' 			   => __('Title', 'theme'),
			'type'             => 'text',
		],
    ];

    function __construct($id_base, $name, $widget_options = [], $control_options = [])
    {
        parent::__construct(
            // Base ID of widget
            'my_widget'
            // Widget name will appear in UI
            'My Widget',
            // Widget description
            $widget_options,
            // Widget options
            $control_options
        );
    }
}