SiteOrigin Widgets Bundle - Version 1.18.2

Version Description

  • 27 April 2021 =
  • SiteOrigin Widget Block: Ensured icons are enqueued.
  • Slider: Only apply foreground height if a background image is set.
Download this release

Release Info

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

Code changes from version 1.18.1 to 1.18.2

base/inc/routes/siteorigin-widgets-resource.class.php CHANGED
@@ -148,7 +148,19 @@ class SiteOrigin_Widgets_Resource extends WP_REST_Controller {
148
  /* @var $widget SiteOrigin_Widget */
149
  $instance = $widget->update( $widget_data, $widget_data );
150
  $widget->widget( array(), $instance );
151
- $rendered_widget = ob_get_clean();
 
 
 
 
 
 
 
 
 
 
 
 
152
  } else {
153
  if ( empty( $valid_widget_class ) ) {
154
  $rendered_widget = new WP_Error(
148
  /* @var $widget SiteOrigin_Widget */
149
  $instance = $widget->update( $widget_data, $widget_data );
150
  $widget->widget( array(), $instance );
151
+ $rendered_widget = array();
152
+ $rendered_widget['html'] = ob_get_clean();
153
+
154
+ // Check if this widget loaded any icons, and if it has, store them.
155
+ $styles = wp_styles();
156
+ if ( ! empty( $styles->queue ) ) {
157
+ $rendered_widget['icons'] = array();
158
+ foreach ( $styles->queue as $style ) {
159
+ if ( strpos( $style, 'siteorigin-widget-icon-font' ) !== false ) {
160
+ $rendered_widget['icons'][] = $style;
161
+ }
162
+ }
163
+ }
164
  } else {
165
  if ( empty( $valid_widget_class ) ) {
166
  $rendered_widget = new WP_Error(
compat/block-editor/widget-block.js CHANGED
@@ -48,6 +48,9 @@
48
  widgetHtml: {
49
  type: 'string',
50
  },
 
 
 
51
  },
52
 
53
  edit: withState( {
@@ -220,7 +223,10 @@
220
  props.attributes.widgetClass &&
221
  props.attributes.widgetData;
222
  if ( loadWidgetPreview ) {
223
- props.setAttributes( { widgetHtml: null } );
 
 
 
224
  jQuery.post( {
225
  url: sowbBlockEditorAdmin.restUrl + 'sowb/v1/widgets/previews',
226
  beforeSend: function ( xhr ) {
@@ -233,11 +239,14 @@
233
  } )
234
  .done( function( widgetPreview ) {
235
  props.setState( {
236
- widgetPreviewHtml: widgetPreview,
237
  previewInitialized: false,
238
  } );
239
 
240
- props.setAttributes( { widgetHtml: widgetPreview } );
 
 
 
241
  } )
242
  .fail( function ( response ) {
243
 
48
  widgetHtml: {
49
  type: 'string',
50
  },
51
+ widgetIcons: {
52
+ type: 'array',
53
+ },
54
  },
55
 
56
  edit: withState( {
223
  props.attributes.widgetClass &&
224
  props.attributes.widgetData;
225
  if ( loadWidgetPreview ) {
226
+ props.setAttributes( {
227
+ widgetHtml: null,
228
+ widgetIcons: null
229
+ } );
230
  jQuery.post( {
231
  url: sowbBlockEditorAdmin.restUrl + 'sowb/v1/widgets/previews',
232
  beforeSend: function ( xhr ) {
239
  } )
240
  .done( function( widgetPreview ) {
241
  props.setState( {
242
+ widgetPreviewHtml: widgetPreview.html,
243
  previewInitialized: false,
244
  } );
245
 
246
+ props.setAttributes( {
247
+ widgetHtml: widgetPreview.html,
248
+ widgetIcons: widgetPreview.icons
249
+ } );
250
  } )
251
  .fail( function ( response ) {
252
 
compat/block-editor/widget-block.min.js CHANGED
@@ -1 +1 @@
1
- !function(e,t,i,n,o,s,d){var r=n.createElement,a=t.registerBlockType,l=d.BlockControls,w=o.SelectControl,g=s.withState,c=o.Toolbar,u=o.ToolbarButton,m=o.Placeholder,b=o.Spinner,p=i.__;a("sowb/widget-block",{title:p("SiteOrigin Widget","so-widgets-bundle"),description:p("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:[sowbBlockEditorAdmin.widgets.reduce((function(e,t){return e.length>0&&(e+=","),e+t.name}),"")],supports:{html:!1},attributes:{widgetClass:{type:"string"},widgetData:{type:"object"},widgetHtml:{type:"string"}},edit:g({editing:!1,formInitialized:!1,previewInitialized:!1,widgetFormHtml:"",widgetSettingsChanged:!1,widgetPreviewHtml:""})((function(e){function t(){e.setState({editing:!1,previewInitialized:!1})}if(!e.editing&&e.attributes.widgetClass&&e.attributes.widgetData){var i=!e.loadingWidgets&&!e.editing&&!e.widgetPreviewHtml&&e.attributes.widgetClass&&e.attributes.widgetData;i&&(e.setAttributes({widgetHtml:null}),jQuery.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/previews",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass,widgetData:e.attributes.widgetData||{}}}).done((function(t){e.setState({widgetPreviewHtml:t,previewInitialized:!1}),e.setAttributes({widgetHtml:t})})).fail((function(t){var i="";t.hasOwnProperty("responseJSON")?i=t.responseJSON.message:t.hasOwnProperty("responseText")&&(i=t.responseText),e.setState({widgetPreviewHtml:"<div>"+i+"</div>"})})));var n=e.widgetPreviewHtml?e.widgetPreviewHtml:"";return[r(l,{key:"controls"},r(c,{label:p("Preview widget.","so-widgets-bundle")},r(u,{className:"components-icon-button components-toolbar__control",label:p("Edit widget.","so-widgets-bundle"),onClick:function(){e.setState({editing:!0,formInitialized:!1})},icon:"edit"}))),r("div",{key:"preview",className:"so-widget-preview-container"},i?r("div",{className:"so-widgets-spinner-container"},r("span",null,r(b))):r("div",{dangerouslySetInnerHTML:{__html:n},ref:function(){e.previewInitialized||(jQuery(window.sowb).trigger("setup_widgets",{preview:!0}),e.setState({previewInitialized:!0}))}}))]}var o=[];sowbBlockEditorAdmin.widgets&&(o=sowbBlockEditorAdmin.widgets.map((function(e){return{value:e.class,label:e.name}}))).unshift({value:"",label:p("Select widget type","so-widgets-bundle")});var s=e.attributes.widgetClass&&!e.widgetFormHtml;s&&jQuery.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/forms",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass,widgetData:e.attributes.widgetData}}).done((function(t){e.setState({widgetFormHtml:t})})).fail((function(t){var i="";t.hasOwnProperty("responseJSON")?i=t.responseJSON.message:t.hasOwnProperty("responseText")&&(i=t.responseText),e.setState({widgetFormHtml:"<div>"+i+"</div>"})}));var d=e.widgetFormHtml?e.widgetFormHtml:"";return[!!d&&r(l,{key:"controls"},r(c,{label:p("Preview widget.","so-widgets-bundle")},r(u,{className:"components-icon-button components-toolbar__control",label:p("Preview widget.","so-widgets-bundle"),onClick:t,icon:"visibility"}))),r(m,{key:"placeholder",className:"so-widget-placeholder",label:p("SiteOrigin Widget","so-widgets-bundle"),instructions:p("Select the type of widget you want to use:","so-widgets-bundle")},e.loadingWidgets||s?r(b):r("div",{className:"so-widget-block-container"},r(w,{options:o,value:e.attributes.widgetClass,onChange:function(t){if(""!==t){if(e.widgetSettingsChanged&&!confirm(sowbBlockEditorAdmin.confirmChangeWidget))return!1;e.setAttributes({widgetClass:t,widgetData:null}),e.setState({editing:!0,widgetFormHtml:null,formInitialized:!1,widgetSettingsChanged:!1,widgetPreviewHtml:null,previewInitialized:!1})}}}),r("div",{className:"so-widget-block-form-container",dangerouslySetInnerHTML:{__html:d},ref:function(i){var n=jQuery(i).find(".siteorigin-widget-form-main");n.length>0&&!e.formInitialized&&(n.siblings(".siteorigin-widget-preview").find("> a").on("click",(function(e){e.stopImmediatePropagation(),t()})),n.data("backupDisabled",!0),n.sowSetupForm(),e.attributes.widgetData?sowbForms.setWidgetFormValues(n,e.attributes.widgetData):e.setAttributes({widgetData:sowbForms.getWidgetFormValues(n)}),n.on("change",(function(){e.setAttributes({widgetData:sowbForms.getWidgetFormValues(n)}),e.setState({widgetSettingsChanged:!0,widgetPreviewHtml:null,previewInitialized:!1})})),e.setState({formInitialized:!0}))}})))]})),save:function(e){return"object"==e.attributes&&e.attributes.hasOwnProperty("widgetHtml")?React.createElement(wp.element.RawHTML,null,attributes.widgetHtml):null}})}(window.wp.editor,window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.compose,window.wp.blockEditor);
1
+ !function(e,t,i,n,o,s,d){var r=n.createElement,a=t.registerBlockType,l=d.BlockControls,w=o.SelectControl,g=s.withState,c=o.Toolbar,u=o.ToolbarButton,m=o.Placeholder,b=o.Spinner,p=i.__;a("sowb/widget-block",{title:p("SiteOrigin Widget","so-widgets-bundle"),description:p("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:[sowbBlockEditorAdmin.widgets.reduce((function(e,t){return e.length>0&&(e+=","),e+t.name}),"")],supports:{html:!1},attributes:{widgetClass:{type:"string"},widgetData:{type:"object"},widgetHtml:{type:"string"},widgetIcons:{type:"array"}},edit:g({editing:!1,formInitialized:!1,previewInitialized:!1,widgetFormHtml:"",widgetSettingsChanged:!1,widgetPreviewHtml:""})((function(e){function t(){e.setState({editing:!1,previewInitialized:!1})}if(!e.editing&&e.attributes.widgetClass&&e.attributes.widgetData){var i=!e.loadingWidgets&&!e.editing&&!e.widgetPreviewHtml&&e.attributes.widgetClass&&e.attributes.widgetData;i&&(e.setAttributes({widgetHtml:null,widgetIcons:null}),jQuery.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/previews",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass,widgetData:e.attributes.widgetData||{}}}).done((function(t){e.setState({widgetPreviewHtml:t.html,previewInitialized:!1}),e.setAttributes({widgetHtml:t.html,widgetIcons:t.icons})})).fail((function(t){var i="";t.hasOwnProperty("responseJSON")?i=t.responseJSON.message:t.hasOwnProperty("responseText")&&(i=t.responseText),e.setState({widgetPreviewHtml:"<div>"+i+"</div>"})})));var n=e.widgetPreviewHtml?e.widgetPreviewHtml:"";return[r(l,{key:"controls"},r(c,{label:p("Preview widget.","so-widgets-bundle")},r(u,{className:"components-icon-button components-toolbar__control",label:p("Edit widget.","so-widgets-bundle"),onClick:function(){e.setState({editing:!0,formInitialized:!1})},icon:"edit"}))),r("div",{key:"preview",className:"so-widget-preview-container"},i?r("div",{className:"so-widgets-spinner-container"},r("span",null,r(b))):r("div",{dangerouslySetInnerHTML:{__html:n},ref:function(){e.previewInitialized||(jQuery(window.sowb).trigger("setup_widgets",{preview:!0}),e.setState({previewInitialized:!0}))}}))]}var o=[];sowbBlockEditorAdmin.widgets&&(o=sowbBlockEditorAdmin.widgets.map((function(e){return{value:e.class,label:e.name}}))).unshift({value:"",label:p("Select widget type","so-widgets-bundle")});var s=e.attributes.widgetClass&&!e.widgetFormHtml;s&&jQuery.post({url:sowbBlockEditorAdmin.restUrl+"sowb/v1/widgets/forms",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",sowbBlockEditorAdmin.nonce)},data:{widgetClass:e.attributes.widgetClass,widgetData:e.attributes.widgetData}}).done((function(t){e.setState({widgetFormHtml:t})})).fail((function(t){var i="";t.hasOwnProperty("responseJSON")?i=t.responseJSON.message:t.hasOwnProperty("responseText")&&(i=t.responseText),e.setState({widgetFormHtml:"<div>"+i+"</div>"})}));var d=e.widgetFormHtml?e.widgetFormHtml:"";return[!!d&&r(l,{key:"controls"},r(c,{label:p("Preview widget.","so-widgets-bundle")},r(u,{className:"components-icon-button components-toolbar__control",label:p("Preview widget.","so-widgets-bundle"),onClick:t,icon:"visibility"}))),r(m,{key:"placeholder",className:"so-widget-placeholder",label:p("SiteOrigin Widget","so-widgets-bundle"),instructions:p("Select the type of widget you want to use:","so-widgets-bundle")},e.loadingWidgets||s?r(b):r("div",{className:"so-widget-block-container"},r(w,{options:o,value:e.attributes.widgetClass,onChange:function(t){if(""!==t){if(e.widgetSettingsChanged&&!confirm(sowbBlockEditorAdmin.confirmChangeWidget))return!1;e.setAttributes({widgetClass:t,widgetData:null}),e.setState({editing:!0,widgetFormHtml:null,formInitialized:!1,widgetSettingsChanged:!1,widgetPreviewHtml:null,previewInitialized:!1})}}}),r("div",{className:"so-widget-block-form-container",dangerouslySetInnerHTML:{__html:d},ref:function(i){var n=jQuery(i).find(".siteorigin-widget-form-main");n.length>0&&!e.formInitialized&&(n.siblings(".siteorigin-widget-preview").find("> a").on("click",(function(e){e.stopImmediatePropagation(),t()})),n.data("backupDisabled",!0),n.sowSetupForm(),e.attributes.widgetData?sowbForms.setWidgetFormValues(n,e.attributes.widgetData):e.setAttributes({widgetData:sowbForms.getWidgetFormValues(n)}),n.on("change",(function(){e.setAttributes({widgetData:sowbForms.getWidgetFormValues(n)}),e.setState({widgetSettingsChanged:!0,widgetPreviewHtml:null,previewInitialized:!1})})),e.setState({formInitialized:!0}))}})))]})),save:function(e){return"object"==e.attributes&&e.attributes.hasOwnProperty("widgetHtml")?React.createElement(wp.element.RawHTML,null,attributes.widgetHtml):null}})}(window.wp.editor,window.wp.blocks,window.wp.i18n,window.wp.element,window.wp.components,window.wp.compose,window.wp.blockEditor);
compat/block-editor/widget-block.php CHANGED
@@ -132,6 +132,17 @@ class SiteOrigin_Widgets_Bundle_Widget_Block {
132
  } else {
133
  $widget->generate_and_enqueue_instance_styles( $instance );
134
  $widget->enqueue_frontend_scripts( $instance );
 
 
 
 
 
 
 
 
 
 
 
135
  echo $attributes['widgetHtml'];
136
  }
137
 
132
  } else {
133
  $widget->generate_and_enqueue_instance_styles( $instance );
134
  $widget->enqueue_frontend_scripts( $instance );
135
+
136
+ // Check if this widget uses any icons that need to be enqueued.
137
+ if ( ! empty( $attributes['widgetIcons'] ) ) {
138
+ $widget_icon_families = apply_filters('siteorigin_widgets_icon_families', array() );
139
+ foreach ( $attributes['widgetIcons'] as $icon_font ) {
140
+ if ( ! wp_style_is( $icon_font ) ) {
141
+ $font_family = explode( 'siteorigin-widget-icon-font-', $icon_font )[1];
142
+ wp_enqueue_style( $icon_font, $widget_icon_families[ $font_family ]['style_uri'] );
143
+ }
144
+ }
145
+ }
146
  echo $attributes['widgetHtml'];
147
  }
148
 
lang/so-widgets-bundle.pot CHANGED
@@ -252,7 +252,7 @@ msgstr ""
252
  msgid "You need to select a widget type before you'll see anything here. :)"
253
  msgstr ""
254
 
255
- #: compat/block-editor/widget-block.php:144
256
  msgid "Invalid widget class %s. Please make sure the widget has been activated in %sSiteOrigin Widgets%s."
257
  msgstr ""
258
 
@@ -2416,7 +2416,7 @@ msgstr ""
2416
  msgid "Controls"
2417
  msgstr ""
2418
 
2419
- #: widgets/slider/slider.php:327
2420
  msgid "Add a Lightbox to your image slides with %sSiteOrigin Premium%s"
2421
  msgstr ""
2422
 
252
  msgid "You need to select a widget type before you'll see anything here. :)"
253
  msgstr ""
254
 
255
+ #: compat/block-editor/widget-block.php:155
256
  msgid "Invalid widget class %s. Please make sure the widget has been activated in %sSiteOrigin Widgets%s."
257
  msgstr ""
258
 
2416
  msgid "Controls"
2417
  msgstr ""
2418
 
2419
+ #: widgets/slider/slider.php:330
2420
  msgid "Add a Lightbox to your image slides with %sSiteOrigin Premium%s"
2421
  msgstr ""
2422
 
readme.txt CHANGED
@@ -3,8 +3,8 @@ Tags: widget, button, slider, hero, google maps, image, carousel, features, icon
3
  Requires at least: 4.2
4
  Tested up to: 5.7
5
  Requires PHP: 5.6.20
6
- Stable tag: 1.18.1
7
- Build time: 2021-04-20T20:58:45+02:00
8
  License: GPLv3 or later
9
  Contributors: gpriday, braam-genis, alexgso
10
  Donate link: https://siteorigin.com/downloads/premium/
@@ -72,6 +72,10 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
72
 
73
  == Changelog ==
74
 
 
 
 
 
75
  = 1.18.1 - 20 April 2021 =
76
  * Reverted Less `3.1.0` update to restore compatibility for PHP versions below `7.1`.
77
 
3
  Requires at least: 4.2
4
  Tested up to: 5.7
5
  Requires PHP: 5.6.20
6
+ Stable tag: 1.18.2
7
+ Build time: 2021-04-27T19:44:58+02:00
8
  License: GPLv3 or later
9
  Contributors: gpriday, braam-genis, alexgso
10
  Donate link: https://siteorigin.com/downloads/premium/
72
 
73
  == Changelog ==
74
 
75
+ = 1.18.2 - 27 April 2021 =
76
+ * SiteOrigin Widget Block: Ensured icons are enqueued.
77
+ * Slider: Only apply foreground height if a background image is set.
78
+
79
  = 1.18.1 - 20 April 2021 =
80
  * Reverted Less `3.1.0` update to restore compatibility for PHP versions below `7.1`.
81
 
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.18.1
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.18.1');
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.18.2
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.18.2');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
widgets/slider/slider.php CHANGED
@@ -191,7 +191,7 @@ class SiteOrigin_Widget_Slider_Widget extends SiteOrigin_Widget_Base_Slider {
191
  <?php endif; ?>
192
  <?php endforeach; ?>>
193
  <?php endif; ?>
194
- <div class="sow-slider-image-foreground-wrapper" style="<?php if ( ! empty( $foreground_src[2] ) ) echo 'height: ' . intval( $foreground_src[2] ) . 'px;'; ?>">
195
  <?php
196
  echo siteorigin_widgets_get_attachment_image(
197
  $frame['foreground_image'],
@@ -200,6 +200,7 @@ class SiteOrigin_Widget_Slider_Widget extends SiteOrigin_Widget_Base_Slider {
200
  array(
201
  'class' => 'sow-slider-foreground-image',
202
  'loading' => 'eager',
 
203
  )
204
  );
205
  ?>
@@ -253,6 +254,8 @@ class SiteOrigin_Widget_Slider_Widget extends SiteOrigin_Widget_Base_Slider {
253
  $link_atts['rel'] = 'noopener noreferrer';
254
  }
255
  $frame['link_attributes'] = $link_atts;
 
 
256
  }
257
  }
258
  return array(
191
  <?php endif; ?>
192
  <?php endforeach; ?>>
193
  <?php endif; ?>
194
+ <div class="sow-slider-image-foreground-wrapper">
195
  <?php
196
  echo siteorigin_widgets_get_attachment_image(
197
  $frame['foreground_image'],
200
  array(
201
  'class' => 'sow-slider-foreground-image',
202
  'loading' => 'eager',
203
+ 'style' => ! empty( $frame['custom_height'] ) && ! empty( $foreground_src[2] ) ? 'height: ' . intval( $foreground_src[2] ) . 'px' : '',
204
  )
205
  );
206
  ?>
254
  $link_atts['rel'] = 'noopener noreferrer';
255
  }
256
  $frame['link_attributes'] = $link_atts;
257
+
258
+ $frame['custom_height'] = ! empty( $instance['design']['height'] );
259
  }
260
  }
261
  return array(