PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.0.8
JetFormBuilder — Dynamic Blocks Form Builder v3.0.8
3.6.3.1 3.6.3 3.6.2.2 3.6.2.1 3.6.2 3.6.1.1 3.6.1 3.6.0.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.3.0 1.3.1 1.3.2 1.3.3 1.4.0 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.10 2.1.11 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 3.0.0 3.0.0.1 3.0.0.2 3.0.0.3 3.0.1 3.0.1.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.0.1 3.1.1 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.2 3.2.3 3.3.0 3.3.1 3.3.2 3.3.3 3.3.3.1 3.3.4 3.3.4.1 3.3.4.2 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.5.1 3.4.5.2 3.4.6 3.4.7 3.4.7.1 3.5.0 3.5.1 3.5.1.1 3.5.1.2 3.5.2 3.5.2.1 3.5.3 3.5.4 3.5.5 3.5.6 3.5.6.1 3.5.6.2 3.5.6.3 3.6.0
jetformbuilder / includes / integrations / active-campaign / actions / active-campaign-action.php
jetformbuilder / includes / integrations / active-campaign / actions Last commit date
active-campaign-action.php 3 years ago
active-campaign-action.php
158 lines
1 <?php
2
3 namespace Jet_Form_Builder\Integrations\Active_Campaign\Actions;
4
5 use Jet_Form_Builder\Actions\Action_Handler;
6 use Jet_Form_Builder\Actions\Types\Base;
7 use Jet_Form_Builder\Exceptions\Action_Exception;
8 use Jet_Form_Builder\Integrations\Active_Campaign\Methods\Contact_Modifier;
9 use Jet_Form_Builder\Integrations\Active_Campaign\Rest_Api\Editor_Fetch_Endpoint;
10 use Jet_Form_Builder\Integrations\Active_Campaign\Rest_Api\Retrieve_Lists;
11 use Jet_Form_Builder\Integrations\Active_Campaign\Rest_Api\Retrieve_Custom_Fields;
12
13 // If this file is called directly, abort.
14 if ( ! defined( 'WPINC' ) ) {
15 die;
16 }
17
18 /**
19 * Define Base_Type class
20 */
21 class Active_Campaign_Action extends Base {
22
23 public $option_name = 'active-campaign-tab';
24
25 public function get_name() {
26 return __( 'ActiveCampaign', 'jet-form-builder' );
27 }
28
29 public function get_id() {
30 return 'active_campaign';
31 }
32
33 public function action_attributes() {
34 return array(
35 'api_key' => array(
36 'default' => '',
37 'path' => 'activecampaign/api_key',
38 ),
39 'api_url' => array(
40 'default' => '',
41 'path' => 'activecampaign/api_url',
42 ),
43 'lists' => array(
44 'default' => '',
45 'path' => 'activecampaign/lists',
46 ),
47 'fields_map' => array(
48 'default' => '',
49 'path' => 'activecampaign/fields_map',
50 ),
51 'isValidAPI' => array(
52 'default' => '',
53 'path' => 'activecampaign/isValidAPI',
54 ),
55 'list_id' => array(
56 'default' => '',
57 'path' => 'activecampaign/list_id',
58 ),
59 'tags' => array(
60 'default' => '',
61 'path' => 'activecampaign/tags',
62 ),
63 );
64 }
65
66 /**
67 * Run a hook notification
68 *
69 * @param array $request
70 * @param Action_Handler $handler
71 *
72 * @return void
73 * @throws Action_Exception
74 */
75 public function do_action( array $request, Action_Handler $handler ) {
76 $settings = $this->global_settings(
77 array(
78 'api_url' => '',
79 'api_key' => '',
80 )
81 );
82
83 $list_id = $this->settings['list_id'] ?? 0;
84 $tags = $this->settings['tags'] ?? '';
85 $fields_map = $this->settings['fields_map'] ?? array();
86
87 ( new Contact_Modifier() )
88 ->set_request( $request )
89 ->set_fields_map( $fields_map, true )
90 ->set_api_key( $settings['api_key'] )
91 ->set_api_url( $settings['api_url'] )
92 ->set( '#list', $list_id )
93 ->set( '#tags', $tags )
94 ->run();
95 }
96
97
98 public function editor_labels() {
99 return array(
100 'api_data' => __( 'API Data', 'jet-form-builder' ),
101 'api_key' => __( 'API Key', 'jet-form-builder' ),
102 'api_url' => __( 'API URL', 'jet-form-builder' ),
103 'validate_api_key' => __( 'Validate API Key', 'jet-form-builder' ),
104 'retry_request' => __( 'Retry request', 'jet-form-builder' ),
105 'list_id' => __( 'List Id:', 'jet-form-builder' ),
106 'update_list_ids' => __( 'Update List', 'jet-form-builder' ),
107 'tags' => __( 'Tags:', 'jet-form-builder' ),
108 'fields_map' => __( 'Fields Map:', 'jet-form-builder' ),
109 'use_global' => __( 'Use Global Settings', 'jet-form-builder' ),
110 );
111 }
112
113 public function editor_labels_help() {
114 return array(
115 'api_key_link_prefix' => __( 'How to obtain your ActiveCampaign API URL and Key? More info', 'jet-form-builder' ),
116 'api_key_link_suffix' => __( 'here', 'jet-form-builder' ),
117 'api_key_link' => 'https://help.activecampaign.com/hc/en-us/articles/207317590-Getting-started-with-the-API',
118 'tags' => __( 'Add as many tags as you want, comma separated.', 'jet-form-builder' ),
119 );
120 }
121
122 /**
123 * Register custom action data for the editor
124 *
125 * @return array [description]
126 */
127 public function action_data() {
128 return array(
129 'fetch' => array(
130 'url' => Editor_Fetch_Endpoint::rest_url(),
131 'method' => Editor_Fetch_Endpoint::get_methods(),
132 ),
133 );
134 }
135
136 /**
137 * Returns ActiveCampaign fields
138 *
139 * @return array
140 */
141 private function get_fields() {
142 return apply_filters(
143 'jet-form-builder/action/activecampaign/fields',
144 array(
145 'email' => __( 'Email', 'jet-form-builder' ),
146 'first_name' => __( 'First Name', 'jet-form-builder' ),
147 'last_name' => __( 'Last Name', 'jet-form-builder' ),
148 'phone' => __( 'Phone', 'jet-form-builder' ),
149 'customer_acct_name' => __( 'Organization', 'jet-form-builder' ),
150 )
151 );
152 }
153
154
155 }
156
157
158