| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking - Libraries |
| 4 |
* @subpackage lite |
| 5 |
* @author E4J s.r.l. |
| 6 |
* @copyright Copyright (C) 2022 E4J s.r.l. All Rights Reserved. |
| 7 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
/** |
| 15 |
* Manager class used to sponsor the missing VikChannelManager features. |
| 16 |
* |
| 17 |
* @since 1.8 |
| 18 |
*/ |
| 19 |
abstract class VikChannelManagerLiteManager |
| 20 |
{ |
| 21 |
/** |
| 22 |
* Flag used to avoid initializing the setup more than once. |
| 23 |
* |
| 24 |
* @var boolean |
| 25 |
*/ |
| 26 |
private static $setup = false; |
| 27 |
|
| 28 |
/** |
| 29 |
* Accessor used to start the setup. |
| 30 |
* |
| 31 |
* @param mixed $helper The implementor instance or a static class. |
| 32 |
* |
| 33 |
* @return void |
| 34 |
*/ |
| 35 |
final public static function setup($helper = null) |
| 36 |
{ |
| 37 |
if (!static::$setup && !VikBookingLicense::hasVcm()) |
| 38 |
{ |
| 39 |
if (!$helper) |
| 40 |
{ |
| 41 |
// use the default implementor |
| 42 |
VikBookingLoader::import('lite.vcm.helper'); |
| 43 |
$helper = new VikChannelManagerLiteHelper(); |
| 44 |
} |
| 45 |
|
| 46 |
// set up only once and in case VCM is missing |
| 47 |
static::$setup = static::doSetup($helper); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
/** |
| 52 |
* Setup implementor. |
| 53 |
* |
| 54 |
* @param mixed $helper The implementor instance or a static class. |
| 55 |
* |
| 56 |
* @return boolean |
| 57 |
*/ |
| 58 |
protected static function doSetup($helper) |
| 59 |
{ |
| 60 |
/** |
| 61 |
* Fires before the controller of VikBooking/VikChannelManager is dispatched. |
| 62 |
* Useful to require libraries and to check user global permissions. |
| 63 |
* |
| 64 |
* @since 1.0 |
| 65 |
*/ |
| 66 |
add_action('init', [$helper, 'hijackChannelManager'], 1); |
| 67 |
add_action('vikbooking_before_dispatch', [$helper, 'displayViewBanners']); |
| 68 |
add_action('vikbooking_before_dispatch', [$helper, 'displayWidgetBanners']); |
| 69 |
add_action('vikbooking_before_dispatch', [$helper, 'hijackWidgetMultitask']); |
| 70 |
} |
| 71 |
} |
| 72 |
|