| 1 |
<?php |
| 2 |
|
| 3 |
namespace FluentBoards\App\Services\Intergrations\FluentCRM; |
| 4 |
|
| 5 |
use FluentBoards\App\App; |
| 6 |
use FluentBoards\App\Hooks\Handlers\FluentCrmIntegration; |
| 7 |
use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\ContactAddedBoardTrigger; |
| 8 |
use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\ContactAddedTaskTrigger; |
| 9 |
use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\StageChangedTrigger; |
| 10 |
use FluentBoards\App\Services\Intergrations\FluentCRM\Automations\TaskCreateAction; |
| 11 |
use FluentBoards\App\Services\TransStrings; |
| 12 |
|
| 13 |
class Init |
| 14 |
{ |
| 15 |
public function __construct() |
| 16 |
{ |
| 17 |
$this->registerToContactSection(); |
| 18 |
|
| 19 |
(new DeepIntegration())->init(); |
| 20 |
$this->registerAutomationFunnels(); |
| 21 |
} |
| 22 |
|
| 23 |
public function registerToContactSection() |
| 24 |
{ |
| 25 |
// (new FluentCrmIntegration())->registerCustomSection(); |
| 26 |
add_action( 'fluent_crm/global_appjs_loaded', function () { |
| 27 |
$app = App::getInstance(); |
| 28 |
|
| 29 |
$assets = $app['url.assets']; |
| 30 |
|
| 31 |
$slug = $app->config->get('app.slug'); |
| 32 |
wp_enqueue_script( $slug . '_in_crm', FLUENT_BOARDS_PLUGIN_URL . 'assets/crm-contact-app.js'); |
| 33 |
wp_enqueue_style($slug . '_in_crm', FLUENT_BOARDS_PLUGIN_URL . 'assets/admin/crm-contact-app.css'); |
| 34 |
wp_localize_script($slug . '_in_crm', 'fluentAddonVars', [ |
| 35 |
'slug' => $slug = $app->config->get('app.slug'), |
| 36 |
'nonce' => wp_create_nonce($slug), |
| 37 |
'rest' => $this->getRestInfo($app), |
| 38 |
'ajaxurl' => admin_url('admin-ajax.php'), |
| 39 |
'asset_url' => $assets, |
| 40 |
'trans' => TransStrings::getStrings(), |
| 41 |
'base_url' => fluent_boards_page_url(), |
| 42 |
]); |
| 43 |
|
| 44 |
|
| 45 |
}); |
| 46 |
} |
| 47 |
|
| 48 |
public function registerAutomationFunnels() |
| 49 |
{ |
| 50 |
// new ContactAddedBoardTrigger(); |
| 51 |
new ContactAddedTaskTrigger(); |
| 52 |
new StageChangedTrigger(); |
| 53 |
|
| 54 |
new TaskCreateAction(); |
| 55 |
} |
| 56 |
|
| 57 |
|
| 58 |
protected function getRestInfo($app) |
| 59 |
{ |
| 60 |
$ns = $app->config->get('app.rest_namespace'); |
| 61 |
$ver = $app->config->get('app.rest_version'); |
| 62 |
|
| 63 |
return [ |
| 64 |
'base_url' => esc_url_raw(rest_url()), |
| 65 |
'url' => rest_url($ns . '/' . $ver), |
| 66 |
'nonce' => wp_create_nonce('wp_rest'), |
| 67 |
'namespace' => $ns, |
| 68 |
'version' => $ver, |
| 69 |
]; |
| 70 |
} |
| 71 |
} |