English (United Kingdom)
1.4.0
<?php
/*
Plugin Name:  VrcCustomAdminWidgets
Plugin URI:   https://vikwp.com/plugin/vikrentcar
Description:  Custom admin widgets for VikRentCar.
Author:       E4J s.r.l.
Author URI:   https://vikwp.com
License:      GPL2
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
*/

// no direct access
defined('ABSPATH') or die('No script kiddies please!');

// register callback for filter "vikrentcar_load_admin_widgets"
add_filter('vikrentcar_load_admin_widgets', function($return)
{
	if (!$return)
	{
		$return = [];
	}

	/**
	 * Since multiple plugins could add their own custom admin widgets, it
	 * is necessary to always merge the paths to the admin widget files of
	 * this plugin to any previous widget that may have already been injected.
	 * Simply define an array of absolute paths to the PHP files that declare
	 * the needed class by VikRentCar to load an admin widget.
	 * 
	 * In this example, we are telling VikRentCar to load two custom admin widgets.
	 */
	return array_merge($return, [
		// WP_PLUGIN_DIR 		 = absolute server path to plugin's directory
		// vrccustomadminwidgets = the name of this custom plugin
		// admin_widgets 		 = a private/internal folder of this custom plugin
		// custom_one.php 		 = the class file that declares the admin widget
		WP_PLUGIN_DIR . '/vrccustomadminwidgets/admin_widgets/custom_one.php',
		
		// custom_two.php 		 = the class file that declares the admin widget
		WP_PLUGIN_DIR . '/vrccustomadminwidgets/admin_widgets/custom_two.php',
	]);
});

add_filter( 'vikrentcar_load_admin_widgets', function$return )

Fired during the plugin installation, it's necessary to define the widgets paths to let VikRentCar recognize them as Widgets for your Dashboard.


Description

This hook is needed to create a new native Wordpress plugin that will be the used by VikRentCar to extend his widgets framework and include the plugins you've created in your VikRentCar dashboard.


Parameters

function($return)

 Function where you'll return the file paths for the callback of the filter 'vikrentcar_load_admin_widgets'

Example

The example below explains how to define a basic VikRentCar widget.

Last Update: 2021-11-17
Helpful?