How to create admin widget

Learn how to create admin widget on tendoo

Create widgets for tendoo let you add piece of code runnable on the main page of your dashboard.

In previous releases, it was required for module to explicitly declare widget compatibility, and it was a feature only available for modules.

Since the 1.3 release, even theme can create admin widget since it's done through "declare_admin_widget" function.

Creating admin widget can be triggered from "init.php". a conditional tag can be added if the script is running dashboard or not.

Here is how you can create a widget for your dashboard.

<?php
/**
 * File : init.php
**/
declare_admin_widget( array(
  	'widget_namespace'	=>	'custom', // since unlimited widgets can been created form unique module/theme
  	'module_namespace'	=>	'custom', // module namespace or theme namespace
  	'widget_title'			=>	__( 'Custom Widget' ),
  	'widget_content'		=>	module_view( 'views/widgets/custom' , 'custom' ), // load ouput for this widget.
  	'widget_description'=>	__( 'Custom description for custom widget' ),
  	'action_control'		=>	current_user()->can( 'custom@see_widgets' )  
) );

Optional key "widget _form" let you customize widget form.