| 1 |
<?php |
| 2 |
|
| 3 |
use FluentForm\Framework\Foundation\Application; |
| 4 |
use FluentForm\App\Hooks\Handlers\ActivationHandler; |
| 5 |
use FluentForm\App\Hooks\Handlers\DeactivationHandler; |
| 6 |
use FluentForm\App\Services\Migrator\Bootstrap as FormsMigrator; |
| 7 |
use FluentForm\App\Services\FluentConversational\Classes\Form as FluentConversational; |
| 8 |
|
| 9 |
return function ($file) { |
| 10 |
add_action('plugins_loaded', function () { |
| 11 |
$isNotCompatible = defined('FLUENTFORMPRO') && version_compare(FLUENTFORMPRO_VERSION, '5.0.0', '<'); |
| 12 |
if ($isNotCompatible) { |
| 13 |
$message = '<div><h3>Fluent Forms Pro is not working. Update required!</h3><p>Current version of the pro plugin is not compatible with the latest version of Core Plugin. <a href="' . admin_url('plugins.php?s=fluentformpro&plugin_status=all&force-check=1') . '">' . __('Please update Fluent Forms Pro to latest version', 'fluentform') . '</a>.</p></div>'; |
| 14 |
$actions = [ |
| 15 |
'fluentform/global_menu', |
| 16 |
'fluentform/after_form_menu', |
| 17 |
'admin_notices' |
| 18 |
]; |
| 19 |
foreach ($actions as $action) { |
| 20 |
add_action($action, function () use ($message) { |
| 21 |
printf('<div class="fluentform-admin-notice notice notice-error">%1$s</div>', $message); |
| 22 |
}); |
| 23 |
} |
| 24 |
} |
| 25 |
}); |
| 26 |
|
| 27 |
$app = new Application($file); |
| 28 |
|
| 29 |
register_activation_hook($file, function ($network_wide) use ($app) { |
| 30 |
($app->make(ActivationHandler::class))->handle($network_wide); |
| 31 |
}); |
| 32 |
|
| 33 |
add_action('wp_insert_site', function ($blog) use ($app) { |
| 34 |
if (is_plugin_active_for_network('fluentform/fluentform.php')) { |
| 35 |
switch_to_blog($blog->blog_id); |
| 36 |
($app->make(ActivationHandler::class))->handle(false); |
| 37 |
restore_current_blog(); |
| 38 |
} |
| 39 |
}); |
| 40 |
|
| 41 |
register_deactivation_hook($file, function () use ($app) { |
| 42 |
($app->make(DeactivationHandler::class))->handle(); |
| 43 |
}); |
| 44 |
|
| 45 |
add_action('plugins_loaded', function () use ($app) { |
| 46 |
do_action_deprecated( |
| 47 |
'fluentform_loaded', |
| 48 |
[ |
| 49 |
$app |
| 50 |
], |
| 51 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 52 |
'fluentform/loaded', |
| 53 |
'Use fluentform/loaded instead of fluentform_loaded.' |
| 54 |
); |
| 55 |
|
| 56 |
do_action_deprecated( |
| 57 |
'fluentform-loaded', |
| 58 |
[ |
| 59 |
$app |
| 60 |
], |
| 61 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 62 |
'fluentform/loaded', |
| 63 |
'Use fluentform/loaded instead of fluentform-loaded.' |
| 64 |
); |
| 65 |
|
| 66 |
do_action('fluentform/loaded', $app); |
| 67 |
}); |
| 68 |
|
| 69 |
fluentformLoadFile('Services/FluentConversational/plugin.php'); |
| 70 |
(new FluentConversational)->boot(); |
| 71 |
(new FormsMigrator())->boot(); |
| 72 |
}; |
| 73 |
|