| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBooking\App\Hooks\Handlers; |
| 4 |
|
| 5 |
use FluentBooking\Framework\Foundation\Application; |
| 6 |
use FluentBooking\Database\DBMigrator; |
| 7 |
use FluentBooking\Database\DBSeeder; |
| 8 |
|
| 9 |
class ActivationHandler |
| 10 |
{ |
| 11 |
protected $app = null; |
| 12 |
|
| 13 |
public function __construct(Application $app) |
| 14 |
{ |
| 15 |
$this->app = $app; |
| 16 |
} |
| 17 |
|
| 18 |
public function handle($network_wide = false) |
| 19 |
{ |
| 20 |
DBMigrator::run($network_wide); |
| 21 |
DBSeeder::run(); |
| 22 |
|
| 23 |
$this->registerWpCron(); |
| 24 |
|
| 25 |
update_option('fluent_booking_db_version', FLUENT_BOOKING_DB_VERSION, 'no'); |
| 26 |
} |
| 27 |
|
| 28 |
public function registerWpCron() |
| 29 |
{ |
| 30 |
$fiveMinutesHook = 'fluent_booking_five_minutes_tasks'; |
| 31 |
$dailyHook = 'fluent_booking/daily_tasks'; |
| 32 |
|
| 33 |
if(function_exists('\as_schedule_recurring_action')) { |
| 34 |
if (!\as_next_scheduled_action($fiveMinutesHook)) { |
| 35 |
\as_schedule_recurring_action(time(), (60 * 5), $fiveMinutesHook, [], 'fluent-booking', true); |
| 36 |
} |
| 37 |
if (!\as_next_scheduled_action($dailyHook)) { |
| 38 |
\as_schedule_recurring_action(time(), (60 * 60 * 24), $dailyHook, [], 'fluent-booking', true); |
| 39 |
} |
| 40 |
} |
| 41 |
} |
| 42 |
} |
| 43 |
|