SiteOrigin Widgets Bundle - Version 1.14.1

Version Description

  • 9 January 2019 =
  • Icon field: Set correct value of currently selected icon for non-FA icons.
  • Icon field: Avoid requiring that third party icon families include a filter.php file.
  • Widget block: Use JS array reduce function instead of lodash.
  • Allow widgets registered by instance.
  • Multi-measurement field: Fix layout.
  • Block editor: Send widgetData when fetching widget forms.
  • Tinymce field: Prevent JS console errors for hidden fields.
  • Order field: Additional sanitization before rendering.
Download this release

Release Info

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

Code changes from version 1.14.0 to 1.14.1

base/inc/fields/css/multi-measurement-field.css CHANGED
@@ -2,13 +2,13 @@
2
  display: flex;
3
  }
4
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container:not(:first-child) {
5
- margin-left: 10px;
6
  }
7
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container > label {
 
8
  padding-left: 5px;
9
  }
10
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container input[type="text"].sow-multi-measurement-input {
11
- float: left;
12
  max-width: 58px;
13
  margin: 1px;
14
  height: 28px;
2
  display: flex;
3
  }
4
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container:not(:first-child) {
5
+ margin-left: 15px;
6
  }
7
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container > label {
8
+ display: block;
9
  padding-left: 5px;
10
  }
11
  .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container input[type="text"].sow-multi-measurement-input {
 
12
  max-width: 58px;
13
  margin: 1px;
14
  height: 28px;
base/inc/fields/icon.class.php CHANGED
@@ -18,8 +18,14 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
18
  protected function render_field( $value, $instance ) {
19
  $widget_icon_families = $this->get_widget_icon_families();
20
  $value_parts = self::get_value_parts( $value );
21
- $value_family = ! empty( $value ) ? $value_parts['family'] : 'fontawesome';
22
- $value = $value_parts['family'] . '-' . ( empty( $value_parts['style'] ) ? '' : $value_parts['style'] ) . '-' . $value_parts['icon'];
 
 
 
 
 
 
23
  ?>
24
 
25
  <div class="siteorigin-widget-icon-selector-current">
@@ -92,13 +98,21 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
92
  }
93
  else {
94
  // We'll get icons from the main filter
95
- static $widget_icon_families;
96
- if( empty( $widget_icon_families ) ) $widget_icon_families = apply_filters('siteorigin_widgets_icon_families', array() );
97
  }
98
 
99
  return $widget_icon_families;
100
  }
101
 
 
 
 
 
 
 
 
 
 
102
  static function get_value_parts( $value ) {
103
 
104
  list( $value_family, $value_icon ) = ( ! empty( $value ) && strpos( $value, '-' ) !== false ) ? explode( '-', $value, 2 ) : array('', '');
@@ -109,9 +123,9 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
109
  $value_style = $style_matches[1];
110
  }
111
 
112
- if ( ! empty( $value_family ) ) {
113
- include_once plugin_dir_path(SOW_BUNDLE_BASE_FILE) . 'icons/' . $value_family . '/filter.php';
114
- }
115
 
116
  return apply_filters( 'siteorigin_widgets_icon_migrate_' . $value_family, array(
117
  'family' => $value_family,
18
  protected function render_field( $value, $instance ) {
19
  $widget_icon_families = $this->get_widget_icon_families();
20
  $value_parts = self::get_value_parts( $value );
21
+ if ( ! empty( $value ) ) {
22
+ $value_family = $value_parts['family'];
23
+ $value_style = empty( $value_parts['style'] ) ? '' : ( '-' . $value_parts['style'] );
24
+ $value = $value_parts['family'] . $value_style . '-' . $value_parts['icon'];
25
+
26
+ } else {
27
+ $value_family = 'fontawesome';
28
+ }
29
  ?>
30
 
31
  <div class="siteorigin-widget-icon-selector-current">
98
  }
99
  else {
100
  // We'll get icons from the main filter
101
+ $widget_icon_families = self::get_icon_families();
 
102
  }
103
 
104
  return $widget_icon_families;
105
  }
106
 
107
+ static function get_icon_families() {
108
+ static $widget_icon_families;
109
+ if( empty( $widget_icon_families ) ) {
110
+ $widget_icon_families = apply_filters( 'siteorigin_widgets_icon_families', array() );
111
+ }
112
+
113
+ return $widget_icon_families;
114
+ }
115
+
116
  static function get_value_parts( $value ) {
117
 
118
  list( $value_family, $value_icon ) = ( ! empty( $value ) && strpos( $value, '-' ) !== false ) ? explode( '-', $value, 2 ) : array('', '');
123
  $value_style = $style_matches[1];
124
  }
125
 
126
+ // Trigger loading of the icon families and their filters. This isn't ideal, but necessary to ensure possible
127
+ // migrations are available.
128
+ self::get_icon_families();
129
 
130
  return apply_filters( 'siteorigin_widgets_icon_migrate_' . $value_family, array(
131
  'family' => $value_family,
base/inc/fields/js/tinymce-field.js CHANGED
@@ -54,7 +54,8 @@
54
  }
55
  } );
56
  $( document ).on( 'tinymce-editor-setup', function () {
57
- if ( ! $field.find( '.wp-editor-wrap' ).hasClass( settings.selectedEditor + '-active' ) ) {
 
58
  setTimeout( function () {
59
  window.switchEditors.go( id );
60
  }, 10 );
54
  }
55
  } );
56
  $( document ).on( 'tinymce-editor-setup', function () {
57
+ var $wpEditorWrap = $field.find( '.wp-editor-wrap' );
58
+ if ( $wpEditorWrap.length > 0 && ! $wpEditorWrap.hasClass( settings.selectedEditor + '-active' ) ) {
59
  setTimeout( function () {
60
  window.switchEditors.go( id );
61
  }, 10 );
base/inc/fields/js/tinymce-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(c){var t=function(r){if(!r.data("initialized")){var i=wp.oldEditor?wp.oldEditor:wp.editor;i&&i.hasOwnProperty("autop")&&(wp.editor.autop=i.autop,wp.editor.removep=i.removep,wp.editor.initialize=i.initialize);var e,n=r.find(".siteorigin-widget-tinymce-container"),d=n.data("editorSettings");if(d.wpautopToggleField){var t=n.closest(".siteorigin-widget-form");e=t.find(d.wpautopToggleField),d.tinymce.wpautop=e.is(":checked")}var a=n.find("textarea"),s=a.attr("id");if(d.tinymce&&(d.tinymce=c.extend({},d.tinymce,{selector:"#"+s,setup:function(i){i.on("change",function(){window.tinymce.get(s).save(),a.trigger("change")}),e&&(e.off("change"),e.on("change",function(){wp.editor.remove(s),d.tinymce.wpautop=e.is(":checked"),wp.editor.initialize(s,d)}))}})),c(document).on("wp-before-tinymce-init",function(i,e){if(e.selector===d.tinymce.selector){var t=n.data("mediaButtons");0===r.find(".wp-media-buttons").length&&r.find(".wp-editor-tabs").before(t.html)}}),c(document).on("tinymce-editor-setup",function(){r.find(".wp-editor-wrap").hasClass(d.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(s)},10)}),i.remove(s),window.tinymce&&window.tinymce.EditorManager.overrideDefaults({base_url:d.baseURL,suffix:d.suffix}),a.is(":visible"))i.initialize(s,d);else var o=setInterval(function(){a.is(":visible")&&(i.initialize(s,d),clearInterval(o))},500);r.on("click",function(i){var e=c(i.target);if(e.is(".wp-switch-editor")){var t=e.hasClass("switch-tmce")?"tmce":"html";if("tmce"===t){var n=window.tinymce.get(s);if(null!==n){var o=a.val();-1!==o.search("<")&&-1===o.search(">")&&(o=o.replace(/</g,""),a.val(o)),n.setContent(window.switchEditors.wpautop(o))}}d.selectedEditor=t,r.find(".siteorigin-widget-tinymce-selected-editor").val(t)}}),r.data("initialized",!0)}};c(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var i=c(this),e=i.closest(".siteorigin-widget-field-repeater-item-form");0<e.length?e.is(":visible")?t(i):e.on("slideToggleOpenComplete",function(){e.is(":visible")&&(t(i),e.off("slideToggleOpenComplete"))}):t(i)}),c(document).on("sortstop",function(i,e){(e.item.is(".siteorigin-widget-field-repeater-item")?e.item.find("> .siteorigin-widget-field-repeater-item-form"):e.item.find(".siteorigin-widget-form")).find(".siteorigin-widget-field-type-tinymce").each(function(){c(this).data("initialized",null),t(c(this))})})}(jQuery);
1
+ !function(c){var t=function(r){if(!r.data("initialized")){var i=wp.oldEditor?wp.oldEditor:wp.editor;i&&i.hasOwnProperty("autop")&&(wp.editor.autop=i.autop,wp.editor.removep=i.removep,wp.editor.initialize=i.initialize);var e,n=r.find(".siteorigin-widget-tinymce-container"),d=n.data("editorSettings");if(d.wpautopToggleField){var t=n.closest(".siteorigin-widget-form");e=t.find(d.wpautopToggleField),d.tinymce.wpautop=e.is(":checked")}var a=n.find("textarea"),s=a.attr("id");if(d.tinymce&&(d.tinymce=c.extend({},d.tinymce,{selector:"#"+s,setup:function(i){i.on("change",function(){window.tinymce.get(s).save(),a.trigger("change")}),e&&(e.off("change"),e.on("change",function(){wp.editor.remove(s),d.tinymce.wpautop=e.is(":checked"),wp.editor.initialize(s,d)}))}})),c(document).on("wp-before-tinymce-init",function(i,e){if(e.selector===d.tinymce.selector){var t=n.data("mediaButtons");0===r.find(".wp-media-buttons").length&&r.find(".wp-editor-tabs").before(t.html)}}),c(document).on("tinymce-editor-setup",function(){var i=r.find(".wp-editor-wrap");0<i.length&&!i.hasClass(d.selectedEditor+"-active")&&setTimeout(function(){window.switchEditors.go(s)},10)}),i.remove(s),window.tinymce&&window.tinymce.EditorManager.overrideDefaults({base_url:d.baseURL,suffix:d.suffix}),a.is(":visible"))i.initialize(s,d);else var o=setInterval(function(){a.is(":visible")&&(i.initialize(s,d),clearInterval(o))},500);r.on("click",function(i){var e=c(i.target);if(e.is(".wp-switch-editor")){var t=e.hasClass("switch-tmce")?"tmce":"html";if("tmce"===t){var n=window.tinymce.get(s);if(null!==n){var o=a.val();-1!==o.search("<")&&-1===o.search(">")&&(o=o.replace(/</g,""),a.val(o)),n.setContent(window.switchEditors.wpautop(o))}}d.selectedEditor=t,r.find(".siteorigin-widget-tinymce-selected-editor").val(t)}}),r.data("initialized",!0)}};c(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(){var i=c(this),e=i.closest(".siteorigin-widget-field-repeater-item-form");0<e.length?e.is(":visible")?t(i):e.on("slideToggleOpenComplete",function(){e.is(":visible")&&(t(i),e.off("slideToggleOpenComplete"))}):t(i)}),c(document).on("sortstop",function(i,e){(e.item.is(".siteorigin-widget-field-repeater-item")?e.item.find("> .siteorigin-widget-field-repeater-item-form"):e.item.find(".siteorigin-widget-form")).find(".siteorigin-widget-field-type-tinymce").each(function(){c(this).data("initialized",null),t(c(this))})})}(jQuery);
base/inc/fields/order.class.php CHANGED
@@ -1,55 +1,61 @@
1
- <?php
2
-
3
- /**
4
- * Class SiteOrigin_Widget_Field_Order
5
- */
6
- class SiteOrigin_Widget_Field_Order extends SiteOrigin_Widget_Field_Base {
7
-
8
- protected $options;
9
-
10
- protected function render_field( $value, $instance ) {
11
-
12
- if( ! empty( $this->options ) && ! empty( $value ) ) {
13
- ?><div class="siteorigin-widget-order-items"><?php
14
- foreach( $value as $key ) {
15
- ?>
16
- <div class="siteorigin-widget-order-item" data-value="<?php echo esc_attr( $key ) ?>">
17
- <?php echo esc_html( $this->options[ $key ] ) ?>
18
- </div>
19
- <?php
20
- }
21
- ?></div><?php
22
- }
23
-
24
- ?>
25
- <input
26
- type="hidden"
27
- name="<?php echo esc_attr( $this->element_name ) ?>"
28
- id="<?php echo esc_attr( $this->element_id ) ?>"
29
- class="siteorigin-widget-input"
30
- value="<?php echo esc_attr( implode( ',', $value ) ) ?>">
31
- <?php
32
-
33
- }
34
-
35
- protected function sanitize_field_input( $value, $instance ) {
36
- if( ! is_array( $value ) ) {
37
- $value = explode(',', $value);
38
- $value = array_map( 'trim', $value );
39
- }
40
-
41
- foreach( $value as $i => $k ) {
42
- if( empty( $this->options[$k] ) ) {
43
- unset( $value[ $i ] );
44
- }
45
- }
46
-
47
- return $value;
48
- }
49
-
50
- public function enqueue_scripts() {
51
- wp_enqueue_script( 'so-order-field', plugin_dir_url(__FILE__) . 'js/order-field' . SOW_BUNDLE_JS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-sortable' ), SOW_BUNDLE_VERSION );
52
- wp_enqueue_style( 'so-order-field', plugin_dir_url(__FILE__) . 'css/order-field.css', array( ), SOW_BUNDLE_VERSION );
53
- }
54
-
55
- }
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class SiteOrigin_Widget_Field_Order
5
+ */
6
+ class SiteOrigin_Widget_Field_Order extends SiteOrigin_Widget_Field_Base {
7
+
8
+ protected $options;
9
+
10
+ protected function render_field( $value, $instance ) {
11
+
12
+ $value = $this->sanitize_field_input( $value, $instance );
13
+
14
+ if( ! empty( $this->options ) && ! empty( $value ) ) {
15
+ ?><div class="siteorigin-widget-order-items"><?php
16
+ foreach( $value as $key ) {
17
+ ?>
18
+ <div class="siteorigin-widget-order-item" data-value="<?php echo esc_attr( $key ) ?>">
19
+ <?php echo esc_html( $this->options[ $key ] ) ?>
20
+ </div>
21
+ <?php
22
+ }
23
+ ?></div><?php
24
+ }
25
+
26
+ ?>
27
+ <input
28
+ type="hidden"
29
+ name="<?php echo esc_attr( $this->element_name ) ?>"
30
+ id="<?php echo esc_attr( $this->element_id ) ?>"
31
+ class="siteorigin-widget-input"
32
+ value="<?php echo esc_attr( implode( ',', $value ) ) ?>">
33
+ <?php
34
+
35
+ }
36
+
37
+ protected function sanitize_field_input( $value, $instance ) {
38
+ if( is_string( $value ) ) {
39
+ $value = explode(',', $value);
40
+ $value = array_map( 'trim', $value );
41
+ }
42
+
43
+ if ( ! is_array( $value ) ) {
44
+ $value = array();
45
+ }
46
+
47
+ foreach( $value as $i => $k ) {
48
+ if( empty( $this->options[$k] ) ) {
49
+ unset( $value[ $i ] );
50
+ }
51
+ }
52
+
53
+ return $value;
54
+ }
55
+
56
+ public function enqueue_scripts() {
57
+ wp_enqueue_script( 'so-order-field', plugin_dir_url(__FILE__) . 'js/order-field' . SOW_BUNDLE_JS_SUFFIX . '.js', array( 'jquery', 'jquery-ui-sortable' ), SOW_BUNDLE_VERSION );
58
+ wp_enqueue_style( 'so-order-field', plugin_dir_url(__FILE__) . 'css/order-field.css', array( ), SOW_BUNDLE_VERSION );
59
+ }
60
+
61
+ }
base/inc/routes/siteorigin-widgets-resource.class.php CHANGED
@@ -5,15 +5,6 @@
5
 
6
  class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
7
 
8
- /**
9
- * @var SiteOrigin_Widgets_Widget_Manager
10
- */
11
- private $widgets_manager;
12
-
13
- public function __construct() {
14
- $this->widgets_manager = SiteOrigin_Widgets_Widget_Manager::single();
15
- }
16
-
17
  public function register_routes() {
18
  $version = '1';
19
  $namespace = 'sowb/v' . $version;
@@ -27,6 +18,9 @@ class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
27
  'widgetClass' => array(
28
  'validate_callback' => array( $this, 'validate_widget_class'),
29
  ),
 
 
 
30
  ),
31
  'permission_callback' => array( $this, 'permissions_check' ),
32
  ) );
@@ -90,15 +84,15 @@ class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
90
  */
91
  public function get_widget_form( $request ) {
92
  $widget_class = $request['widgetClass'];
 
93
 
94
- global $wp_widget_factory;
95
-
96
- $widget = ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ? $wp_widget_factory->widgets[ $widget_class ] : false;
97
 
98
  if ( ! empty( $widget ) && is_object( $widget ) && is_subclass_of( $widget, 'SiteOrigin_Widget' ) ) {
 
99
  ob_start();
100
- /* @var $widget SiteOrigin_Widget */
101
- $widget->form( array() );
102
  $widget_form = ob_get_clean();
103
  } else {
104
  $widget_form = new WP_Error( '', 'Invalid widget class.' );
@@ -132,9 +126,7 @@ class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
132
  $widget_class = $request['widgetClass'];
133
  $widget_data = $request['widgetData'];
134
 
135
- global $wp_widget_factory;
136
-
137
- $widget = ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ? $wp_widget_factory->widgets[ $widget_class ] : false;
138
  // This ensures styles are added inline.
139
  add_filter( 'siteorigin_widgets_is_preview', '__return_true' );
140
 
5
 
6
  class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
7
 
 
 
 
 
 
 
 
 
 
8
  public function register_routes() {
9
  $version = '1';
10
  $namespace = 'sowb/v' . $version;
18
  'widgetClass' => array(
19
  'validate_callback' => array( $this, 'validate_widget_class'),
20
  ),
21
+ 'widgetData' => array(
22
+ 'validate_callback' => array( $this, 'validate_widget_data'),
23
+ ),
24
  ),
25
  'permission_callback' => array( $this, 'permissions_check' ),
26
  ) );
84
  */
85
  public function get_widget_form( $request ) {
86
  $widget_class = $request['widgetClass'];
87
+ $widget_data = empty( $request['widgetData'] ) ? array() : $request['widgetData'];
88
 
89
+ /* @var $widget SiteOrigin_Widget */
90
+ $widget = SiteOrigin_Widgets_Widget_Manager::get_widget_instance( $widget_class );
 
91
 
92
  if ( ! empty( $widget ) && is_object( $widget ) && is_subclass_of( $widget, 'SiteOrigin_Widget' ) ) {
93
+ $widget_data = $widget->update( $widget_data, $widget_data );
94
  ob_start();
95
+ $widget->form( $widget_data );
 
96
  $widget_form = ob_get_clean();
97
  } else {
98
  $widget_form = new WP_Error( '', 'Invalid widget class.' );
126
  $widget_class = $request['widgetClass'];
127
  $widget_data = $request['widgetData'];
128
 
129
+ $widget = SiteOrigin_Widgets_Widget_Manager::get_widget_instance( $widget_class );
 
 
130
  // This ensures styles are added inline.
131
  add_filter( 'siteorigin_widgets_is_preview', '__return_true' );
132
 
base/inc/widget-manager.class.php CHANGED
@@ -131,6 +131,28 @@ class SiteOrigin_Widgets_Widget_Manager {
131
  function get_registered_widgets() {
132
  return $this->registered;
133
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
  SiteOrigin_Widgets_Widget_Manager::single();
136
 
131
  function get_registered_widgets() {
132
  return $this->registered;
133
  }
134
+
135
+ /**
136
+ * Get the registered widget instance by it's class name or the hash generated when it was registered.
137
+ *
138
+ * @param $class_or_hash
139
+ *
140
+ * @return array
141
+ *
142
+ */
143
+ static function get_widget_instance( $class_or_hash ) {
144
+ global $wp_widget_factory;
145
+ if ( isset( $wp_widget_factory->widgets[ $class_or_hash ] ) ) {
146
+ return $wp_widget_factory->widgets[ $class_or_hash ];
147
+ } else {
148
+ foreach ( $wp_widget_factory->widgets as $widget_instance ) {
149
+ if ( $widget_instance instanceof $class_or_hash ) {
150
+ return $widget_instance;
151
+ }
152
+ }
153
+ }
154
+ return null;
155
+ }
156
  }
157
  SiteOrigin_Widgets_Widget_Manager::single();
158
 
base/siteorigin-widget.class.php CHANGED
@@ -335,6 +335,19 @@ abstract class SiteOrigin_Widget extends WP_Widget {
335
  global $wp_customize;
336
  return is_a( $wp_customize, 'WP_Customize_Manager' ) && $wp_customize->is_preview();
337
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
338
 
339
  /**
340
  * Get an array of variables to make available to templates. By default, just return an array. Should be overwritten by child widgets.
@@ -1329,11 +1342,12 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1329
  function is_preview( $instance = array() ) {
1330
  // Check if the instance is a preview
1331
  if( !empty( $instance[ 'is_preview' ] ) ) return true;
1332
-
1333
  // Check if the general request is a preview
1334
  $is_preview =
1335
  is_preview() || // Is this a standard preview
1336
  $this->is_customize_preview() || // Is this a customizer preview
 
1337
  !empty( $_GET['siteorigin_panels_live_editor'] ) || // Is this a Page Builder live editor request
1338
  ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ) || // Is this a Page Builder content ajax request
1339
  ! empty( $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] ); // Is this a Page Builder preview render.
335
  global $wp_customize;
336
  return is_a( $wp_customize, 'WP_Customize_Manager' ) && $wp_customize->is_preview();
337
  }
338
+
339
+ private function is_block_editor_page() {
340
+ // This is for the Gutenberg plugin.
341
+ $is_gutenberg_page = function_exists( 'is_gutenberg_page' ) && is_gutenberg_page();
342
+ // This is for WP 5 with the integrated block editor.
343
+ $is_block_editor = false;
344
+ $current_screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
345
+ if ( ! empty( $current_screen ) && method_exists( $current_screen, 'is_block_editor' ) ) {
346
+ $is_block_editor = $current_screen->is_block_editor();
347
+ }
348
+
349
+ return $is_block_editor || $is_gutenberg_page;
350
+ }
351
 
352
  /**
353
  * Get an array of variables to make available to templates. By default, just return an array. Should be overwritten by child widgets.
1342
  function is_preview( $instance = array() ) {
1343
  // Check if the instance is a preview
1344
  if( !empty( $instance[ 'is_preview' ] ) ) return true;
1345
+
1346
  // Check if the general request is a preview
1347
  $is_preview =
1348
  is_preview() || // Is this a standard preview
1349
  $this->is_customize_preview() || // Is this a customizer preview
1350
+ $this->is_block_editor_page() || // Is this a block editor page
1351
  !empty( $_GET['siteorigin_panels_live_editor'] ) || // Is this a Page Builder live editor request
1352
  ( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ) || // Is this a Page Builder content ajax request
1353
  ! empty( $GLOBALS[ 'SITEORIGIN_PANELS_PREVIEW_RENDER' ] ); // Is this a Page Builder preview render.
compat/block-editor/widget-block.js CHANGED
@@ -27,8 +27,8 @@
27
 
28
  category: 'widgets',
29
 
30
- keywords: [_.reduce( sowbBlockEditorAdmin.widgets, function ( keywords, widgetObj ) {
31
- if ( !_.isEmpty( keywords ) ) {
32
  keywords += ',';
33
  }
34
  return keywords + widgetObj.name;
@@ -91,11 +91,7 @@
91
  } );
92
  $mainForm.data( 'backupDisabled', true );
93
  $mainForm.sowSetupForm();
94
- if ( props.attributes.widgetData ) {
95
- // If we call `setWidgetFormValues` with the last parameter ( `triggerChange` ) set to false,
96
- // it won't show the correct values for some fields e.g. color and media fields.
97
- sowbForms.setWidgetFormValues( $mainForm, props.attributes.widgetData );
98
- } else {
99
  props.setAttributes( { widgetData: sowbForms.getWidgetFormValues( $mainForm ) } );
100
  }
101
  $mainForm.on( 'change', function () {
@@ -142,7 +138,8 @@
142
  xhr.setRequestHeader( 'X-WP-Nonce', sowbBlockEditorAdmin.nonce );
143
  },
144
  data: {
145
- widgetClass: props.attributes.widgetClass
 
146
  }
147
  } )
148
  .then( function( widgetForm ) {
27
 
28
  category: 'widgets',
29
 
30
+ keywords: [sowbBlockEditorAdmin.widgets.reduce( function ( keywords, widgetObj ) {
31
+ if ( keywords.length > 0 ) {
32
  keywords += ',';
33
  }
34
  return keywords + widgetObj.name;
91
  } );
92
  $mainForm.data( 'backupDisabled', true );
93
  $mainForm.sowSetupForm();
94
+ if ( ! props.attributes.widgetData ) {
 
 
 
 
95
  props.setAttributes( { widgetData: sowbForms.getWidgetFormValues( $mainForm ) } );
96
  }
97
  $mainForm.on( 'change', function () {
138
  xhr.setRequestHeader( 'X-WP-Nonce', sowbBlockEditorAdmin.nonce );
139
  },
140
  data: {
141
+ widgetClass: props.attributes.widgetClass,
142
+ widgetData: props.attributes.widgetData,
143
  }
144
  } )
145
  .then( function( widgetForm ) {
compat/block-editor/widget-block.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,i,n,o,s){var r=n.createElement,d=t.registerBlockType,a=e.BlockControls,l=o.SelectControl,w=s.withState,g=o.Toolbar,c=o.IconButton,u=o.Placeholder,m=o.Spinner,b=i.__;d("sowb/widget-block",{title:b("SiteOrigin Widget","so-widgets-bundle"),description:b("Select a SiteOrigin widget from the dropdown.","so-widgets-bundle"),icon:function(){return r("span",{className:"widget-icon so-widget-icon so-block-editor-icon"})},category:"widgets",keywords:[_.reduce(sowbBlockEditorAdmin.widgets,function(e,t){return _.isEmpty(e)||(e+=","),e+t.name},"")],supports:{html:!1},attributes:{widgetClass:{type:"string"},widgetData:{type:"object"}},edit:w({editing:!1,formInitialized:!1,previewInitialized:!1,widgetFormHtml:"",widgetSettingsChanged:!1,widgetPreviewHtml:""})(function(i){function n(){i.setState({editing:!1,previewInitialized:!1})}if(i.editing||!i.attributes.widgetClass){var e=[];sowbBlockEditorAdmin.widgets&&(sowbBlockEditorAdmin.widgets.sort(function(e,t){return e.name<t.name?-1:e.name>t.name?1:0}),(e=sowbBlockEditorAdmin.widgets.map(function(e){return{value:e.class,label:e.name}})).unshift({value:"",label:b("Select widget type","so-widgets-bundle")}));var t=i.attributes.widgetClass&&!i.widgetFormHtml;t&&$.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/forms",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:i.attributes.widgetClass}}).then(function(e){i.setState({widgetFormHtml:e})});var o=i.widgetFormHtml?i.widgetFormHtml:"";return[!!o&&r(a,{key:"controls"},r(g,null,r(c,{className:"components-icon-button components-toolbar__control",label:b("Preview widget.","so-widgets-bundle"),onClick:n,icon:"visibility"}))),r(u,{key:"placeholder",className:"so-widget-placeholder",label:b("SiteOrigin Widget","so-widgets-bundle"),instructions:b("Select the type of widget you want to use:","so-widgets-bundle")},i.loadingWidgets||t?r(m):r("div",{className:"so-widget-block-container"},r(l,{options:e,value:i.attributes.widgetClass,onChange:function(e){if(""!==e){if(i.widgetSettingsChanged&&!confirm(sowbBlockEditorAdmin.confirmChangeWidget))return!1;i.setAttributes({widgetClass:e,widgetData:null}),i.setState({editing:!0,widgetFormHtml:null,formInitialized:!1,widgetSettingsChanged:!1,widgetPreviewHtml:null,previewInitialized:!1})}}}),r("div",{className:"so-widget-block-form-container",dangerouslySetInnerHTML:{__html:o},ref:function(e){var t=$(e).find(".siteorigin-widget-form-main");0<t.length&&!i.formInitialized&&(t.siblings(".siteorigin-widget-preview").find("> a").on("click",function(e){e.stopImmediatePropagation(),n()}),t.data("backupDisabled",!0),t.sowSetupForm(),i.attributes.widgetData?sowbForms.setWidgetFormValues(t,i.attributes.widgetData):i.setAttributes({widgetData:sowbForms.getWidgetFormValues(t)}),t.on("change",function(){i.setAttributes({widgetData:sowbForms.getWidgetFormValues(t)}),i.setState({widgetSettingsChanged:!0,widgetPreviewHtml:null,previewInitialized:!1})}),i.setState({formInitialized:!0}))}})))]}var s=!i.loadingWidgets&&!i.editing&&!i.widgetPreviewHtml&&i.attributes.widgetClass;s&&$.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/previews",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:i.attributes.widgetClass,widgetData:i.attributes.widgetData||{}}}).then(function(e){i.setState({widgetPreviewHtml:e,previewInitialized:!1})});var d=i.widgetPreviewHtml?i.widgetPreviewHtml:"";return[r(a,{key:"controls"},r(g,null,r(c,{className:"components-icon-button components-toolbar__control",label:b("Edit widget.","so-widgets-bundle"),onClick:function(){i.setState({editing:!0,formInitialized:!1})},icon:"edit"}))),r("div",{key:"preview",className:"so-widget-preview-container"},s?r("div",{className:"so-widgets-spinner-container"},r("span",null,r(m))):r("div",{dangerouslySetInnerHTML:{__html:d},ref:function(){i.previewInitialized||($(window.sowb).trigger("setup_widgets",{preview:!0}),i.setState({previewInitialized:!0}))}}))]}),save:function(){return null}})}(window.wp.editor,window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.compose);
1
+ !function(e,t,i,n,o,s){var a=n.createElement,d=t.registerBlockType,r=e.BlockControls,l=o.SelectControl,w=s.withState,g=o.Toolbar,c=o.IconButton,u=o.Placeholder,m=o.Spinner,b=i.__;d("sowb/widget-block",{title:b("SiteOrigin Widget","so-widgets-bundle"),description:b("Select a SiteOrigin widget from the dropdown.","so-widgets-bundle"),icon:function(){return a("span",{className:"widget-icon so-widget-icon so-block-editor-icon"})},category:"widgets",keywords:[sowbBlockEditorAdmin.widgets.reduce(function(e,t){return 0<e.length&&(e+=","),e+t.name},"")],supports:{html:!1},attributes:{widgetClass:{type:"string"},widgetData:{type:"object"}},edit:w({editing:!1,formInitialized:!1,previewInitialized:!1,widgetFormHtml:"",widgetSettingsChanged:!1,widgetPreviewHtml:""})(function(i){function n(){i.setState({editing:!1,previewInitialized:!1})}if(i.editing||!i.attributes.widgetClass){var e=[];sowbBlockEditorAdmin.widgets&&(sowbBlockEditorAdmin.widgets.sort(function(e,t){return e.name<t.name?-1:e.name>t.name?1:0}),(e=sowbBlockEditorAdmin.widgets.map(function(e){return{value:e.class,label:e.name}})).unshift({value:"",label:b("Select widget type","so-widgets-bundle")}));var t=i.attributes.widgetClass&&!i.widgetFormHtml;t&&$.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/forms",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:i.attributes.widgetClass,widgetData:i.attributes.widgetData}}).then(function(e){i.setState({widgetFormHtml:e})});var o=i.widgetFormHtml?i.widgetFormHtml:"";return[!!o&&a(r,{key:"controls"},a(g,null,a(c,{className:"components-icon-button components-toolbar__control",label:b("Preview widget.","so-widgets-bundle"),onClick:n,icon:"visibility"}))),a(u,{key:"placeholder",className:"so-widget-placeholder",label:b("SiteOrigin Widget","so-widgets-bundle"),instructions:b("Select the type of widget you want to use:","so-widgets-bundle")},i.loadingWidgets||t?a(m):a("div",{className:"so-widget-block-container"},a(l,{options:e,value:i.attributes.widgetClass,onChange:function(e){if(""!==e){if(i.widgetSettingsChanged&&!confirm(sowbBlockEditorAdmin.confirmChangeWidget))return!1;i.setAttributes({widgetClass:e,widgetData:null}),i.setState({editing:!0,widgetFormHtml:null,formInitialized:!1,widgetSettingsChanged:!1,widgetPreviewHtml:null,previewInitialized:!1})}}}),a("div",{className:"so-widget-block-form-container",dangerouslySetInnerHTML:{__html:o},ref:function(e){var t=$(e).find(".siteorigin-widget-form-main");0<t.length&&!i.formInitialized&&(t.siblings(".siteorigin-widget-preview").find("> a").on("click",function(e){e.stopImmediatePropagation(),n()}),t.data("backupDisabled",!0),t.sowSetupForm(),i.attributes.widgetData||i.setAttributes({widgetData:sowbForms.getWidgetFormValues(t)}),t.on("change",function(){i.setAttributes({widgetData:sowbForms.getWidgetFormValues(t)}),i.setState({widgetSettingsChanged:!0,widgetPreviewHtml:null,previewInitialized:!1})}),i.setState({formInitialized:!0}))}})))]}var s=!i.loadingWidgets&&!i.editing&&!i.widgetPreviewHtml&&i.attributes.widgetClass;s&&$.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/previews",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:i.attributes.widgetClass,widgetData:i.attributes.widgetData||{}}}).then(function(e){i.setState({widgetPreviewHtml:e,previewInitialized:!1})});var d=i.widgetPreviewHtml?i.widgetPreviewHtml:"";return[a(r,{key:"controls"},a(g,null,a(c,{className:"components-icon-button components-toolbar__control",label:b("Edit widget.","so-widgets-bundle"),onClick:function(){i.setState({editing:!0,formInitialized:!1})},icon:"edit"}))),a("div",{key:"preview",className:"so-widget-preview-container"},s?a("div",{className:"so-widgets-spinner-container"},a("span",null,a(m))):a("div",{dangerouslySetInnerHTML:{__html:d},ref:function(){i.previewInitialized||($(window.sowb).trigger("setup_widgets",{preview:!0}),i.setState({previewInitialized:!0}))}}))]}),save:function(){return null}})}(window.wp.editor,window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.compose);
lang/so-widgets-bundle.pot CHANGED
@@ -80,7 +80,7 @@ msgstr ""
80
  msgid "Invalid post."
81
  msgstr ""
82
 
83
- #: base/inc/actions.php:50, base/siteorigin-widget.class.php:642
84
  msgid "Widget Preview"
85
  msgstr ""
86
 
@@ -165,11 +165,11 @@ msgstr ""
165
  msgid "Use theme font"
166
  msgstr ""
167
 
168
- #: base/inc/fields/icon.class.php:27
169
  msgid "Choose Icon"
170
  msgstr ""
171
 
172
- #: base/inc/fields/icon.class.php:30, base/inc/fields/media.class.php:111
173
  msgid "Remove"
174
  msgstr ""
175
 
@@ -409,7 +409,7 @@ msgstr ""
409
  msgid "Widgets Bundle Post Meta Data"
410
  msgstr ""
411
 
412
- #: base/inc/routes/siteorigin-widgets-resource.class.php:61, so-widgets-bundle.php:374, so-widgets-bundle.php:397, so-widgets-bundle.php:440
413
  msgid "Insufficient permissions."
414
  msgstr ""
415
 
@@ -529,39 +529,39 @@ msgstr ""
529
  msgid "previous slide"
530
  msgstr ""
531
 
532
- #: base/siteorigin-widget.class.php:486
533
  msgid "Preview"
534
  msgstr ""
535
 
536
- #: base/siteorigin-widget.class.php:491
537
  msgid "Help"
538
  msgstr ""
539
 
540
- #: base/siteorigin-widget.class.php:557
541
  msgid "This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page."
542
  msgstr ""
543
 
544
- #: base/siteorigin-widget.class.php:558
545
  msgid "You will only need to do this once."
546
  msgstr ""
547
 
548
- #: base/siteorigin-widget.class.php:585
549
  msgid "Are you sure?"
550
  msgstr ""
551
 
552
- #: base/siteorigin-widget.class.php:587
553
  msgid "There is a newer version of this widget's content available."
554
  msgstr ""
555
 
556
- #: base/siteorigin-widget.class.php:588, base/siteorigin-widget.class.php:592
557
  msgid "Restore"
558
  msgstr ""
559
 
560
- #: base/siteorigin-widget.class.php:589
561
  msgid "Dismiss"
562
  msgstr ""
563
 
564
- #: base/siteorigin-widget.class.php:591
565
  msgid "Clicking %s will replace the current widget contents. You can revert by refreshing the page before updating."
566
  msgstr ""
567
 
80
  msgid "Invalid post."
81
  msgstr ""
82
 
83
+ #: base/inc/actions.php:50, base/siteorigin-widget.class.php:655
84
  msgid "Widget Preview"
85
  msgstr ""
86
 
165
  msgid "Use theme font"
166
  msgstr ""
167
 
168
+ #: base/inc/fields/icon.class.php:33
169
  msgid "Choose Icon"
170
  msgstr ""
171
 
172
+ #: base/inc/fields/icon.class.php:36, base/inc/fields/media.class.php:111
173
  msgid "Remove"
174
  msgstr ""
175
 
409
  msgid "Widgets Bundle Post Meta Data"
410
  msgstr ""
411
 
412
+ #: base/inc/routes/siteorigin-widgets-resource.class.php:55, so-widgets-bundle.php:374, so-widgets-bundle.php:397, so-widgets-bundle.php:440
413
  msgid "Insufficient permissions."
414
  msgstr ""
415
 
529
  msgid "previous slide"
530
  msgstr ""
531
 
532
+ #: base/siteorigin-widget.class.php:499
533
  msgid "Preview"
534
  msgstr ""
535
 
536
+ #: base/siteorigin-widget.class.php:504
537
  msgid "Help"
538
  msgstr ""
539
 
540
+ #: base/siteorigin-widget.class.php:570
541
  msgid "This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page."
542
  msgstr ""
543
 
544
+ #: base/siteorigin-widget.class.php:571
545
  msgid "You will only need to do this once."
546
  msgstr ""
547
 
548
+ #: base/siteorigin-widget.class.php:598
549
  msgid "Are you sure?"
550
  msgstr ""
551
 
552
+ #: base/siteorigin-widget.class.php:600
553
  msgid "There is a newer version of this widget's content available."
554
  msgstr ""
555
 
556
+ #: base/siteorigin-widget.class.php:601, base/siteorigin-widget.class.php:605
557
  msgid "Restore"
558
  msgstr ""
559
 
560
+ #: base/siteorigin-widget.class.php:602
561
  msgid "Dismiss"
562
  msgstr ""
563
 
564
+ #: base/siteorigin-widget.class.php:604
565
  msgid "Clicking %s will replace the current widget contents. You can revert by refreshing the page before updating."
566
  msgstr ""
567
 
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: 5.0
5
- Stable tag: 1.14.0
6
- Build time: 2019-01-04T16:02:45-08:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
@@ -65,6 +65,16 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
65
 
66
  == Changelog ==
67
 
 
 
 
 
 
 
 
 
 
 
68
  = 1.14.0 - 4 January 2019 =
69
  * Accordion: allow multiple panels with the same title.
70
  * Actions when widgets' CSS files are created/deleted.
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: 5.0
5
+ Stable tag: 1.14.1
6
+ Build time: 2019-01-09T13:17:13-08:00
7
  License: GPLv3 or later
8
  Contributors: gpriday, braam-genis
9
  Donate link: https://siteorigin.com/downloads/contribution/
65
 
66
  == Changelog ==
67
 
68
+ = 1.14.1 - 9 January 2019 =
69
+ * Icon field: Set correct value of currently selected icon for non-FA icons.
70
+ * Icon field: Avoid requiring that third party icon families include a `filter.php` file.
71
+ * Widget block: Use JS array reduce function instead of lodash.
72
+ * Allow widgets registered by instance.
73
+ * Multi-measurement field: Fix layout.
74
+ * Block editor: Send widgetData when fetching widget forms.
75
+ * Tinymce field: Prevent JS console errors for hidden fields.
76
+ * Order field: Additional sanitization before rendering.
77
+
78
  = 1.14.0 - 4 January 2019 =
79
  * Accordion: allow multiple panels with the same title.
80
  * Actions when widgets' CSS files are created/deleted.
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.14.0
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.14.0');
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.14.1
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.14.1');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set