PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.9.0
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.9.0
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / boot / app.php

app.php in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.9.0, at boot/app.php

108 lines 4.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 /*
46 * A stale schema is repaired from two places. Portal render catches sites where
47 * an admin browses the community; admin_init catches the plugin-update case,
48 * where the first request after the new code lands is a wp-admin page and a
49 * newly added table would otherwise not exist yet. A missing index only slows
50 * things down, but a missing table is fatal, so the second entry point matters.
51 */
52 if (!function_exists('fluent_community_maybe_migrate_db')) {
53 function fluent_community_maybe_migrate_db()
54 {
55 $currentDBVersion = get_option('fluent_community_db_version');
56
57 if ($currentDBVersion && version_compare($currentDBVersion, FLUENT_COMMUNITY_DB_VERSION, '>=')) {
58 return;
59 }
60
61 if (get_transient('fluent_community_db_migration_lock')) {
62 return;
63 }
64
65 set_transient('fluent_community_db_migration_lock', 1, 5 * MINUTE_IN_SECONDS);
66 \FluentCommunity\Database\DBMigrator::run();
67 update_option('fluent_community_db_version', FLUENT_COMMUNITY_DB_VERSION, false);
68 delete_transient('fluent_community_db_migration_lock');
69 }
70 }
71
72 add_action('admin_init', function () {
73 if (current_user_can('activate_plugins')) {
74 fluent_community_maybe_migrate_db();
75 }
76 });
77
78 add_action('fluent_community/portal_render_for_user', function () {
79 if (!\FluentCommunity\App\Services\Helper::isSiteAdmin()) {
80 return;
81 }
82
83 if (!\as_next_scheduled_action('fluent_community_scheduled_hour_jobs')) {
84 as_schedule_recurring_action(time(), 3600, 'fluent_community_scheduled_hour_jobs', [], 'fluent-community');
85 }
86
87 if (!\as_next_scheduled_action('fluent_community_daily_jobs')) {
88 \as_schedule_recurring_action(time(), 86400, 'fluent_community_daily_jobs', [], 'fluent-community');
89 }
90 /*
91 * We will remove this after final release
92 */
93 fluent_community_maybe_migrate_db();
94
95
96 if (defined('FLUENT_COMMUNITY_PRO_VERSION')) {
97 add_filter('fluent_community/portal_notices', function ($notices) {
98 if (FLUENT_COMMUNITY_MIN_PRO_VERSION !== FLUENT_COMMUNITY_PRO_VERSION && version_compare(FLUENT_COMMUNITY_MIN_PRO_VERSION, FLUENT_COMMUNITY_PRO_VERSION, '>')) {
99 $updateUrl = admin_url('plugins.php?s=fluent-community&plugin_status=all&fluent-fluent-community-pro-check-update=' . time());
100 $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>';
101 }
102 return $notices;
103 });
104 }
105
106 });
107 };
108