MWP\Framwork\Plugin\Widget
A base class is available that you can use to easily add widgets to your plugin. To create a new widget, create a new class that extends MWP\Framework\Plugin\Widget
. Then enable it for your plugin.
@Example Code
namespace VendorName\PackageName;
use MWP\Framework\Plugin\Widget;
class WidgetClass extends Widget
{
// Required property
protected static $plugin;
// Widget name
public $name = 'Hello Widget';
// Widget description
public $description = 'A widget to greet the world.';
// Widget output
public function widget( $args, $instance )
{
echo $this->getPlugin()->getTemplateContent( 'views/template-name' );
}
}
Enable the widget for your plugin like this:
use VendorName\PackageName\Plugin;
use VendorName\PackageName\WidgetClass;
$plugin = Plugin::instance();
WidgetClass::enableOn( $plugin );