English (United Kingdom)
Knowledge Base  >  Vik Appointments  >  Hooks  >  Export  >  Fetch Supported Drivers

apply_filters( 'vikappointments_fetch_supported_export_drivers', array $drivers )

Fires while loading the list of supported exporting drivers.


Description

Trigger hook to let the plugins register external drivers to export the appointments.

This filter should simply return a list of paths to include (as drivers) within the script. The base name of the files to load can specify only letters, numbers and underscores.

Note: at the first execution of the hook the $drivers argument isn't an array.


Parameters

$drivers

(array|null)  The array holding the files of the external drivers to load.


Example

The example below adds support for all the drivers contained in a specific folder of the plugin. Such as:

/wp-content/plugins/vikwp/drivers/

All the PHP files contained within the drivers folder of the VikWP plugin will be loaded.

/**
 * Trigger hook to let the plugins register external drivers
 * as supported exporters.
 *
 * @param  array|null  $drivers  The array holding the drivers to load.
 */
add_filter('vikappointments_fetch_supported_export_drivers', function($drivers)
{
    if (!$drivers)
    {
        // first cycle of the filter, init the list of drivers
        $drivers = array();
    }

    // create base path to "drivers" folder contained within the plugin
    $base = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'drivers' . DIRECTORY_SEPARATOR;

    // load all PHP files from "drivers" folder
    $files = glob($base . '*.php');

    // merge existing drivers with this ones
    return array_merge($drivers, $files);
});

Changelog

Version Description
1.2 Introduced.
Last Update: 2021-08-20
Helpful?
This site uses cookies. By continuing to browse you accept their use. Further information