Newsletter - Version 6.1.3

Version Description

  • Fix to avoid third party plugin notices to interfere with the composer
  • NEW! Added subscription block to the Gutenberg editor
  • Code cleanup
Download this release

Release Info

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

Code changes from version 6.1.2 to 6.1.3

emails/blocks/posts/block.php CHANGED
@@ -71,6 +71,8 @@ if (empty($posts) && $options['block_context'] == 'automated') {
71
  return;
72
  }
73
 
 
 
74
  $button_background = $options['button_background'];
75
  $button_label = $options['button_label'];
76
  $button_font_family = $options['button_font_family'];
71
  return;
72
  }
73
 
74
+ $options['block_subject'] = $posts[0]->post_title;
75
+
76
  $button_background = $options['button_background'];
77
  $button_label = $options['button_label'];
78
  $button_font_family = $options['button_font_family'];
emails/emails.php CHANGED
@@ -133,7 +133,7 @@ class NewsletterEmails extends NewsletterModule {
133
  $preset = $this->get_preset($_REQUEST['id']);
134
 
135
  foreach ($preset->blocks as $item) {
136
- $content .= $this->render_block($item->block, true, (array) $item->options);
137
  }
138
  } else {
139
 
@@ -150,9 +150,9 @@ class NewsletterEmails extends NewsletterModule {
150
  }
151
 
152
  $content .= '<div class="clear"></div>';
 
153
  }
154
-
155
- echo $content;
156
  wp_die();
157
  }
158
 
@@ -172,6 +172,7 @@ class NewsletterEmails extends NewsletterModule {
172
  preg_match_all('/data-json="(.*?)"/m', $theme, $matches, PREG_PATTERN_ORDER);
173
  $result = '';
174
  $all_empty = true; // If all dynamic content blocks return an empty html
 
175
  foreach ($matches[1] as $match) {
176
  $a = html_entity_decode($match, ENT_QUOTES, 'UTF-8');
177
  $options = $this->options_decode($a);
@@ -185,7 +186,8 @@ class NewsletterEmails extends NewsletterModule {
185
  $options['block_context'] = $context;
186
 
187
  ob_start();
188
- $this->render_block($options['block_id'], true, $options, true);
 
189
  $block_html = ob_get_clean();
190
  $result .= trim($block_html);
191
  // If a dynamic blocks return something, we need to return a regenerated template
@@ -204,7 +206,7 @@ class NewsletterEmails extends NewsletterModule {
204
  } else {
205
 
206
  }
207
- return $result;
208
  }
209
 
210
  function remove_block_data($text) {
@@ -350,6 +352,8 @@ class NewsletterEmails extends NewsletterModule {
350
  }
351
  echo "\n";
352
  }
 
 
353
  }
354
 
355
  /**
133
  $preset = $this->get_preset($_REQUEST['id']);
134
 
135
  foreach ($preset->blocks as $item) {
136
+ $this->render_block($item->block, true, (array) $item->options);
137
  }
138
  } else {
139
 
150
  }
151
 
152
  $content .= '<div class="clear"></div>';
153
+ echo $content;
154
  }
155
+
 
156
  wp_die();
157
  }
158
 
172
  preg_match_all('/data-json="(.*?)"/m', $theme, $matches, PREG_PATTERN_ORDER);
173
  $result = '';
174
  $all_empty = true; // If all dynamic content blocks return an empty html
175
+ $subject = '';
176
  foreach ($matches[1] as $match) {
177
  $a = html_entity_decode($match, ENT_QUOTES, 'UTF-8');
178
  $options = $this->options_decode($a);
186
  $options['block_context'] = $context;
187
 
188
  ob_start();
189
+ $s = $this->render_block($options['block_id'], true, $options, true);
190
+ if (empty($subject) && !empty($s)) $subject = $s;
191
  $block_html = ob_get_clean();
192
  $result .= trim($block_html);
193
  // If a dynamic blocks return something, we need to return a regenerated template
206
  } else {
207
 
208
  }
209
+ return array('body'=>$result, 'subject'=>$subject);
210
  }
211
 
212
  function remove_block_data($text) {
352
  }
353
  echo "\n";
354
  }
355
+
356
+ if (isset($options['block_subject'])) return $options['block_subject'];
357
  }
358
 
359
  /**
emails/tnp-composer/_scripts/newsletter-builder.js CHANGED
@@ -292,7 +292,7 @@ function tnpc_save(form) {
292
 
293
  let css = jQuery.trim(form.elements["options[css]"].value);
294
 
295
- let export_content = '<!DOCTYPE html>\n<html>\n<head>\n<title>Newsletter</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';
296
  export_content += '<style type="text/css">' + css + '</style>';
297
  export_content += '</head>\n<body style="margin: 0; padding: 0;">\n';
298
  export_content += preload_export_html;
292
 
293
  let css = jQuery.trim(form.elements["options[css]"].value);
294
 
295
+ let export_content = '<!DOCTYPE html>\n<html>\n<head>\n<title>{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';
296
  export_content += '<style type="text/css">' + css + '</style>';
297
  export_content += '</head>\n<body style="margin: 0; padding: 0;">\n';
298
  export_content += preload_export_html;
includes/controls.php CHANGED
@@ -788,6 +788,14 @@ class NewsletterControls {
788
  echo esc_html(__('Reset', 'newsletter'));
789
  echo '</button>';
790
  }
 
 
 
 
 
 
 
 
791
 
792
  function button_back($url) {
793
  echo '<a href="';
@@ -913,7 +921,7 @@ class NewsletterControls {
913
  if ($label != '') {
914
  echo '<label>';
915
  }
916
- echo '<input type="checkbox" id="' . esc_attr($name) . '" name="options[' . esc_attr($name) . ']" value="1"';
917
  if (!empty($this->data[$name])) {
918
  echo ' checked';
919
  }
788
  echo esc_html(__('Reset', 'newsletter'));
789
  echo '</button>';
790
  }
791
+
792
+ function button_link($url, $label) {
793
+ echo '<a href="', esc_attr($url), '" class="button-primary">', $label, '</a>';
794
+ }
795
+
796
+ function button_configure($url) {
797
+ echo '<a href="', esc_attr($url), '" class="button-primary"><i class="fa fa-cog"></i>', _e('Configure', 'newsletter'), '</a>';
798
+ }
799
 
800
  function button_back($url) {
801
  echo '<a href="';
921
  if ($label != '') {
922
  echo '<label>';
923
  }
924
+ echo '<input type="checkbox" id="options-' . esc_attr($name) . '" name="options[' . esc_attr($name) . ']" value="1"';
925
  if (!empty($this->data[$name])) {
926
  echo ' checked';
927
  }
includes/fields.php CHANGED
@@ -264,12 +264,16 @@ class NewsletterFields {
264
  'author' => '',
265
  'author_name' => '',
266
  'post_status' => 'publish',
267
- 'suppress_filters' => true
 
268
  )), $args);
269
  $args['filters']['posts_per_page'] = $count;
270
 
271
  $posts = get_posts($args['filters']);
272
  $options = array();
 
 
 
273
  foreach ($posts as $post) {
274
  $options['' . $post->ID] = $post->post_title;
275
  }
264
  'author' => '',
265
  'author_name' => '',
266
  'post_status' => 'publish',
267
+ 'suppress_filters' => true,
268
+ 'last_post_option'=>false
269
  )), $args);
270
  $args['filters']['posts_per_page'] = $count;
271
 
272
  $posts = get_posts($args['filters']);
273
  $options = array();
274
+ if ($args['last_post_option']) {
275
+ $options['last'] = 'Most recent post';
276
+ }
277
  foreach ($posts as $post) {
278
  $options['' . $post->ID] = $post->post_title;
279
  }
includes/tnp-blocks.js ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ (function (blocks, editor, element, components) {
2
+
3
+ const el = element.createElement;
4
+ const {registerBlockType} = blocks;
5
+ const { RichText, InspectorControls, withColors, PanelColorSettings, getColorClassName, AlignmentToolbar, BlockControls } = editor;
6
+ const { Fragment } = element;
7
+ const { TextControl, RadioControl, Panel, PanelBody, PanelRow, SelectControl, RangeControl } = components;
8
+ const colorSamples = [
9
+ {
10
+ name: 'GREEN SEA',
11
+ slug: 'GREENSEA',
12
+ color: '#16A085'
13
+ },
14
+ {
15
+ name: 'NEPHRITIS',
16
+ slug: 'NEPHRITIS',
17
+ color: '#27AE60'
18
+ },
19
+ {
20
+ name: 'BELIZE HOLE',
21
+ slug: 'BELIZEHOLE',
22
+ color: '#2980B9'
23
+ },
24
+ {
25
+ name: 'WISTERIA',
26
+ slug: 'WISTERIA',
27
+ color: '#8E44AD'
28
+ },
29
+ {
30
+ name: 'MIDNIGHT BLUE',
31
+ slug: 'MIDNIGHTBLUE',
32
+ color: '#2C3E50'
33
+ },
34
+ {
35
+ name: 'ORANGE',
36
+ slug: 'ORANGE',
37
+ color: '#F39C12'
38
+ },
39
+ {
40
+ name: 'ALIZARIN',
41
+ slug: 'ALIZARIN',
42
+ color: '#E74C3C'
43
+ },
44
+ {
45
+ name: 'WHITE',
46
+ slug: 'WHITE',
47
+ color: '#FFFFFF'
48
+ },
49
+ {
50
+ name: 'CLOUDS',
51
+ slug: 'CLOUDS',
52
+ color: '#ECF0F1'
53
+ },
54
+ {
55
+ name: 'ASBESTOS',
56
+ slug: 'ASBESTOS',
57
+ color: '#7F8C8D'
58
+ }
59
+ ];
60
+
61
+ registerBlockType('tnp/minimal', {
62
+ title: 'Newsletter subscription form',
63
+ icon: 'email',
64
+ category: 'common',
65
+ keywords: ['newsletter', 'subscription', 'form'],
66
+ attributes: {
67
+ formtype: {type: 'string', default: 'minimal'},
68
+ content: { type: 'array', source: 'children', selector: 'p', default: 'Subscribe to our newsletter!'},
69
+ list_ids: { type: 'string' },
70
+ rowColor: { type: 'string'},
71
+ customRowColor: { type: 'string'},
72
+ textColor: { type: 'string'},
73
+ customTextColor: { type: 'string'},
74
+ buttonColor: { type: 'string'},
75
+ customButtonColor: { type: 'string'},
76
+ padding: {type: 'integer', default: 20},
77
+ alignment: { type: 'string'}
78
+ },
79
+
80
+ edit: withColors('rowColor', 'textColor', 'buttonColor')(function (props) {
81
+
82
+ function onChangeContent( newContent ) {
83
+ props.setAttributes( { content: newContent } );
84
+ }
85
+
86
+ function onChangeAlignment( newAlignment ) {
87
+ props.setAttributes( { alignment: newAlignment } );
88
+ }
89
+
90
+ return el( Fragment, {},
91
+ el( InspectorControls, {},
92
+
93
+ // 1st Panel - Form Settings
94
+ el( PanelBody, { title: 'Form Settings', initialOpen: true },
95
+
96
+ /* Form type */
97
+ el( RadioControl,
98
+ {
99
+ label: 'Form type',
100
+ options : [
101
+ { label: 'Minimal', value: 'minimal' },
102
+ { label: 'Full', value: 'full' },
103
+ ],
104
+ onChange: ( value ) => {
105
+ props.setAttributes( { formtype: value } );
106
+ },
107
+ selected: props.attributes.formtype
108
+ }
109
+ ),
110
+
111
+ /* Lists field */
112
+ el( PanelRow, {},
113
+ el( TextControl,
114
+ {
115
+ label: 'Lists IDs (comma separated)',
116
+ onChange: ( value ) => {
117
+ props.setAttributes( { list_ids: value } );
118
+ },
119
+ value: props.attributes.list_ids
120
+ }
121
+ )
122
+ )
123
+ ),
124
+
125
+ /* Style */
126
+ el( PanelColorSettings, {
127
+ title: 'Style',
128
+ colorSettings: [
129
+ {
130
+ colors: colorSamples, // here you can pass custom colors
131
+ value: props.rowColor.color,
132
+ label: 'Background color',
133
+ onChange: props.setRowColor,
134
+ },
135
+ {
136
+ colors: colorSamples, // here you can pass custom colors
137
+ value: props.textColor.color,
138
+ label: 'Text color',
139
+ onChange: props.setTextColor,
140
+ },
141
+ {
142
+ colors: colorSamples, // here you can pass custom colors
143
+ value: props.buttonColor.color,
144
+ label: 'Button color',
145
+ onChange: props.setButtonColor,
146
+ }
147
+ ]
148
+ }),
149
+
150
+ el( RangeControl,
151
+ {
152
+ label: 'Padding',
153
+ min: 0,
154
+ max: 100,
155
+ onChange: ( value ) => {
156
+ props.setAttributes( { padding: value } );
157
+ },
158
+ value: props.attributes.padding
159
+ }
160
+ )
161
+
162
+ ),
163
+
164
+ el(
165
+ "div",
166
+ {style: {backgroundColor: props.rowColor.color, color: props.textColor.color, padding: props.attributes.padding, textAlign: props.attributes.alignment}},
167
+ el(
168
+ BlockControls,
169
+ { key: 'controls' },
170
+ el(
171
+ AlignmentToolbar,
172
+ {
173
+ value: props.attributes.alignment,
174
+ onChange: onChangeAlignment
175
+ }
176
+ )
177
+ ),
178
+ el(RichText,
179
+ {
180
+ tagName: 'p',
181
+ format: 'string',
182
+ onChange: onChangeContent,
183
+ value: props.attributes.content,
184
+ // formattingControls: [ 'bold' ]
185
+ }),
186
+ el('div',
187
+ {style: {backgroundColor: 'lightGrey', margin: '20px', padding: '5px',
188
+ fontFamily: '-apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen-Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif'}},
189
+ el('svg',
190
+ {
191
+ width: 20,
192
+ height: 20
193
+ },
194
+ wp.element.createElement( 'path',
195
+ {
196
+ d: "M6 14H4V6h2V4H2v12h4M7.1 17h2.1l3.7-14h-2.1M14 4v2h2v8h-2v2h4V4"
197
+ }
198
+ )
199
+ ),
200
+ ' Newsletter Form'
201
+ ),
202
+ ))
203
+ }),
204
+ save: function (props) {
205
+
206
+ var rowClass = getColorClassName( 'row-color', props.attributes.rowColor );
207
+ var textClass = getColorClassName( 'text-color', props.attributes.textColor );
208
+ var buttonClass = getColorClassName( 'button-color', props.attributes.buttonColor );
209
+
210
+ formtype_attr = "";
211
+ if (props.attributes.formtype != "full") {
212
+ formtype_attr = " type=\"minimal\"";
213
+ }
214
+
215
+ lists_attr = "";
216
+ if (props.attributes.list_ids != "") {
217
+ lists_attr = " lists=\"" + props.attributes.list_ids + "\"";
218
+ }
219
+
220
+ button_color_attr = "";
221
+ button_color = buttonClass ? undefined : props.attributes.customButtonColor;
222
+ if (button_color != "") {
223
+ button_color_attr = " button_color=\"" + button_color + "\"";
224
+ }
225
+
226
+ var formStyles = {
227
+ backgroundColor: rowClass ? undefined : props.attributes.customRowColor,
228
+ color: textClass ? undefined : props.attributes.customTextColor,
229
+ padding: props.attributes.padding,
230
+ textAlign: props.attributes.alignment
231
+ };
232
+
233
+ return (
234
+ el('div', {style: formStyles},
235
+ el( RichText.Content, {
236
+ tagName: 'p',
237
+ value: props.attributes.content
238
+ }),
239
+ el(
240
+ "div",
241
+ {},
242
+ "[newsletter_form" + formtype_attr + lists_attr + button_color_attr + "]"
243
+ )));
244
+ }
245
+ });
246
+
247
+ })(
248
+ window.wp.blocks,
249
+ window.wp.editor,
250
+ window.wp.element,
251
+ window.wp.components,
252
+ );
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.1.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.
@@ -29,7 +29,7 @@
29
  */
30
 
31
  // Used as dummy parameter on css and js links
32
- define('NEWSLETTER_VERSION', '6.1.2');
33
 
34
  global $newsletter, $wpdb;
35
 
@@ -274,8 +274,7 @@ class Newsletter extends NewsletterModule {
274
  `click_count` int(10) unsigned NOT NULL DEFAULT '0',
275
  `version` varchar(10) NOT NULL DEFAULT '',
276
  `open_count` int(10) unsigned NOT NULL DEFAULT '0',
277
- PRIMARY KEY (`id`)
278
- ) $charset_collate;";
279
 
280
  dbDelta($sql);
281
 
@@ -392,7 +391,7 @@ class Newsletter extends NewsletterModule {
392
  add_shortcode('newsletter_replace', array($this, 'shortcode_newsletter_replace'));
393
 
394
  if (is_admin()) {
395
- add_action('admin_notices', array($this, 'hook_admin_notices'));
396
 
397
  if ($this->is_admin_page()) {
398
  $newsletter_url = plugins_url('newsletter');
@@ -426,8 +425,6 @@ class Newsletter extends NewsletterModule {
426
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
427
  }
428
 
429
- //add_filter('site_transient_update_plugins', array($this, 'hook_site_transient_update_plugins'));
430
-
431
  do_action('newsletter_init');
432
 
433
  if (empty($this->action)) {
@@ -450,6 +447,16 @@ class Newsletter extends NewsletterModule {
450
  die();
451
  }
452
  }
 
 
 
 
 
 
 
 
 
 
453
 
454
  function hook_admin_notices() {
455
  // Check of Newsletter dedicated page
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.1.3
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.
29
  */
30
 
31
  // Used as dummy parameter on css and js links
32
+ define('NEWSLETTER_VERSION', '6.1.3');
33
 
34
  global $newsletter, $wpdb;
35
 
274
  `click_count` int(10) unsigned NOT NULL DEFAULT '0',
275
  `version` varchar(10) NOT NULL DEFAULT '',
276
  `open_count` int(10) unsigned NOT NULL DEFAULT '0',
277
+ PRIMARY KEY (`id`)) $charset_collate;";
 
278
 
279
  dbDelta($sql);
280
 
391
  add_shortcode('newsletter_replace', array($this, 'shortcode_newsletter_replace'));
392
 
393
  if (is_admin()) {
394
+ add_action('in_admin_header', array($this, 'hook_in_admin_header'), 1000);
395
 
396
  if ($this->is_admin_page()) {
397
  $newsletter_url = plugins_url('newsletter');
425
  add_action('wp_enqueue_scripts', array($this, 'hook_wp_enqueue_scripts'));
426
  }
427
 
 
 
428
  do_action('newsletter_init');
429
 
430
  if (empty($this->action)) {
447
  die();
448
  }
449
  }
450
+
451
+ function hook_in_admin_header() {
452
+ if (!$this->is_admin_page()) {
453
+ add_action('admin_notices', array($this, 'hook_admin_notices'));
454
+ return;
455
+ }
456
+ remove_all_actions('admin_notices');
457
+ remove_all_actions('all_admin_notices');
458
+ add_action('admin_notices', array($this, 'hook_admin_notices'));
459
+ }
460
 
461
  function hook_admin_notices() {
462
  // Check of Newsletter dedicated page
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.2.2
5
- Stable tag: 6.1.2
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
@@ -108,6 +108,12 @@ Thank you, The Newsletter Team
108
 
109
  == Changelog ==
110
 
 
 
 
 
 
 
111
  = 6.1.2 =
112
 
113
  * Added support for roles
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.2.2
5
+ Stable tag: 6.1.3
6
  Contributors: satollo,webagile,michael-travan
7
 
8
  Add a real newsletter system to your blog. For free. With unlimited newsletters and subscribers.
108
 
109
  == Changelog ==
110
 
111
+ = 6.1.3 =
112
+
113
+ * Fix to avoid third party plugin notices to interfere with the composer
114
+ * NEW! Added subscription block to the Gutenberg editor
115
+ * Code cleanup
116
+
117
  = 6.1.2 =
118
 
119
  * Added support for roles
subscription/subscription.php CHANGED
@@ -60,6 +60,13 @@ class NewsletterSubscription extends NewsletterModule {
60
  if (isset($_GET['page']) && $_GET['page'] === 'newsletter_subscription_forms') {
61
  header('X-XSS-Protection: 0');
62
  }
 
 
 
 
 
 
 
63
  }
64
 
65
  function hook_wp_enqueue_scripts() {
@@ -1536,10 +1543,15 @@ class NewsletterSubscription extends NewsletterModule {
1536
 
1537
  $buffer .= '<div class="tnp-field tnp-field-button">';
1538
 
 
 
 
 
 
1539
  if (strpos($options_profile['subscribe'], 'http') === 0) {
1540
  $buffer .= '<input class="tnp-submit-image" type="image" src="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1541
  } else {
1542
- $buffer .= '<input class="tnp-submit" type="submit" value="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1543
  }
1544
 
1545
  $buffer .= "</div>\n</form>\n";
@@ -1628,12 +1640,15 @@ class NewsletterSubscription extends NewsletterModule {
1628
  }
1629
 
1630
  function get_subscription_form_minimal($attrs) {
 
1631
  $language = $this->get_current_language();
1632
  if (!is_array($attrs)) {
1633
  $attrs = array();
1634
  }
1635
  $options_profile = $this->get_options('profile', $language);
1636
- $attrs = array_merge(array('class' => '', 'referrer' => 'minimal', 'button' => $options_profile['subscribe'], 'placeholder' => $options_profile['email']), $attrs);
 
 
1637
 
1638
  $form = '';
1639
  $form .= '<div class="tnp tnp-subscription-minimal ' . $attrs['class'] . '">';
@@ -1647,7 +1662,8 @@ class NewsletterSubscription extends NewsletterModule {
1647
  $form .= '<input type="hidden" name="nr" value="' . esc_attr($attrs['referrer']) . '">';
1648
  $form .= '<input type="hidden" name="nlang" value="' . esc_attr($language) . '">' . "\n";
1649
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1650
- $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '">';
 
1651
 
1652
  $privacy_field = $this->get_privacy_field();
1653
  if (!empty($privacy_field)) {
60
  if (isset($_GET['page']) && $_GET['page'] === 'newsletter_subscription_forms') {
61
  header('X-XSS-Protection: 0');
62
  }
63
+ // Add custom blocks to Gutenberg
64
+ wp_enqueue_script(
65
+ 'tnp-blocks',
66
+ NEWSLETTER_URL . '/includes/tnp-blocks.js',
67
+ array('wp-blocks', 'wp-element', 'wp-editor'),
68
+ true
69
+ );
70
  }
71
 
72
  function hook_wp_enqueue_scripts() {
1543
 
1544
  $buffer .= '<div class="tnp-field tnp-field-button">';
1545
 
1546
+ $button_style = '';
1547
+ if (!empty($attrs['button_color'])) {
1548
+ $button_style = 'style="background-color:' . esc_attr( $attrs['button_color'] ) . '"';
1549
+ }
1550
+
1551
  if (strpos($options_profile['subscribe'], 'http') === 0) {
1552
  $buffer .= '<input class="tnp-submit-image" type="image" src="' . esc_attr($options_profile['subscribe']) . '">' . "\n";
1553
  } else {
1554
+ $buffer .= '<input class="tnp-submit" type="submit" value="' . esc_attr($options_profile['subscribe']) . '" ' . $button_style .'>' . "\n";
1555
  }
1556
 
1557
  $buffer .= "</div>\n</form>\n";
1640
  }
1641
 
1642
  function get_subscription_form_minimal($attrs) {
1643
+
1644
  $language = $this->get_current_language();
1645
  if (!is_array($attrs)) {
1646
  $attrs = array();
1647
  }
1648
  $options_profile = $this->get_options('profile', $language);
1649
+ $attrs = array_merge(array('class' => '', 'referrer' => 'minimal',
1650
+ 'button' => $options_profile['subscribe'], 'button_color' => '',
1651
+ 'button_radius' => '', 'placeholder' => $options_profile['email']), $attrs);
1652
 
1653
  $form = '';
1654
  $form .= '<div class="tnp tnp-subscription-minimal ' . $attrs['class'] . '">';
1662
  $form .= '<input type="hidden" name="nr" value="' . esc_attr($attrs['referrer']) . '">';
1663
  $form .= '<input type="hidden" name="nlang" value="' . esc_attr($language) . '">' . "\n";
1664
  $form .= '<input class="tnp-email" type="email" required name="ne" value="" placeholder="' . esc_attr($attrs['placeholder']) . '">';
1665
+ $form .= '<input class="tnp-submit" type="submit" value="' . esc_attr($attrs['button']) . '"'
1666
+ .' style="background-color:' . esc_attr($attrs['button_color']) . '">';
1667
 
1668
  $privacy_field = $this->get_privacy_field();
1669
  if (!empty($privacy_field)) {