1. Home
  2. Docs
  3. Application Framework
  4. Plugin Guide
  5. Widgets



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 );
Was this article helpful to you? Yes No

How can we help?