f71c34a8 by Jeff Balicki

SSS

1 parent 54fe6eef
......@@ -2,7 +2,6 @@
namespace Tz\WordPress\Tools\Notifications\Settings;
use Tz\Common;
use Tz\WordPress\Tools;
use Tz\WordPress\Tools\Notifications;
......@@ -107,7 +106,6 @@ function display_page()
$link = $_POST[$lang . '_push_notifications_link'];
$status = $_POST[$lang . '_push_notifications_status'];
if (count($entry->email[$lang . '_attachments']) > 0) {
$attachments = array_merge($entry->email[$lang . '_attachments'], $attachments);
}
......@@ -118,14 +116,14 @@ function display_page()
$lang . '_subject' => $subject,
$lang . '_text' => $text,
$lang . '_html' => $html,
$lang . '_attachments' => $attachments
$lang . '_attachments' => $attachments,
]
);
$systemMessageData = array_merge(
$systemMessageData,
[
'system_message_type' => $systemMessageType,
$lang . '_message' => $system
$lang . '_message' => $system,
]
);
$pushMessageData = array_merge(
......@@ -135,7 +133,7 @@ function display_page()
$lang . '_title' => $title,
$lang . '_message' => $message,
$lang . '_link' => $link,
$lang . '_status' => $status
$lang . '_status' => $status,
]
);
}
......@@ -148,8 +146,7 @@ function display_page()
'sendto' => $sendto,
'status' => $entry->details['status'],
'trigger' => $trigger,
'execute_date' => $executeDate
'execute_date' => $executeDate,
]
);
......@@ -182,9 +179,9 @@ function display_page()
$entry->push = $push;
$flash = '<strong>Notification Saved Successfully!</strong><br /><a href=""/wp-admin/admin.php?page=notifications">Click here</a> to view all notifications.</a>';
require_once(__DIR__ . '/views/form.php');
require_once __DIR__ . '/views/form.php';
} else {
require_once(__DIR__ . '/views/form.php');
require_once __DIR__ . '/views/form.php';
}
} else {
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
......@@ -211,7 +208,7 @@ function display_page()
'order' => 'desc',
'meta_key' => 'send_status',
'meta_compare' => '=',
'meta_value' => 'pending'
'meta_value' => 'pending',
];
$entries = get_posts($args);
......@@ -239,7 +236,7 @@ function display_page()
}
}
require_once(__DIR__ . '/views/admin.php');
require_once __DIR__ . '/views/admin.php';
}
}
......@@ -296,7 +293,7 @@ function fixFilesArray(&$files)
function notification_settings()
{
require_once(__DIR__ . '/views/settings.php');
require_once __DIR__ . '/views/settings.php';
}
function create_notification()
......@@ -326,7 +323,7 @@ function create_notification()
if ($_POST && ($_POST['en_subject'] == '' && $_POST['fr_subject'] == '' && $_POST['en_system'] == '' && $_POST['fr_system'] == '')) {
$form_error = true;
require_once(__DIR__ . '/views/create.php');
require_once __DIR__ . '/views/create.php';
} else {
if ($validation->run() == true) {
......@@ -353,14 +350,7 @@ function create_notification()
$emailData = [];
$systemMessageData = [];
$pushMessageData = [];
$def_trid = "";
foreach (['en', 'fr'] as $lang) {
// email
$subject = $_POST[$lang . '_subject'];
......@@ -396,7 +386,7 @@ function create_notification()
'post_title' => $subject,
'post_status' => 'publish',
'post_type' => 'newsLetter',
'post_content' => '<div id="newsletter">' . $html . '</div>',
'post_content' => $html,
)
);
......@@ -415,15 +405,25 @@ function create_notification()
'element_type' => $wpml_element_type,
'trid' => $original_post_language_info->trid,
'language_code' => $lang,
'source_language_code' => $original_post_language_info->language_code
'source_language_code' => $original_post_language_info->language_code,
);
do_action('wpml_set_element_language_details', $set_language_args);
}
if ($post_id && $lang == 'en') {
$postIdEn = $post_id;
}
if ($post_id && $lang == 'fr') {
$postIdFr = $post_id;
}
} else {
$post_id = -2;
}
}
// system
......@@ -436,8 +436,6 @@ function create_notification()
$link = $_POST[$lang . '_push_notifications_link'];
$status = $_POST[$lang . '_push_notifications_status'];
$emailData = array_merge(
$emailData,
[
......@@ -452,7 +450,7 @@ function create_notification()
$systemMessageData,
[
'system_message_type' => $systemMessageType,
$lang . '_message' => $system
$lang . '_message' => $system,
]
);
$pushMessageData = array_merge(
......@@ -462,16 +460,13 @@ function create_notification()
$lang . '_title' => $title,
$lang . '_message' => $message,
$lang . '_link' => $link,
$lang . '_status' => $status
$lang . '_status' => $status,
]
);
$links[$lang] = get_permalink($post_id);
}
// make post...
$notification = new PostTemplate();
$notification->post_title = $title;
......@@ -484,6 +479,9 @@ function create_notification()
if ($style == 'newsletter') {
update_post_meta($id, 'links', $links);
global $sitepress;
$def_trid = $sitepress->get_element_trid($postIdEn, 'post_newsletter');
$sitepress->set_element_language_details($postIdFr, 'post_newsletter', $def_trid, 'fr');
}
update_post_meta(
......@@ -494,7 +492,7 @@ function create_notification()
'sendto' => $sendto,
'status' => 'pending',
'trigger' => $trigger,
'execute_date' => $executeDate
'execute_date' => $executeDate,
]
);
......@@ -505,26 +503,22 @@ function create_notification()
update_post_meta($id, 'trigger', $trigger);
update_post_meta($id, 'email', $emailData);
update_post_meta($id, 'style', $style);
update_post_meta($id, 'system', $systemMessageData);
update_post_meta($id, 'push', $pushMessageData);
$flash = "<strong>Notification Saved Successfully!</strong><br /><a href='/wp-admin/admin.php?page=notifications'>Click here</a> to view all notifications.</a>";
require_once(__DIR__ . '/views/create.php');
require_once __DIR__ . '/views/create.php';
} else {
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php');
require_once __DIR__ . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'create.php';
}
}
}
function strip_word_html($text, $allowed_tags = '<b><i><sup><sub><em><strong><u><br>')
{
mb_regex_encoding('UTF-8');
//replace MS special characters first
$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>
$text = preg_replace('/\<!--(.)*--\>/isu', '', $text);
}
$text = preg_replace('/(?:width\=\"\d*\")\S/mxi', '>', $text);
$text = preg_replace('/(?:width\=\"\d*%\")\S/mxi', '>', $text);
return $text;
......