SiteOrigin Widgets Bundle - Version 1.11.8

Version Description

  • 12 April 2018 =
  • Added action just before rendering widget previews.
  • Editor: Removed unwpautop.
  • Editor: Ensure TinyMCE field knows whether to apply autop or not.
  • Editor: Only apply autop on display when using HTML editor.
  • Editor: Prevent widget_text filters from running do_shortcode.
Download this release

Release Info

Developer gpriday
Plugin Icon 128x128 SiteOrigin Widgets Bundle
Version 1.11.8
Comparing to
See all releases

Code changes from version 1.11.7 to 1.11.8

base/inc/actions.php CHANGED
@@ -31,6 +31,8 @@ function siteorigin_widget_preview_widget_action() {
31
 
32
  $sowb = SiteOrigin_Widgets_Bundle::single();
33
  $sowb->register_general_scripts();
 
 
34
 
35
  ob_start();
36
  $widget->widget( array(
31
 
32
  $sowb = SiteOrigin_Widgets_Bundle::single();
33
  $sowb->register_general_scripts();
34
+
35
+ do_action( 'siteorigin_widgets_render_preview_' . $widget->id_base, $widget );
36
 
37
  ob_start();
38
  $widget->widget( array(
base/inc/fields/js/tinymce-field.js CHANGED
@@ -9,6 +9,12 @@
9
 
10
  var $container = $field.find( '.siteorigin-widget-tinymce-container' );
11
  var settings = $container.data( 'editorSettings' );
 
 
 
 
 
 
12
  var $textarea = $container.find( 'textarea' );
13
  var id = $textarea.attr( 'id' );
14
  var setupEditor = function ( editor ) {
@@ -18,16 +24,24 @@
18
  $textarea.trigger( 'change' );
19
  }
20
  );
 
 
 
 
 
 
 
 
21
  };
22
 
23
  settings.tinymce = $.extend( {}, settings.tinymce, { selector: '#' + id, setup: setupEditor } );
24
- $( document ).one( 'wp-before-tinymce-init', function ( event, init ) {
25
  if ( init.selector === settings.tinymce.selector ) {
26
  var mediaButtons = $container.data( 'mediaButtons' );
27
  $field.find( '.wp-editor-tabs' ).before( mediaButtons.html );
28
  }
29
  } );
30
- $( document ).one( 'tinymce-editor-setup', function () {
31
  if ( ! $field.find( '.wp-editor-wrap' ).hasClass( settings.selectedEditor + '-active' ) ) {
32
  setTimeout( function () {
33
  window.switchEditors.go( id );
@@ -65,6 +79,7 @@
65
  editor.setContent(window.switchEditors.wpautop(content));
66
  }
67
  }
 
68
  $field.find( '.siteorigin-widget-tinymce-selected-editor' ).val( mode );
69
  } );
70
 
9
 
10
  var $container = $field.find( '.siteorigin-widget-tinymce-container' );
11
  var settings = $container.data( 'editorSettings' );
12
+ var $wpautopToggleField;
13
+ if ( settings.wpautopToggleField ) {
14
+ var $widgetForm = $container.closest( '.siteorigin-widget-form' );
15
+ $wpautopToggleField = $widgetForm.find( settings.wpautopToggleField );
16
+ settings.tinymce.wpautop = $wpautopToggleField.is( ':checked' );
17
+ }
18
  var $textarea = $container.find( 'textarea' );
19
  var id = $textarea.attr( 'id' );
20
  var setupEditor = function ( editor ) {
24
  $textarea.trigger( 'change' );
25
  }
26
  );
27
+ if ( $wpautopToggleField ) {
28
+ $wpautopToggleField.off( 'change' );
29
+ $wpautopToggleField.on( 'change', function () {
30
+ wp.editor.remove( id );
31
+ settings.tinymce.wpautop = $wpautopToggleField.is( ':checked' );
32
+ wp.editor.initialize( id, settings );
33
+ } );
34
+ }
35
  };
36
 
37
  settings.tinymce = $.extend( {}, settings.tinymce, { selector: '#' + id, setup: setupEditor } );
38
+ $( document ).on( 'wp-before-tinymce-init', function ( event, init ) {
39
  if ( init.selector === settings.tinymce.selector ) {
40
  var mediaButtons = $container.data( 'mediaButtons' );
41
  $field.find( '.wp-editor-tabs' ).before( mediaButtons.html );
42
  }
43
  } );
44
+ $( document ).on( 'tinymce-editor-setup', function () {
45
  if ( ! $field.find( '.wp-editor-wrap' ).hasClass( settings.selectedEditor + '-active' ) ) {
46
  setTimeout( function () {
47
  window.switchEditors.go( id );
79
  editor.setContent(window.switchEditors.wpautop(content));
80
  }
81
  }
82
+ settings.selectedEditor = mode;
83
  $field.find( '.siteorigin-widget-tinymce-selected-editor' ).val( mode );
84
  } );
85
 
base/inc/fields/js/tinymce-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(i){var e=function(e){if(!e.data("initialized")){var t=e.find(".siteorigin-widget-tinymce-container"),n=t.data("editorSettings"),o=t.find("textarea"),r=o.attr("id"),s=function(i){i.on("change",function(){window.tinymce.get(r).save(),o.trigger("change")})};if(n.tinymce=i.extend({},n.tinymce,{selector:"#"+r,setup:s}),i(document).one("wp-before-tinymce-init",function(i,o){if(o.selector===n.tinymce.selector){var r=t.data("mediaButtons");e.find(".wp-editor-tabs").before(r.html)}}),i(document).one("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(n.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(r)},10)}),wp.editor.remove(r),o.is(":visible"))wp.editor.initialize(r,n);else var d=setInterval(function(){o.is(":visible")&&(wp.editor.initialize(r,n),clearInterval(d))},500);e.on("click",function(t){var n=i(t.target),s=n.hasClass("switch-tmce")?"tmce":"html";if("tmce"===s){var d=window.tinymce.get(r);if(n.hasClass("wp-switch-editor")&&null!==d){var a=o.val();-1!==a.search("<")&&-1===a.search(">")&&(a=a.replace(/</g,""),o.val(a)),d.setContent(window.switchEditors.wpautop(a))}}e.find(".siteorigin-widget-tinymce-selected-editor").val(s)}),e.data("initialized",!0)}};i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var t=i(this),n=t.closest(".siteorigin-widget-field-repeater-item-form");n.length>0?n.is(":visible")?e(t):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(e(t),n.off("slideToggleOpenComplete"))}):e(t)}),i(document).on("sortstop",function(t,n){var o;o=n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form"):n.item.find(".siteorigin-widget-form"),o.find(".siteorigin-widget-field-type-tinymce").each(function(){i(this).data("initialized",null),e(i(this))})})}(jQuery);
1
+ !function(i){var e=function(e){if(!e.data("initialized")){var t,n=e.find(".siteorigin-widget-tinymce-container"),o=n.data("editorSettings");if(o.wpautopToggleField){var r=n.closest(".siteorigin-widget-form");t=r.find(o.wpautopToggleField),o.tinymce.wpautop=t.is(":checked")}var d=n.find("textarea"),s=d.attr("id"),a=function(i){i.on("change",function(){window.tinymce.get(s).save(),d.trigger("change")}),t&&(t.off("change"),t.on("change",function(){wp.editor.remove(s),o.tinymce.wpautop=t.is(":checked"),wp.editor.initialize(s,o)}))};if(o.tinymce=i.extend({},o.tinymce,{selector:"#"+s,setup:a}),i(document).on("wp-before-tinymce-init",function(i,t){if(t.selector===o.tinymce.selector){var r=n.data("mediaButtons");e.find(".wp-editor-tabs").before(r.html)}}),i(document).on("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(o.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(s)},10)}),wp.editor.remove(s),d.is(":visible"))wp.editor.initialize(s,o);else var c=setInterval(function(){d.is(":visible")&&(wp.editor.initialize(s,o),clearInterval(c))},500);e.on("click",function(t){var n=i(t.target),r=n.hasClass("switch-tmce")?"tmce":"html";if("tmce"===r){var a=window.tinymce.get(s);if(n.hasClass("wp-switch-editor")&&null!==a){var c=d.val();-1!==c.search("<")&&-1===c.search(">")&&(c=c.replace(/</g,""),d.val(c)),a.setContent(window.switchEditors.wpautop(c))}}o.selectedEditor=r,e.find(".siteorigin-widget-tinymce-selected-editor").val(r)}),e.data("initialized",!0)}};i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var t=i(this),n=t.closest(".siteorigin-widget-field-repeater-item-form");n.length>0?n.is(":visible")?e(t):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(e(t),n.off("slideToggleOpenComplete"))}):e(t)}),i(document).on("sortstop",function(t,n){var o;o=n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form"):n.item.find(".siteorigin-widget-form"),o.find(".siteorigin-widget-field-type-tinymce").each(function(){i(this).data("initialized",null),e(i(this))})})}(jQuery);
base/inc/fields/tinymce.class.php CHANGED
@@ -100,14 +100,6 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
100
  */
101
  private $wp_version_lt_4_8;
102
 
103
- public static function unautop( $text ) {
104
- $text = str_replace('<p>', '', $text);
105
- $text = str_replace(array('<br />', '<br>', '<br/>'), "\n", $text);
106
- $text = str_replace('</p>', "\n\n", $text);
107
-
108
- return $text;
109
- }
110
-
111
  protected function get_default_options() {
112
  return array(
113
  'wpautop' => true,
@@ -320,9 +312,9 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
320
  }
321
 
322
  protected function render_before_field( $value, $instance ) {
323
- $selected_editor_name = $this->get_selected_editor_field_name( $this->base_name );
324
- if( ! empty( $instance[ $selected_editor_name ] ) ) {
325
- $this->selected_editor = $instance[ $selected_editor_name ];
326
  }
327
  else {
328
  $this->selected_editor = $this->default_editor;
@@ -496,8 +488,9 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
496
  }
497
 
498
  protected function sanitize_field_input( $value, $instance ) {
499
- if ( ! empty( $this->wpautop ) ) {
500
- $value = wpautop( self::unautop( $value ) );
 
501
  }
502
  if( current_user_can( 'unfiltered_html' ) ) {
503
  $sanitized_value = $value;
@@ -517,6 +510,16 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
517
  return $instance;
518
  }
519
 
 
 
 
 
 
 
 
 
 
 
520
  public function get_selected_editor_field_name( $base_name ) {
521
  $v_name = $base_name;
522
  if( strpos($v_name, '][') !== false ) {
100
  */
101
  private $wp_version_lt_4_8;
102
 
 
 
 
 
 
 
 
 
103
  protected function get_default_options() {
104
  return array(
105
  'wpautop' => true,
312
  }
313
 
314
  protected function render_before_field( $value, $instance ) {
315
+ $selected_editor = $this->get_selected_editor( $instance );
316
+ if( ! empty( $selected_editor ) ) {
317
+ $this->selected_editor = $selected_editor;
318
  }
319
  else {
320
  $this->selected_editor = $this->default_editor;
488
  }
489
 
490
  protected function sanitize_field_input( $value, $instance ) {
491
+ $selected_editor = $this->get_selected_editor( $instance );
492
+ if ( in_array( $selected_editor, array( 'tinymce', 'tmce' ) ) && ! empty( $this->wpautop ) ) {
493
+ $value = wpautop( $value );
494
  }
495
  if( current_user_can( 'unfiltered_html' ) ) {
496
  $sanitized_value = $value;
510
  return $instance;
511
  }
512
 
513
+ public function get_selected_editor( $instance ) {
514
+ $selected_editor = null;
515
+ $selected_editor_name = $this->get_selected_editor_field_name( $this->base_name );
516
+ if( ! empty( $instance[ $selected_editor_name ] ) ) {
517
+ $selected_editor = $instance[ $selected_editor_name ];
518
+ }
519
+
520
+ return $selected_editor;
521
+ }
522
+
523
  public function get_selected_editor_field_name( $base_name ) {
524
  $v_name = $base_name;
525
  if( strpos($v_name, '][') !== false ) {
lang/so-widgets-bundle.pot CHANGED
@@ -69,7 +69,7 @@ msgstr ""
69
  msgid "Save"
70
  msgstr ""
71
 
72
- #: tmp/base/inc/actions.php:19, tmp/base/inc/actions.php:145, tmp/base/inc/actions.php:233, tmp/base/inc/actions.php:305, tmp/base/inc/actions.php:331, tmp/base/inc/actions.php:339, tmp/base/inc/actions.php:521, tmp/base/inc/actions.php:527, tmp/so-widgets-bundle.php:739, tmp/so-widgets-bundle.php:787, tmp/so-widgets-bundle.php:813, tmp/so-widgets-bundle.php:873, tmp/so-widgets-bundle.php:895, tmp/so-widgets-bundle.php:1027, tmp/so-widgets-bundle.php:1049
73
  msgid "Invalid request."
74
  msgstr ""
75
 
@@ -77,19 +77,19 @@ msgstr ""
77
  msgid "Invalid post."
78
  msgstr ""
79
 
80
- #: tmp/base/inc/actions.php:95, tmp/base/siteorigin-widget.class.php:1273
81
  msgid "Widget Preview"
82
  msgstr ""
83
 
84
- #: tmp/base/inc/actions.php:417
85
  msgid "Nonce error"
86
  msgstr ""
87
 
88
- #: tmp/base/inc/actions.php:437
89
  msgid "Signature error"
90
  msgstr ""
91
 
92
- #: tmp/base/inc/actions.php:489
93
  msgid "Attachment error"
94
  msgstr ""
95
 
69
  msgid "Save"
70
  msgstr ""
71
 
72
+ #: tmp/base/inc/actions.php:19, tmp/base/inc/actions.php:149, tmp/base/inc/actions.php:237, tmp/base/inc/actions.php:309, tmp/base/inc/actions.php:335, tmp/base/inc/actions.php:343, tmp/base/inc/actions.php:525, tmp/base/inc/actions.php:531, tmp/so-widgets-bundle.php:739, tmp/so-widgets-bundle.php:787, tmp/so-widgets-bundle.php:813, tmp/so-widgets-bundle.php:873, tmp/so-widgets-bundle.php:895, tmp/so-widgets-bundle.php:1027, tmp/so-widgets-bundle.php:1049
73
  msgid "Invalid request."
74
  msgstr ""
75
 
77
  msgid "Invalid post."
78
  msgstr ""
79
 
80
+ #: tmp/base/inc/actions.php:99, tmp/base/siteorigin-widget.class.php:1273
81
  msgid "Widget Preview"
82
  msgstr ""
83
 
84
+ #: tmp/base/inc/actions.php:421
85
  msgid "Nonce error"
86
  msgstr ""
87
 
88
+ #: tmp/base/inc/actions.php:441
89
  msgid "Signature error"
90
  msgstr ""
91
 
92
+ #: tmp/base/inc/actions.php:493
93
  msgid "Attachment error"
94
  msgstr ""
95
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
3
  Requires at least: 4.2
4
  Tested up to: 4.9.1
5
- Stable tag: 1.11.7
6
- Build time: 2018-03-23T11:39:23+02:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
@@ -47,7 +47,7 @@ Once you enable a widget, you'll be able to use it anywhere standard widgets are
47
 
48
  == Documentation ==
49
 
50
- [Documentation](https://siteorigin.com/css/getting-started/) is available on SiteOrigin.
51
 
52
  == Support ==
53
 
@@ -65,6 +65,13 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
68
  = 1.11.7 - 23 March 2018 =
69
  * Image: Add title alignment setting.
70
  * Button: Add max-width to ensure buttons are responsive.
2
  Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
3
  Requires at least: 4.2
4
  Tested up to: 4.9.1
5
+ Stable tag: 1.11.8
6
+ Build time: 2018-04-12T16:11:39+02:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
47
 
48
  == Documentation ==
49
 
50
+ [Documentation](https://siteorigin.com/widgets-bundle/getting-started/) is available on SiteOrigin.
51
 
52
  == Support ==
53
 
65
 
66
  == Changelog ==
67
 
68
+ = 1.11.8 - 12 April 2018 =
69
+ * Added action just before rendering widget previews.
70
+ * Editor: Removed `unwpautop`.
71
+ * Editor: Ensure TinyMCE field knows whether to apply `autop` or not.
72
+ * Editor: Only apply `autop` on display when using HTML editor.
73
+ * Editor: Prevent `widget_text` filters from running `do_shortcode`.
74
+
75
  = 1.11.7 - 23 March 2018 =
76
  * Image: Add title alignment setting.
77
  * Button: Add max-width to ensure buttons are responsive.
so-widgets-bundle.php CHANGED
@@ -2,7 +2,7 @@
2
  /*
3
  Plugin Name: SiteOrigin Widgets Bundle
4
  Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
5
- Version: 1.11.7
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
@@ -12,7 +12,7 @@ License: GPL3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
- define('SOW_BUNDLE_VERSION', '1.11.7');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
2
  /*
3
  Plugin Name: SiteOrigin Widgets Bundle
4
  Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
5
+ Version: 1.11.8
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
+ define('SOW_BUNDLE_VERSION', '1.11.8');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
widgets/editor/editor.php CHANGED
@@ -34,7 +34,7 @@ class SiteOrigin_Widget_Editor_Widget extends SiteOrigin_Widget {
34
  'text' => array(
35
  'type' => 'tinymce',
36
  'rows' => 20,
37
- 'wpautop' => false, // Let the editor handle it's own processing.
38
  ),
39
  'autop' => array(
40
  'type' => 'checkbox',
@@ -54,27 +54,17 @@ class SiteOrigin_Widget_Editor_Widget extends SiteOrigin_Widget {
54
  );
55
  }
56
 
57
- function unwpautop($string) {
58
- $string = str_replace("<p>", "", $string);
59
- $string = str_replace(array("<br />", "<br>", "<br/>"), "\n", $string);
60
- $string = str_replace("</p>", "\n\n", $string);
61
-
62
- return $string;
63
- }
64
-
65
  public function get_template_variables( $instance, $args ) {
66
  $instance = wp_parse_args(
67
  $instance,
68
  array( 'text' => '' )
69
- );
70
 
71
  if (
72
  // Only run these parts if we're rendering for the frontend
73
  empty( $GLOBALS[ 'SITEORIGIN_PANELS_CACHE_RENDER' ] ) &&
74
  empty( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] )
75
  ) {
76
- $instance['text'] = $this->unwpautop( $instance['text'] );
77
-
78
  if (function_exists('wp_make_content_images_responsive')) {
79
  $instance['text'] = wp_make_content_images_responsive( $instance['text'] );
80
  }
@@ -93,11 +83,22 @@ class SiteOrigin_Widget_Editor_Widget extends SiteOrigin_Widget {
93
  $instance['text'] = $GLOBALS['wp_embed']->run_shortcode( $instance['text'] );
94
  $instance['text'] = $GLOBALS['wp_embed']->autoembed( $instance['text'] );
95
  }
96
-
 
 
 
 
 
 
 
97
  $instance['text'] = apply_filters( 'widget_text', $instance['text'] );
98
 
 
 
 
 
99
  if( $instance['autop'] ) {
100
- $instance['text'] = wpautop( $instance['text'] );
101
  }
102
 
103
  $instance['text'] = do_shortcode( shortcode_unautop( $instance['text'] ) );
34
  'text' => array(
35
  'type' => 'tinymce',
36
  'rows' => 20,
37
+ 'wpautop_toggle_field' => '.siteorigin-widget-field-autop input[type="checkbox"]',
38
  ),
39
  'autop' => array(
40
  'type' => 'checkbox',
54
  );
55
  }
56
 
 
 
 
 
 
 
 
 
57
  public function get_template_variables( $instance, $args ) {
58
  $instance = wp_parse_args(
59
  $instance,
60
  array( 'text' => '' )
61
+ );
62
 
63
  if (
64
  // Only run these parts if we're rendering for the frontend
65
  empty( $GLOBALS[ 'SITEORIGIN_PANELS_CACHE_RENDER' ] ) &&
66
  empty( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] )
67
  ) {
 
 
68
  if (function_exists('wp_make_content_images_responsive')) {
69
  $instance['text'] = wp_make_content_images_responsive( $instance['text'] );
70
  }
83
  $instance['text'] = $GLOBALS['wp_embed']->run_shortcode( $instance['text'] );
84
  $instance['text'] = $GLOBALS['wp_embed']->autoembed( $instance['text'] );
85
  }
86
+
87
+ // As in the Text Widget, we need to prevent plugins and themes from running `do_shortcode` in the `widget_text`
88
+ // filter to avoid running it twice and to prevent `wpautop` from interfering with shortcodes' output.
89
+ $widget_text_do_shortcode_priority = has_filter( 'widget_text', 'do_shortcode' );
90
+ if ( $widget_text_do_shortcode_priority !== false ) {
91
+ remove_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );
92
+ }
93
+
94
  $instance['text'] = apply_filters( 'widget_text', $instance['text'] );
95
 
96
+ if ( $widget_text_do_shortcode_priority !== false ) {
97
+ add_filter( 'widget_text', 'do_shortcode', $widget_text_do_shortcode_priority );
98
+ }
99
+
100
  if( $instance['autop'] ) {
101
+ $instance['text'] = wpautop( $instance['text'] );
102
  }
103
 
104
  $instance['text'] = do_shortcode( shortcode_unautop( $instance['text'] ) );