| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The Integration Loader |
| 5 |
*/ |
| 6 |
class WeForms_Integration_Manager { |
| 7 |
|
| 8 |
/** |
| 9 |
* The integration instances |
| 10 |
* |
| 11 |
* @var array |
| 12 |
*/ |
| 13 |
public $integrations = []; |
| 14 |
|
| 15 |
/** |
| 16 |
* Return loaded integrations. |
| 17 |
* |
| 18 |
* @return array |
| 19 |
*/ |
| 20 |
public function get_integrations() { |
| 21 |
if ( $this->integrations ) { |
| 22 |
return $this->integrations; |
| 23 |
} |
| 24 |
|
| 25 |
require_once WEFORMS_INCLUDES . '/integrations/slack/class-integration-slack.php'; |
| 26 |
require_once WEFORMS_INCLUDES . '/integrations/erp/class-integration-erp.php'; |
| 27 |
require_once WEFORMS_INCLUDES . '/integrations/mailpoet/class-integration-mailpoet.php'; |
| 28 |
require_once WEFORMS_INCLUDES . '/integrations/sprout-invoices/class-integration-sprout-invoices.php'; |
| 29 |
|
| 30 |
$integrations = apply_filters( 'weforms_integrations', [ |
| 31 |
'WeForms_Integration_Slack', 'WeForms_Integration_ERP', 'WeForms_Integration_MailPoet_Free', 'WeForms_Integration_SI', |
| 32 |
] ); |
| 33 |
|
| 34 |
// Load integration classes |
| 35 |
foreach ( $integrations as $integration ) { |
| 36 |
$integration_instance = new $integration(); |
| 37 |
|
| 38 |
$this->integrations[ $integration_instance->id ] = $integration_instance; |
| 39 |
} |
| 40 |
|
| 41 |
return $this->integrations; |
| 42 |
} |
| 43 |
|
| 44 |
public function get_integration_js_settings() { |
| 45 |
$settings = []; |
| 46 |
|
| 47 |
foreach ( $this->get_integrations() as $integration_id => $integration ) { |
| 48 |
$settings[ $integration_id ] = $integration->get_js_settings(); |
| 49 |
} |
| 50 |
|
| 51 |
return $settings; |
| 52 |
} |
| 53 |
} |