English (United Kingdom)

apply_filters_ref_array( 'vikappointments_build_head_export_ics', string $rules, array &$head, mixed $handler )

Fires while constructing the head of the ICS file.


Description

Trigger hook to allow the plugins to include custom rules within the head of the ICS file.

Here it is possible to attach new rules or to overwrite the existing ones.

It is possible to include new options by appending them to the $rules argument or by using the helper methods provided by $handler instance.

// append to return argument
$rules .= "X-VAP-CUSTOM:XYZ\n";
// append through the ICS handler
$handler->addLine('X-VAP-CUSTOM', 'XYZ');

Parameters

$rules

(string)  The rules to append at the end of the ICS head.

&$head

(array)  An associative array containing the default head settings.

  • version - this property specifies the identifier corresponding to the highest version number or the minimum and maximum range of the iCalendar specification that is required in order to interpret the iCalendar object (2.0 by default).
  • prodid - this property specifies the identifier for the product that created the iCalendar object. It is suggested to change this value in case you are planning to apply some changes to the structure of the ICS file.
  • calscale - this property defines the calendar scale used for the calendar information specified in the iCalendar object (GREGORIAN by default).
  • calname - this non standard property defines the default name that will be used when creating a new subscription (the company name by default).
$handler

(VAPOrderExportDriverIcs)  The instance used to export the records. Provides some helper methods to encode the ICS lines.


Example

/**
 * Trigger hook to allow the plugins to include custom options within the
 * head of the ICS file.
 *
 * @param  string  $rules    The rules to include within the head.
 * @param  array   &$head    The default head data.
 * @param  mixed   $handler  The current handler instance.
 */
add_filter('vikappointments_build_head_export_ics', function($rules, &$head, $handler)
{
    // include a new custom rule in the form: [PROPERTY]:[VALUE]
    $handler->addLine('X-VAP-LAST-UPDATE', $handler->tsToCal('now'));

    // include a new custom rule in the form: [PROPERTY];[RULE]:[VALUE]
    $handler->addLine(['X-VAP-URL', 'VALUE=URI'], 'https://domain.com');

    // manually include a custom rule
    $rules .= "X-VAP-URL-SHORT;VALUE=URI:https://dmn.com\n";

    // overwrite calendar name
    $head['calname'] = 'My Own Calendar';

    return $rules;
}, 10, 3);

Changelog

Version Description
1.2.0 The $head argument is now passed by reference as array to allow the manipulation of the default options.
1.1.8 Introduced.
Last Update: 2021-08-08
Helpful?
See Also: