| 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!', |
| 14 |
'fluentform') . '</h3><p>' . __('Current version of the pro plugin is not compatible with the latest version of Core Plugin.', |
| 15 |
'fluentform') . '<a href="' . admin_url('plugins.php?s=fluentformpro&plugin_status=all&force-check=1') . '">' . __('Please update Fluent Forms Pro to latest version.', |
| 16 |
'fluentform') . '</a></p></div>'; |
| 17 |
$actions = [ |
| 18 |
'fluentform/global_menu', |
| 19 |
'fluentform/after_form_menu', |
| 20 |
'admin_notices' |
| 21 |
]; |
| 22 |
foreach ($actions as $action) { |
| 23 |
add_action($action, function () use ($message) { |
| 24 |
printf('<div class="fluentform-admin-notice notice notice-error">%1$s</div>', $message); |
| 25 |
}); |
| 26 |
} |
| 27 |
} |
| 28 |
}); |
| 29 |
|
| 30 |
$app = new Application($file); |
| 31 |
|
| 32 |
register_activation_hook($file, function ($network_wide) use ($app) { |
| 33 |
($app->make(ActivationHandler::class))->handle($network_wide); |
| 34 |
}); |
| 35 |
|
| 36 |
add_action('wp_insert_site', function ($blog) use ($app) { |
| 37 |
if (is_plugin_active_for_network('fluentform/fluentform.php')) { |
| 38 |
switch_to_blog($blog->blog_id); |
| 39 |
($app->make(ActivationHandler::class))->handle(false); |
| 40 |
restore_current_blog(); |
| 41 |
} |
| 42 |
}); |
| 43 |
|
| 44 |
register_deactivation_hook($file, function () use ($app) { |
| 45 |
($app->make(DeactivationHandler::class))->handle(); |
| 46 |
}); |
| 47 |
|
| 48 |
add_action('plugins_loaded', function () use ($app) { |
| 49 |
do_action_deprecated( |
| 50 |
'fluentform_loaded', |
| 51 |
[ |
| 52 |
$app |
| 53 |
], |
| 54 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 55 |
'fluentform/loaded', |
| 56 |
'Use fluentform/loaded instead of fluentform_loaded.' |
| 57 |
); |
| 58 |
|
| 59 |
do_action_deprecated( |
| 60 |
'fluentform-loaded', |
| 61 |
[ |
| 62 |
$app |
| 63 |
], |
| 64 |
FLUENTFORM_FRAMEWORK_UPGRADE, |
| 65 |
'fluentform/loaded', |
| 66 |
'Use fluentform/loaded instead of fluentform-loaded.' |
| 67 |
); |
| 68 |
|
| 69 |
do_action('fluentform/loaded', $app); |
| 70 |
}); |
| 71 |
|
| 72 |
fluentformLoadFile('Services/FluentConversational/plugin.php'); |
| 73 |
fluentformLoadFile('Services/Libraries/action-scheduler/action-scheduler.php'); |
| 74 |
|
| 75 |
(new FluentConversational)->boot(); |
| 76 |
(new FormsMigrator())->boot(); |
| 77 |
|
| 78 |
/* Plugin Meta Links */ |
| 79 |
|
| 80 |
add_filter('plugin_row_meta', 'fluentform_plugin_row_meta', 10, 2); |
| 81 |
|
| 82 |
function fluentform_plugin_row_meta($links, $file) |
| 83 |
{ |
| 84 |
if ('fluentform/fluentform.php' == $file) { |
| 85 |
$row_meta = [ |
| 86 |
'docs' => '<a rel="noopener" href="https://fluentforms.com/docs/" style="color: #197efb;font-weight: 600;" aria-label="' . esc_attr(esc_html__('View Fluent Form Documentation', 'fluentform')) . '" target="_blank">' . esc_html__('Docs', 'fluentform') . '</a>', |
| 87 |
'support' => '<a rel="noopener" href="https://wpmanageninja.com/support-tickets/#/" style="color: #197efb;font-weight: 600;" aria-label="' . esc_attr(esc_html__('Get Support', 'fluentform')) . '" target="_blank">' . esc_html__('Support', 'fluentform') . '</a>', |
| 88 |
'developer_docs' => '<a rel="noopener" href="https://developers.fluentforms.com" style="color: #197efb;font-weight: 600;" aria-label="' . esc_attr(esc_html__('Developer Docs', 'fluentform')) . '" target="_blank">' . esc_html__('Developer Docs', 'fluentform') . '</a>', |
| 89 |
]; |
| 90 |
if (!defined('FLUENTFORMPRO')) { |
| 91 |
$row_meta['pro'] = '<a rel="noopener" href="https://fluentforms.com" style="color: #7742e6;font-weight: bold;" aria-label="' . esc_attr(esc_html__('Upgrade to Pro', 'fluentform')) . '" target="_blank">' . esc_html__('Upgrade to Pro', 'fluentform') . '</a>'; |
| 92 |
} |
| 93 |
return array_merge($links, $row_meta); |
| 94 |
} |
| 95 |
return (array)$links; |
| 96 |
} |
| 97 |
}; |
| 98 |
|