| 1 |
<?php if (!defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
|
| 3 |
use FluentCommunity\App\Hooks\Handlers\ActivationHandler; |
| 4 |
use FluentCommunity\App\Hooks\Handlers\DeactivationHandler; |
| 5 |
use FluentCommunity\Framework\Foundation\Application; |
| 6 |
|
| 7 |
return function ($file) { |
| 8 |
|
| 9 |
$app = new Application($file); |
| 10 |
|
| 11 |
register_activation_hook($file, function () use ($app) { |
| 12 |
($app->make(ActivationHandler::class))->handle(); |
| 13 |
|
| 14 |
if (function_exists('\as_next_scheduled_action')) { |
| 15 |
if (!as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) { |
| 16 |
as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community'); |
| 17 |
} |
| 18 |
|
| 19 |
if (!as_next_scheduled_action('fluent_community_daily_jobs')) { |
| 20 |
as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community'); |
| 21 |
} |
| 22 |
} |
| 23 |
|
| 24 |
}); |
| 25 |
|
| 26 |
register_deactivation_hook($file, function () use ($app) { |
| 27 |
($app->make(DeactivationHandler::class))->handle(); |
| 28 |
}); |
| 29 |
|
| 30 |
require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php'; |
| 31 |
require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'app/Functions/helpers.php'; |
| 32 |
|
| 33 |
if (file_exists(FLUENT_COMMUNITY_PLUGIN_DIR . 'Modules/modules_init.php')) { |
| 34 |
require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'Modules/modules_init.php'; |
| 35 |
} |
| 36 |
|
| 37 |
add_action('plugins_loaded', function () use ($app) { |
| 38 |
do_action('fluent_community/portal_loaded', $app); |
| 39 |
}); |
| 40 |
|
| 41 |
add_action('fluent_community/portal_render_for_user', function () { |
| 42 |
if (!\FluentCommunity\App\Services\Helper::isSiteAdmin()) { |
| 43 |
return; |
| 44 |
} |
| 45 |
|
| 46 |
if (!as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) { |
| 47 |
as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community'); |
| 48 |
} |
| 49 |
|
| 50 |
if (!as_next_scheduled_action('fluent_community_daily_jobs')) { |
| 51 |
as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community'); |
| 52 |
} |
| 53 |
|
| 54 |
/* |
| 55 |
* We will remove this after final release |
| 56 |
*/ |
| 57 |
$currentDBVersion = get_option('fluent_community_db_version'); |
| 58 |
if (!$currentDBVersion || version_compare($currentDBVersion, FLUENT_COMMUNITY_DB_VERSION, '<')) { |
| 59 |
update_option('fluent_community_db_version', FLUENT_COMMUNITY_DB_VERSION, 'no'); |
| 60 |
\FluentCommunity\Database\DBMigrator::run(); |
| 61 |
} |
| 62 |
}); |
| 63 |
}; |
| 64 |
|