Bonjour à tous,

J'ai fait appel à un développeur pour un site wordpress et du développement spécifique a été fait concernant l'envoie d'email.

Malheuresement elle est partie du jour au lendemain à cause de problèmes personnels et l'envoie de mail ne fonctionne pas... J'ai regardé le code et j'ai remarqué qu'à partir de la ligne 90, tout était en commentaire (alors que c'est le contenu du mail que j'avais demandé !). Quand j'enlève le guillemet à la ligne 90, j'ai ce message d'erreur qui apparait “syntax error unexpected < expecting ;” mais malheuresement je ne sais pas quoi faire pour le corriger... Est ce que vous avez des idées?

J'ai copié ci-dessous le code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
<?php
 
/**
* Plugin Name: Custom CRON
* Description: Nouvelles tâches CRON
* Version: 1.0
*/
 
if ( ! defined( ‘ABSPATH’ ) ) {
exit; // Exit if accessed directly
}
 
if ( ! class_exists( ‘customCron’ ) ) :
 
class customCron {
 
protected $adminEmail;
 
public function __construct() {
 
// cron task
add_action(‘my_cron_task’, array($this, ‘alerteTask’));
 
// activation du plugin
register_activation_hook(__FILE__, array($this, ‘activation’));
 
// désactivation du plugin
register_deactivation_hook(__FILE__, array($this, ‘desactivation’));
 
$this->adminEmail = get_option( ‘admin_email’, ” );
}
 
public function activation() {
// register cron task
wp_mail( $this->adminEmail, ‘Activation du cron’, ‘Activation du cron’ );
if (!wp_next_scheduled(‘my_cron_task’)) {
wp_schedule_event( time(), ‘daily’, ‘my_cron_task’ );
}
}
public function desactivation() {
// de-register cron task
wp_mail( $this->adminEmail, ‘Désactivation du cron’, ‘Désactivation du cron’ );
if (wp_next_scheduled(‘mp_cron_import’)) {
$timeStamp = wp_next_scheduled(‘my_cron_task’);
wp_unschedule_event( $timeStamp, ‘my_cron_task’);
}
}
 
public function alerteTask() {
$subscriptions = wcs_get_subscriptions([
‘subscription_status’ => ‘active’
]);
foreach ($subscriptions as $subscription) {
if ($this->checkDate($subscription->get_date(‘next_payment’))) {
$user_email = $subscription->get_user()->user_email;
$next_date = $subscription->get_date(‘next_payment’)->format(‘d/m/Y’);
$title = “Il est temps de renouveler votre abonnement Elysée”;
$body = $this->getEmailTemplate(
$title,
$subscription->get_user()->first_name,
$subscription->get_id(),
$subscription->get_view_order_url(),
$next_date
);
$content_type = function() { return ‘text/html’; };
wp_mail( $user_email, $title, $body );
remove_filter( ‘wp_mail_content_type’, $content_type );
}
}
}
 
private function checkDate($created_at) {
if (empty($created_at)) {
return false;
}
$created_at = Datetime::createFromFormat(“Y-m-d H:i:s”, $created_at);
$interval = new DateInterval(“P7D”);
$created_at->sub($interval);
$created_at->setTime(0, 0);
$date = new DateTime();
$date->setTime(0, 0);
return ($date == $created_at);
}
 
function getEmailTemplate($title, $firstName, $subscription_id, $view_url, $next_date) {
//$image = “<p style=”margin-top:0;”><img src=”‘ . esc_url( $img ) . ‘” alt=”Elysée” /></p>”;
$image = “”;
 
return
<!DOCTYPE html>
<html lang=”fr-FR”>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″ />
<title>Elysée</title>
<style type=”text/css”>
body {
padding: 0;
}
 
#wrapper {
background-color: #fff;
margin: 0;
padding: 70px 0;
-webkit-text-size-adjust: none !important;
width: 100%;
}
 
#template_container {
box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1) !important;
background-color: #ffffff;
border: 1px solid #3c3c3c;
border-radius: 3px !important;
}
 
#template_header {
background-color: #faca33;
border-radius: 3px 3px 0 0 !important;
color: #3c3c3c;
border-bottom: 0;
font-weight: bold;
line-height: 100%;
vertical-align: middle;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
}
 
#template_header h1,
#template_header h1 a {
color: #3c3c3c;
background-color: inherit;
}
 
#template_header_image img {
margin-left: 0;
margin-right: 0;
}
 
#template_footer td {
padding: 0;
border-radius: 6px;
}
 
#template_footer #credit {
border: 0;
color: #3c3c3c;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
font-size: 12px;
line-height: 150%;
text-align: center;
padding: 24px 0;
}
 
#template_footer #credit p {
margin: 0 0 16px;
}
 
#body_content {
background-color: #ffffff;
}
 
#body_content table td {
padding: 48px 48px 32px;
}
 
#body_content table td td {
padding: 12px;
}
 
#body_content table td th {
padding: 12px;
}
 
#body_content td ul.wc-item-meta {
font-size: small;
margin: 1em 0 0;
padding: 0;
list-style: none;
}
 
#body_content td ul.wc-item-meta li {
margin: 0.5em 0 0;
padding: 0;
}
 
#body_content td ul.wc-item-meta li p {
margin: 0;
}
 
#body_content p {
margin: 0 0 16px;
}
 
#body_content_inner {
color: #3c3c3c;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
font-size: 14px;
line-height: 150%;
text-align: left;
}
 
.td {
color: #3c3c3c;
border: 1px solid #3c3c3c;
vertical-align: middle;
}
 
.address {
padding: 12px;
color: #3c3c3c;
border: 1px solid #3c3c3c;
}
 
.text {
color: #3c3c3c;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
}
 
.link {
color: #faca33;
}
 
#header_wrapper {
padding: 36px 48px;
display: block;
}
 
h1 {
color: #faca33;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
font-size: 30px;
font-weight: 300;
line-height: 150%;
margin: 0;
text-align: left;
text-shadow: 0 1px 0;
}
 
h2 {
color: #faca33;
display: block;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
font-size: 18px;
font-weight: bold;
line-height: 130%;
margin: 0 0 18px;
text-align: left;
}
 
h3 {
color: #faca33;
display: block;
font-family: “Helvetica Neue”, Helvetica, Roboto, Arial, sans-serif;
font-size: 16px;
font-weight: bold;
line-height: 130%;
margin: 16px 0 8px;
text-align: left;
}
 
a {
color: #faca33;
font-weight: normal;
text-decoration: underline;
}
 
img {
border: none;
display: inline-block;
font-size: 14px;
font-weight: bold;
height: auto;
outline: none;
text-decoration: none;
text-transform: capitalize;
vertical-align: middle;
margin-left: 10px;
max-width: 100%;
height: auto;
}
</style>
</head>
<body marginwidth=”0″ topmargin=”0″ marginheight=”0″ offset=”0″>
<div id=”wrapper” dir=”ltr”>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ height=”100%” width=”100%”>
<tr>
<td align=”center” valign=”top”>
<div id=”template_header_image”>
‘.$image.’
</div>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”600″ id=”template_container”>
<tr>
<td align=”center” valign=”top”>
<!– Header –>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”100%” id=”template_header”>
<tr>
<td id=”header_wrapper”>
<h1>’.$title.'</h1>
</td>
</tr>
</table>
<!– End Header –>
</td>
</tr>
<tr>
<td align=”center” valign=”top”>
<!– Body –>
<table border=”0″ cellpadding=”0″ cellspacing=”0″ width=”600″ id=”template_body”>
<tr>
<td valign=”top” id=”body_content”>
<!– Content –>
<table border=”0″ cellpadding=”20″ cellspacing=”0″ width=”100%”>
<tr>
<td valign=”top”>
<div id=”body_content_inner”>
<p>Bonjour ‘.$firstName.’,</p>
<p>Votre abonnement mensuel ‘.$subscription_id.’ se termine le ‘.$next_date.’.</p>
<p>Vous avez dorénavant la possibilité de :</p>
<li>Nous restituer l’ensemble des vêtements que vous avez loués et en louer 5, 10 ou 20 nouveaux en suivant ce lien : <a href=”‘.$view_url.'”>’.$view_url.'</a></li>
<li>Conserver les vêtements de votre abonnement actuel, dans ce cas vous n’avez rien a faire, le renouvellement de votre abonnement se fera automatiquement le ‘.$next_date.’ pour une nouvelle période de 30 jours</li>
<li>Nous restituer l’ensemble des vêtements que vous avez loués sans en louer d’autres. Dans ce cas, nous vous demandons de nous restituer les vêtements d’ici le ‘.$next_date.’, sinon vous serez prélevé d’un mois supplémentaire. Voici le lien à suivre pour nous restituer les vêtements : <a href=”‘.$view_url.'”>’.$view_url.'</a></li>
</ul>

<p>L’équipe de Elysée »</p>
<p>…</p>
</div>
</td>
</tr>
</table>
<!– End Content –>
</td>
</tr>
</table>
<!– End Body –>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td align=”center” valign=”top”>
<!– Footer –>
<table border=”0″ cellpadding=”10″ cellspacing=”0″ width=”600″ id=”template_footer”>
<tr>
<td valign=”top”>
<table border=”0″ cellpadding=”10″ cellspacing=”0″ width=”100%”>
<tr>
<td colspan=”2″ valign=”middle” id=”credit”>

</td>
</tr>
</table>
</td>
</tr>
</table>
<!– End Footer –>
</td>
</tr>
</table>
</div>
</body>
</html>’;
}
}

new customCron;
endif;
Merci beaucoup pour votre aide 🙂 !