| 1 |
<?php |
| 2 |
|
| 3 |
if ( !class_exists( 'WPUF_Abstract_Integration' ) ) { |
| 4 |
|
| 5 |
/** |
| 6 |
* The Integration abstract class |
| 7 |
*/ |
| 8 |
abstract class WPUF_Abstract_Integration { |
| 9 |
|
| 10 |
/** |
| 11 |
* The integration id |
| 12 |
* |
| 13 |
* @var bool |
| 14 |
*/ |
| 15 |
public $id; |
| 16 |
|
| 17 |
/** |
| 18 |
* If the integration is enabled |
| 19 |
* |
| 20 |
* @var bool |
| 21 |
*/ |
| 22 |
public $enabled; |
| 23 |
|
| 24 |
/** |
| 25 |
* Integration title |
| 26 |
* |
| 27 |
* @var string |
| 28 |
*/ |
| 29 |
public $title; |
| 30 |
|
| 31 |
/** |
| 32 |
* URL to the integration icon |
| 33 |
* |
| 34 |
* @var string |
| 35 |
*/ |
| 36 |
public $icon; |
| 37 |
|
| 38 |
/** |
| 39 |
* The settings fields for this integrations |
| 40 |
* |
| 41 |
* @var array |
| 42 |
*/ |
| 43 |
public $settings_fields = []; |
| 44 |
|
| 45 |
/** |
| 46 |
* Get the integration title |
| 47 |
* |
| 48 |
* @return string |
| 49 |
*/ |
| 50 |
public function get_title() { |
| 51 |
return apply_filters( 'wpuf_integration_title', $this->title, $this ); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get the integration id |
| 56 |
* |
| 57 |
* @return string |
| 58 |
*/ |
| 59 |
public function get_id() { |
| 60 |
return apply_filters( 'wpuf_integration_title', $this->id, $this ); |
| 61 |
} |
| 62 |
|
| 63 |
/** |
| 64 |
* Get intgration icon |
| 65 |
* |
| 66 |
* @return string |
| 67 |
*/ |
| 68 |
public function get_icon() { |
| 69 |
return apply_filters( 'wpuf_integration_icon', $this->icon, $this ); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Check if the integration is enabled |
| 74 |
* |
| 75 |
* @return bool |
| 76 |
*/ |
| 77 |
public function is_enabled() { |
| 78 |
return $this->enabled == true; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Get the settings fields |
| 83 |
* |
| 84 |
* @return array |
| 85 |
*/ |
| 86 |
public function get_settings_fields() { |
| 87 |
return $this->settings_fields; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Get the integration settings for the component |
| 92 |
* |
| 93 |
* @return array |
| 94 |
*/ |
| 95 |
public function get_js_settings() { |
| 96 |
return [ |
| 97 |
'id' => $this->get_id(), |
| 98 |
'title' => $this->get_title(), |
| 99 |
'icon' => $this->get_icon(), |
| 100 |
'settings' => $this->get_settings_fields(), |
| 101 |
]; |
| 102 |
} |
| 103 |
|
| 104 |
/** |
| 105 |
* Register the integration in the builder settings |
| 106 |
* |
| 107 |
* @param array $integrations |
| 108 |
* |
| 109 |
* @return array |
| 110 |
*/ |
| 111 |
public function register_integration_settings( $integrations ) { |
| 112 |
$integrations[ $this->id ] = $this->get_js_settings(); |
| 113 |
|
| 114 |
return $integrations; |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
|