Your cart is empty!
Widget file
This is the widget's main PHP file. The method render() is declared as abstract by the parent class, and so it must be implemented as described.
You can add any kind of custom PHP code, methods and variables to this example class. You can also make use of AJAX requests and schedule Browser notifications.
Here's an example of how to create a custom admin widget for Vik Booking (the file should be named exactly as custom_two.php in this example):
<?php
/**
* @package VikBooking
* @subpackage custom_two_admin_widget
* @license GNU General Public License version 2 or later; see LICENSE
* @link https://vikwp.com
*/
defined('ABSPATH') or die('No script kiddies please!');
/**
* Class handler for admin widget "custom two".
*/
class VikBookingAdminWidgetCustomTwo extends VikBookingAdminWidget
{
/**
* Class constructor will define the widget name, the description,
* an optional icon, a style and the unique identifier.
*/
public function __construct()
{
// call parent constructor
parent::__construct();
$this->widgetName = 'Custom Two';
$this->widgetDescr = 'Description for admin widget custom two...';
$this->widgetId = basename(__FILE__, '.php');
// define optional widget icon and style name
$this->widgetIcon = '<i class="' . VikBookingIcons::i('bell') . '"></i>';
$this->widgetStyleName = 'green';
}
/**
* Render method will output the content of the widget.
*
* @param VBOMultitaskData $data multitask data object.
*
* @return void
*/
public function render(VBOMultitaskData $data = null)
{
?>
<div class="vbo-admin-widget-wrapper">
<div class="vbo-admin-widget-head">
<h4><?php echo $this->getName(); ?></h4>
</div>
<div class="vbo-admin-widget-body">
<?php echo '<p class="info">Hey, I am a custom admin widget for VikBooking called "' . $this->getName() . '".</p>'; ?>
<p>I can send HTML contents to output, and I can perform operations through PHP.</p>
</div>
</div>
<?php
}
}
Last Update: 2022-02-24
Helpful?
75% of people found this helpful.