| 1 |
<?php |
| 2 |
|
| 3 |
/** |
| 4 |
* The Integration abstract class |
| 5 |
* |
| 6 |
* @since 1.1.0 |
| 7 |
*/ |
| 8 |
abstract class WeForms_Abstract_Integration { |
| 9 |
|
| 10 |
/** |
| 11 |
* The integration id |
| 12 |
* |
| 13 |
* @var boolean |
| 14 |
*/ |
| 15 |
public $id; |
| 16 |
|
| 17 |
/** |
| 18 |
* If the integration is enabled |
| 19 |
* |
| 20 |
* @var boolean |
| 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 = array(); |
| 44 |
|
| 45 |
/** |
| 46 |
* Get the integration title |
| 47 |
* |
| 48 |
* @return string |
| 49 |
*/ |
| 50 |
public function get_title() { |
| 51 |
return apply_filters( 'weforms_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( 'weforms_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( 'weforms_integration_icon', $this->icon, $this ); |
| 70 |
} |
| 71 |
|
| 72 |
/** |
| 73 |
* Check if the integration is enabled |
| 74 |
* |
| 75 |
* @return boolean |
| 76 |
*/ |
| 77 |
public function is_enabled() { |
| 78 |
return $this->enabled == true; |
| 79 |
} |
| 80 |
|
| 81 |
/** |
| 82 |
* Check if it's a pro field |
| 83 |
* |
| 84 |
* @return boolean |
| 85 |
*/ |
| 86 |
public function is_pro() { |
| 87 |
return false; |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Get the settings fields |
| 92 |
* |
| 93 |
* @return array |
| 94 |
*/ |
| 95 |
public function get_settings_fields() { |
| 96 |
return $this->settings_fields; |
| 97 |
} |
| 98 |
|
| 99 |
/** |
| 100 |
* Get the integration settings for the component |
| 101 |
* |
| 102 |
* @return array |
| 103 |
*/ |
| 104 |
public function get_js_settings() { |
| 105 |
return array( |
| 106 |
'id' => $this->get_id(), |
| 107 |
'title' => $this->get_title(), |
| 108 |
'icon' => $this->get_icon(), |
| 109 |
'settings' => $this->get_settings_fields(), |
| 110 |
'pro' => $this->is_pro() |
| 111 |
); |
| 112 |
} |
| 113 |
|
| 114 |
} |
| 115 |
|