PluginProbe
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress / 11.1.0
AcyMailing – An Ultimate Newsletter Plugin and Marketing Automation Solution for WordPress v11.1.0
11.1.1 11.1.0 11.0.5 11.0.4 11.0.3 11.0.2 11.0.1 11.0.0 10.11.1 10.11.0 10.10.2 10.10.1 10.10.0 10.9.1 trunk 10.0.0 10.0.1 10.1.0 10.1.1 10.1.2 10.1.3 10.1.4 10.2.0 10.2.1 10.2.2 All 62 releases
← All changes | back/dynamics/mailgun/plugin.php +43 -27 10.11.1 → 11.1.0 View file →
@@ -34,16 +34,15 @@
34 34 ];
35 35 $config = empty($data['tab']) ? $this->config : $data['tab']->config;
36 36 $defaultDomain = $config->get(self::SENDING_METHOD_ID.'_api_domain');
37 37 $defaultApiKey = $config->get(self::SENDING_METHOD_ID.'_api_key');
38 - ob_start();
39 38 ?>
40 - <div class="send_settings cell grid-x acym_vcenter" id="<?php echo self::SENDING_METHOD_ID; ?>_settings">
39 + <div class="send_settings cell grid-x acym_vcenter" id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings">
41 40 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
42 41 <label class="cell large-3 medium-4 margin-right-1">
43 42 <?php
44 - echo acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION', self::SENDING_METHOD_NAME);
45 - echo acym_info(
43 + echo esc_html(acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION', self::SENDING_METHOD_NAME));
44 + acym_info(
46 45 [
47 46 'textShownInTooltip' => acym_translationSprintf('ACYM_SENDING_METHOD_API_REGION_DESC', self::SENDING_METHOD_NAME),
48 47 ]
49 48 );
@@ -49,9 +48,9 @@
49 48 );
50 49 ?>
51 50 </label>
52 51 <?php
53 - echo acym_radio(
52 + acym_radio(
54 53 $regions,
55 54 'config['.self::SENDING_METHOD_ID.'_api_region]',
56 55 $this->config->get(self::SENDING_METHOD_ID.'_api_region', 'us')
57 56 );
@@ -57,39 +56,42 @@
57 56 );
58 57 ?>
59 58 </div>
60 59 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
61 - <label class="cell" for="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-domain">
62 - <?php echo acym_translationSprintf(
63 - 'ACYM_SENDING_METHOD_API_DOMAIN',
64 - self::SENDING_METHOD_NAME
60 + <label class="cell" for="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-domain">
61 + <?php echo esc_html(
62 + acym_translationSprintf(
63 + 'ACYM_SENDING_METHOD_API_DOMAIN',
64 + self::SENDING_METHOD_NAME
65 + )
65 66 ); ?>
66 67 </label>
67 68 <input type="text"
68 - id="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-domain"
69 - value="<?php echo empty($defaultDomain) ? $this->config->get(self::SENDING_METHOD_ID.'_api_domain') : $defaultDomain; ?>"
70 - name="config[<?php echo self::SENDING_METHOD_ID; ?>_api_domain]"
71 - class="cell acym__configuration__mail__settings__text">
69 + id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-domain"
70 + value="<?php echo esc_attr(empty($defaultDomain) ? $this->config->get(self::SENDING_METHOD_ID.'_api_domain') : $defaultDomain); ?>"
71 + name="config[<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_api_domain]"
72 + class="cell acym__configuration__mail__settings__text">
72 73 </div>
73 74 <div class="cell grid-x acym_vcenter acym__sending__methods__one__settings">
74 - <label class="cell shrink margin-right-1" for="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-key">
75 - <?php echo acym_translationSprintf(
76 - 'ACYM_SENDING_METHOD_API_KEY',
77 - self::SENDING_METHOD_NAME
75 + <label class="cell shrink margin-right-1" for="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-key">
76 + <?php echo esc_html(
77 + acym_translationSprintf(
78 + 'ACYM_SENDING_METHOD_API_KEY',
79 + self::SENDING_METHOD_NAME
80 + )
78 81 ); ?>
79 82 </label>
80 - <?php echo $this->getLinks('https://signup.mailgun.com/new/signup', 'https://www.mailgun.com/pricing/'); ?>
83 + <?php $this->getLinks('https://signup.mailgun.com/new/signup', 'https://www.mailgun.com/pricing/'); ?>
81 84 <input type="text"
82 - id="<?php echo self::SENDING_METHOD_ID; ?>_settings_api-key"
83 - value="<?php echo empty($defaultApiKey) ? $this->config->get(self::SENDING_METHOD_ID.'_api_key') : $defaultApiKey; ?>"
84 - name="config[<?php echo self::SENDING_METHOD_ID; ?>_api_key]"
85 - class="cell acym__configuration__mail__settings__text">
86 - <?php echo $this->getTestCredentialsSendingMethodButton(self::SENDING_METHOD_ID); ?>
87 - <?php echo $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
85 + id="<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_settings_api-key"
86 + value="<?php echo esc_attr(empty($defaultApiKey) ? $this->config->get(self::SENDING_METHOD_ID.'_api_key') : $defaultApiKey); ?>"
87 + name="config[<?php echo esc_attr(self::SENDING_METHOD_ID); ?>_api_key]"
88 + class="cell acym__configuration__mail__settings__text">
89 + <?php $this->getTestCredentialsSendingMethodButton(self::SENDING_METHOD_ID); ?>
90 + <?php $this->getCopySettingsButton($data, self::SENDING_METHOD_ID, 'wp_mail_smtp'); ?>
88 91 </div>
89 92 </div>
90 93 <?php
91 - $data['sendingMethodsHtmlSettings'][self::SENDING_METHOD_ID] = ob_get_clean();
92 94 }
93 95
94 96 public function onAcymTestCredentialSendingMethod($sendingMethod, $credentials)
95 97 {
@@ -107,8 +109,9 @@
107 109 ];
108 110
109 111 $response = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true);
110 112
113 + // If call didn't work, the response is always null
111 114 if (empty($response)) {
112 115 acym_sendAjaxResponse(acym_translation('ACYM_AUTHENTICATION_FAILS_WITH_API_KEY'), [], false);
113 116 } else {
114 117 acym_sendAjaxResponse(acym_translation('ACYM_API_KEY_CORRECT'));
@@ -116,8 +119,9 @@
116 119 }
117 120
118 121 public function onAcymSendEmail(&$response, $mailerHelper, $to, $from, $replyTo, $bcc = [], $attachments = [], $sendingMethodListParams = [])
119 122 {
123 + //https://documentation.mailgun.com/en/latest/user_manual.html#sending-via-api
120 124 if ($mailerHelper->externalMailer !== self::SENDING_METHOD_ID) return;
121 125
122 126 $this->setSendingMethodApiUrl();
123 127 $headers = $this->getHeadersSendingMethod(self::SENDING_METHOD_ID);
@@ -146,15 +150,20 @@
146 150 $data['bcc['.$key.']'] = $bccEmail[0];
147 151 }
148 152 }
149 153
154 + $files = [];
150 155 if (!empty($attachments)) {
151 156 foreach ($attachments as $key => $attachment) {
152 - $data['attachment['.$key.']'] = curl_file_create($attachment[0]);
157 + $files[] = [
158 + 'name' => 'attachment['.$key.']',
159 + 'path' => $attachment[0],
160 + 'filename' => basename($attachment[0]),
161 + ];
153 162 }
154 163 }
155 164
156 - $responseMailer = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true);
165 + $responseMailer = $this->callApiSendingMethod($this->sendingMethodApiUrl.'messages', $data, $headers, 'POST', $authentication, true, $files);
157 166
158 167 if (empty($responseMailer['message']) || empty($responseMailer['id']) || $responseMailer['message'] !== 'Queued. Thank you.') {
159 168 $response['error'] = true;
160 169 $response['message'] = $responseMailer['message'] ?? ($responseMailer['error_curl'] ?? acym_translation('ACYM_ERROR'));
@@ -178,8 +187,15 @@
178 187 $this->sendingMethodApiUrl .= $credentials[self::SENDING_METHOD_ID.'_api_domain'].'/';
179 188 }
180 189 }
181 190
191 + /**
192 + * @param array $credentials
193 + * @param string $sendingMethod
194 + * @param array $sendingMethodListParams this parameter is only used for the plugin sending method list
195 + *
196 + * @return void
197 + */
182 198 public function onAcymGetCredentialsSendingMethod(array &$credentials, string $sendingMethod, array $sendingMethodListParams = [])
183 199 {
184 200 if ($sendingMethod != self::SENDING_METHOD_ID) return;
185 201