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?

This website uses cookies

This website uses cookies and similar technologies. Some of these technologies are necessary for the proper functioning of the website (Essential). Other technologies are used to evaluate user behavior (Analysis), to integrate external media or for advertising purposes. If you agree, these technologies are activated. For details, please refer to the privacy policy. From this same page you can also update/revoke your consent. If you do not give your consent, only cookies with essential functions will be activated.

We use technologies from the USA on our website. If you give your consent, you therefore consent at the same time to your data being transferred to the USA. We would like to point out that the USA does not have a level of data protection comparable to that of the EU and that any US company can be obliged by state authorities to hand over your data without you having any effective legal protection against this.