| @@ -1,53 +1,62 @@ | ||
| 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 | -} | |
| 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 = array(); | |
| 14 | + | |
| 15 | + /** | |
| 16 | + * Initialize the integrations | |
| 17 | + */ | |
| 18 | + public function __construct() { | |
| 19 | + | |
| 20 | + | |
| 21 | + } | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * Return loaded integrations. | |
| 25 | + * | |
| 26 | + * @return array | |
| 27 | + */ | |
| 28 | + public function get_integrations() { | |
| 29 | + | |
| 30 | + if ( $this->integrations ) { | |
| 31 | + return $this->integrations; | |
| 32 | + } | |
| 33 | + | |
| 34 | + require_once WEFORMS_INCLUDES . '/integrations/slack/class-integration-slack.php'; | |
| 35 | + require_once WEFORMS_INCLUDES . '/integrations/erp/class-integration-erp.php'; | |
| 36 | + require_once WEFORMS_INCLUDES . '/integrations/mailpoet/class-integration-mailpoet.php'; | |
| 37 | + | |
| 38 | + $integrations = apply_filters( 'weforms_integrations', array( | |
| 39 | + 'WeForms_Integration_Slack', 'WeForms_Integration_ERP', 'WeForms_Integration_MailPoet_Free', | |
| 40 | + ) ); | |
| 41 | + | |
| 42 | + // Load integration classes | |
| 43 | + foreach ( $integrations as $integration ) { | |
| 44 | + | |
| 45 | + $integration_instance = new $integration(); | |
| 46 | + | |
| 47 | + $this->integrations[ $integration_instance->id ] = $integration_instance; | |
| 48 | + } | |
| 49 | + | |
| 50 | + return $this->integrations; | |
| 51 | + } | |
| 52 | + | |
| 53 | + public function get_integration_js_settings() { | |
| 54 | + $settings = array(); | |
| 55 | + | |
| 56 | + foreach ($this->get_integrations() as $integration_id => $integration) { | |
| 57 | + $settings[ $integration_id ] = $integration->get_js_settings(); | |
| 58 | + } | |
| 59 | + | |
| 60 | + return $settings; | |
| 61 | + } | |
| 62 | +} | |