w
Showing
2 changed files
with
85 additions
and
10 deletions
| ... | @@ -327,6 +327,13 @@ function create_notification() | ... | @@ -327,6 +327,13 @@ function create_notification() |
| 327 | $style = $_POST['email_style']; | 327 | $style = $_POST['email_style']; |
| 328 | $emailData = []; | 328 | $emailData = []; |
| 329 | $systemMessageData = []; | 329 | $systemMessageData = []; |
| 330 | |||
| 331 | |||
| 332 | |||
| 333 | |||
| 334 | |||
| 335 | |||
| 336 | |||
| 330 | 337 | ||
| 331 | foreach (['en', 'fr'] as $lang) { | 338 | foreach (['en', 'fr'] as $lang) { |
| 332 | 339 | ||
| ... | @@ -345,6 +352,56 @@ function create_notification() | ... | @@ -345,6 +352,56 @@ function create_notification() |
| 345 | $attachments[] = $file['name']; | 352 | $attachments[] = $file['name']; |
| 346 | } | 353 | } |
| 347 | } | 354 | } |
| 355 | |||
| 356 | if($style == 'newsletter'){ | ||
| 357 | $newletter_id = -1; | ||
| 358 | $author_id = 1; | ||
| 359 | $slug = strtolower($subject); | ||
| 360 | |||
| 361 | if( null == get_page_by_title( $title ) ) { | ||
| 362 | |||
| 363 | // Set the page ID so that we know the page was created successfully | ||
| 364 | $post_id = wp_insert_post( | ||
| 365 | array( | ||
| 366 | 'comment_status' => 'closed', | ||
| 367 | 'ping_status' => 'closed', | ||
| 368 | 'post_author' => '1', | ||
| 369 | 'post_name' => $slug, | ||
| 370 | 'post_title' => $subject, | ||
| 371 | 'post_status' => 'publish', | ||
| 372 | 'post_type' => 'newsLetter', | ||
| 373 | 'post_content' => '<div id="newsletter">'.$html.'</div>' , | ||
| 374 | |||
| 375 | ) | ||
| 376 | ); | ||
| 377 | |||
| 378 | if ($post_id) { | ||
| 379 | // https://wpml.org/wpml-hook/wpml_element_type/ | ||
| 380 | $wpml_element_type = apply_filters( 'wpml_element_type', 'newsletter' ); | ||
| 381 | |||
| 382 | // get the language info of the original post | ||
| 383 | // https://wpml.org/wpml-hook/wpml_element_language_details/ | ||
| 384 | $get_language_args = array('element_id' => $post_id, 'element_type' => 'post_product' ); | ||
| 385 | $original_post_language_info = apply_filters( 'wpml_element_language_details', null, $get_language_args ); | ||
| 386 | |||
| 387 | $set_language_args = array( | ||
| 388 | 'element_id' => $post_id, | ||
| 389 | 'element_type' => $wpml_element_type, | ||
| 390 | 'trid' => $original_post_language_info->trid, | ||
| 391 | 'language_code' => $lang, | ||
| 392 | 'source_language_code' => $original_post_language_info->language_code | ||
| 393 | ); | ||
| 394 | |||
| 395 | do_action( 'wpml_set_element_language_details', $set_language_args ); | ||
| 396 | } | ||
| 397 | |||
| 398 | } else { | ||
| 399 | |||
| 400 | $post_id = -2; | ||
| 401 | |||
| 402 | } | ||
| 403 | |||
| 404 | } | ||
| 348 | 405 | ||
| 349 | // system | 406 | // system |
| 350 | $systemMessageType = $_POST['system_message_type']; | 407 | $systemMessageType = $_POST['system_message_type']; |
| ... | @@ -356,7 +413,8 @@ function create_notification() | ... | @@ -356,7 +413,8 @@ function create_notification() |
| 356 | $lang.'_subject' => $subject, | 413 | $lang.'_subject' => $subject, |
| 357 | $lang.'_text' => $text, | 414 | $lang.'_text' => $text, |
| 358 | $lang.'_html' => $html, | 415 | $lang.'_html' => $html, |
| 359 | $lang.'_attachments' => $attachments | 416 | $lang.'_attachments' => $attachments, |
| 417 | |||
| 360 | ] | 418 | ] |
| 361 | ); | 419 | ); |
| 362 | $systemMessageData = array_merge( | 420 | $systemMessageData = array_merge( |
| ... | @@ -366,7 +424,13 @@ function create_notification() | ... | @@ -366,7 +424,13 @@ function create_notification() |
| 366 | $lang.'_message' => $system | 424 | $lang.'_message' => $system |
| 367 | ] | 425 | ] |
| 368 | ); | 426 | ); |
| 427 | |||
| 428 | |||
| 429 | $links[$lang] = get_permalink($post_id); | ||
| 430 | |||
| 369 | } | 431 | } |
| 432 | |||
| 433 | |||
| 370 | 434 | ||
| 371 | // make post... | 435 | // make post... |
| 372 | $notification = new PostTemplate(); | 436 | $notification = new PostTemplate(); |
| ... | @@ -377,6 +441,10 @@ function create_notification() | ... | @@ -377,6 +441,10 @@ function create_notification() |
| 377 | $notification->post_date_gmt = date('Y-m-d H:i:s', time()); | 441 | $notification->post_date_gmt = date('Y-m-d H:i:s', time()); |
| 378 | 442 | ||
| 379 | $id = wp_insert_post((array)$notification); | 443 | $id = wp_insert_post((array)$notification); |
| 444 | |||
| 445 | if($style == 'newsletter'){ | ||
| 446 | update_post_meta($id, 'links', $links); | ||
| 447 | } | ||
| 380 | 448 | ||
| 381 | update_post_meta( | 449 | update_post_meta( |
| 382 | $id, | 450 | $id, |
| ... | @@ -396,6 +464,7 @@ function create_notification() | ... | @@ -396,6 +464,7 @@ function create_notification() |
| 396 | update_post_meta($id, 'execute_date', strtotime($executeDate)); | 464 | update_post_meta($id, 'execute_date', strtotime($executeDate)); |
| 397 | 465 | ||
| 398 | update_post_meta($id, 'trigger', $trigger); | 466 | update_post_meta($id, 'trigger', $trigger); |
| 467 | |||
| 399 | 468 | ||
| 400 | update_post_meta($id, 'email', $emailData); | 469 | update_post_meta($id, 'email', $emailData); |
| 401 | update_post_meta($id, 'style', $style); | 470 | update_post_meta($id, 'style', $style); |
| ... | @@ -403,6 +472,12 @@ function create_notification() | ... | @@ -403,6 +472,12 @@ function create_notification() |
| 403 | 472 | ||
| 404 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; | 473 | $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; |
| 405 | require_once(__DIR__.'/views/create.php'); | 474 | require_once(__DIR__.'/views/create.php'); |
| 475 | |||
| 476 | |||
| 477 | |||
| 478 | |||
| 479 | |||
| 480 | |||
| 406 | } else { | 481 | } else { |
| 407 | require_once(__DIR__.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'create.php'); | 482 | require_once(__DIR__.DIRECTORY_SEPARATOR.'views'.DIRECTORY_SEPARATOR.'create.php'); |
| 408 | } | 483 | } | ... | ... |
| ... | @@ -330,13 +330,13 @@ function getInputFormValues($validation, $name) { | ... | @@ -330,13 +330,13 @@ function getInputFormValues($validation, $name) { |
| 330 | var type = jQuery('#notif_type').val(); | 330 | var type = jQuery('#notif_type').val(); |
| 331 | var date = new Date().toLocaleDateString("en-US", {year: 'numeric', month: 'long', day: 'numeric'}); | 331 | var date = new Date().toLocaleDateString("en-US", {year: 'numeric', month: 'long', day: 'numeric'}); |
| 332 | 332 | ||
| 333 | var header ='<div class="content"><div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span></div><br/><br/>'; | 333 | // var header ='<div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span></div><br/><br/>'; |
| 334 | 334 | // | |
| 335 | var footer ='</div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'; | 335 | // var footer ='<div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'; |
| 336 | 336 | // | |
| 337 | var header_fr ='<div class="content"><div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo_fr.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span></div>><br/><br/></div>'; | 337 | // var header_fr ='<div class="content"><div><span style="font-size: 9.5pt;">If you are unable to clearly view the below E-Flash, please click<b><a><span style="font-weight: normal;"> here</span></a></b></span><hr /><img class="alignnone" src="https://cbvinstitute.com/wp-content/uploads/2019/02/email_logo_fr.png" alt="Logo" width="81" height="57" align="left" /><span style="font-size: 9.5pt; line-height: 115%; float: right;">'+date+'</span></div>><br/><br/>'; |
| 338 | 338 | // | |
| 339 | var footer_fr ='</div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'; | 339 | // var footer_fr ='</div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><div> </div><p class="footer"><strong><span style="font-family: GothamLight; font-size: 12px;"> To opt out, please:<br />1. Log in to cicbv.ca<br />2. Click on your name<br />3. From the drop down menu select profile<br />4. Edit E-flash settings<br />If you have any questions, please contact us: admin@cicbv.ca<br /></span></strong></p>'; |
| 340 | 340 | ||
| 341 | 341 | ||
| 342 | 342 | ||
| ... | @@ -353,8 +353,8 @@ function getInputFormValues($validation, $name) { | ... | @@ -353,8 +353,8 @@ function getInputFormValues($validation, $name) { |
| 353 | jQuery(".text_verson").hide(); | 353 | jQuery(".text_verson").hide(); |
| 354 | jQuery('.attachments').hide(); | 354 | jQuery('.attachments').hide(); |
| 355 | jQuery('.scheduled_sendto').show(); | 355 | jQuery('.scheduled_sendto').show(); |
| 356 | $(tinymce.get('en_html').getBody()).html(header+footer); | 356 | //$(tinymce.get('en_html').getBody()).html(header+footer); |
| 357 | $(tinymce.get('fr_html').getBody()).html(header_fr+footer_fr); | 357 | //$(tinymce.get('fr_html').getBody()).html(header_fr+footer_fr); |
| 358 | 358 | ||
| 359 | jQuery('#execute_date').datetimepicker({ | 359 | jQuery('#execute_date').datetimepicker({ |
| 360 | format: 'Y-m-d, H:i', | 360 | format: 'Y-m-d, H:i', | ... | ... |
-
Please register or sign in to post a comment