f71c34a8 by Jeff Balicki

SSS

1 parent 54fe6eef
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
2 2
3 namespace Tz\WordPress\Tools\Notifications\Settings; 3 namespace Tz\WordPress\Tools\Notifications\Settings;
4 4
5 use Tz\Common;
6 use Tz\WordPress\Tools; 5 use Tz\WordPress\Tools;
7 use Tz\WordPress\Tools\Notifications; 6 use Tz\WordPress\Tools\Notifications;
8 7
...@@ -107,7 +106,6 @@ function display_page() ...@@ -107,7 +106,6 @@ function display_page()
107 $link = $_POST[$lang . '_push_notifications_link']; 106 $link = $_POST[$lang . '_push_notifications_link'];
108 $status = $_POST[$lang . '_push_notifications_status']; 107 $status = $_POST[$lang . '_push_notifications_status'];
109 108
110
111 if (count($entry->email[$lang . '_attachments']) > 0) { 109 if (count($entry->email[$lang . '_attachments']) > 0) {
112 $attachments = array_merge($entry->email[$lang . '_attachments'], $attachments); 110 $attachments = array_merge($entry->email[$lang . '_attachments'], $attachments);
113 } 111 }
...@@ -118,14 +116,14 @@ function display_page() ...@@ -118,14 +116,14 @@ function display_page()
118 $lang . '_subject' => $subject, 116 $lang . '_subject' => $subject,
119 $lang . '_text' => $text, 117 $lang . '_text' => $text,
120 $lang . '_html' => $html, 118 $lang . '_html' => $html,
121 $lang . '_attachments' => $attachments 119 $lang . '_attachments' => $attachments,
122 ] 120 ]
123 ); 121 );
124 $systemMessageData = array_merge( 122 $systemMessageData = array_merge(
125 $systemMessageData, 123 $systemMessageData,
126 [ 124 [
127 'system_message_type' => $systemMessageType, 125 'system_message_type' => $systemMessageType,
128 $lang . '_message' => $system 126 $lang . '_message' => $system,
129 ] 127 ]
130 ); 128 );
131 $pushMessageData = array_merge( 129 $pushMessageData = array_merge(
...@@ -135,7 +133,7 @@ function display_page() ...@@ -135,7 +133,7 @@ function display_page()
135 $lang . '_title' => $title, 133 $lang . '_title' => $title,
136 $lang . '_message' => $message, 134 $lang . '_message' => $message,
137 $lang . '_link' => $link, 135 $lang . '_link' => $link,
138 $lang . '_status' => $status 136 $lang . '_status' => $status,
139 ] 137 ]
140 ); 138 );
141 } 139 }
...@@ -148,8 +146,7 @@ function display_page() ...@@ -148,8 +146,7 @@ function display_page()
148 'sendto' => $sendto, 146 'sendto' => $sendto,
149 'status' => $entry->details['status'], 147 'status' => $entry->details['status'],
150 'trigger' => $trigger, 148 'trigger' => $trigger,
151 'execute_date' => $executeDate 149 'execute_date' => $executeDate,
152
153 150
154 ] 151 ]
155 ); 152 );
...@@ -182,9 +179,9 @@ function display_page() ...@@ -182,9 +179,9 @@ function display_page()
182 $entry->push = $push; 179 $entry->push = $push;
183 180
184 $flash = '<strong>Notification Saved Successfully!</strong><br /><a href=""/wp-admin/admin.php?page=notifications">Click here</a> to view all notifications.</a>'; 181 $flash = '<strong>Notification Saved Successfully!</strong><br /><a href=""/wp-admin/admin.php?page=notifications">Click here</a> to view all notifications.</a>';
185 require_once(__DIR__ . '/views/form.php'); 182 require_once __DIR__ . '/views/form.php';
186 } else { 183 } else {
187 require_once(__DIR__ . '/views/form.php'); 184 require_once __DIR__ . '/views/form.php';
188 } 185 }
189 } else { 186 } else {
190 if (isset($_GET['action']) && $_GET['action'] == 'delete') { 187 if (isset($_GET['action']) && $_GET['action'] == 'delete') {
...@@ -211,7 +208,7 @@ function display_page() ...@@ -211,7 +208,7 @@ function display_page()
211 'order' => 'desc', 208 'order' => 'desc',
212 'meta_key' => 'send_status', 209 'meta_key' => 'send_status',
213 'meta_compare' => '=', 210 'meta_compare' => '=',
214 'meta_value' => 'pending' 211 'meta_value' => 'pending',
215 ]; 212 ];
216 213
217 $entries = get_posts($args); 214 $entries = get_posts($args);
...@@ -239,7 +236,7 @@ function display_page() ...@@ -239,7 +236,7 @@ function display_page()
239 } 236 }
240 } 237 }
241 238
242 require_once(__DIR__ . '/views/admin.php'); 239 require_once __DIR__ . '/views/admin.php';
243 } 240 }
244 } 241 }
245 242
...@@ -296,7 +293,7 @@ function fixFilesArray(&$files) ...@@ -296,7 +293,7 @@ function fixFilesArray(&$files)
296 function notification_settings() 293 function notification_settings()
297 { 294 {
298 295
299 require_once(__DIR__ . '/views/settings.php'); 296 require_once __DIR__ . '/views/settings.php';
300 } 297 }
301 298
302 function create_notification() 299 function create_notification()
...@@ -326,7 +323,7 @@ function create_notification() ...@@ -326,7 +323,7 @@ function create_notification()
326 323
327 if ($_POST && ($_POST['en_subject'] == '' && $_POST['fr_subject'] == '' && $_POST['en_system'] == '' && $_POST['fr_system'] == '')) { 324 if ($_POST && ($_POST['en_subject'] == '' && $_POST['fr_subject'] == '' && $_POST['en_system'] == '' && $_POST['fr_system'] == '')) {
328 $form_error = true; 325 $form_error = true;
329 require_once(__DIR__ . '/views/create.php'); 326 require_once __DIR__ . '/views/create.php';
330 } else { 327 } else {
331 if ($validation->run() == true) { 328 if ($validation->run() == true) {
332 329
...@@ -353,14 +350,7 @@ function create_notification() ...@@ -353,14 +350,7 @@ function create_notification()
353 $emailData = []; 350 $emailData = [];
354 $systemMessageData = []; 351 $systemMessageData = [];
355 $pushMessageData = []; 352 $pushMessageData = [];
356 353 $def_trid = "";
357
358
359
360
361
362
363
364 foreach (['en', 'fr'] as $lang) { 354 foreach (['en', 'fr'] as $lang) {
365 // email 355 // email
366 $subject = $_POST[$lang . '_subject']; 356 $subject = $_POST[$lang . '_subject'];
...@@ -396,7 +386,7 @@ function create_notification() ...@@ -396,7 +386,7 @@ function create_notification()
396 'post_title' => $subject, 386 'post_title' => $subject,
397 'post_status' => 'publish', 387 'post_status' => 'publish',
398 'post_type' => 'newsLetter', 388 'post_type' => 'newsLetter',
399 'post_content' => '<div id="newsletter">' . $html . '</div>', 389 'post_content' => $html,
400 390
401 ) 391 )
402 ); 392 );
...@@ -415,15 +405,25 @@ function create_notification() ...@@ -415,15 +405,25 @@ function create_notification()
415 'element_type' => $wpml_element_type, 405 'element_type' => $wpml_element_type,
416 'trid' => $original_post_language_info->trid, 406 'trid' => $original_post_language_info->trid,
417 'language_code' => $lang, 407 'language_code' => $lang,
418 'source_language_code' => $original_post_language_info->language_code 408 'source_language_code' => $original_post_language_info->language_code,
419 ); 409 );
420 410
421 do_action('wpml_set_element_language_details', $set_language_args); 411 do_action('wpml_set_element_language_details', $set_language_args);
412
413 }
414
415 if ($post_id && $lang == 'en') {
416 $postIdEn = $post_id;
417 }
418
419 if ($post_id && $lang == 'fr') {
420 $postIdFr = $post_id;
422 } 421 }
423 } else { 422 } else {
424 423
425 $post_id = -2; 424 $post_id = -2;
426 } 425 }
426
427 } 427 }
428 428
429 // system 429 // system
...@@ -436,8 +436,6 @@ function create_notification() ...@@ -436,8 +436,6 @@ function create_notification()
436 $link = $_POST[$lang . '_push_notifications_link']; 436 $link = $_POST[$lang . '_push_notifications_link'];
437 $status = $_POST[$lang . '_push_notifications_status']; 437 $status = $_POST[$lang . '_push_notifications_status'];
438 438
439
440
441 $emailData = array_merge( 439 $emailData = array_merge(
442 $emailData, 440 $emailData,
443 [ 441 [
...@@ -452,7 +450,7 @@ function create_notification() ...@@ -452,7 +450,7 @@ function create_notification()
452 $systemMessageData, 450 $systemMessageData,
453 [ 451 [
454 'system_message_type' => $systemMessageType, 452 'system_message_type' => $systemMessageType,
455 $lang . '_message' => $system 453 $lang . '_message' => $system,
456 ] 454 ]
457 ); 455 );
458 $pushMessageData = array_merge( 456 $pushMessageData = array_merge(
...@@ -462,16 +460,13 @@ function create_notification() ...@@ -462,16 +460,13 @@ function create_notification()
462 $lang . '_title' => $title, 460 $lang . '_title' => $title,
463 $lang . '_message' => $message, 461 $lang . '_message' => $message,
464 $lang . '_link' => $link, 462 $lang . '_link' => $link,
465 $lang . '_status' => $status 463 $lang . '_status' => $status,
466 ] 464 ]
467 ); 465 );
468 466
469
470 $links[$lang] = get_permalink($post_id); 467 $links[$lang] = get_permalink($post_id);
471 } 468 }
472 469
473
474
475 // make post... 470 // make post...
476 $notification = new PostTemplate(); 471 $notification = new PostTemplate();
477 $notification->post_title = $title; 472 $notification->post_title = $title;
...@@ -484,6 +479,9 @@ function create_notification() ...@@ -484,6 +479,9 @@ function create_notification()
484 479
485 if ($style == 'newsletter') { 480 if ($style == 'newsletter') {
486 update_post_meta($id, 'links', $links); 481 update_post_meta($id, 'links', $links);
482 global $sitepress;
483 $def_trid = $sitepress->get_element_trid($postIdEn, 'post_newsletter');
484 $sitepress->set_element_language_details($postIdFr, 'post_newsletter', $def_trid, 'fr');
487 } 485 }
488 486
489 update_post_meta( 487 update_post_meta(
...@@ -494,7 +492,7 @@ function create_notification() ...@@ -494,7 +492,7 @@ function create_notification()
494 'sendto' => $sendto, 492 'sendto' => $sendto,
495 'status' => 'pending', 493 'status' => 'pending',
496 'trigger' => $trigger, 494 'trigger' => $trigger,
497 'execute_date' => $executeDate 495 'execute_date' => $executeDate,
498 496
499 ] 497 ]
500 ); 498 );
...@@ -505,26 +503,22 @@ function create_notification() ...@@ -505,26 +503,22 @@ function create_notification()
505 503
506 update_post_meta($id, 'trigger', $trigger); 504 update_post_meta($id, 'trigger', $trigger);
507 505
508
509 update_post_meta($id, 'email', $emailData); 506 update_post_meta($id, 'email', $emailData);
510 update_post_meta($id, 'style', $style); 507 update_post_meta($id, 'style', $style);
511 update_post_meta($id, 'system', $systemMessageData); 508 update_post_meta($id, 'system', $systemMessageData);
512 update_post_meta($id, 'push', $pushMessageData); 509 update_post_meta($id, 'push', $pushMessageData);
513 510
514 $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>"; 511 $flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
515 require_once(__DIR__ . '/views/create.php'); 512 require_once __DIR__ . '/views/create.php';
516 } else { 513 } else {
517 require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php'); 514 require_once __DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php';
518 } 515 }
519 } 516 }
520 } 517 }
521 518
522
523
524 function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>') 519 function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
525 { 520 {
526 521
527
528 mb_regex_encoding('UTF-8'); 522 mb_regex_encoding('UTF-8');
529 //replace MS special characters first 523 //replace MS special characters first
530 $search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u'); 524 $search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
...@@ -542,7 +536,6 @@ function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u> ...@@ -542,7 +536,6 @@ function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u>
542 $text = preg_replace('/\<!--(.)*--\>/isu', '', $text); 536 $text = preg_replace('/\<!--(.)*--\>/isu', '', $text);
543 } 537 }
544 538
545
546 $text = preg_replace('/(?:width\=\"\d*\")\S/mxi', '>', $text); 539 $text = preg_replace('/(?:width\=\"\d*\")\S/mxi', '>', $text);
547 $text = preg_replace('/(?:width\=\"\d*%\")\S/mxi', '>', $text); 540 $text = preg_replace('/(?:width\=\"\d*%\")\S/mxi', '>', $text);
548 return $text; 541 return $text;
......