English (United Kingdom)

apply_filters( 'vikappointments_create_timeline_renderer', string $classname, mixed $timeline, string $renderer )

Fires while instantiating the object used to render the availability timeline.


Description

This hook can be used to safely change the class instance responsible of rendering the availability timeline.

In addition to returning the new class name, plugins must include all the needed resources.

The returned object must also inherit the VAPAvailabilityTimelineRenderer class. Take a look at the file below to figure out all the abstract methods that should be implemented.

/wp-content/plugins/vikappointments/helpers/libraries/availability/timeline/renderer.php

In case of no returned classes, the class matching the identifier defined by $renderer argument will be used.


Parameters

$classname

(string)  The classname that will be used to instantiate the timeline renderer.

$timeline

(VAPAvailabilityTimeline)  The timeline wrapper.

$renderer

(string)  The default renderer identifier.


Example

The example provides the instantiation of the "Column" timeline renderer, located within the VikWP plugin.

/wp-content/plugins/vikwp/column.php
/**
 * This hook can be used to safely change the class instance
 * responsible of rendering the availability timeline.
 * In addition to returning the new class name, plugins must
 * include all the needed resources. The returned object must
 * also inherit VAPAvailabilityTimelineRenderer class.
 *
 * @param  string  $classname  The classname of the renderer to use.
 * @param  mixed   $timeline   The search handler.
 * @param  string  $renderer   The renderer name.
 */
add_filter('vikappointments_create_timeline_renderer', function($classname, $timeline, $renderer)
{
    // load class handler
    require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'column.php';
	
    // return instance name
    return 'VAPAvailabilityTimelineRendererColumn';
}, 10, 3);

Changelog

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