academylms
2 years ago
advanced-ads
2 years ago
advanced-coupons
2 years ago
advanced-custom-fields
1 year ago
affiliatewp
2 years ago
amelia
2 years ago
appointment-hour-booking
2 years ago
asgaros
2 years ago
badgeos
3 years ago
bbpress
1 year ago
beaver-builder
3 years ago
better-messages
2 years ago
bricks-builder
1 year ago
buddyboss
1 year ago
buddypress
3 years ago
cartflows
1 year ago
contact-form7
2 years ago
convertpro
1 year ago
divi-builder
1 year ago
easy-affiliate
2 years ago
edd
2 years ago
elementor-pro
2 years ago
event-calendar
1 year ago
events-manager
2 years ago
fluent-boards
1 year ago
fluent-booking
2 years ago
fluent-form
1 year ago
fluent-support
2 years ago
fluentcrm
1 year ago
fluentsmtp
1 year ago
formidable-forms
3 years ago
forminator
3 years ago
funnel-kit-automations
3 years ago
gamipress
2 years ago
geo-directory
2 years ago
givewp
1 year ago
gravity-form
1 year ago
gravity-kit
2 years ago
groundhogg
2 years ago
happyforms
3 years ago
jetengine
3 years ago
jetformbuilder
1 year ago
jetpack-crm
2 years ago
kadence-forms
3 years ago
late-point
1 year ago
learndash
1 year ago
learndash-achievements
2 years ago
learnpress
2 years ago
lifterlms
2 years ago
mail-mint
2 years ago
mailpoet
1 year ago
masteriyo
2 years ago
masterstudy-lms
2 years ago
memberpress
2 years ago
memberpress-course
3 years ago
metabox
1 year ago
metform
3 years ago
modern-events-calendar
2 years ago
mycred
2 years ago
newsletter
2 years ago
ninja-forms
3 years ago
ninja-tables
2 years ago
paid-memberships-pro
2 years ago
paymattic
2 years ago
peepso
2 years ago
pie-forms
3 years ago
powerful-docs
1 year ago
presto-player
1 year ago
profilegrid
1 year ago
projecthuddle
1 year ago
raffle-press
2 years ago
restrict-content
2 years ago
sensei-lms
2 years ago
services-for-surecart
1 year ago
simply-schedule-appointments
2 years ago
slice-wp
2 years ago
support-portal-for-surecart
1 year ago
sureemails
1 year ago
sureforms
1 year ago
suremembers
1 year ago
thrive-leads
1 year ago
triggerbutton
1 year ago
tutorlms
1 year ago
ultimate-addons-for-gutenberg
3 years ago
ultimate-member
1 year ago
voxel
1 year ago
wishlistmember
1 year ago
woocommerce
1 year ago
woocommerce-bookings
2 years ago
woocommerce-memberships
2 years ago
woocommerce-shipstation
2 years ago
woocommerce-subscriptions
1 year ago
wordpress
1 year ago
wp-all-import
2 years ago
wp-courseware
2 years ago
wp-fusion
2 years ago
wp-job-manager
3 years ago
wp-polls
2 years ago
wp-simple-pay
2 years ago
wp-user-manager
2 years ago
wpforms
3 years ago
wpforo
2 years ago
wplms
3 years ago
wployalty
2 years ago
ws-form
2 years ago
AutomateAction.php
2 years ago
Integrations.php
3 years ago
Integrations.php
251 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Integration base class file |
| 4 | * |
| 5 | * @package SureTrigger |
| 6 | * @since 1.0.0 |
| 7 | */ |
| 8 | |
| 9 | namespace SureTriggers\Integrations; |
| 10 | |
| 11 | use SureTriggers\Controllers\EventController; |
| 12 | |
| 13 | if ( ! function_exists( 'is_plugin_active' ) ) { |
| 14 | include_once ABSPATH . 'wp-admin/includes/plugin.php'; |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Class Integrations |
| 19 | * |
| 20 | * @package SureTriggers\Integrations |
| 21 | */ |
| 22 | abstract class Integrations { |
| 23 | |
| 24 | /** |
| 25 | * ID of the integration |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | protected $id; |
| 30 | |
| 31 | /** |
| 32 | * Integration Name |
| 33 | * |
| 34 | * @var string |
| 35 | */ |
| 36 | protected $name; |
| 37 | |
| 38 | /** |
| 39 | * Integration Description |
| 40 | * |
| 41 | * @var string |
| 42 | */ |
| 43 | protected $description; |
| 44 | |
| 45 | /** |
| 46 | * Integration icon/logo URL |
| 47 | * |
| 48 | * @var string |
| 49 | */ |
| 50 | protected $icon_url; |
| 51 | |
| 52 | /** |
| 53 | * Contains configuration form fields. |
| 54 | * |
| 55 | * @var array |
| 56 | */ |
| 57 | protected $config_fields = []; |
| 58 | |
| 59 | /** |
| 60 | * Contains saved configurations |
| 61 | * |
| 62 | * @var array |
| 63 | */ |
| 64 | protected $config = []; |
| 65 | |
| 66 | /** |
| 67 | * Contains errors list |
| 68 | * |
| 69 | * @var array |
| 70 | */ |
| 71 | protected $errors = []; |
| 72 | |
| 73 | /** |
| 74 | * If the form should be verify or not. |
| 75 | * |
| 76 | * @var bool |
| 77 | */ |
| 78 | protected $form_validation = false; |
| 79 | |
| 80 | /** |
| 81 | * Get api key page URL |
| 82 | * |
| 83 | * @var null|bool |
| 84 | */ |
| 85 | protected $api_page_url = null; |
| 86 | |
| 87 | /** |
| 88 | * Contains it's actions list, if any. For the future usage |
| 89 | * |
| 90 | * @var array |
| 91 | */ |
| 92 | protected $actions = []; |
| 93 | |
| 94 | /** |
| 95 | * Contains it's triggers list, if any. For the future usage |
| 96 | * |
| 97 | * @var array |
| 98 | */ |
| 99 | protected $triggers = []; |
| 100 | |
| 101 | /** |
| 102 | * Integrations constructor. |
| 103 | */ |
| 104 | public function __construct() { |
| 105 | $this->process_events(); |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Process and get all events |
| 110 | * |
| 111 | * @return void |
| 112 | */ |
| 113 | public function process_events() { |
| 114 | $events = EventController::get_instance(); |
| 115 | |
| 116 | if ( ! empty( $events->triggers[ $this->id ] ) ) { |
| 117 | $this->triggers = $events->triggers[ $this->id ]; |
| 118 | } |
| 119 | |
| 120 | if ( ! empty( $events->actions[ $this->id ] ) ) { |
| 121 | $this->actions = $events->actions[ $this->id ]; |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * If enabled or not |
| 127 | * |
| 128 | * @return bool |
| 129 | */ |
| 130 | public function is_enabled() { |
| 131 | return (bool) $this->is_plugin_installed(); |
| 132 | } |
| 133 | |
| 134 | /** |
| 135 | * Check if plugin is installed. |
| 136 | * |
| 137 | * @return bool |
| 138 | */ |
| 139 | abstract public function is_plugin_installed(); |
| 140 | |
| 141 | /** |
| 142 | * Returns ID |
| 143 | * |
| 144 | * @return string |
| 145 | */ |
| 146 | public function get_id() { |
| 147 | return $this->id; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Returns integration name |
| 152 | * |
| 153 | * @return string |
| 154 | */ |
| 155 | public function get_name() { |
| 156 | return $this->name; |
| 157 | } |
| 158 | |
| 159 | /** |
| 160 | * Returns integration description |
| 161 | * |
| 162 | * @return string |
| 163 | */ |
| 164 | public function get_description() { |
| 165 | return $this->description; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Get the integration URL |
| 170 | * |
| 171 | * @return string |
| 172 | */ |
| 173 | public function get_icon_url() { |
| 174 | return $this->icon_url; |
| 175 | } |
| 176 | |
| 177 | /** |
| 178 | * Get config form fields |
| 179 | * |
| 180 | * @return array |
| 181 | */ |
| 182 | public function get_config_fields() { |
| 183 | return $this->config_fields; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Get saved |
| 188 | * |
| 189 | * @return array |
| 190 | */ |
| 191 | public function get_config() { |
| 192 | return $this->config; |
| 193 | } |
| 194 | |
| 195 | /** |
| 196 | * Get errors if any |
| 197 | * |
| 198 | * @return array |
| 199 | */ |
| 200 | public function get_errors() { |
| 201 | return $this->errors; |
| 202 | } |
| 203 | |
| 204 | /** |
| 205 | * Determine if the form is require validation. |
| 206 | * |
| 207 | * @return bool |
| 208 | */ |
| 209 | public function form_validation() { |
| 210 | return $this->form_validation; |
| 211 | } |
| 212 | |
| 213 | /** |
| 214 | * Get API key page URL |
| 215 | * |
| 216 | * @return bool |
| 217 | */ |
| 218 | public function get_api_page_url() { |
| 219 | return $this->api_page_url; |
| 220 | } |
| 221 | |
| 222 | /** |
| 223 | * Get actions if any |
| 224 | * |
| 225 | * @return array |
| 226 | */ |
| 227 | public function get_actions() { |
| 228 | return $this->actions; |
| 229 | } |
| 230 | |
| 231 | /** |
| 232 | * Get triggers if any |
| 233 | * |
| 234 | * @return array |
| 235 | */ |
| 236 | public function get_triggers() { |
| 237 | return $this->triggers; |
| 238 | } |
| 239 | |
| 240 | /** |
| 241 | * Default validation abstract method (optional) |
| 242 | * |
| 243 | * @param array $args Form input as $args. |
| 244 | * |
| 245 | * @return false |
| 246 | */ |
| 247 | public function validation( $args = [] ) { |
| 248 | return false; |
| 249 | } |
| 250 | } |
| 251 |