make(ActivationHandler::class))->handle(); if (function_exists('\as_next_scheduled_action')) { if (!\as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) { \as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community', true); } if (!\as_next_scheduled_action('fluent_community_daily_jobs')) { \as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community', true); } } }); register_deactivation_hook($file, function () use ($app) { ($app->make(DeactivationHandler::class))->handle(); }); require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'vendor/woocommerce/action-scheduler/action-scheduler.php'; require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'app/Functions/helpers.php'; if (file_exists(FLUENT_COMMUNITY_PLUGIN_DIR . 'Modules/modules_init.php')) { require_once FLUENT_COMMUNITY_PLUGIN_DIR . 'Modules/modules_init.php'; } add_action('plugins_loaded', function () use ($app) { do_action('fluent_community/portal_loaded', $app); add_action('init', function () use ($app) { do_action('fluent_community/on_wp_init', $app); }); }); /* * A stale schema is repaired from two places. Portal render catches sites where * an admin browses the community; admin_init catches the plugin-update case, * where the first request after the new code lands is a wp-admin page and a * newly added table would otherwise not exist yet. A missing index only slows * things down, but a missing table is fatal, so the second entry point matters. */ if (!function_exists('fluent_community_maybe_migrate_db')) { function fluent_community_maybe_migrate_db() { $currentDBVersion = get_option('fluent_community_db_version'); if ($currentDBVersion && version_compare($currentDBVersion, FLUENT_COMMUNITY_DB_VERSION, '>=')) { return; } if (get_transient('fluent_community_db_migration_lock')) { return; } set_transient('fluent_community_db_migration_lock', 1, 5 * MINUTE_IN_SECONDS); \FluentCommunity\Database\DBMigrator::run(); update_option('fluent_community_db_version', FLUENT_COMMUNITY_DB_VERSION, false); delete_transient('fluent_community_db_migration_lock'); } } add_action('admin_init', function () { if (current_user_can('activate_plugins')) { fluent_community_maybe_migrate_db(); } }); add_action('fluent_community/portal_render_for_user', function () { if (!\FluentCommunity\App\Services\Helper::isSiteAdmin()) { return; } if (!\as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) { as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community'); } if (!\as_next_scheduled_action('fluent_community_daily_jobs')) { \as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community'); } /* * We will remove this after final release */ fluent_community_maybe_migrate_db(); if (defined('FLUENT_COMMUNITY_PRO_VERSION')) { add_filter('fluent_community/portal_notices', function ($notices) { if (FLUENT_COMMUNITY_MIN_PRO_VERSION !== FLUENT_COMMUNITY_PRO_VERSION && version_compare(FLUENT_COMMUNITY_MIN_PRO_VERSION, FLUENT_COMMUNITY_PRO_VERSION, '>')) { $updateUrl = admin_url('plugins.php?s=fluent-community&plugin_status=all&fluent-fluent-community-pro-check-update=' . time()); $notices[] = '
' . esc_html__('Heads UP:', 'fluent-community') . ' ' . esc_html__('FluentCommunityPro Plugin needs to be updated to the latest version.', 'fluent-community') . ' ' . esc_html__('Click here to update', 'fluent-community') . '
'; } return $notices; }); } }); };