English (United Kingdom)

apply_filters_ref_array( 'vikrestaurants_init_special_day', bool $status, mixed &$day, object $data )

Fires while initializing a special day instance.


Description

Trigger hook to let external plugins construct the special day with those properties that they might have added.


Parameters

$status

(bool)  True on success, false otherwise.

&$day

(VRESpecialDay)  The instance to construct with the details of the current special day.

$data

(object)  The object holding the database record of the current special day.


Example

The example below injects the status of the special day within the instance. It is assumed that a new published column has been already introduced within the database table of the special days.

/**
 * Trigger event to let external plugins construct the special day with
 * those properties that they might have added.
 *
 * @param  bool           $status  True on success, false otherwise.
 * @param  VRESpecialDay  &$day    The special day instance.
 * @param  object         $data    The database record of the special day.
 */
add_filter('vikrestaurants_init_special_day', function($status, &$day, $data)
{
    // check published status
    if (isset($data->published))
    {
        // inject status within special day
        $this->published = (bool) $data->published;

        $status = true;
    }

    return $status;
}, 10, 3);

Changelog

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