Newsletter - Version 6.8.2

Version Description

  • Added HTML filtering on block rendering
Download this release

Release Info

Developer satollo
Plugin Icon 128x128 Newsletter
Version 6.8.2
Comparing to
See all releases

Code changes from version 6.8.1 to 6.8.2

emails/emails.php CHANGED
@@ -108,7 +108,7 @@ class NewsletterEmails extends NewsletterModule {
108
  if (isset($controls->data['inline_edits'])) {
109
  $inline_edits = $controls->data['inline_edits'];
110
  }
111
- echo '<input type="hidden" name="options[inline_edits]" value="' . esc_attr(serialize($inline_edits)) . '">';
112
 
113
  ob_start();
114
  include $block['dir'] . '/options.php';
@@ -179,7 +179,7 @@ class NewsletterEmails extends NewsletterModule {
179
  * so they can act in the right manner.
180
  *
181
  * $context contains a type and, for automated, the last_run.
182
- *
183
  * $email can actually be even a string containing the full newsletter HTML code.
184
  *
185
  * @param TNP_Email $email (Rinominare)
@@ -251,7 +251,7 @@ class NewsletterEmails extends NewsletterModule {
251
  $x = strpos($theme, '>', $x);
252
  $result = substr($theme, 0, $x + 1) . $result . '</body></html>';
253
  } else {
254
-
255
  }
256
 
257
  if (is_object($email)) {
@@ -297,6 +297,8 @@ class NewsletterEmails extends NewsletterModule {
297
  $options = array();
298
  }
299
 
 
 
300
  $block_options = get_option('newsletter_main');
301
 
302
  $block = $this->get_block($block_id);
@@ -324,11 +326,11 @@ class NewsletterEmails extends NewsletterModule {
324
  }
325
 
326
  $out = array('subject' => '', 'return_empty_message' => false, 'stop' => false, 'skip' => false);
327
-
328
  $dir = is_rtl()?'rtl':'ltr';
329
  $align_left = is_rtl()?'right':'left';
330
  $align_right = is_rtl()?'left':'right';
331
-
332
 
333
  ob_start();
334
  $logger = $this->logger;
@@ -416,6 +418,10 @@ class NewsletterEmails extends NewsletterModule {
416
  * @param type $wrapper
417
  */
418
  function tnpc_render_callback() {
 
 
 
 
419
  $block_id = $_POST['b'];
420
  $wrapper = isset($_POST['full']);
421
  $options = $this->restore_options_from_request();
@@ -454,7 +460,7 @@ class NewsletterEmails extends NewsletterModule {
454
  /**
455
  * Returns the button linked to the correct "edit" page for the passed newsletter. The edit page can be an editor
456
  * or the targeting page (it depends on newsletter status).
457
- *
458
  * @param TNP_Email $email
459
  */
460
  function get_edit_button($email) {
@@ -691,7 +697,7 @@ class NewsletterEmails extends NewsletterModule {
691
  /**
692
  * Builds a block data structure starting from the folder containing the block
693
  * files.
694
- *
695
  * @param string $dir
696
  * @return array | WP_Error
697
  */
@@ -726,7 +732,7 @@ class NewsletterEmails extends NewsletterModule {
726
  }
727
 
728
  /**
729
- *
730
  * @param type $dir
731
  * @return type
732
  */
@@ -927,7 +933,7 @@ class NewsletterEmails extends NewsletterModule {
927
 
928
  /**
929
  * Send an email to the test subscribers.
930
- *
931
  * @param TNP_Email $email Could be any object with the TNP_Email attributes
932
  * @param NewsletterControls $controls
933
  */
@@ -982,12 +988,12 @@ class NewsletterEmails extends NewsletterModule {
982
 
983
  // Deserialize inline edits when
984
  // render is preformed on saving block options
985
- if (isset($options['inline_edits']) && is_serialized($options['inline_edits'])) {
986
- $options['inline_edits'] = unserialize($options['inline_edits']);
987
- }
988
 
989
  // Restore inline edits from data-json
990
- // coming from inline editing
991
  // and merge with current inline edit
992
  if (isset($_POST['encoded_options'])) {
993
  $decoded_options = $this->options_decode($_POST['encoded_options']);
108
  if (isset($controls->data['inline_edits'])) {
109
  $inline_edits = $controls->data['inline_edits'];
110
  }
111
+ echo '<input type="hidden" name="options[inline_edits]" value="' . $this->options_encode($inline_edits) . '">';
112
 
113
  ob_start();
114
  include $block['dir'] . '/options.php';
179
  * so they can act in the right manner.
180
  *
181
  * $context contains a type and, for automated, the last_run.
182
+ *
183
  * $email can actually be even a string containing the full newsletter HTML code.
184
  *
185
  * @param TNP_Email $email (Rinominare)
251
  $x = strpos($theme, '>', $x);
252
  $result = substr($theme, 0, $x + 1) . $result . '</body></html>';
253
  } else {
254
+
255
  }
256
 
257
  if (is_object($email)) {
297
  $options = array();
298
  }
299
 
300
+ $options = wp_kses_post_deep($options);
301
+
302
  $block_options = get_option('newsletter_main');
303
 
304
  $block = $this->get_block($block_id);
326
  }
327
 
328
  $out = array('subject' => '', 'return_empty_message' => false, 'stop' => false, 'skip' => false);
329
+
330
  $dir = is_rtl()?'rtl':'ltr';
331
  $align_left = is_rtl()?'right':'left';
332
  $align_right = is_rtl()?'left':'right';
333
+
334
 
335
  ob_start();
336
  $logger = $this->logger;
418
  * @param type $wrapper
419
  */
420
  function tnpc_render_callback() {
421
+ if (!check_ajax_referer('save')) {
422
+ $this->dienow('Expired request');
423
+ }
424
+
425
  $block_id = $_POST['b'];
426
  $wrapper = isset($_POST['full']);
427
  $options = $this->restore_options_from_request();
460
  /**
461
  * Returns the button linked to the correct "edit" page for the passed newsletter. The edit page can be an editor
462
  * or the targeting page (it depends on newsletter status).
463
+ *
464
  * @param TNP_Email $email
465
  */
466
  function get_edit_button($email) {
697
  /**
698
  * Builds a block data structure starting from the folder containing the block
699
  * files.
700
+ *
701
  * @param string $dir
702
  * @return array | WP_Error
703
  */
732
  }
733
 
734
  /**
735
+ *
736
  * @param type $dir
737
  * @return type
738
  */
933
 
934
  /**
935
  * Send an email to the test subscribers.
936
+ *
937
  * @param TNP_Email $email Could be any object with the TNP_Email attributes
938
  * @param NewsletterControls $controls
939
  */
988
 
989
  // Deserialize inline edits when
990
  // render is preformed on saving block options
991
+ if ( isset( $options['inline_edits'] ) && ! is_array( $options['inline_edits'] ) ) {
992
+ $options['inline_edits'] = $this->options_decode( $options['inline_edits'] );
993
+ }
994
 
995
  // Restore inline edits from data-json
996
+ // coming from inline editing
997
  // and merge with current inline edit
998
  if (isset($_POST['encoded_options'])) {
999
  $decoded_options = $this->options_decode($_POST['encoded_options']);
emails/tnp-composer/_scripts/newsletter-builder-v2.js CHANGED
@@ -58,7 +58,7 @@ jQuery.fn.perform_block_edit = function () {
58
  if (!options) {
59
  options = target.attr("data-options");
60
  }
61
- //debugger;
62
  jQuery("#tnpc-block-options-form").load(ajaxurl, {
63
  action: "tnpc_options",
64
  id: container.data("id"),
@@ -123,7 +123,7 @@ jQuery(function () {
123
  if (!preloadedContent) {
124
  preloadedContent = jQuery('input[name="options[message]"]').val();
125
  }
126
- // console.log(preloadedContent);
127
  if (!preloadedContent) {
128
  tnpc_show_presets();
129
  } else {
@@ -157,9 +157,6 @@ function start_composer() {
157
  return helper;
158
  },
159
  update: function (event, ui) {
160
- //console.log(event);
161
- //console.log(ui.item.data("id"));
162
- // debugger;
163
  if (ui.item.attr("id") == "draggable-helper") {
164
  loading_row = jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>');
165
  ui.item.before(loading_row);
@@ -167,9 +164,11 @@ function start_composer() {
167
  var data = {
168
  'action': 'tnpc_render',
169
  'b': ui.item.data("id"),
170
- 'full': 1
 
171
  };
172
  jQuery.post(ajaxurl, data, function (response) {
 
173
  new_row = jQuery(response);
174
  // ui.item.before(new_row);
175
  // ui.item.remove();
@@ -501,6 +500,7 @@ jQuery(document).ready(function () {
501
  'action': 'tnpc_render',
502
  'b': container.data('id'),
503
  'full': 1,
 
504
  'options': {
505
  'inline_edits': [{
506
  'type': type,
58
  if (!options) {
59
  options = target.attr("data-options");
60
  }
61
+
62
  jQuery("#tnpc-block-options-form").load(ajaxurl, {
63
  action: "tnpc_options",
64
  id: container.data("id"),
123
  if (!preloadedContent) {
124
  preloadedContent = jQuery('input[name="options[message]"]').val();
125
  }
126
+
127
  if (!preloadedContent) {
128
  tnpc_show_presets();
129
  } else {
157
  return helper;
158
  },
159
  update: function (event, ui) {
 
 
 
160
  if (ui.item.attr("id") == "draggable-helper") {
161
  loading_row = jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>');
162
  ui.item.before(loading_row);
164
  var data = {
165
  'action': 'tnpc_render',
166
  'b': ui.item.data("id"),
167
+ 'full': 1,
168
+ '_wpnonce': tnp_nonce
169
  };
170
  jQuery.post(ajaxurl, data, function (response) {
171
+
172
  new_row = jQuery(response);
173
  // ui.item.before(new_row);
174
  // ui.item.remove();
500
  'action': 'tnpc_render',
501
  'b': container.data('id'),
502
  'full': 1,
503
+ '_wpnonce': tnp_nonce,
504
  'options': {
505
  'inline_edits': [{
506
  'type': type,
emails/tnp-composer/_scripts/newsletter-builder-v2.min.js ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.fn.add_delete=function(){this.append('<div class="tnpc-row-delete" title="Delete"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/delete.png" width="32"></div>');this.find(".tnpc-row-delete").perform_delete()};jQuery.fn.perform_delete=function(){this.click(function(){jQuery("#tnpc-block-options").hide();jQuery(this).parent().remove();tnpc_mobile_preview()})};
2
+ jQuery.fn.add_block_edit=function(){this.append('<div class="tnpc-row-edit-block" title="Edit"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/edit.png" width="32"></div>');this.find(".tnpc-row-edit-block").perform_block_edit()};jQuery.fn.add_block_clone=function(){this.append('<div class="tnpc-row-clone" title="Clone"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/copy.png" width="32"></div>');this.find(".tnpc-row-clone").perform_clone()};let start_options=null,container=null;
3
+ jQuery.fn.perform_block_edit=function(){jQuery(".tnpc-row-edit-block").click(function(a){a.preventDefault()});this.click(function(a){a.preventDefault();target=jQuery(this).parent().find(".edit-block");jQuery("#tnpc-edit-block .bgcolor").val(target.css("background-color"));jQuery("#tnpc-edit-block .font").val(target.css("font-family"));jQuery(".bgcolor").wpColorPicker().iris("color",target.css("background-color"));container=jQuery(this).closest("table");container.hasClass("tnpc-row-block")?(jQuery("#tnpc-block-options").fadeIn(500),
4
+ (a=container.find(".tnpc-block-content").attr("data-json"))||(a=target.attr("data-options")),jQuery("#tnpc-block-options-form").load(ajaxurl,{action:"tnpc_options",id:container.data("id"),context_type:tnp_context_type,options:a},function(){start_options=jQuery("#tnpc-block-options-form").serialize()})):alert("This is deprecated block version and cannot be edited. Please replace it with a new one.")})};
5
+ jQuery.fn.perform_clone=function(){jQuery(".tnpc-row-clone").click(function(a){a.preventDefault()});this.click(function(a){a.preventDefault();jQuery("#tnpc-block-options").hide();a=jQuery(this).closest(".tnpc-row");let b=a.clone();b.find(".tnpc-row-delete").remove();b.find(".tnpc-row-edit-block").remove();b.find(".tnpc-row-clone").remove();b.add_delete();b.add_block_edit();b.add_block_clone();b.insertAfter(a);tnpc_mobile_preview()})};
6
+ jQuery(function(){jQuery("body").addClass("folded");document.getElementById("defaultOpen").click();var a=jQuery('input[name="message"]').val();a||(a=jQuery('input[name="options[message]"]').val());a?(jQuery("#newsletter-builder-area-center-frame-content").html(a),start_composer()):tnpc_show_presets();jQuery("#options-title").val(jQuery('#tnpc-form input[name="options[subject]"]').val());jQuery("#options-options_composer_background").on("change",function(a){jQuery("#newsletter-builder-area-center-frame-content").css("background-color",
7
+ a.target.value)});jQuery("#newsletter-builder-area-center-frame-content").css("background-color",jQuery("#options-options_composer_background").val())});
8
+ function start_composer(){jQuery("#newsletter-builder-area-center-frame-content").sortable({revert:!1,placeholder:"placeholder",forcePlaceholderSize:!0,opacity:.6,tolerance:"pointer",helper:function(a){return jQuery(document.getElementById("sortable-helper")).clone()},update:function(a,b){"draggable-helper"==b.item.attr("id")?(loading_row=jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>'),b.item.before(loading_row),
9
+ b.item.remove(),a={action:"tnpc_render",b:b.item.data("id"),full:1,_wpnonce:tnp_nonce},jQuery.post(ajaxurl,a,function(a){new_row=jQuery(a);loading_row.before(new_row);loading_row.remove();new_row.add_delete();new_row.add_block_edit();new_row.add_block_clone();new_row.hasClass("tnpc-row-block")&&new_row.find(".tnpc-row-edit-block").click();tnpc_mobile_preview()}).fail(function(){alert("Block rendering failed.");loading_row.remove()})):tnpc_mobile_preview()}});jQuery(".newsletter-sidebar-buttons-content-tab").draggable({connectToSortable:"#newsletter-builder-area-center-frame-content",
10
+ helper:function(a){var b=jQuery(document.getElementById("draggable-helper")).clone();b.attr("data-id",a.currentTarget.dataset.id);b.html(a.currentTarget.dataset.name);return b},revert:!1,start:function(){jQuery(".tnpc-row").length||jQuery("#newsletter-builder-area-center-frame-content").append('<div class="tnpc-drop-here">Drag&Drop blocks here!</div>')},stop:function(a,b){jQuery(".tnpc-drop-here").remove()}});jQuery("#tnpc-block-options-cancel").click(function(){jQuery(this).parent().parent().fadeOut(500);
11
+ jQuery.post(ajaxurl,start_options,function(a){target.html(a);jQuery("#tnpc-block-options-form").html("")})});jQuery("#tnpc-block-options-save").click(function(a){a.preventDefault();"undefined"!==typeof templateEditor&&templateEditor.save();window.tinymce&&window.tinymce.triggerSave();jQuery("#tnpc-block-options").fadeOut(500);a=jQuery("#tnpc-block-options-form").serialize();jQuery.post(ajaxurl,a,function(a){target.html(a);tnpc_mobile_preview();jQuery("#tnpc-block-options-form").html("")})});jQuery("#tnpc-block-options-form").change(function(a){var b=
12
+ jQuery("#tnpc-block-options-form").serialize();jQuery.post(ajaxurl,b,function(b){target.html(b);"reload"===a.target.dataset.afterRendering&&container.find(".tnpc-row-edit-block").click()}).fail(function(){alert("Block rendering failed")})});jQuery(".tnpc-row").add_delete();jQuery(".tnpc-row").add_block_edit();jQuery(".tnpc-row").add_block_clone();tnpc_mobile_preview()}
13
+ function tnpc_mobile_preview(){var a=document.getElementById("tnpc-mobile-preview").contentWindow.document;a.open();a.write("<!DOCTYPE html>\n<html>\n<head>\n");a.write("<link rel='stylesheet' href='"+TNP_HOME_URL+"?na=emails-composer-css&ver="+Math.random()+"' type='text/css'>");a.write("<style>.tnpc-row-delete, .tnpc-row-edit-block, .tnpc-row-clone { display: none; }</style>");a.write("<style>body::-webkit-scrollbar {width: 0px;background: transparent;}</style>");a.write("<style>body{scrollbar-width: none; -ms-overflow-style: none;}</style>");
14
+ a.write("</head>\n<body style='margin: 0; padding: 0;'><div style='width: 320px!important'>");a.write(jQuery("#newsletter-builder-area-center-frame-content").html());a.write("</div>\n</body>\n</html>");a.close()}
15
+ function tnpc_save(a){jQuery("#newsletter-preloaded-export").html(jQuery("#newsletter-builder-area-center-frame-content").html());jQuery("#newsletter-preloaded-export .tnpc-row-delete").remove();jQuery("#newsletter-preloaded-export .tnpc-row-edit-block").remove();jQuery("#newsletter-preloaded-export .tnpc-row-clone").remove();jQuery("#newsletter-preloaded-export .tnpc-row").removeClass("ui-draggable");jQuery("#newsletter-preloaded-export #sortable-helper").remove();a.elements["options[message]"].value=
16
+ jQuery("#newsletter-preloaded-export").html();document.getElementById("options-title")?a.elements["options[subject]"].value=jQuery("#options-title").val():a.elements["options[subject]"].value="";var b=document.getElementById("tnpc-global-styles-form");tnpc_copy_form(b,a);jQuery("#newsletter-preloaded-export").html(" ")}function tnpc_copy_form(a,b){for(var c=0;c<a.elements.length;c++){var d=a.elements[c].cloneNode();d.style.display="none";b.appendChild(d)}}
17
+ function tnpc_test(){let a=document.getElementById("tnpc-form");tnpc_save(a);a.act.value="test";a.submit()}function openTab(a,b){a.preventDefault();var c;var d=document.getElementsByClassName("tabcontent");for(c=0;c<d.length;c++)d[c].style.display="none";d=document.getElementsByClassName("tablinks");for(c=0;c<d.length;c++)d[c].className=d[c].className.replace(" active","");document.getElementById(b).style.display="block";a.currentTarget.className+=" active"}
18
+ function tnpc_show_presets(){jQuery(".tnpc-controls input").attr("disabled",!0);jQuery("#newsletter-builder-area-center-frame-content").load(ajaxurl,{action:"tnpc_presets"})}function tnpc_load_preset(a){jQuery("#newsletter-builder-area-center-frame-content").load(ajaxurl,{action:"tnpc_presets",id:a},function(){start_composer();jQuery(".tnpc-controls input").attr("disabled",!1)})}function tnpc_scratch(){jQuery("#newsletter-builder-area-center-frame-content").html(" ");start_composer()}
19
+ function tnpc_reload_options(a){a.preventDefault();a=jQuery("#tnpc-block-options-form").serializeArray();for(let b=0;b<a.length;b++)"action"===a[b].name&&(a[b].value="tnpc_options");jQuery("#tnpc-block-options-form").load(ajaxurl,a)}
20
+ jQuery(document).ready(function(){(function(){function a(){d.forEach(function(a){a.originalEl.show();a.newEl.off();a.newEl.remove()});d=[]}function b(a,b,c){var d="";switch(c){case "text":d="<textarea name='new_name' class='tnpc-inline-editable-textarea' rows='5'>"+a+"</textarea>";break;case "title":d="<textarea name='new_name' class='tnpc-inline-editable-textarea' rows='2'>"+a+"</textarea>"}var e="<td>"+("<form class='tnpc-inline-editable-form tnpc-inline-editable-form-"+c+b+"'>")+("<input type='hidden' name='id' value='"+
21
+ b+"'>")+("<input type='hidden' name='type' value='"+c+"'>");e+="<input type='hidden' name='old_value' value='"+a+"'>";e+="<div class='tnpc-inline-editable-container'>";e+=d;e+="<div class='tnpc-inline-editable-form-actions'>";e+="<button type='submit'><span class='dashicons dashicons-yes-alt' title='save'></span></button>";e=e+("<span class='dashicons dashicons-dismiss tnpc-dismiss-"+c+b+"' title='close'></span>")+"</div></div>";e+="</form>";return e+="</td>"}function c(a,b,c,d){var e=a.closest(".edit-block");
22
+ a=e.closest("table");var f=e.children(".tnpc-block-content");a.hasClass("tnpc-row-block")&&(b={action:"tnpc_render",b:a.data("id"),full:1,_wpnonce:tnp_nonce,options:{inline_edits:[{type:b,post_id:c,content:d}]},encoded_options:f.data("json")},jQuery.post(ajaxurl,b,function(a){new_row=jQuery(a);e.before(new_row);e.remove();new_row.add_delete();new_row.add_block_edit();new_row.add_block_clone();new_row.hasClass("tnpc-row-block")&&new_row.find(".tnpc-row-edit-block").click();tnpc_mobile_preview()}).fail(function(){alert("Block rendering failed.")}))}
23
+ var d=[];return{init:function(){jQuery("#newsletter-builder-area-center-frame-content").on("click",".tnpc-inline-editable",function(g){a();var h=jQuery(this).hide(),f=jQuery(b(this.innerText.trim(),this.dataset.id,this.dataset.type)).insertAfter(this);d.push({originalEl:h,newEl:f});jQuery(".tnpc-inline-editable-form-"+this.dataset.type+this.dataset.id).on("submit",function(a){var b=jQuery(h);a.preventDefault();a=f.find("form input[name=id]").val();var d=f.find("form input[name=type]").val(),g=f.find('form [name="new_name"]').val();
24
+ c(b,d,a,g);f.remove();b.show()});jQuery(".tnpc-inline-editable-form-actions .tnpc-dismiss-"+this.dataset.type+this.dataset.id).on("click",function(b){a()})});jQuery("#newsletter-builder-area-center-frame-content").on("click",function(b){0<d.length&&!jQuery(b.target).hasClass("tnpc-inline-editable")&&0===jQuery(b.target).closest(".tnpc-inline-editable-container").length&&a()})}}})().init()});
emails/tnp-composer/_scripts/newsletter-builder.js CHANGED
@@ -58,7 +58,7 @@ jQuery.fn.perform_block_edit = function () {
58
  if (!options) {
59
  options = target.attr("data-options");
60
  }
61
- //debugger;
62
  jQuery("#tnpc-block-options-form").load(ajaxurl, {
63
  action: "tnpc_options",
64
  id: container.data("id"),
@@ -123,14 +123,9 @@ jQuery(function () {
123
  if (!preloadedContent) {
124
  preloadedContent = jQuery('input[name="options[body]"]').val();
125
  }
126
- // console.log(preloadedContent);
127
  if (!preloadedContent) {
128
  tnpc_show_presets();
129
  } else {
130
- // Extract the body part
131
- //var x = preloadedContent.indexOf("<body");
132
- //var y = preloadedContent.indexOf("</body>");
133
- //preloadedContent = preloadedContent.substring(x, y);
134
  jQuery('#newsletter-builder-area-center-frame-content').html(preloadedContent);
135
  start_composer();
136
  }
@@ -154,9 +149,7 @@ function start_composer() {
154
  return helper;
155
  },
156
  update: function (event, ui) {
157
- //console.log(event);
158
- //console.log(ui.item.data("id"));
159
- // debugger;
160
  if (ui.item.attr("id") == "draggable-helper") {
161
  loading_row = jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>');
162
  ui.item.before(loading_row);
@@ -376,8 +369,7 @@ function tnpc_reload_options(e) {
376
  options[i].value = 'tnpc_options';
377
  }
378
  }
379
- //console.log(options);
380
- //debugger;
381
  options["action"] = "tnpc_options";
382
  options["id"] = container.data("id");
383
  jQuery("#tnpc-block-options-form").load(ajaxurl, options);
58
  if (!options) {
59
  options = target.attr("data-options");
60
  }
61
+
62
  jQuery("#tnpc-block-options-form").load(ajaxurl, {
63
  action: "tnpc_options",
64
  id: container.data("id"),
123
  if (!preloadedContent) {
124
  preloadedContent = jQuery('input[name="options[body]"]').val();
125
  }
 
126
  if (!preloadedContent) {
127
  tnpc_show_presets();
128
  } else {
 
 
 
 
129
  jQuery('#newsletter-builder-area-center-frame-content').html(preloadedContent);
130
  start_composer();
131
  }
149
  return helper;
150
  },
151
  update: function (event, ui) {
152
+
 
 
153
  if (ui.item.attr("id") == "draggable-helper") {
154
  loading_row = jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>');
155
  ui.item.before(loading_row);
369
  options[i].value = 'tnpc_options';
370
  }
371
  }
372
+
 
373
  options["action"] = "tnpc_options";
374
  options["id"] = container.data("id");
375
  jQuery("#tnpc-block-options-form").load(ajaxurl, options);
emails/tnp-composer/_scripts/newsletter-builder.min.js ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.fn.add_delete=function(){this.append('<div class="tnpc-row-delete" title="Delete"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/delete.png" width="32"></div>');this.find(".tnpc-row-delete").perform_delete()};jQuery.fn.perform_delete=function(){this.click(function(){jQuery("#tnpc-block-options").hide();jQuery(this).parent().remove();tnpc_mobile_preview()})};
2
+ jQuery.fn.add_block_edit=function(){this.append('<div class="tnpc-row-edit-block" title="Edit"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/edit.png" width="32"></div>');this.find(".tnpc-row-edit-block").perform_block_edit()};jQuery.fn.add_block_clone=function(){this.append('<div class="tnpc-row-clone" title="Clone"><img src="'+TNP_PLUGIN_URL+'/emails/tnp-composer/_assets/copy.png" width="32"></div>');this.find(".tnpc-row-clone").perform_clone()};let start_options=null,container=null;
3
+ jQuery.fn.perform_block_edit=function(){jQuery(".tnpc-row-edit-block").click(function(a){a.preventDefault()});this.click(function(a){a.preventDefault();target=jQuery(this).parent().find(".edit-block");jQuery("#tnpc-edit-block .bgcolor").val(target.css("background-color"));jQuery("#tnpc-edit-block .font").val(target.css("font-family"));jQuery(".bgcolor").wpColorPicker().iris("color",target.css("background-color"));container=jQuery(this).closest("table");container.hasClass("tnpc-row-block")?(jQuery("#tnpc-block-options").fadeIn(500),
4
+ (a=container.find(".tnpc-block-content").attr("data-json"))||(a=target.attr("data-options")),jQuery("#tnpc-block-options-form").load(ajaxurl,{action:"tnpc_options",id:container.data("id"),context_type:tnp_context_type,options:a},function(){start_options=jQuery("#tnpc-block-options-form").serialize()})):alert("This is deprecated block version and cannot be edited. Please replace it with a new one.")})};
5
+ jQuery.fn.perform_clone=function(){jQuery(".tnpc-row-clone").click(function(a){a.preventDefault()});this.click(function(a){a.preventDefault();jQuery("#tnpc-block-options").hide();a=jQuery(this).closest(".tnpc-row");let b=a.clone();b.find(".tnpc-row-delete").remove();b.find(".tnpc-row-edit-block").remove();b.find(".tnpc-row-clone").remove();b.add_delete();b.add_block_edit();b.add_block_clone();b.insertAfter(a);tnpc_mobile_preview()})};
6
+ jQuery(function(){jQuery("body").addClass("folded");document.getElementById("defaultOpen").click();var a=jQuery('input[name="body"]').val();a||(a=jQuery('input[name="options[body]"]').val());a?(jQuery("#newsletter-builder-area-center-frame-content").html(a),start_composer()):tnpc_show_presets();jQuery("#options-title").val(jQuery('#tnpc-form input[name="options[subject]"]').val())});
7
+ function start_composer(){jQuery("#newsletter-builder-area-center-frame-content").sortable({revert:!1,placeholder:"placeholder",forcePlaceholderSize:!0,opacity:.6,tolerance:"pointer",helper:function(a){return jQuery(document.getElementById("sortable-helper")).clone()},update:function(a,b){"draggable-helper"==b.item.attr("id")?(loading_row=jQuery('<div style="text-align: center; padding: 20px; background-color: #d4d5d6; color: #52BE7F;"><i class="fa fa-cog fa-2x fa-spin" /></div>'),b.item.before(loading_row),
8
+ b.item.remove(),a={action:"tnpc_render",b:b.item.data("id"),full:1},jQuery.post(ajaxurl,a,function(a){new_row=jQuery(a);loading_row.before(new_row);loading_row.remove();new_row.add_delete();new_row.add_block_edit();new_row.add_block_clone();new_row.hasClass("tnpc-row-block")&&new_row.find(".tnpc-row-edit-block").click();tnpc_mobile_preview()}).fail(function(){alert("Block rendering failed.");loading_row.remove()})):tnpc_mobile_preview()}});jQuery(".newsletter-sidebar-buttons-content-tab").draggable({connectToSortable:"#newsletter-builder-area-center-frame-content",
9
+ helper:function(a){var b=jQuery(document.getElementById("draggable-helper")).clone();b.attr("data-id",a.currentTarget.dataset.id);b.html(a.currentTarget.dataset.name);return b},revert:!1,start:function(){jQuery(".tnpc-row").length||jQuery("#newsletter-builder-area-center-frame-content").append('<div class="tnpc-drop-here">Drag&Drop blocks here!</div>')},stop:function(a,b){jQuery(".tnpc-drop-here").remove()}});jQuery("#tnpc-block-options-cancel").click(function(){jQuery(this).parent().parent().fadeOut(500);
10
+ jQuery.post(ajaxurl,start_options,function(a){target.html(a);jQuery("#tnpc-block-options-form").html("")})});jQuery("#tnpc-block-options-save").click(function(a){a.preventDefault();"undefined"!==typeof templateEditor&&templateEditor.save();window.tinymce&&window.tinymce.triggerSave();jQuery("#tnpc-block-options").fadeOut(500);a=jQuery("#tnpc-block-options-form").serialize();jQuery.post(ajaxurl,a,function(a){target.html(a);tnpc_mobile_preview();jQuery("#tnpc-block-options-form").html("")})});jQuery("#tnpc-block-options-form").change(function(a){var b=
11
+ jQuery("#tnpc-block-options-form").serialize();jQuery.post(ajaxurl,b,function(b){target.html(b);"reload"===a.target.dataset.afterRendering&&container.find(".tnpc-row-edit-block").click()}).fail(function(){alert("Block rendering failed")})});jQuery(".tnpc-row").add_delete();jQuery(".tnpc-row").add_block_edit();jQuery(".tnpc-row").add_block_clone();tnpc_mobile_preview()}
12
+ function tnpc_mobile_preview(){var a=document.getElementById("tnpc-mobile-preview").contentWindow.document;a.open();a.write("<!DOCTYPE html>\n<html>\n<head>\n");a.write("<link rel='stylesheet' href='"+TNP_HOME_URL+"?na=emails-composer-css&ver="+Math.random()+"' type='text/css'>");a.write("<style type='text/css'>.tnpc-row-delete, .tnpc-row-edit-block, .tnpc-row-clone { display: none; }</style>");a.write("</head>\n<body style='margin: 0; padding: 0;'><div style='width: 320px!important'>");a.write(jQuery("#newsletter-builder-area-center-frame-content").html());
13
+ a.write("</div>\n</body>\n</html>");a.close()}
14
+ function tnpc_save(a){jQuery("#newsletter-preloaded-export").html(jQuery("#newsletter-builder-area-center-frame-content").html());jQuery("#newsletter-preloaded-export .tnpc-row-delete").remove();jQuery("#newsletter-preloaded-export .tnpc-row-edit-block").remove();jQuery("#newsletter-preloaded-export .tnpc-row-clone").remove();jQuery("#newsletter-preloaded-export .tnpc-row").removeClass("ui-draggable");let b=jQuery("#newsletter-preloaded-export").html();b=jQuery.trim(b);let c;c='<!DOCTYPE html>\n<html>\n<head>\n<title>{email_subject}</title>\n<meta charset="utf-8">\n<meta name="viewport" content="width=device-width, initial-scale=1">\n<meta http-equiv="X-UA-Compatible" content="IE=edge">\n'+
15
+ ('<style type="text/css">'+jQuery.trim(a.elements["options[css]"].value)+"</style>")+'</head>\n<body style="margin: 0; padding: 0;">\n';c=c+b+"\n</body>\n</html>";a.elements["options[body]"].value=c;a.elements["options[subject]"].value=jQuery("#options-title").val();jQuery("#newsletter-preloaded-export").html(" ")}function tnpc_test(){let a=document.getElementById("tnpc-form");tnpc_save(a);a.act.value="test";a.submit()}
16
+ function openTab(a,b){a.preventDefault();var c;var d=document.getElementsByClassName("tabcontent");for(c=0;c<d.length;c++)d[c].style.display="none";d=document.getElementsByClassName("tablinks");for(c=0;c<d.length;c++)d[c].className=d[c].className.replace(" active","");document.getElementById(b).style.display="block";a.currentTarget.className+=" active"}
17
+ function tnpc_show_presets(){jQuery(".tnpc-controls input").attr("disabled",!0);jQuery("#newsletter-builder-area-center-frame-content").load(ajaxurl,{action:"tnpc_presets"})}function tnpc_load_preset(a){jQuery("#newsletter-builder-area-center-frame-content").load(ajaxurl,{action:"tnpc_presets",id:a},function(){start_composer();jQuery(".tnpc-controls input").attr("disabled",!1)})}function tnpc_scratch(){jQuery("#newsletter-builder-area-center-frame-content").html(" ");start_composer()}
18
+ function tnpc_reload_options(a){a.preventDefault();a=jQuery("#tnpc-block-options-form").serializeArray();for(let b=0;b<a.length;b++)"action"==a[b].name&&(a[b].value="tnpc_options");a.action="tnpc_options";a.id=container.data("id");jQuery("#tnpc-block-options-form").load(ajaxurl,a)};
emails/tnp-composer/index-v2.php CHANGED
@@ -142,9 +142,10 @@ $fields = new NewsletterFields($controls);
142
  </div>
143
 
144
  <script type="text/javascript">
145
- TNP_PLUGIN_URL = "<?php echo NEWSLETTER_URL ?>";
146
- TNP_HOME_URL = "<?php echo home_url('/', is_ssl() ? 'https' : 'http') ?>";
147
- tnp_context_type = "<?php echo $context_type ?>";
 
148
  </script>
149
  <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/emails/tnp-composer/_scripts/newsletter-builder-v2.js?ver=<?php echo time() ?>"></script>
150
 
142
  </div>
143
 
144
  <script type="text/javascript">
145
+ TNP_PLUGIN_URL = "<?php echo esc_js(NEWSLETTER_URL) ?>";
146
+ TNP_HOME_URL = "<?php echo esc_js(home_url('/', is_ssl() ? 'https' : 'http')) ?>";
147
+ tnp_context_type = "<?php echo esc_js($context_type) ?>";
148
+ tnp_nonce = '<?php echo esc_js(wp_create_nonce('save'))?>';
149
  </script>
150
  <script type="text/javascript" src="<?php echo plugins_url('newsletter'); ?>/emails/tnp-composer/_scripts/newsletter-builder-v2.js?ver=<?php echo time() ?>"></script>
151
 
plugin.php CHANGED
@@ -4,7 +4,7 @@
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
- Version: 6.8.1
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: https://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
@@ -35,7 +35,7 @@ if (version_compare(phpversion(), '5.6', '<')) {
35
  return;
36
  }
37
 
38
- define('NEWSLETTER_VERSION', '6.8.1');
39
 
40
  global $newsletter, $wpdb;
41
 
4
  Plugin Name: Newsletter
5
  Plugin URI: https://www.thenewsletterplugin.com/plugins/newsletter
6
  Description: Newsletter is a cool plugin to create your own subscriber list, to send newsletters, to build your business. <strong>Before update give a look to <a href="https://www.thenewsletterplugin.com/category/release">this page</a> to know what's changed.</strong>
7
+ Version: 6.8.2
8
  Author: Stefano Lissa & The Newsletter Team
9
  Author URI: https://www.thenewsletterplugin.com
10
  Disclaimer: Use at your own risk. No warranty expressed or implied is provided.
35
  return;
36
  }
37
 
38
+ define('NEWSLETTER_VERSION', '6.8.2');
39
 
40
  global $newsletter, $wpdb;
41
 
readme.txt CHANGED
@@ -2,7 +2,7 @@
2
  Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
3
  Requires at least: 3.4.0
4
  Tested up to: 5.4.2
5
- Stable tag: 6.8.1
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
 
@@ -113,6 +113,10 @@ Thank you, The Newsletter Team
113
 
114
  == Changelog ==
115
 
 
 
 
 
116
  = 6.8.1 =
117
 
118
  * Fixed welcome message not being displayed (on 6.8.0)
2
  Tags: email, email marketing, newsletter, newsletter subscribers, welcome email, signup forms, contact, lead generation, popup, marketing automation
3
  Requires at least: 3.4.0
4
  Tested up to: 5.4.2
5
+ Stable tag: 6.8.2
6
  Requires PHP: 5.6
7
  Contributors: satollo,webagile,michael-travan
8
 
113
 
114
  == Changelog ==
115
 
116
+ = 6.8.2 =
117
+
118
+ * Added HTML filtering on block rendering
119
+
120
  = 6.8.1 =
121
 
122
  * Fixed welcome message not being displayed (on 6.8.0)