PluginProbe ʕ •ᴥ•ʔ
JetFormBuilder — Dynamic Blocks Form Builder / 3.6.5.1
JetFormBuilder — Dynamic Blocks Form Builder v3.6.5.1
3.6.5.1 3.6.5 3.6.4.2 3.6.4.1 3.6.4 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 / modules / actions-v2 / mailchimp / api / put-member-in-list-action.php
jetformbuilder / modules / actions-v2 / mailchimp / api Last commit date
interfaces 2 years ago traits 2 years ago action-factory.php 2 years ago base-api-action.php 2 years ago create-tags-action.php 2 years ago get-categories-action.php 2 years ago get-categories-interests-action.php 2 years ago get-fields-action.php 2 years ago get-lists-action.php 2 years ago put-member-in-list-action.php 1 year ago
put-member-in-list-action.php
120 lines
1 <?php
2
3 namespace JFB_Modules\Actions_V2\Mailchimp\Api;
4
5 use Jet_Form_Builder\Classes\Tools;
6 use JFB_Modules\Actions_V2\Mailchimp\Api\interfaces\Subscriber_Interface;
7 use JFB_Modules\Actions_V2\Mailchimp\Api\traits\Subscriber_Trait;
8
9 class Put_Member_In_List_Action extends Base_Api_Action implements Subscriber_Interface {
10
11 use Subscriber_Trait;
12
13 protected $method = 'PUT';
14
15 private $status_if_new = '';
16 private $merge_fields = array();
17 private $interests = array();
18
19 public function action_endpoint() {
20 return 'lists/{list_id}/members/{email_md5}';
21 }
22
23
24 public function action_headers() {
25 return array(
26 'Content-Type' => 'application/json; charset=utf-8',
27 );
28 }
29
30 public function action_body() {
31 $data = array(
32 'status' => 'subscribed',
33 'email_address' => $this->get_email_address(),
34 'status_if_new' => $this->get_status_if_new(),
35 'merge_fields' => $this->get_merge_fields(),
36 );
37
38 $interests = $this->get_interests();
39 if ( ! empty( $interests ) ) {
40 $data['interests'] = $interests;
41 }
42
43 return $data;
44 }
45
46
47 /**
48 * @param int|string $birthday
49 *
50 * @return void
51 */
52 public function set_birthday( $birthday ) {
53 if ( ! $birthday ) {
54 return;
55 }
56
57 if ( ! Tools::is_valid_timestamp( $birthday ) ) {
58 $birthday = strtotime( $birthday );
59 }
60
61 // phpcs:ignore WordPress.DateTime.RestrictedFunctions
62 $this->set_merge_fields( 'BIRTHDAY', date( 'm/d', $birthday ) );
63 }
64
65 public function set_merge_fields( string $name, $value ) {
66 $this->merge_fields[ $name ] = $value;
67 }
68
69 /**
70 * @return array
71 */
72 public function get_merge_fields(): array {
73 return $this->merge_fields;
74 }
75
76 public function set_opt_in( $opt_in ) {
77 $is_opt_in = filter_var(
78 $opt_in,
79 defined( 'FILTER_VALIDATE_BOOL' ) ? FILTER_VALIDATE_BOOL : FILTER_VALIDATE_BOOLEAN
80 );
81
82 $this->set_status_if_new( $is_opt_in ? 'pending' : 'subscribed' );
83 }
84
85 public function set_status_if_new( string $status_if_new ) {
86 $this->status_if_new = $status_if_new;
87 }
88
89 /**
90 * @return string
91 */
92 public function get_status_if_new(): string {
93 return $this->status_if_new;
94 }
95
96 /**
97 * @return array
98 */
99 public function get_interests(): array {
100 return $this->interests;
101 }
102
103 /**
104 * @param array $interests
105 */
106 public function set_interests( array $interests ) {
107 if ( ! wp_is_numeric_array( $interests ) ) {
108 $this->interests = $interests;
109
110 return;
111 }
112
113 foreach ( $interests as $interest ) {
114 $this->interests[ $interest ] = true;
115 }
116 }
117
118
119 }
120