| 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', true); |
| 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', true); |
| 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 |
add_action('init', function () use ($app) { |
| 41 |
do_action('fluent_community/on_wp_init', $app); |
| 42 |
}); |
| 43 |
}); |
| 44 |
|
| 45 |
add_action('fluent_community/portal_render_for_user', function () { |
| 46 |
if (!\FluentCommunity\App\Services\Helper::isSiteAdmin()) { |
| 47 |
return; |
| 48 |
} |
| 49 |
|
| 50 |
if (!\as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) { |
| 51 |
as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community'); |
| 52 |
} |
| 53 |
|
| 54 |
if (!\as_next_scheduled_action('fluent_community_daily_jobs')) { |
| 55 |
\as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community'); |
| 56 |
} |
| 57 |
/* |
| 58 |
* We will remove this after final release |
| 59 |
*/ |
| 60 |
$currentDBVersion = get_option('fluent_community_db_version'); |
| 61 |
if (!$currentDBVersion || version_compare($currentDBVersion, FLUENT_COMMUNITY_DB_VERSION, '<')) { |
| 62 |
update_option('fluent_community_db_version', FLUENT_COMMUNITY_DB_VERSION, 'no'); |
| 63 |
\FluentCommunity\Database\DBMigrator::run(); |
| 64 |
} |
| 65 |
|
| 66 |
|
| 67 |
if (defined('FLUENT_COMMUNITY_PRO_VERSION')) { |
| 68 |
add_filter('fluent_community/portal_notices', function ($notices) { |
| 69 |
if (FLUENT_COMMUNITY_MIN_PRO_VERSION !== FLUENT_COMMUNITY_PRO_VERSION && version_compare(FLUENT_COMMUNITY_MIN_PRO_VERSION, FLUENT_COMMUNITY_PRO_VERSION, '>')) { |
| 70 |
$updateUrl = admin_url('plugins.php?s=fluent-community&plugin_status=all&fluent-fluent-community-pro-check-update=' . time()); |
| 71 |
$notices[] = '<div style="padding: 10px; background-color: var(--fcom-primary-bg, white);" class="error"><b>' . esc_html__('Heads UP:', 'fluent-community') . ' </b> ' . esc_html__('FluentCommunityPro Plugin needs to be updated to the latest version.', 'fluent-community') . ' <a href="' . esc_url($updateUrl) . '">' . esc_html__('Click here to update', 'fluent-community') . '</a></div>'; |
| 72 |
} |
| 73 |
return $notices; |
| 74 |
}); |
| 75 |
} |
| 76 |
|
| 77 |
}); |
| 78 |
}; |
| 79 |
|