| 1 |
<?php if ( ! defined( 'ABSPATH' ) ) exit; ?> |
| 2 |
<?php |
| 3 |
|
| 4 |
use FluentCart\Database\DBMigrator; |
| 5 |
use FluentCart\Framework\Foundation\Application; |
| 6 |
use FluentCart\App\Hooks\Handlers\ActivationHandler; |
| 7 |
use FluentCart\App\Hooks\Handlers\DeactivationHandler; |
| 8 |
use FluentCart\App\Services\Permission\PermissionManager; |
| 9 |
|
| 10 |
return function ($file) { |
| 11 |
|
| 12 |
// $errorHandler = __DIR__ . "/error_handler.php"; |
| 13 |
|
| 14 |
// if (0 !== error_reporting() && file_exists($errorHandler)) { |
| 15 |
// require_once $errorHandler; |
| 16 |
// } |
| 17 |
|
| 18 |
$app = new Application($file); |
| 19 |
|
| 20 |
register_activation_hook($file, function ($networkwide = false) use ($app) { |
| 21 |
($app->make(ActivationHandler::class))->handle($networkwide); |
| 22 |
}); |
| 23 |
|
| 24 |
register_deactivation_hook($file, function () use ($app) { |
| 25 |
($app->make(DeactivationHandler::class))->handle(); |
| 26 |
}); |
| 27 |
|
| 28 |
require_once(FLUENTCART_PLUGIN_PATH . 'boot/action_scheduler_loader.php'); |
| 29 |
|
| 30 |
add_action('plugins_loaded', function () use ($app) { |
| 31 |
do_action('fluentcart_loaded', $app); |
| 32 |
|
| 33 |
(new FluentCart\App\Modules\Data\ProductDataSetup())->boot(); |
| 34 |
|
| 35 |
add_action('init', function () use ($app) { |
| 36 |
|
| 37 |
// maybe database changes |
| 38 |
DBMigrator::maybeMigrateDBChanges(); |
| 39 |
|
| 40 |
do_action('fluent_cart/init', $app); |
| 41 |
|
| 42 |
if (defined('DATABASE_TYPE') && DATABASE_TYPE === 'sqlite') { |
| 43 |
add_action('admin_notices', function () { |
| 44 |
?> |
| 45 |
<div class="notice notice-warning"> |
| 46 |
<p><?php echo 'FluentCart requires MySQL/MariaDB database Engine. Looks like you are using sqlite database. FluentCart will not work on this site.'; ?></p> |
| 47 |
</div> |
| 48 |
<?php |
| 49 |
}); |
| 50 |
} |
| 51 |
|
| 52 |
|
| 53 |
}); |
| 54 |
|
| 55 |
if (defined('FLUENTCART_PRO_PLUGIN_VERSION')) { |
| 56 |
add_filter('fluent_cart/admin_notices', function ($notices) { |
| 57 |
if (FLUENTCART_MIN_PRO_VERSION !== FLUENTCART_PRO_PLUGIN_VERSION && version_compare(FLUENTCART_MIN_PRO_VERSION, FLUENTCART_PRO_PLUGIN_VERSION, '>')) { |
| 58 |
if(!PermissionManager::userCan('is_super_admin')) { |
| 59 |
return $notices; |
| 60 |
} |
| 61 |
|
| 62 |
$updateUrl = admin_url('plugins.php?s=fluent-cart&plugin_status=all&fluent-cart-pro-check-update=' . time()); |
| 63 |
|
| 64 |
$notices[] = [ |
| 65 |
'id' => 'update_license', |
| 66 |
'type' => 'core_update', |
| 67 |
'html' => '<div>FluentCart Pro Plugin needs to be updated to the latest version. <a href="' . esc_url($updateUrl) . '">Click here to update</a></div>' |
| 68 |
]; |
| 69 |
} |
| 70 |
return $notices; |
| 71 |
}); |
| 72 |
} |
| 73 |
}); |
| 74 |
|
| 75 |
|
| 76 |
add_action('wp_insert_site', function ($new_site) use ($app) { |
| 77 |
if (is_plugin_active_for_network('fluent-cart/fluent-cart.php')) { |
| 78 |
switch_to_blog($new_site->blog_id); |
| 79 |
($app->make(ActivationHandler::class))->handle(false); |
| 80 |
restore_current_blog(); |
| 81 |
} |
| 82 |
}); |
| 83 |
|
| 84 |
return $app; |
| 85 |
}; |
| 86 |
|