| 1 |
<?php |
| 2 |
|
| 3 |
defined('ABSPATH') or die; |
| 4 |
|
| 5 |
/** |
| 6 |
* @var $app FluentSupport\Framework\Foundation\Application |
| 7 |
*/ |
| 8 |
|
| 9 |
(new \FluentSupport\App\Hooks\Handlers\AuthHandler)->init(); |
| 10 |
|
| 11 |
$app->addCustomAction('handle_exception', 'ExceptionHandler@handle'); |
| 12 |
|
| 13 |
$app->addAction('admin_menu', 'Menu@add'); |
| 14 |
$app->addAction('admin_enqueue_scripts', 'Menu@maybeEnqueueAssets'); |
| 15 |
/* |
| 16 |
* Admin Bar |
| 17 |
*/ |
| 18 |
$app->addAction('admin_bar_menu', 'AdminBarHandler@init'); |
| 19 |
$app->addAction('wp_dashboard_setup', 'AdminBarHandler@initAdminWidget'); |
| 20 |
|
| 21 |
$app->addShortcode('fluent_support_portal', 'ShortcodeHandler@fluentSupportPortal'); |
| 22 |
|
| 23 |
// init integrations |
| 24 |
add_action('init', function () { |
| 25 |
(new \FluentSupport\App\Services\Integrations\IntegrationInit())->init(); |
| 26 |
}); |
| 27 |
|
| 28 |
// Activities |
| 29 |
(new \FluentSupport\App\Hooks\Handlers\ActivityLogger())->init(); |
| 30 |
|
| 31 |
//AI Activities |
| 32 |
(new \FluentSupport\App\Hooks\Handlers\AIActivityLogger())->init(); |
| 33 |
|
| 34 |
// Internal notifications |
| 35 |
(new \FluentSupport\App\Hooks\Handlers\InternalNotificationHandler())->init(); |
| 36 |
|
| 37 |
/* |
| 38 |
* Email Notification Hooks |
| 39 |
*/ |
| 40 |
|
| 41 |
$app->addAction('fluent_support/ticket_created', 'EmailNotificationHandler@ticketCreated', 10, 2); |
| 42 |
$app->addAction('fluent_support/response_added_by_agent', 'EmailNotificationHandler@agentReplied', 10, 3); |
| 43 |
$app->addAction('fluent_support/response_added_by_customer', 'EmailNotificationHandler@customerReplied', 10, 3); |
| 44 |
$app->addAction('fluent_support/ticket_closed_by_agent', 'EmailNotificationHandler@closedByAgent', 10, 2); |
| 45 |
$app->addAction('fluent_support/agent_assigned_to_ticket', 'EmailNotificationHandler@onAgentAssign', 10, 3); |
| 46 |
$app->addAction('fluent_support/ticket_created_behalf_of_customer', 'EmailNotificationHandler@ticketCreatedByAgent', 10, 3); |
| 47 |
$app->addAction('fluent_support/agent_initiated_ticket_response', 'EmailNotificationHandler@ticketCreatedByAgentOnBehalf', 10, 3); |
| 48 |
|
| 49 |
$app->addAction('fluent_support/async_agent_assigned_to_ticket', 'AsyncActionHandler@resolveAgentAssigned', 10, 4); |
| 50 |
|
| 51 |
// Cleanup |
| 52 |
$app->addAction('fluent_support_hourly_tasks', 'CleanupHandler@initHourlyTasks'); |
| 53 |
$app->addAction('fluent_support_daily_tasks', 'CleanupHandler@initDailyTasks'); |
| 54 |
$app->addAction('fluent_support_weekly_tasks', 'CleanupHandler@maybeMaintanceTask'); |
| 55 |
|
| 56 |
$app->addAction('fluent_support/deleting_ticket', 'CleanupHandler@deleteTicketAttachments'); |
| 57 |
$app->addAction('fluent_support/ticket_closed', 'CleanupHandler@maybeDeleteAttachmentsOnClose'); |
| 58 |
|
| 59 |
if(isset($_GET['fs_view'])) { |
| 60 |
$app->addAction('init', 'ExternalPages@route'); |
| 61 |
} |
| 62 |
|
| 63 |
if (isset($_GET['fst_file'])) { |
| 64 |
add_action('init', function () { |
| 65 |
(new \FluentSupport\App\Hooks\Handlers\ExternalPages())->view_attachment(); |
| 66 |
}); |
| 67 |
} |
| 68 |
|
| 69 |
// require the CLI |
| 70 |
if ( defined( 'WP_CLI' ) && WP_CLI ) { |
| 71 |
\WP_CLI::add_command( 'fluent_support', '\FluentSupport\App\Hooks\CLI\FluentCli' ); |
| 72 |
} |
| 73 |
|
| 74 |
|
| 75 |
(new \FluentSupport\App\Hooks\Handlers\PermissionFilterManager)->init(); |
| 76 |
|
| 77 |
// Register the WordPress personal data exporter and eraser |
| 78 |
(new \FluentSupport\App\Hooks\Handlers\PrivacyHandler())->init(); |
| 79 |
|
| 80 |
// Action will be triggered when a support customer update their profile in wp |
| 81 |
$app->addAction('profile_update', '\FluentSupport\App\Services\ProfileInfoService@onWPProfileUpdate', 10, 3); |
| 82 |
$app->addAction('wp_ajax_fs_export_agent_report', 'FluentSupport\App\Hooks\Handlers\DataExporter@exportReport'); |
| 83 |
|
| 84 |
// LiteSpeed Cache ESI mode enabled issue fixed |
| 85 |
if(defined('LSCWP_V')){ |
| 86 |
add_action('litespeed_init', function (){ |
| 87 |
if(isset($_SERVER['REQUEST_URI']) && strpos(esc_url_raw(wp_unslash($_SERVER['REQUEST_URI'])), 'fluent-support') !== false){ |
| 88 |
defined( 'LITESPEED_ESI_OFF' ) || define( 'LITESPEED_ESI_OFF', true ); |
| 89 |
} |
| 90 |
}); |
| 91 |
} |
| 92 |
|
| 93 |
$app->addAction('init', 'BlockEditorHandler@init'); |
| 94 |
|
| 95 |
// MCP — toolkit discovery runs unconditionally so FluentHub can list Fluent |
| 96 |
// Support even on WP < 6.9. The Abilities API / server hooks inside init() |
| 97 |
// fire only when wp_register_ability / mcp_adapter_init are available. |
| 98 |
\FluentSupport\App\Modules\MCP\MCPInit::boot(); |
| 99 |
|
| 100 |
|