PluginProbe ʕ •ᴥ•ʔ
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor / 4.0.0
ElementsKit Elementor Addons – Advanced Widgets & Templates Addons for Elementor v4.0.0
4.0.3 4.0.2 4.0.1 4.0.0 3.10.02 3.10.01 3.9.10 3.9.9 3.9.8 3.9.7 3.9.5 3.9.6 3.9.3 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.3.0 2.3.1 2.3.1.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.4.0 2.5.0 2.5.1 2.5.10 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.8.5 2.8.6 2.8.7 2.8.8 2.9.0 2.9.1 2.9.2 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4 3.2.0 3.2.1 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0 3.3.1 3.3.2 3.3.3 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.4.7 3.4.8 3.4.9 3.5.0 3.5.1 3.5.2 3.5.3 3.5.4 3.5.5 3.5.6 3.6.0 3.6.1 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.7.5 3.7.6 3.7.7 3.7.8 3.7.9 3.8.0 3.8.1 3.8.2 3.9.0 3.9.1 3.9.2 trunk 1.2.6 1.2.7 1.2.9 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.8 1.3.9 1.4.0 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.4.7 1.4.8 1.4.9 1.5.0 1.5.1 1.5.10 1.5.11 1.5.12 1.5.2 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.5.9 2.0.0 2.0.1 2.0.10 2.0.11 2.0.12 2.0.13 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.0.9.1 2.0.9.2 2.0.9.3
elementskit-lite / widgets / mail-chimp / classes / mail-chimp-rest.php
elementskit-lite / widgets / mail-chimp / classes Last commit date
mail-chimp-rest.php 2 years ago
mail-chimp-rest.php
70 lines
1 <?php
2 if(!function_exists('ekit_mail_chimp_rest')){
3
4 function ekit_mail_chimp_rest(WP_REST_Request $request ){
5 $return = ['success' => [], 'error' => [] ];
6
7 $token = $request['token'];
8 $list = $request['list'];
9 $email = $request['email'];
10 $firstname = $request['firstname'];
11 $lastname = $request['lastname'];
12 $phone = $request['phone'];
13
14 $url = 'https://us20.api.mailchimp.com/3.0/lists/'.$list.'/members/';
15
16 $margeFiled = [];
17 if(strlen($firstname) > 1):
18 $margeFiled['FNAME'] = $firstname;
19 endif;
20 if(strlen($lastname) > 1):
21 $margeFiled['LNAME'] = $lastname;
22 endif;
23 if(strlen($phone) > 1):
24 $margeFiled['PHONE'] = $phone;
25 endif;
26
27 $postData = [];
28 $postData['email_address'] = $email;
29 $postData['status'] = 'subscribed';
30 if(sizeof($margeFiled) > 0):
31 $postData['merge_fields'] = $margeFiled;
32 endif;
33 $postData['status_if_new'] = 'subscribed';
34
35 $response = wp_remote_post( $url, [
36 'method' => 'POST',
37 'data_format' => 'body',
38 'timeout' => 45,
39 'headers' => [
40
41 'Authorization' => 'apikey '.$token,
42 'Content-Type' => 'application/json; charset=utf-8'
43 ],
44 'body' => wp_json_encode($postData )
45 ]
46 );
47
48 if ( is_wp_error( $response ) ) {
49 $error_message = $response->get_error_message();
50 $return['error'] = "Something went wrong: $error_message";
51 } else {
52 $return['success'] = $response;
53 }
54
55 return $return;
56 }
57 }
58
59 /**
60 * wp rest api add action
61 */
62 add_action( 'rest_api_init', function () {
63 register_rest_route( 'elementskit-lite', '/mailchimp/',
64 array(
65 'methods' => 'GET',
66 'callback' => 'ekit_mail_chimp_rest',
67 'permission_callback' => '__return_true',
68 )
69 );
70 });