English (United Kingdom)

apply_filters( 'vikbooking_load_pms_reports', array $return )

Fired during the plugin installation, it's necessary to define the driver paths to let VikBooking recognize them as PMS Report drivers. Your driver(s) will then be available for selection in the apposite back-end page PMS - Reports as well as in the apposite Cron Job to automate the export functions.


Description

This hook is needed when creating a new native Wordpress plugin that will be used by VikBooking to extend its PMS Report framework. Reports are useful to export any kind of data and information, as well as to perform calculations.


Parameters

$return

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

Example

The example below shows how to define two custom PMS Report driver files that will be installed in VikBooking.

<?php
/*
Plugin Name:  VBO Custom PMS Reports
Plugin URI:   https://vikwp.com/plugin/vikbooking
Description:  Custom PMS Reports for VikBooking.
Version:      1.0.0
Author:       E4J s.r.l.
Author URI:   https://vikwp.com
License:      GPL2
License URI:  https://www.gnu.org/licenses/gpl-2.0.html
Text Domain:  vbocustomadminreports
*/

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

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

    /**
     * Since multiple plugins could add their own custom PMS reports, it
     * is necessary to always merge the paths to the PMS report files of
     * this plugin to any previous report that may have already been injected.
     * Simply define an array of absolute paths to the PHP files that declare
     * the needed class by VikBooking to load a PMS report driver.
     * 
     * In this example, we are telling VikBooking to load two custom PMS Reports.
     */
    return array_merge($return, [
        // WP_PLUGIN_DIR         = absolute server path to plugin's directory
        // vbocustomadminreports = the name of this custom plugin
        // reports               = a private/internal folder of this custom plugin
        // custom_one.php        = the class file that declares the PMS Report
        WP_PLUGIN_DIR . '/vbocustomadminreports/reports/custom_one.php',

        // custom_two.php        = the class file that declares the PMS Report
        WP_PLUGIN_DIR . '/vbocustomadminreports/reports/custom_two.php',
    ]);
});

By using the code above inside the main plugin file (vbocustomadminreports.php) you can load as many custom PMS Reports as you want. The tree below shows the files and folders structure of the custom plugin you can install on your WordPress website:

  • Folder: vbocustomadminreports
    • File: vbocustomadminreports.php
    • Folder: reports
      • File: custom_one.php
      • File: custom_two.php

At this point you need to actually code your custom PMS Report driver files to let them generate columns and rows for the data extracted just like if it was a calculation sheet.

Last Update: 2023-06-13
Helpful?
100% of people found this helpful.
This site uses cookies. By continuing to browse you accept their use. Further information