Italian (Italy)

apply_filters( 'vikrestaurants_search_special_days', bool $accept, mixed $manager, mixed $day )

Fires while checking whether a special day can be used or not.


Description

Trigger hook to let external plugins apply additional filters while searching for a compatible special day. The filter applies once for each special day separately.

When this hook is triggered, the system already validated the standard conditions and the special day has been approved for the usage.

NOTE: it is possible to check for which section we are searching the special days by accessing the $manager->getGroup() method. This method will return 1 for restaurant and 2 for take-away.


Parameters

$accept

(bool)  Use false to discard the special day.

$manager

(VRESpecialDaysManager)  The instance used to search the compatible special days.

$day

(VRESpecialDay)  The instance holding the details of the current special day.


Example

The example below automatically discards all the special days that have been temporarily unpublished. 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 apply additional filters
 * while seatching for a compatible special day.
 *
 * @param  bool                   $accept   True to accept the payment, false to discard it.
 * @param  VRESpecialDaysManager  $manager  The manager instance.
 * @param  VRESpecialDay          $day      The special day instance.
 */
add_filter('vikrestaurants_search_special_days', function($accept, $manager, $day)
{
    // check published status
    if (isset($day->published) && $day->published == false)
    {
        // unpublished special day, discard it
        $accept = false;
    }

    return $accept;
}, 10, 3);

Changelog

Version Description
1.2 Introduced.
Ultimo aggiornamento: 2021-01-26
Utile?
Potrebbe interessarti: