SiteOrigin Widgets Bundle - Version 1.10.0

Version Description

  • 11 October 2017 =
  • New Accordion widget!
  • Prevent multiple initialization of media field.
  • Use correct path for widget banner when defined in a theme.
  • Video: Added option to show/hide related YouTube videos at end of video.
  • Slider: Handle links inside slider frames first and then allow processing of frame background clicks.
  • Give repeated fields in widget fields unique ids for state handling.
  • New multi-measurement field.
  • Widget Manager Path Comparison fix. (allows for settings to work)
  • Button: Use esc_js instead of esc_attr for onclick.
Download this release

Release Info

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

Code changes from version 1.9.10 to 1.10.0

admin/tpl/admin.php CHANGED
@@ -22,14 +22,18 @@
22
23
<div id="widgets-list">
24
25
- <?php foreach( $widgets as $file => $widget ): ?>
26
<div class="so-widget-wrap">
27
<div class="so-widget so-widget-is-<?php echo $widget['Active'] ? 'active' : 'inactive' ?>" data-id="<?php echo esc_attr( $widget['ID'] ) ?>">
28
29
<?php
30
$banner = '';
31
- if( file_exists( plugin_dir_path( $widget['File'] ) . 'assets/banner.svg' ) ) {
32
- $banner = plugin_dir_url( $widget['File'] ) . 'assets/banner.svg';
33
}
34
$banner = apply_filters('siteorigin_widgets_widget_banner', $banner, $widget);
35
?>
@@ -71,8 +75,8 @@
71
/** @var SiteOrigin_Widget $widget_object */
72
$widget_object = !empty( $widget_objects[ $file ] ) ? $widget_objects[ $file ] : false;
73
if( !empty( $widget_object ) && $widget_object->has_form( 'settings' ) ) {
74
- $rel_path = str_replace( WP_PLUGIN_DIR, '', $file );
75
-
76
$form_url = add_query_arg( array(
77
'id' => $rel_path,
78
'action' => 'so_widgets_setting_form',
22
23
<div id="widgets-list">
24
25
+ <?php
26
+ foreach( $widgets as $file => $widget ):
27
+ $file = wp_normalize_path( $file );
28
+ ?>
29
<div class="so-widget-wrap">
30
<div class="so-widget so-widget-is-<?php echo $widget['Active'] ? 'active' : 'inactive' ?>" data-id="<?php echo esc_attr( $widget['ID'] ) ?>">
31
32
<?php
33
$banner = '';
34
+ $widget_dir = dirname( $widget['File'] );
35
+ if( file_exists( $widget_dir . '/assets/banner.svg' ) ) {
36
+ $banner = str_replace( WP_CONTENT_DIR, content_url(), $widget_dir ) . '/assets/banner.svg';
37
}
38
$banner = apply_filters('siteorigin_widgets_widget_banner', $banner, $widget);
39
?>
75
/** @var SiteOrigin_Widget $widget_object */
76
$widget_object = !empty( $widget_objects[ $file ] ) ? $widget_objects[ $file ] : false;
77
if( !empty( $widget_object ) && $widget_object->has_form( 'settings' ) ) {
78
+ $rel_path = str_replace( wp_normalize_path( WP_PLUGIN_DIR ), '', $file );
79
+
80
$form_url = add_query_arg( array(
81
'id' => $rel_path,
82
'action' => 'so_widgets_setting_form',
base/base.php CHANGED
@@ -7,6 +7,7 @@ include plugin_dir_path(__FILE__).'inc/widget-manager.class.php';
7
include plugin_dir_path(__FILE__).'inc/meta-box-manager.php';
8
include plugin_dir_path(__FILE__).'inc/post-selector.php';
9
include plugin_dir_path(__FILE__).'inc/string-utils.php';
10
include plugin_dir_path(__FILE__).'inc/attachments.php';
11
include plugin_dir_path(__FILE__).'inc/actions.php';
12
include plugin_dir_path(__FILE__).'inc/shortcode.php';
7
include plugin_dir_path(__FILE__).'inc/meta-box-manager.php';
8
include plugin_dir_path(__FILE__).'inc/post-selector.php';
9
include plugin_dir_path(__FILE__).'inc/string-utils.php';
10
+ include plugin_dir_path(__FILE__).'inc/array-utils.php';
11
include plugin_dir_path(__FILE__).'inc/attachments.php';
12
include plugin_dir_path(__FILE__).'inc/actions.php';
13
include plugin_dir_path(__FILE__).'inc/shortcode.php';
base/inc/array-utils.php ADDED
@@ -0,0 +1,23 @@
1
+ <?php
2
+
3
+ /**
4
+ * From this SO answer by Halil Özgür: https://stackoverflow.com/a/18781630/3710600
5
+ *
6
+ * Works with both integer and string positions.
7
+ *
8
+ * @param array $array
9
+ * @param int|string $position
10
+ * @param mixed $insert
11
+ */
12
+ function siteorigin_widgets_array_insert( &$array, $position, $insert ) {
13
+ if ( is_int( $position ) ) {
14
+ array_splice( $array, $position, 0, $insert );
15
+ } else {
16
+ $pos = array_search( $position, array_keys( $array ) );
17
+ $array = array_merge(
18
+ array_slice( $array, 0, $pos ),
19
+ $insert,
20
+ array_slice( $array, $pos )
21
+ );
22
+ }
23
+ }
base/inc/fields/css/multi-measurement-field.css ADDED
@@ -0,0 +1,19 @@
1
+ .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container {
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;
15
+ vertical-align: middle;
16
+ }
17
+ .siteorigin-widget-form .siteorigin-widget-field .sow-multi-measurement-container .sow-multi-measurement-input-container select.sow-multi-measurement-select-unit {
18
+ min-width: inherit;
19
+ }
base/inc/fields/js/media-field.js CHANGED
@@ -7,6 +7,10 @@
7
var $media = $field.find('> .media-field-wrapper');
8
var $inputField = $field.find( '.siteorigin-widget-input' ).not('.media-fallback-external');
9
10
// Handle the media uploader
11
$media.find( '.media-upload-button' ).click(function(e){
12
e.preventDefault();
@@ -99,7 +103,7 @@
99
} );
100
101
// Everything for the dialog
102
- var dialog = false;
103
104
var reflowDialog = function() {
105
if( ! dialog ) return;
@@ -398,6 +402,7 @@
398
}
399
} );
400
401
});
402
403
} )( jQuery );
7
var $media = $field.find('> .media-field-wrapper');
8
var $inputField = $field.find( '.siteorigin-widget-input' ).not('.media-fallback-external');
9
10
+ if ( $media.data( 'initialized' ) ) {
11
+ return;
12
+ }
13
+
14
// Handle the media uploader
15
$media.find( '.media-upload-button' ).click(function(e){
16
e.preventDefault();
103
} );
104
105
// Everything for the dialog
106
+ var dialog;
107
108
var reflowDialog = function() {
109
if( ! dialog ) return;
402
}
403
} );
404
405
+ $media.data( 'initialized', true );
406
});
407
408
} )( jQuery );
base/inc/fields/js/media-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-media",function(t){var i=e(this),s=i.find("> .media-field-wrapper"),a=i.find(".siteorigin-widget-input").not(".media-fallback-external");s.find(".media-upload-button").click(function(t){if(t.preventDefault(),void 0!==wp.media){var s=e(this),n=e(this).data("frame");if(n)return n.open(),!1;n=wp.media({title:s.data("choose"),library:{type:s.data("library").split(",").map(function(e){return e.trim()})},button:{text:s.data("update"),close:!1}}),s.data("frame",n),n.on("select",function(){var e=n.state().get("selection").first().attributes;i.find(".current .title").html(e.title),a.val(e.id),a.trigger("change",{silent:!0});var t=i.find(".current .thumbnail");void 0!==e.sizes?void 0!==e.sizes.thumbnail?t.attr("src",e.sizes.thumbnail.url).fadeIn():t.attr("src",e.sizes.full.url).fadeIn():t.attr("src",e.icon).fadeIn(),i.find(".media-remove-button").removeClass("remove-hide"),n.close()}),n.open()}}),s.find(".current").mouseenter(function(){var t=e(this).find(".title");""!==t.html()&&t.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),i.find("a.media-remove-button").click(function(t){t.preventDefault(),i.find(".current .title").html(""),a.val(""),i.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")});var n=!1,r=function(){if(n){var e=n.find(".so-widgets-image-results");if(0!==e.length){var t=e.width(),i=Math.floor(t/276),s=t-276*i,a=s/i+260;e.find(".so-widgets-result-image").css({width:a,height:a/1.4})}}};e(window).resize(r);var o=function(){if(!n){n=e(e("#so-widgets-bundle-tpl-image-search-dialog").html().trim()).appendTo("body"),n.find(".close").click(function(){n.hide()});var t=n.find(".so-widgets-image-results"),s=function(i,s){n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("loading")),n.find(".so-widgets-results-more").hide(),e.get(ajaxurl,{action:"so_widgets_image_search",q:i,page:s,_sononce:n.find('input[name="_sononce"]').val()},function(a){if(a.error)return void alert(a.message);t.removeClass("so-loading"),e.each(a.items,function(i,s){var a=e(e("#so-widgets-bundle-tpl-image-search-result").html().trim()).appendTo(t).addClass("source-"+s.source),n=a.find(".so-widgets-result-image");n.css("background-image","url("+s.thumbnail+")"),n.data("thumbnail",s.thumbnail),n.data("preview",s.preview),s.url&&n.attr({href:s.url,target:"_blank"}),s.full_url&&(n.data({full_url:s.full_url,import_signature:s.import_signature}),n.attr("href",s.full_url)),"shutterstock"===s.source&&n.append(e("#so-widgets-bundle-tpl-image-search-result-sponsored").html())}),1===s&&(n.find("#so-widgets-image-search-suggestions ul").empty(),e.each(a.keywords,function(t,i){n.find("#so-widgets-image-search-suggestions").show(),n.find("#so-widgets-image-search-suggestions ul").append(e("<li></li>").append(e('<a href="#"></a>').html(i).data("keyword",i)))})),n.find(".so-widgets-results-loading").fadeOut("fast"),r(),n.find(".so-widgets-results-more").show().find("button").data({query:i,page:s+1})})};n.find("#so-widgets-image-search-form").submit(function(e){e.preventDefault();var i=n.find(".so-widgets-search-input").val();t.empty(),""!==i&&s(i,1)}),n.on("click",".so-keywords-list a",function(t){t.preventDefault();var i=e(this).blur();n.find(".so-widgets-search-input").val(i.data("keyword")),n.find("#so-widgets-image-search-form").submit()}),n.find(".so-widgets-results-more button").click(function(){var t=e(this);s(t.data("query"),t.data("page"))});var o;n.on("click",".so-widgets-result-image",function(t){var s=e(this);if(s.data("full_url")&&(t.preventDefault(),confirm(n.data("confirm-import")))){n.addClass("so-widgets-importing");var r=e("#post_ID").val();null===r&&(r=""),e.get(ajaxurl,{action:"so_widgets_image_import",full_url:s.data("full_url"),import_signature:s.data("import_signature"),post_id:r,_sononce:n.find('input[name="_sononce"]').val()},function(e){n.find("#so-widgets-image-search-frame").removeClass("so-widgets-importing"),!1===e.error?(n.hide(),n.find(".so-widgets-results-loading").hide(),a.val(e.attachment_id).trigger("change",{silent:!0}),i.find(".current .thumbnail").attr("src",e.thumb).fadeIn(),i.find(".media-remove-button").removeClass("remove-hide")):(alert(e.message),n.find(".so-widgets-results-loading").hide())}),n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("importing")),n.find(".so-widgets-results-more").hide(),n.find("#so-widgets-image-search-frame").addClass("so-widgets-importing")}});var d=n.find(".so-widgets-preview-window");n.on("mouseenter",".so-widgets-result-image",function(){var t=e(this),i=t.data("preview");clearTimeout(o),o=setTimeout(function(){var s=1,a=1;i[1]>.33*e(window).outerWidth()&&(s=.33*e(window).outerWidth()/i[1]),i[2]>.5*e(window).outerHeight()&&(a=.5*e(window).outerHeight()/i[2]);var r=Math.min(s,a);r>1&&(r=1),d.show().find(".so-widgets-preview-window-inside").css({"background-image":"url("+t.data("thumbnail")+")",width:i[1]*r,height:i[2]*r}).append(e("<img />").attr("src",i[0])),n.trigger("mousemove")},1e3)}).on("mouseleave",".so-widgets-result-image",function(){d.hide().find("img").remove(),clearTimeout(o)});var l,u;n.on("mousemove",function(t){if(t.clientX&&(l=t.clientX),t.clientY&&(u=t.clientY),d.is(":visible")){var i=d.outerHeight(),s=d.outerWidth(),a=e(window).outerHeight(),n=e(window).outerWidth(),r=u-i/2;r=Math.max(r,10),r=Math.min(r,a-10-i);var o=l<n/2?l+15:l-15-s;d.css({top:r,left:o})}})}n.show(),n.find(".so-widgets-search-input").focus()};s.find(".find-image-button").click(function(e){e.preventDefault(),o()}),a.change(function(e,t){if(!t||!t.silent){var s=a.val();if(s){var n=i.find(".current .thumbnail"),r=wp.media.attachment(s);r.fetch().done(function(){if(r.has("sizes")){var e=r.get("sizes");void 0!==e.thumbnail?n.attr("src",e.thumbnail.url).fadeIn():n.attr("src",e.full.url).fadeIn()}else n.attr("src",r.get("icon")).fadeIn();i.find(".media-remove-button").removeClass("remove-hide")})}else i.find("a.media-remove-button").click()}})})}(jQuery);
1
+ !function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-media",function(t){var i=e(this),a=i.find("> .media-field-wrapper"),s=i.find(".siteorigin-widget-input").not(".media-fallback-external");if(!a.data("initialized")){a.find(".media-upload-button").click(function(t){if(t.preventDefault(),void 0!==wp.media){var a=e(this),n=e(this).data("frame");if(n)return n.open(),!1;n=wp.media({title:a.data("choose"),library:{type:a.data("library").split(",").map(function(e){return e.trim()})},button:{text:a.data("update"),close:!1}}),a.data("frame",n),n.on("select",function(){var e=n.state().get("selection").first().attributes;i.find(".current .title").html(e.title),s.val(e.id),s.trigger("change",{silent:!0});var t=i.find(".current .thumbnail");void 0!==e.sizes?void 0!==e.sizes.thumbnail?t.attr("src",e.sizes.thumbnail.url).fadeIn():t.attr("src",e.sizes.full.url).fadeIn():t.attr("src",e.icon).fadeIn(),i.find(".media-remove-button").removeClass("remove-hide"),n.close()}),n.open()}}),a.find(".current").mouseenter(function(){var t=e(this).find(".title");""!==t.html()&&t.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),i.find("a.media-remove-button").click(function(t){t.preventDefault(),i.find(".current .title").html(""),s.val(""),i.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")});var n,r=function(){if(n){var e=n.find(".so-widgets-image-results");if(0!==e.length){var t=e.width(),i=Math.floor(t/276),a=t-276*i,s=a/i+260;e.find(".so-widgets-result-image").css({width:s,height:s/1.4})}}};e(window).resize(r);var o=function(){if(!n){n=e(e("#so-widgets-bundle-tpl-image-search-dialog").html().trim()).appendTo("body"),n.find(".close").click(function(){n.hide()});var t=n.find(".so-widgets-image-results"),a=function(i,a){n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("loading")),n.find(".so-widgets-results-more").hide(),e.get(ajaxurl,{action:"so_widgets_image_search",q:i,page:a,_sononce:n.find('input[name="_sononce"]').val()},function(s){if(s.error)return void alert(s.message);t.removeClass("so-loading"),e.each(s.items,function(i,a){var s=e(e("#so-widgets-bundle-tpl-image-search-result").html().trim()).appendTo(t).addClass("source-"+a.source),n=s.find(".so-widgets-result-image");n.css("background-image","url("+a.thumbnail+")"),n.data("thumbnail",a.thumbnail),n.data("preview",a.preview),a.url&&n.attr({href:a.url,target:"_blank"}),a.full_url&&(n.data({full_url:a.full_url,import_signature:a.import_signature}),n.attr("href",a.full_url)),"shutterstock"===a.source&&n.append(e("#so-widgets-bundle-tpl-image-search-result-sponsored").html())}),1===a&&(n.find("#so-widgets-image-search-suggestions ul").empty(),e.each(s.keywords,function(t,i){n.find("#so-widgets-image-search-suggestions").show(),n.find("#so-widgets-image-search-suggestions ul").append(e("<li></li>").append(e('<a href="#"></a>').html(i).data("keyword",i)))})),n.find(".so-widgets-results-loading").fadeOut("fast"),r(),n.find(".so-widgets-results-more").show().find("button").data({query:i,page:a+1})})};n.find("#so-widgets-image-search-form").submit(function(e){e.preventDefault();var i=n.find(".so-widgets-search-input").val();t.empty(),""!==i&&a(i,1)}),n.on("click",".so-keywords-list a",function(t){t.preventDefault();var i=e(this).blur();n.find(".so-widgets-search-input").val(i.data("keyword")),n.find("#so-widgets-image-search-form").submit()}),n.find(".so-widgets-results-more button").click(function(){var t=e(this);a(t.data("query"),t.data("page"))});var o;n.on("click",".so-widgets-result-image",function(t){var a=e(this);if(a.data("full_url")&&(t.preventDefault(),confirm(n.data("confirm-import")))){n.addClass("so-widgets-importing");var r=e("#post_ID").val();null===r&&(r=""),e.get(ajaxurl,{action:"so_widgets_image_import",full_url:a.data("full_url"),import_signature:a.data("import_signature"),post_id:r,_sononce:n.find('input[name="_sononce"]').val()},function(e){n.find("#so-widgets-image-search-frame").removeClass("so-widgets-importing"),!1===e.error?(n.hide(),n.find(".so-widgets-results-loading").hide(),s.val(e.attachment_id).trigger("change",{silent:!0}),i.find(".current .thumbnail").attr("src",e.thumb).fadeIn(),i.find(".media-remove-button").removeClass("remove-hide")):(alert(e.message),n.find(".so-widgets-results-loading").hide())}),n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("importing")),n.find(".so-widgets-results-more").hide(),n.find("#so-widgets-image-search-frame").addClass("so-widgets-importing")}});var d=n.find(".so-widgets-preview-window");n.on("mouseenter",".so-widgets-result-image",function(){var t=e(this),i=t.data("preview");clearTimeout(o),o=setTimeout(function(){var a=1,s=1;i[1]>.33*e(window).outerWidth()&&(a=.33*e(window).outerWidth()/i[1]),i[2]>.5*e(window).outerHeight()&&(s=.5*e(window).outerHeight()/i[2]);var r=Math.min(a,s);r>1&&(r=1),d.show().find(".so-widgets-preview-window-inside").css({"background-image":"url("+t.data("thumbnail")+")",width:i[1]*r,height:i[2]*r}).append(e("<img />").attr("src",i[0])),n.trigger("mousemove")},1e3)}).on("mouseleave",".so-widgets-result-image",function(){d.hide().find("img").remove(),clearTimeout(o)});var l,u;n.on("mousemove",function(t){if(t.clientX&&(l=t.clientX),t.clientY&&(u=t.clientY),d.is(":visible")){var i=d.outerHeight(),a=d.outerWidth(),s=e(window).outerHeight(),n=e(window).outerWidth(),r=u-i/2;r=Math.max(r,10),r=Math.min(r,s-10-i);var o=l<n/2?l+15:l-15-a;d.css({top:r,left:o})}})}n.show(),n.find(".so-widgets-search-input").focus()};a.find(".find-image-button").click(function(e){e.preventDefault(),o()}),s.change(function(e,t){if(!t||!t.silent){var a=s.val();if(a){var n=i.find(".current .thumbnail"),r=wp.media.attachment(a);r.fetch().done(function(){if(r.has("sizes")){var e=r.get("sizes");void 0!==e.thumbnail?n.attr("src",e.thumbnail.url).fadeIn():n.attr("src",e.full.url).fadeIn()}else n.attr("src",r.get("icon")).fadeIn();i.find(".media-remove-button").removeClass("remove-hide")})}else i.find("a.media-remove-button").click()}}),a.data("initialized",!0)}})}(jQuery);
base/inc/fields/js/multi-measurement-field.js ADDED
@@ -0,0 +1,57 @@
1
+ /* global jQuery */
2
+
3
+ (function( $ ) {
4
+ $( document ).on( 'sowsetupformfield', '.siteorigin-widget-field-type-multi-measurement', function ( e ) {
5
+
6
+ var valField = $( this ).find( 'input[type="hidden"][class="siteorigin-widget-input"]' );
7
+ var separator = valField.data( 'separator' );
8
+ var autoFillEnabled = valField.data( 'autofill' );
9
+ var values = valField.val() === '' ? [] : valField.val().split( separator );
10
+ var $valInputs = $( this ).find( '.sow-multi-measurement-input' );
11
+ var $inputContainers = $( this ).find( '.sow-multi-measurement-input-container' );
12
+
13
+ var updateValue = function ( $element ) {
14
+ var vals = valField.val() === '' ? [] : valField.val().split( separator );
15
+ var $unitInput = $element.find( '+ .sow-multi-measurement-select-unit' );
16
+ var index = $valInputs.index( $element );
17
+ vals[ index ] = $element.val() + ( $element.val() === '' ? '' : $unitInput.val() );
18
+ valField.val( vals.join( separator ) );
19
+ };
20
+
21
+ $valInputs.each( function ( index, element ) {
22
+ if ( values.length > index ) {
23
+ var valueResult = values[ index ].match( /(\d+\.?\d*)([a-z%]+)*/ );
24
+ if ( valueResult && valueResult.length ) {
25
+ var amount = valueResult[ 1 ];
26
+ var unit = valueResult[ 2 ];
27
+ $( element ).val( amount );
28
+ $( element ).find( '+ .sow-multi-measurement-select-unit' ).val( unit );
29
+ }
30
+ } else {
31
+ updateValue( $( element ) );
32
+ }
33
+ } );
34
+
35
+ $inputContainers.change( function ( event ) {
36
+ var $valInput = $( event.currentTarget ).find( '> .sow-multi-measurement-input' );
37
+ var doAutofill = autoFillEnabled;
38
+ if ( autoFillEnabled ) {
39
+ $valInputs.each( function ( index, element ) {
40
+ // Only want to autofill if it has been enabled and no other inputs have values.
41
+ if ( element !== $valInput.eq( 0 ) ) {
42
+ doAutofill = doAutofill && !( $( element ).val() );
43
+ }
44
+ } );
45
+ }
46
+ if ( doAutofill ) {
47
+ $valInputs.each( function( index, element ) {
48
+ $( element ).val( $valInput.val() );
49
+ updateValue( $( element ) );
50
+ } );
51
+ } else {
52
+ updateValue( $valInput );
53
+ }
54
+ } );
55
+
56
+ } );
57
+ })( jQuery );
base/inc/fields/js/multi-measurement-field.min.js ADDED
@@ -0,0 +1 @@
1
+ !function(t){t(document).on("sowsetupformfield",".siteorigin-widget-field-type-multi-measurement",function(e){var i=t(this).find('input[type="hidden"][class="siteorigin-widget-input"]'),n=i.data("separator"),a=i.data("autofill"),l=""===i.val()?[]:i.val().split(n),u=t(this).find(".sow-multi-measurement-input"),s=t(this).find(".sow-multi-measurement-input-container"),o=function(t){var e=""===i.val()?[]:i.val().split(n),a=t.find("+ .sow-multi-measurement-select-unit");e[u.index(t)]=t.val()+(""===t.val()?"":a.val()),i.val(e.join(n))};u.each(function(e,i){if(l.length>e){var n=l[e].match(/(\d+\.?\d*)([a-z%]+)*/);if(n&&n.length){var a=n[1],u=n[2];t(i).val(a),t(i).find("+ .sow-multi-measurement-select-unit").val(u)}}else o(t(i))}),s.change(function(e){var i=t(e.currentTarget).find("> .sow-multi-measurement-input"),n=a;a&&u.each(function(e,a){a!==i.eq(0)&&(n=n&&!t(a).val())}),n?u.each(function(e,n){t(n).val(i.val()),o(t(n))}):o(i)})})}(jQuery);
base/inc/fields/multi-measurement.class.php ADDED
@@ -0,0 +1,113 @@
1
+ <?php
2
+
3
+ /**
4
+ * Class SiteOrigin_Widget_Field_Multi_Measurement
5
+ */
6
+ class SiteOrigin_Widget_Field_Multi_Measurement extends SiteOrigin_Widget_Field_Text_Input_Base {
7
+
8
+ /**
9
+ * Configuration of the measurements to be taken. Should be in the form:
10
+ * `array(
11
+ * 'padding_left' => array(
12
+ * 'label' => __( 'Padding left', 'so-widgets-bundle' ),
13
+ * 'units' => array( 'px', 'rem', 'em', '%' ),
14
+ * ),
15
+ * 'padding_right' => __( 'Padding right', 'so-widgets-bundle' ),
16
+ * 'padding_bottom' => __( 'Padding bottom', 'so-widgets-bundle' ),
17
+ * 'padding_top' => __( 'Padding top', 'so-widgets-bundle' ),
18
+ * )`
19
+ *
20
+ * The 'units' property is optional and defaults to the list returned by `siteorigin_widgets_get_measurements_list`.
21
+ *
22
+ * @access protected
23
+ * @var array
24
+ */
25
+ protected $measurements;
26
+
27
+ /**
28
+ * String separator for the measurements. Default is an empty space.
29
+ *
30
+ * @access protected
31
+ * @var string
32
+ */
33
+ protected $separator;
34
+
35
+ /**
36
+ * Whether to automatically fill the rest of the inputs when the first value is entered.
37
+ * Default is false.
38
+ *
39
+ * @access protected
40
+ * @var boolean
41
+ */
42
+ protected $autofill;
43
+
44
+ protected function get_default_options() {
45
+ return array(
46
+ 'separator' => ' ',
47
+ 'autofill' => false,
48
+ );
49
+ }
50
+
51
+ protected function render_field( $value, $instance ) {
52
+ ?>
53
+ <div class="sow-multi-measurement-container">
54
+ <?php
55
+ foreach ( $this->measurements as $name => $measurement_config ) {
56
+ $label = empty( $measurement_config['label'] ) ? '' : $measurement_config['label'];
57
+ $units = empty( $measurement_config['units'] ) ?
58
+ siteorigin_widgets_get_measurements_list() :
59
+ $measurement_config['units'];
60
+ $input_id = $this->element_id . '-' . $name;
61
+ ?>
62
+ <div class="sow-multi-measurement-input-container">
63
+ <label for="<?php echo esc_attr( $input_id ) ?>"><?php echo esc_html( $label ) ?></label>
64
+ <input id="<?php echo esc_attr( $input_id ) ?>" type="text" class="sow-multi-measurement-input">
65
+ <select class="sow-multi-measurement-select-unit">
66
+ <?php foreach ( $units as $unit ):?>
67
+ <option value="<?php echo esc_attr( $unit ) ?>"><?php echo esc_html( $unit ) ?></option>
68
+ <?php endforeach?>
69
+ </select>
70
+ <div class="clear"></div>
71
+ </div>
72
+ <?php
73
+ }
74
+ ?>
75
+ </div>
76
+ <input type="hidden"
77
+ class="siteorigin-widget-input"
78
+ value="<?php echo esc_attr( $value ) ?>"
79
+ name="<?php echo esc_attr( $this->element_name ) ?>"
80
+ data-autofill="<?php echo empty( $this->autofill ) ? 'false' : 'true'; ?>"
81
+ data-separator="<?php echo esc_attr( $this->separator ) ?>"/><?php
82
+ }
83
+
84
+ public function enqueue_scripts() {
85
+ wp_enqueue_style( 'so-multi-measurement-field', plugin_dir_url( __FILE__ ) . 'css/multi-measurement-field.css', array(),
86
+ SOW_BUNDLE_VERSION );
87
+ wp_enqueue_script( 'so-multi-measurement-field',
88
+ plugin_dir_url( __FILE__ ) . 'js/multi-measurement-field' . SOW_BUNDLE_JS_SUFFIX . '.js', array( 'jquery' ),
89
+ SOW_BUNDLE_VERSION );
90
+ }
91
+
92
+ protected function sanitize_field_input( $value, $instance ) {
93
+ if ( empty( $value ) ) {
94
+ return $value;
95
+ }
96
+
97
+ $values = explode( $this->separator, $value );
98
+ $any_values = false;
99
+ foreach ( $values as $index => $measurement ) {
100
+ $any_values = $any_values || ! empty( $measurement );
101
+ preg_match('/(\d+\.?\d*)([a-z%]+)*/', $measurement, $matches);
102
+
103
+ $num_matches = count( $matches );
104
+
105
+ $val = $num_matches > 1 ? $matches[1] : '0';
106
+ $unit = $num_matches > 2 ? $matches[2] : 'px';
107
+ $measurement = $val . $unit;
108
+ $values[ $index ] = $measurement;
109
+ }
110
+ // If all values are empty, just return an empty string.
111
+ return $any_values ? implode( $this->separator, $values ) : '';
112
+ }
113
+ }
base/inc/fields/widget.class.php CHANGED
@@ -27,7 +27,8 @@ class SiteOrigin_Widget_Field_Widget extends SiteOrigin_Widget_Field_Container_B
27
}
28
29
protected function render_field( $value, $instance ) {
30
- // Create the extra form entries
31
if ( $this->collapsible ) {
32
?><div class="siteorigin-widget-section <?php if( $this->state == 'closed' ) echo 'siteorigin-widget-section-hide'; ?>"><?php
33
}
@@ -53,6 +54,7 @@ class SiteOrigin_Widget_Field_Widget extends SiteOrigin_Widget_Field_Container_B
53
if ( $this->collapsible ) {
54
?></div><?php
55
}
56
}
57
58
- }
27
}
28
29
protected function render_field( $value, $instance ) {
30
+
31
+ echo '<div class="siteorigin-widget-widget">';
32
if ( $this->collapsible ) {
33
?><div class="siteorigin-widget-section <?php if( $this->state == 'closed' ) echo 'siteorigin-widget-section-hide'; ?>"><?php
34
}
54
if ( $this->collapsible ) {
55
?></div><?php
56
}
57
+ echo '</div>';
58
}
59
60
+ }
base/inc/widget-manager.class.php CHANGED
@@ -40,7 +40,7 @@ class SiteOrigin_Widgets_Widget_Manager {
40
* @return mixed
41
*/
42
public function register( $id, $path, $class = false ){
43
- $path = realpath( $path );
44
if ( empty( $class ) ) {
45
$class = 'SiteOrigin_Widget_' . str_replace( ' ', '', ucwords( str_replace('-', ' ', $id) ) ) . '_Widget';
46
}
@@ -117,7 +117,6 @@ class SiteOrigin_Widgets_Widget_Manager {
117
* @return mixed
118
*/
119
function get_class_from_path( $path ) {
120
- $path = realpath( $path );
121
foreach( $this->registered as $id => $r ) {
122
if( $r->path == $path ) return $r->class;
123
}
40
* @return mixed
41
*/
42
public function register( $id, $path, $class = false ){
43
+ $path = wp_normalize_path( $path );
44
if ( empty( $class ) ) {
45
$class = 'SiteOrigin_Widget_' . str_replace( ' ', '', ucwords( str_replace('-', ' ', $id) ) ) . '_Widget';
46
}
117
* @return mixed
118
*/
119
function get_class_from_path( $path ) {
120
foreach( $this->registered as $id => $r ) {
121
if( $r->path == $path ) return $r->class;
122
}
base/js/admin.js CHANGED
@@ -48,7 +48,7 @@ var sowbForms = window.sowbForms || {};
48
// Indicates if the handler has run
49
var handlerRun = {};
50
51
- var repeaterIndex = sowbForms.getRepeaterId($);
52
if (repeaterIndex !== false) {
53
var repeaterHandler = {};
54
for ( var rptrState in handler) {
@@ -56,6 +56,23 @@ var sowbForms = window.sowbForms || {};
56
}
57
handler = repeaterHandler;
58
}
59
60
// Go through all the handlers
61
for (var state in handler) {
@@ -196,10 +213,10 @@ var sowbForms = window.sowbForms || {};
196
var $fields = $el.find('> .siteorigin-widget-field');
197
198
// Process any sub sections
199
- $fields.find('> .siteorigin-widget-section').sowSetupForm();
200
201
// Process any sub widgets whose fields aren't contained in a section
202
- $fields.filter('.siteorigin-widget-field-type-widget:not(:has(> .siteorigin-widget-section))').sowSetupForm();
203
204
// Store the field names
205
$fields.find('.siteorigin-widget-input').each(function (i, input) {
@@ -234,15 +251,16 @@ var sowbForms = window.sowbForms || {};
234
// Handle the sections
235
var expandContainer = function () {
236
$(this).toggleClass('siteorigin-widget-section-visible');
237
- $(this).siblings('.siteorigin-widget-section').slideToggle('fast', function () {
238
- $(window).resize();
239
- $(this).find('> .siteorigin-widget-field-container-state').val($(this).is(':visible') ? 'open' : 'closed');
240
241
- if ( $( this ).is( ':visible' ) ) {
242
- var $fields = $( this ).find( '> .siteorigin-widget-field' );
243
- $fields.trigger( 'sowsetupformfield' );
244
- }
245
- });
246
};
247
$fields.filter('.siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section').find('> label').click(expandContainer);
248
$fields.filter('.siteorigin-widget-field-type-posts').find('.posts-container-label-wrapper').click(expandContainer);
@@ -374,12 +392,20 @@ var sowbForms = window.sowbForms || {};
374
}
375
376
// Check if this is inside a repeater
377
- var repeaterIndex = sowbForms.getRepeaterId($);
378
if (repeaterIndex !== false) {
379
emitter.args = emitter.args.map(function (a) {
380
return a.replace('{$repeater}', repeaterIndex);
381
});
382
}
383
384
var val = $.is('[type="checkbox"]') ? $.is(':checked') : $.val();
385
// Return an array that has the new states added to the array
@@ -823,25 +849,29 @@ var sowbForms = window.sowbForms || {};
823
824
// Widgets Bundle utility functions
825
/**
826
- * Get the unique index of a repeater item.
827
*
828
* @param $el
829
* @return {*}
830
*/
831
- sowbForms.getRepeaterId = function ($el) {
832
- if (typeof this.id === 'undefined') {
833
- this.id = 1;
834
}
835
-
836
- var $r = $el.closest('.siteorigin-widget-field-repeater-item');
837
- if ($r.length) {
838
- var itemId = $r.data('item-id');
839
- if (itemId === undefined) {
840
- itemId = this.id++;
841
}
842
- $r.data('item-id', itemId);
843
-
844
- return itemId;
845
}
846
else {
847
return false;
48
// Indicates if the handler has run
49
var handlerRun = {};
50
51
+ var repeaterIndex = sowbForms.getContainerFieldId( $, 'repeater', '.siteorigin-widget-field-repeater-item' );
52
if (repeaterIndex !== false) {
53
var repeaterHandler = {};
54
for ( var rptrState in handler) {
56
}
57
handler = repeaterHandler;
58
}
59
+
60
+ var widgetFieldId = sowbForms.getContainerFieldId( $, 'widget', '.siteorigin-widget-widget' );
61
+ if ( widgetFieldId !== false ) {
62
+ var widgetFieldHandler = {};
63
+ for ( var wdgFldState in handler) {
64
+ var stMatches = wdgFldState.match( /_else\[(.*)\]|(.*)\[(.*)\]/ );
65
+ var st = '';
66
+ if ( stMatches && stMatches.length && stMatches[1] === undefined ) {
67
+ st = stMatches[ 2 ] + '_' + widgetFieldId + '[' + stMatches[ 3 ] + ']';
68
+ } else {
69
+ st = '_else[' + stMatches[ 1 ] + '_' + widgetFieldId + ']';
70
+ }
71
+
72
+ widgetFieldHandler[st] = handler[wdgFldState];
73
+ }
74
+ handler = widgetFieldHandler;
75
+ }
76
77
// Go through all the handlers
78
for (var state in handler) {
213
var $fields = $el.find('> .siteorigin-widget-field');
214
215
// Process any sub sections
216
+ $fields.find('> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section').sowSetupForm();
217
218
// Process any sub widgets whose fields aren't contained in a section
219
+ $fields.filter('.siteorigin-widget-widget:not(:has(> .siteorigin-widget-section))').sowSetupForm();
220
221
// Store the field names
222
$fields.find('.siteorigin-widget-input').each(function (i, input) {
251
// Handle the sections
252
var expandContainer = function () {
253
$(this).toggleClass('siteorigin-widget-section-visible');
254
+ $(this).parent().find('> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section')
255
+ .slideToggle('fast', function () {
256
+ $(window).resize();
257
+ $(this).find('> .siteorigin-widget-field-container-state').val($(this).is(':visible') ? 'open' : 'closed');
258
259
+ if ( $( this ).is( ':visible' ) ) {
260
+ var $fields = $( this ).find( '> .siteorigin-widget-field' );
261
+ $fields.trigger( 'sowsetupformfield' );
262
+ }
263
+ } );
264
};
265
$fields.filter('.siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section').find('> label').click(expandContainer);
266
$fields.filter('.siteorigin-widget-field-type-posts').find('.posts-container-label-wrapper').click(expandContainer);
392
}
393
394
// Check if this is inside a repeater
395
+ var repeaterIndex = sowbForms.getContainerFieldId( $, 'repeater', '.siteorigin-widget-field-repeater-item' );
396
if (repeaterIndex !== false) {
397
emitter.args = emitter.args.map(function (a) {
398
return a.replace('{$repeater}', repeaterIndex);
399
});
400
}
401
+
402
+ var widgetFieldId = sowbForms.getContainerFieldId( $, 'widget', '.siteorigin-widget-widget' );
403
+ if ( widgetFieldId !== false && ! emitter.hasOwnProperty( 'widgetFieldId' ) ) {
404
+ emitter.widgetFieldId = widgetFieldId;
405
+ emitter.args = emitter.args.map(function (arg) {
406
+ return arg + '_' + widgetFieldId;
407
+ });
408
+ }
409
410
var val = $.is('[type="checkbox"]') ? $.is(':checked') : $.val();
411
// Return an array that has the new states added to the array
849
850
// Widgets Bundle utility functions
851
/**
852
+ * Get the unique index of a repeated item. Could be in a repeater or if multiple widget fields with the same
853
+ * widget class.
854
*
855
* @param $el
856
+ * @param containerType
857
+ * @param containerClass
858
* @return {*}
859
*/
860
+ sowbForms.getContainerFieldId = function ( $el, containerType, containerClass ) {
861
+ var fieldIdPropName = containerType + 'FieldId';
862
+ if ( ! this.hasOwnProperty( fieldIdPropName ) ) {
863
+ this[ fieldIdPropName ] = 1;
864
}
865
+
866
+ var $field = $el.closest( containerClass );
867
+ if ( $field.length ) {
868
+ var fieldId = $field.data( 'field-id' );
869
+ if ( fieldId === undefined ) {
870
+ fieldId = this[ fieldIdPropName ]++;
871
}
872
+ $field.data( 'field-id', fieldId );
873
+
874
+ return fieldId;
875
}
876
else {
877
return false;
base/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- var sowbForms=window.sowbForms||{};!function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var n,r=e(t),a=!0,s=e("body"),o=r.find("input[name]");if(o.length&&-1!==o.attr("name").indexOf("__i__"))return this;if(r.is(".siteorigin-widget-form-main")){if(!0===r.data("sow-form-setup"))return!0;if(s.hasClass("widgets-php")&&!r.is(":visible")&&0===r.closest(".panel-dialog").length)return!0;r.on("sowstatechange",function(i,t,n){r.find("[data-state-handler]").each(function(){var i=e(this),r=e.extend({},i.data("state-handler"),a?i.data("state-handler-initial"):{});if(0===Object.keys(r).length)return!0;var s,o,d,l,f,g,c={},p=sowbForms.getRepeaterId(i);if(!1!==p){var u={};for(var m in r)u[m.replace("{$repeater}",p)]=r[m];r=u}for(var w in r)if(f=!1,null!==(s=w.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?#x2F;))){if(o={group:"default",name:"",multi:!1},void 0!==s[2]?(o.group=s[1],o.name=s[3]):o.name=s[0],o.multi=void 0!==s[4],"_else"===o.group)o.group=o.name,o.name="",f=o.group===t&&void 0===c[o.group];else{g=o.name.split(",").map(function(e){return e.trim()});for(var v=0;v<g.length&&!(f=o.group===t&&g[v]===n);v++);}if(f){d=r[w],o.multi||(d=[d]);for(var v=0;v<d.length;v++)l=void 0!==d[v][1]&&Boolean(d[v][1])?i.find(d[v][1]):i,l[d[v][0]].apply(l,void 0!==d[v][2]?d[v][2]:[]);c[o.group]=!0}}})}),r.sowSetupPreview(),n=r;var d=r.find(".siteorigin-widget-teaser");d.find(".dashicons-dismiss").click(function(){var i=e(this);e.get(i.data("dismiss-url")),d.slideUp("normal",function(){d.remove()})});var l=r.find("> .siteorigin-widgets-form-id").val(),f=r.find("> .siteorigin-widgets-form-timestamp"),g=parseInt(f.val()||0),c=JSON.parse(sessionStorage.getItem(l));if(c)if(c._sow_form_timestamp>g){var p=e('<div class="siteorigin-widget-form-notification"><span>'+soWidgets.backup.newerVersion+'</span><a class="button button-small so-backup-restore">'+soWidgets.backup.restore+'</a><a class="button button-small so-backup-dismiss">'+soWidgets.backup.dismiss+"</a><div><small>"+soWidgets.backup.replaceWarning+"</small></div></div>");r.prepend(p),p.find(".so-backup-restore").click(function(){sowbForms.setWidgetFormValues(n,c),p.slideUp("fast",function(){p.remove()})}),p.find(".so-backup-dismiss").click(function(){p.slideUp("fast",function(){sessionStorage.removeItem(l),p.remove()})})}else sessionStorage.removeItem(l);r.change(function(){f.val((new Date).getTime());var e=sowbForms.getWidgetFormValues(r);sessionStorage.setItem(l,JSON.stringify(e))})}else n=r.closest(".siteorigin-widget-form-main");n.find("> .siteorigin-widgets-form-id").val();var u=r.find("> .siteorigin-widget-field");u.find("> .siteorigin-widget-section").sowSetupForm(),u.filter(".siteorigin-widget-field-type-widget:not(:has(> .siteorigin-widget-section))").sowSetupForm(),u.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),u.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),r.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),u.find("> .siteorigin-widget-input-color").each(function(){var i=e(this),t={change:function(i,t){setTimeout(function(){e(i.target).trigger("change")},100)}};i.data("defaultColor")&&(t.defaultColor=i.data("defaultColor")),i.wpColorPicker(t)});var m=function(){e(this).toggleClass("siteorigin-widget-section-visible"),e(this).siblings(".siteorigin-widget-section").slideToggle("fast",function(){if(e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed"),e(this).is(":visible")){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}})};u.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(m),u.filter(".siteorigin-widget-field-type-posts").find(".posts-container-label-wrapper").click(m),u.filter(".siteorigin-widget-field-type-slider").each(function(){var i=e(this),t=i.find('input[type="number"]'),n=i.find(".siteorigin-widget-value-slider");n.slider({max:parseInt(t.attr("max")),min:parseInt(t.attr("min")),value:parseInt(t.val()),slide:function(e,i){t.val(parseInt(i.value)),t.trigger("change")},change:function(e,t){i.find(".siteorigin-widget-slider-value").html(t.value)}}),t.change(function(e,i){i&&i.silent||n.slider("value",parseInt(t.val()))})}),u.filter(".siteorigin-widget-field-type-link").each(function(){var i=e(this),t=null,n=function(){null!==t&&t.abort();var n=i.find(".content-text-search"),r=n.val(),a=n.data("postTypes"),s=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:r,postTypes:a},function(i){for(var t=0;t<i.length;t++)""===i[t].label&&(i[t].label="&nbsp;"),s.append(e("<li>").addClass("post").html(i[t].label+"<span>("+i[t].type+")</span>").data(i[t]));s.removeClass("loading")})};i.find(".select-content-button, .button-close").click(function(t){t.preventDefault(),e(this).blur();var r=i.find(".existing-content-selector");r.toggle(),r.is(":visible")&&0===r.find("ul.posts li").length&&n()}),i.on("click",".posts li",function(t){t.preventDefault();var n=e(this);i.find("input.siteorigin-widget-input").val("post: "+n.data("value")),i.find(".existing-content-selector").toggle()});var r=null;i.find(".content-text-search").keyup(function(){null!==r&&clearTimeout(r),r=setTimeout(function(){n()},500)})}),void 0!==jQuery.fn.soPanelsSetupBuilderWidget&&u.filter(".siteorigin-widget-field-type-builder").each(function(){e(this).find("> .siteorigin-page-builder-field").soPanelsSetupBuilderWidget()});var w=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if(void 0!==t){var r={default:""};void 0===t.length&&(t=[t]);for(var a=0;a<t.length;a++)r=function(t,n){if(void 0===sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return n;var r=sowbForms.getRepeaterId(i);!1!==r&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",r)}));var a=i.is('[type="checkbox"]')?i.is(":checked"):i.val();return e.extend(n,sowEmitters[t.callback](a,t.args))}(t[a],r);var s=n.data("states");void 0===s&&(s={default:""});for(var o in r)void 0!==s[o]&&r[o]===s[o]||(s[o]=r[o],n.trigger("sowstatechange",[o,r[o]]));n.data("states",s)}};u.filter("[data-state-emitter]").each(function(){e(this).find(".siteorigin-widget-input").on("keyup change",w),e(this).find(".siteorigin-widget-input").each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&w.call(i[0]):w.call(i[0])})}),r.trigger("sowsetupform",u).data("sow-form-setup",!0),u.trigger("sowsetupformfield"),r.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),(s.hasClass("wp-customizer")||s.hasClass("widgets-php"))&&r.closest(".ui-sortable").on("sortstop",function(e,i){i.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}),a=!1})},e.fn.sowSetupPreview=function(){var i=e(this);i.siblings(".siteorigin-widget-preview").find("> a").click(function(t){t.preventDefault();var n=sowbForms.getWidgetFormValues(i),r=e(e("#so-widgets-bundle-tpl-preview-dialog").html().trim()).appendTo("body");r.find('input[name="data"]').val(JSON.stringify(n)),r.find('input[name="class"]').val(i.data("class")),r.find("iframe").on("load",function(){e(this).css("visibility","visible")}),r.find("form").submit(),r.find(".close").click(function(){r.remove()})})},e.fn.sowSetupRepeater=function(){return e(this).each(function(i,t){var n=e(t),r=n.find(".siteorigin-widget-field-repeater-items"),a=n.data("repeater-name");r.bind("updateFieldPositions",function(){var i=e(this),t=i.find("> .siteorigin-widget-field-repeater-item");t.each(function(i,t){e(t).find(".siteorigin-widget-input").each(function(t,n){var r=e(n).data("repeater-positions");void 0===r&&(r={}),r[a]=i,e(n).data("repeater-positions",r)})}),i.find(".siteorigin-widget-input").each(function(i,t){var n=e(t).data("repeater-positions"),r=e(t);if(void 0!==n){var a=r.attr("data-original-name");if(a||(r.attr("data-original-name",r.attr("name")),a=r.attr("name")),!a)return;if(n)for(var s in n)a=a.replace("#"+s+"#",n[s]);r.attr("name",a)}}),i.data("initialSetup")||(i.find(".siteorigin-widget-input").each(function(i,t){var n=e(t);n.prop("checked",n.prop("defaultChecked"))}),i.data("initialSetup",!0));var r=n.data("scroll-count")?parseInt(n.data("scroll-count")):0;if(r>0&&t.length>r){var s=t.first().outerHeight();i.css("max-height",s*r).css("overflow","auto")}else i.css("max-height","").css("overflow","")}),r.sortable({handle:".siteorigin-widget-field-repeater-item-top",items:"> .siteorigin-widget-field-repeater-item",update:function(){r.trigger("updateFieldPositions")},sortstop:function(i,t){if(t.item.is(".siteorigin-widget-field-repeater-item"))t.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")});else{t.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}}),r.trigger("updateFieldPositions"),n.find("> .siteorigin-widget-field-repeater-add").disableSelection().click(function(i){i.preventDefault(),n.closest(".siteorigin-widget-field-repeater").sowAddRepeaterItem().find("> .siteorigin-widget-field-repeater-items").slideDown("fast",function(){e(window).resize()})}),n.find("> .siteorigin-widget-field-repeater-top > .siteorigin-widget-field-repeater-expand").click(function(i){i.preventDefault(),n.closest(".siteorigin-widget-field-repeater").find("> .siteorigin-widget-field-repeateritems-").slideToggle("fast",function(){e(window).resize()})})})},e.fn.sowAddRepeaterItem=function(){return e(this).each(function(i,t){var n=e(t),r=n.find("> .siteorigin-widget-field-repeater-items").children().length+1,a=e("<div>"+n.find("> .siteorigin-widget-field-repeater-item-html").html()+"</div>");a.find(".siteorigin-widget-input[data-name]").each(function(){var i=e(this);0===i.closest(".siteorigin-widget-field-repeater-item-html").length&&i.attr("name",e(this).data("name"))});var s=a.html().replace(/_id_/g,r),o=void 0!==n.attr("readonly"),d=e('<div class="siteorigin-widget-field-repeater-item ui-draggable" />').append(e('<div class="siteorigin-widget-field-repeater-item-top" />').append(e('<div class="siteorigin-widget-field-expand" />')).append(o?"":e('<div class="siteorigin-widget-field-copy" />')).append(o?"":e('<div class="siteorigin-widget-field-remove" />')).append(e("<h4 />").html(n.data("item-name")))).append(e('<div class="siteorigin-widget-field-repeater-item-form" />').html(s));n.find("> .siteorigin-widget-field-repeater-items").append(d).sortable("refresh").trigger("updateFieldPositions"),d.sowSetupRepeaterItems(),d.hide().slideDown("fast",function(){e(window).resize()})})},e.fn.sowRemoveRepeaterItem=function(){return e(this).each(function(i,t){var n=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).remove(),n.sortable("refresh").trigger("updateFieldPositions")})},e.fn.sowSetupRepeaterItems=function(){return e(this).each(function(i,t){var n=e(t);if(void 0===n.data("sowrepeater-actions-setup")){var r=n.closest(".siteorigin-widget-field-repeater"),a=n.find("> .siteorigin-widget-field-repeater-item-top"),s=r.data("item-label");if(s&&s.selector){var o=function(){var e=s.hasOwnProperty("valueMethod")&&s.valueMethod?s.valueMethod:"val",i=n.find(s.selector)[e]();i&&(i.length>80&&(i=i.substr(0,79)+"..."),a.find("h4").text(i))};o();var d=s.hasOwnProperty("updateEvent")&&s.updateEvent?s.updateEvent:"change";n.bind(d,o)}a.click(function(i){"siteorigin-widget-field-remove"!==i.target.className&&"siteorigin-widget-field-copy"!==i.target.className&&(i.preventDefault(),e(this).closest(".siteorigin-widget-field-repeater-item").find(".siteorigin-widget-field-repeater-item-form").eq(0).slideToggle("fast",function(){if(e(window).resize(),e(this).is(":visible")){e(this).trigger("slideToggleOpenComplete");e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}else e(this).trigger("slideToggleCloseComplete")}))}),a.find(".siteorigin-widget-field-remove").click(function(i,t){i.preventDefault();var n=e(this).closest(".siteorigin-widget-field-repeater-items"),r=e(this).closest(".siteorigin-widget-field-repeater-item"),a=function(){r.remove(),n.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?a():confirm(soWidgets.sure)&&r.slideUp("fast",a)}),a.find(".siteorigin-widget-field-copy").click(function(i){i.preventDefault();var t=e(this).closest(".siteorigin-widget-form-main"),r=e(this).closest(".siteorigin-widget-field-repeater-item"),a=r.clone(),s=r.closest(".siteorigin-widget-field-repeater-items"),o=s.children().length,d={};a.find("*[name]").each(function(){var i=e(this),s=i.attr("id"),l=i.attr("name");if(i.is("textarea")&&i.parent().is(".wp-editor-container")&&"undefined"!=typeof tinymce){i.parent().empty().append(i),i.css("display","");var f=tinymce.get(s);f&&i.val(f.getContent())}else if(i.is(".wp-color-picker")){var g=i.closest(".wp-picker-container"),c=i.closest(".siteorigin-widget-field");g.remove(),c.append(i.remove())}else{var p=r.find('[name="'+l+'"]');p.length&&null!=p.val()&&i.val(p.val())}if(s){var u,m,w;if(i.is('[type="radio"]')){m=s.replace(/-\d+-\d+#x2F;,"");var v=s.replace(/-\d+#x2F;,"");if(!d[m]){var h={};d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").filter(function(i,t){var n=e(t).attr("name");return!h[n]&&(h[n]=!0,!0)}).length+1}var b=m+"-"+d[m];w=b+s.match(/-\d+#x2F;)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+quot;),m=s.replace(u,""),d[m]||(d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").length+1),w=m+"-"+d[m]++;i.attr("id",w),a.find("label[for="+s+"]").attr("for",w),a.find("[id*="+s+"]").each(function(){var i=e(this).attr("id"),t=i.replace(s,w);e(this).attr("id",t)}),"undefined"!=typeof tinymce&&tinymce.get(w)&&tinymce.get(w).remove()}var y=r.parents(".siteorigin-widget-field-repeater").length,k=e("body");(k.hasClass("wp-customizer")||k.hasClass("widgets-php"))&&0===n.closest(".panel-dialog").length&&(y+=1);var _=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(y-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",_),i.data("original-name",_)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()})}),n.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),n.data("sowrepeater-actions-setup",!0)}})},sowbForms.getRepeaterId=function(e){void 0===this.id&&(this.id=1);var i=e.closest(".siteorigin-widget-field-repeater-item");if(i.length){var t=i.data("item-id");return void 0===t&&(t=this.id++),i.data("item-id",t),t}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var n=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var r=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=r.split("]["),s=a.length?n:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,n){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,n(window.sowVars[t][i])}):n(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var n=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(n))return!0;n=n[1];var r=n.split("][");r=r.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),s=null===d||"function"!=typeof d.getContent||d.isHidden()?i.val():d.getContent()}else if("SELECT"===i.prop("tagName")){var l=i.find("option:selected");1===l.length?s=i.find("option:selected").val():l.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var f=0;f<r.length;f++)f===r.length-1?""===r[f]?a.push(s):a[r[f]]=s:(_.isUndefined(a[r[f]])&&(_.isNumber(r[f+1])||""===r[f+1]?a[r[f]]=[]:a[r[f]]={}),a=a[r[f]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t){var n=0,r=function(i,t){10!=++n&&i.find("> .siteorigin-widget-field-type-repeater").each(function(){var i=e(this).find("> .siteorigin-widget-field-repeater"),n=i.data("repeaterName"),a=t.hasOwnProperty(n)?t[n]:null;if(a&&Array.isArray(a)&&0!==a.length){var s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),o=a.length,d=s.length;if(o>d)for(var l=0;l<o-d;l++)i.find("> .siteorigin-widget-field-repeater-add").click();else if(o<d)for(var f=o;f<d;f++){var g=e(s.eq(f));g.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var c=0;c<s.length;c++)s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),r(s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),a[c])}})};r(i,t),i.find("*[name]").each(function(){var i=e(this),n=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===n)return!0;n=n[1];var r=n.split("][");r=r.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var a,s=t,o=0;o<r.length;o++)o===r.length-1?a=s[r[o]]:s=s[r[o]];if("checkbox"===i.attr("type"))i.prop("checked",a);else if("radio"===i.attr("type"))i.prop("checked",a===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),null===d||"function"!=typeof d.getContent||d.isHidden()?i.val(a):d.setContent(a)}else i.val(a);i.trigger("change")})},e(".widgets-holder-wrap").on("click",".widget:has(.siteorigin-widget-form-main) .widget-top",function(){var i=e(this).closest(".widget").find(".siteorigin-widget-form-main");setTimeout(function(){i.sowSetupForm()},200)}),e("body").hasClass("wp-customizer")&&e(document).on("widget-added",function(e,i){i.find(".siteorigin-widget-form").sowSetupForm()}),e(document).on("open_dialog",function(i,t){if(t.$el.find(".so-panels-dialog").is(".so-panels-dialog-edit-widget")){e(i.target).find(".siteorigin-widget-form-main").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){void 0===i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *quot;),n=t.exec(e);if(null===n)return!1;var r="",a="default";return void 0!==n[3]?(a=n[1],r=n[3]):r=n[1],{match:n[4].trim(),group:a,state:r}},_checker:function(e,i,t,n){var r={};void 0===i.length&&(i=[i]);for(var a,s=0;s<i.length;s++)!1!==(a=sowEmitters._match(i[s],t))&&("_true"===a.match||n(e,i,a.match))&&(r[a.group]=a.state);return r},select:function(e,i){void 0===i.length&&(i=[i]);for(var t={},n=0;n<i.length;n++)""===i[n]&&(i[n]="default"),t[i[n]]=e;return t},conditional:function(val,args){return sowEmitters._checker(val,args,"[^;{}]*",function(val,args,match){return eval(match)})},in:function(e,i){return sowEmitters._checker(e,i,"[^;{}]*",function(e,i,t){return-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};window.sowbForms=sowbForms;
1
+ var sowbForms=window.sowbForms||{};!function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var r,n=e(t),a=!0,s=e("body"),o=n.find("input[name]");if(o.length&&-1!==o.attr("name").indexOf("__i__"))return this;if(n.is(".siteorigin-widget-form-main")){if(!0===n.data("sow-form-setup"))return!0;if(s.hasClass("widgets-php")&&!n.is(":visible")&&0===n.closest(".panel-dialog").length)return!0;n.on("sowstatechange",function(i,t,r){n.find("[data-state-handler]").each(function(){var i=e(this),n=e.extend({},i.data("state-handler"),a?i.data("state-handler-initial"):{});if(0===Object.keys(n).length)return!0;var s,o,d,l,g,f,c={},p=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");if(!1!==p){var u={};for(var m in n)u[m.replace("{$repeater}",p)]=n[m];n=u}var w=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");if(!1!==w){var v={};for(var h in n){var b=h.match(/_else\[(.*)\]|(.*)\[(.*)\]/),y="";y=b&&b.length&&void 0===b[1]?b[2]+"_"+w+"["+b[3]+"]":"_else["+b[1]+"_"+w+"]",v[y]=n[h]}n=v}for(var k in n)if(g=!1,null!==(s=k.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?#x2F;))){if(o={group:"default",name:"",multi:!1},void 0!==s[2]?(o.group=s[1],o.name=s[3]):o.name=s[0],o.multi=void 0!==s[4],"_else"===o.group)o.group=o.name,o.name="",g=o.group===t&&void 0===c[o.group];else{f=o.name.split(",").map(function(e){return e.trim()});for(var F=0;F<f.length&&!(g=o.group===t&&f[F]===r);F++);}if(g){d=n[k],o.multi||(d=[d]);for(var F=0;F<d.length;F++)l=void 0!==d[F][1]&&Boolean(d[F][1])?i.find(d[F][1]):i,l[d[F][0]].apply(l,void 0!==d[F][2]?d[F][2]:[]);c[o.group]=!0}}})}),n.sowSetupPreview(),r=n;var d=n.find(".siteorigin-widget-teaser");d.find(".dashicons-dismiss").click(function(){var i=e(this);e.get(i.data("dismiss-url")),d.slideUp("normal",function(){d.remove()})});var l=n.find("> .siteorigin-widgets-form-id").val(),g=n.find("> .siteorigin-widgets-form-timestamp"),f=parseInt(g.val()||0),c=JSON.parse(sessionStorage.getItem(l));if(c)if(c._sow_form_timestamp>f){var p=e('<div class="siteorigin-widget-form-notification"><span>'+soWidgets.backup.newerVersion+'</span><a class="button button-small so-backup-restore">'+soWidgets.backup.restore+'</a><a class="button button-small so-backup-dismiss">'+soWidgets.backup.dismiss+"</a><div><small>"+soWidgets.backup.replaceWarning+"</small></div></div>");n.prepend(p),p.find(".so-backup-restore").click(function(){sowbForms.setWidgetFormValues(r,c),p.slideUp("fast",function(){p.remove()})}),p.find(".so-backup-dismiss").click(function(){p.slideUp("fast",function(){sessionStorage.removeItem(l),p.remove()})})}else sessionStorage.removeItem(l);n.change(function(){g.val((new Date).getTime());var e=sowbForms.getWidgetFormValues(n);sessionStorage.setItem(l,JSON.stringify(e))})}else r=n.closest(".siteorigin-widget-form-main");r.find("> .siteorigin-widgets-form-id").val();var u=n.find("> .siteorigin-widget-field");u.find("> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section").sowSetupForm(),u.filter(".siteorigin-widget-widget:not(:has(> .siteorigin-widget-section))").sowSetupForm(),u.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),u.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),n.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),u.find("> .siteorigin-widget-input-color").each(function(){var i=e(this),t={change:function(i,t){setTimeout(function(){e(i.target).trigger("change")},100)}};i.data("defaultColor")&&(t.defaultColor=i.data("defaultColor")),i.wpColorPicker(t)});var m=function(){e(this).toggleClass("siteorigin-widget-section-visible"),e(this).parent().find("> .siteorigin-widget-section, > .siteorigin-widget-widget > .siteorigin-widget-section").slideToggle("fast",function(){if(e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed"),e(this).is(":visible")){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}})};u.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(m),u.filter(".siteorigin-widget-field-type-posts").find(".posts-container-label-wrapper").click(m),u.filter(".siteorigin-widget-field-type-slider").each(function(){var i=e(this),t=i.find('input[type="number"]'),r=i.find(".siteorigin-widget-value-slider");r.slider({max:parseInt(t.attr("max")),min:parseInt(t.attr("min")),value:parseInt(t.val()),slide:function(e,i){t.val(parseInt(i.value)),t.trigger("change")},change:function(e,t){i.find(".siteorigin-widget-slider-value").html(t.value)}}),t.change(function(e,i){i&&i.silent||r.slider("value",parseInt(t.val()))})}),u.filter(".siteorigin-widget-field-type-link").each(function(){var i=e(this),t=null,r=function(){null!==t&&t.abort();var r=i.find(".content-text-search"),n=r.val(),a=r.data("postTypes"),s=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:n,postTypes:a},function(i){for(var t=0;t<i.length;t++)""===i[t].label&&(i[t].label="&nbsp;"),s.append(e("<li>").addClass("post").html(i[t].label+"<span>("+i[t].type+")</span>").data(i[t]));s.removeClass("loading")})};i.find(".select-content-button, .button-close").click(function(t){t.preventDefault(),e(this).blur();var n=i.find(".existing-content-selector");n.toggle(),n.is(":visible")&&0===n.find("ul.posts li").length&&r()}),i.on("click",".posts li",function(t){t.preventDefault();var r=e(this);i.find("input.siteorigin-widget-input").val("post: "+r.data("value")),i.find(".existing-content-selector").toggle()});var n=null;i.find(".content-text-search").keyup(function(){null!==n&&clearTimeout(n),n=setTimeout(function(){r()},500)})}),void 0!==jQuery.fn.soPanelsSetupBuilderWidget&&u.filter(".siteorigin-widget-field-type-builder").each(function(){e(this).find("> .siteorigin-page-builder-field").soPanelsSetupBuilderWidget()});var w=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if(void 0!==t){var n={default:""};void 0===t.length&&(t=[t]);for(var a=0;a<t.length;a++)n=function(t,r){if(void 0===sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return r;var n=sowbForms.getContainerFieldId(i,"repeater",".siteorigin-widget-field-repeater-item");!1!==n&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",n)}));var a=sowbForms.getContainerFieldId(i,"widget",".siteorigin-widget-widget");!1===a||t.hasOwnProperty("widgetFieldId")||(t.widgetFieldId=a,t.args=t.args.map(function(e){return e+"_"+a}));var s=i.is('[type="checkbox"]')?i.is(":checked"):i.val();return e.extend(r,sowEmitters[t.callback](s,t.args))}(t[a],n);var s=r.data("states");void 0===s&&(s={default:""});for(var o in n)void 0!==s[o]&&n[o]===s[o]||(s[o]=n[o],r.trigger("sowstatechange",[o,n[o]]));r.data("states",s)}};u.filter("[data-state-emitter]").each(function(){e(this).find(".siteorigin-widget-input").on("keyup change",w),e(this).find(".siteorigin-widget-input").each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&w.call(i[0]):w.call(i[0])})}),n.trigger("sowsetupform",u).data("sow-form-setup",!0),u.trigger("sowsetupformfield"),n.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),(s.hasClass("wp-customizer")||s.hasClass("widgets-php"))&&n.closest(".ui-sortable").on("sortstop",function(e,i){i.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}),a=!1})},e.fn.sowSetupPreview=function(){var i=e(this);i.siblings(".siteorigin-widget-preview").find("> a").click(function(t){t.preventDefault();var r=sowbForms.getWidgetFormValues(i),n=e(e("#so-widgets-bundle-tpl-preview-dialog").html().trim()).appendTo("body");n.find('input[name="data"]').val(JSON.stringify(r)),n.find('input[name="class"]').val(i.data("class")),n.find("iframe").on("load",function(){e(this).css("visibility","visible")}),n.find("form").submit(),n.find(".close").click(function(){n.remove()})})},e.fn.sowSetupRepeater=function(){return e(this).each(function(i,t){var r=e(t),n=r.find(".siteorigin-widget-field-repeater-items"),a=r.data("repeater-name");n.bind("updateFieldPositions",function(){var i=e(this),t=i.find("> .siteorigin-widget-field-repeater-item");t.each(function(i,t){e(t).find(".siteorigin-widget-input").each(function(t,r){var n=e(r).data("repeater-positions");void 0===n&&(n={}),n[a]=i,e(r).data("repeater-positions",n)})}),i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t).data("repeater-positions"),n=e(t);if(void 0!==r){var a=n.attr("data-original-name");if(a||(n.attr("data-original-name",n.attr("name")),a=n.attr("name")),!a)return;if(r)for(var s in r)a=a.replace("#"+s+"#",r[s]);n.attr("name",a)}}),i.data("initialSetup")||(i.find(".siteorigin-widget-input").each(function(i,t){var r=e(t);r.prop("checked",r.prop("defaultChecked"))}),i.data("initialSetup",!0));var n=r.data("scroll-count")?parseInt(r.data("scroll-count")):0;if(n>0&&t.length>n){var s=t.first().outerHeight();i.css("max-height",s*n).css("overflow","auto")}else i.css("max-height","").css("overflow","")}),n.sortable({handle:".siteorigin-widget-field-repeater-item-top",items:"> .siteorigin-widget-field-repeater-item",update:function(){n.trigger("updateFieldPositions")},sortstop:function(i,t){if(t.item.is(".siteorigin-widget-field-repeater-item"))t.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")});else{t.item.find(".siteorigin-widget-form").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}}),n.trigger("updateFieldPositions"),r.find("> .siteorigin-widget-field-repeater-add").disableSelection().click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").sowAddRepeaterItem().find("> .siteorigin-widget-field-repeater-items").slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-top > .siteorigin-widget-field-repeater-expand").click(function(i){i.preventDefault(),r.closest(".siteorigin-widget-field-repeater").find("> .siteorigin-widget-field-repeateritems-").slideToggle("fast",function(){e(window).resize()})})})},e.fn.sowAddRepeaterItem=function(){return e(this).each(function(i,t){var r=e(t),n=r.find("> .siteorigin-widget-field-repeater-items").children().length+1,a=e("<div>"+r.find("> .siteorigin-widget-field-repeater-item-html").html()+"</div>");a.find(".siteorigin-widget-input[data-name]").each(function(){var i=e(this);0===i.closest(".siteorigin-widget-field-repeater-item-html").length&&i.attr("name",e(this).data("name"))});var s=a.html().replace(/_id_/g,n),o=void 0!==r.attr("readonly"),d=e('<div class="siteorigin-widget-field-repeater-item ui-draggable" />').append(e('<div class="siteorigin-widget-field-repeater-item-top" />').append(e('<div class="siteorigin-widget-field-expand" />')).append(o?"":e('<div class="siteorigin-widget-field-copy" />')).append(o?"":e('<div class="siteorigin-widget-field-remove" />')).append(e("<h4 />").html(r.data("item-name")))).append(e('<div class="siteorigin-widget-field-repeater-item-form" />').html(s));r.find("> .siteorigin-widget-field-repeater-items").append(d).sortable("refresh").trigger("updateFieldPositions"),d.sowSetupRepeaterItems(),d.hide().slideDown("fast",function(){e(window).resize()})})},e.fn.sowRemoveRepeaterItem=function(){return e(this).each(function(i,t){var r=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).remove(),r.sortable("refresh").trigger("updateFieldPositions")})},e.fn.sowSetupRepeaterItems=function(){return e(this).each(function(i,t){var r=e(t);if(void 0===r.data("sowrepeater-actions-setup")){var n=r.closest(".siteorigin-widget-field-repeater"),a=r.find("> .siteorigin-widget-field-repeater-item-top"),s=n.data("item-label");if(s&&s.selector){var o=function(){var e=s.hasOwnProperty("valueMethod")&&s.valueMethod?s.valueMethod:"val",i=r.find(s.selector)[e]();i&&(i.length>80&&(i=i.substr(0,79)+"..."),a.find("h4").text(i))};o();var d=s.hasOwnProperty("updateEvent")&&s.updateEvent?s.updateEvent:"change";r.bind(d,o)}a.click(function(i){"siteorigin-widget-field-remove"!==i.target.className&&"siteorigin-widget-field-copy"!==i.target.className&&(i.preventDefault(),e(this).closest(".siteorigin-widget-field-repeater-item").find(".siteorigin-widget-field-repeater-item-form").eq(0).slideToggle("fast",function(){if(e(window).resize(),e(this).is(":visible")){e(this).trigger("slideToggleOpenComplete");e(this).find("> .siteorigin-widget-field").trigger("sowsetupformfield")}else e(this).trigger("slideToggleCloseComplete")}))}),a.find(".siteorigin-widget-field-remove").click(function(i,t){i.preventDefault();var r=e(this).closest(".siteorigin-widget-field-repeater-items"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=function(){n.remove(),r.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()};t&&t.silent?a():confirm(soWidgets.sure)&&n.slideUp("fast",a)}),a.find(".siteorigin-widget-field-copy").click(function(i){i.preventDefault();var t=e(this).closest(".siteorigin-widget-form-main"),n=e(this).closest(".siteorigin-widget-field-repeater-item"),a=n.clone(),s=n.closest(".siteorigin-widget-field-repeater-items"),o=s.children().length,d={};a.find("*[name]").each(function(){var i=e(this),s=i.attr("id"),l=i.attr("name");if(i.is("textarea")&&i.parent().is(".wp-editor-container")&&"undefined"!=typeof tinymce){i.parent().empty().append(i),i.css("display","");var g=tinymce.get(s);g&&i.val(g.getContent())}else if(i.is(".wp-color-picker")){var f=i.closest(".wp-picker-container"),c=i.closest(".siteorigin-widget-field");f.remove(),c.append(i.remove())}else{var p=n.find('[name="'+l+'"]');p.length&&null!=p.val()&&i.val(p.val())}if(s){var u,m,w;if(i.is('[type="radio"]')){m=s.replace(/-\d+-\d+#x2F;,"");var v=s.replace(/-\d+#x2F;,"");if(!d[m]){var h={};d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").filter(function(i,t){var r=e(t).attr("name");return!h[r]&&(h[r]=!0,!0)}).length+1}var b=m+"-"+d[m];w=b+s.match(/-\d+#x2F;)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+quot;),m=s.replace(u,""),d[m]||(d[m]=t.find(".siteorigin-widget-input[id^="+m+"]").not("[id*=_id_]").length+1),w=m+"-"+d[m]++;i.attr("id",w),a.find("label[for="+s+"]").attr("for",w),a.find("[id*="+s+"]").each(function(){var i=e(this).attr("id"),t=i.replace(s,w);e(this).attr("id",t)}),"undefined"!=typeof tinymce&&tinymce.get(w)&&tinymce.get(w).remove()}var y=n.parents(".siteorigin-widget-field-repeater").length,k=e("body");(k.hasClass("wp-customizer")||k.hasClass("widgets-php"))&&0===r.closest(".panel-dialog").length&&(y+=1);var F=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(y-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",F),i.data("original-name",F)}),s.append(a).sortable("refresh").trigger("updateFieldPositions"),a.sowSetupRepeaterItems(),a.hide().slideDown("fast",function(){e(window).resize()})}),r.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),r.data("sowrepeater-actions-setup",!0)}})},sowbForms.getContainerFieldId=function(e,i,t){var r=i+"FieldId";this.hasOwnProperty(r)||(this[r]=1);var n=e.closest(t);if(n.length){var a=n.data("field-id");return void 0===a&&(a=this[r]++),n.data("field-id",a),a}return!1},sowbForms.getWidgetFieldVariable=function(e,i,t){var r=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var n=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],a=n.split("]["),s=a.length?r:null;a.length;)s=s[a.shift()];return s[t]},sowbForms.fetchWidgetVariable=function(i,t,r){window.sowVars=window.sowVars||{},void 0===window.sowVars[t]?e.post(soWidgets.ajaxurl,{action:"sow_get_javascript_variables",widget:t,key:i},function(e){window.sowVars[t]=e,r(window.sowVars[t][i])}):r(window.sowVars[t][i])},sowbForms.getWidgetFormValues=function(i){if(_.isUndefined(i))return null;var t={};return i.find("*[name]").each(function(){var i=e(this);try{var r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(_.isEmpty(r))return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});var a=t,s=null,o=_.isString(i.attr("type"))?i.attr("type").toLowerCase():null;if("checkbox"===o)s=!!i.is(":checked")&&(""===i.val()||i.val());else if("radio"===o){if(!i.is(":checked"))return;s=i.val()}else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),s=null===d||"function"!=typeof d.getContent||d.isHidden()?i.val():d.getContent()}else if("SELECT"===i.prop("tagName")){var l=i.find("option:selected");1===l.length?s=i.find("option:selected").val():l.length>1&&(s=_.map(i.find("option:selected"),function(i,t){return e(i).val()}))}else s=i.val();for(var g=0;g<n.length;g++)g===n.length-1?""===n[g]?a.push(s):a[n[g]]=s:(_.isUndefined(a[n[g]])&&(_.isNumber(n[g+1])||""===n[g+1]?a[n[g]]=[]:a[n[g]]={}),a=a[n[g]])}catch(e){console.error("Field ["+i.attr("name")+"] could not be processed and was skipped - "+e.message)}}),t},sowbForms.setWidgetFormValues=function(i,t){var r=0,n=function(i,t){10!=++r&&i.find("> .siteorigin-widget-field-type-repeater").each(function(){var i=e(this).find("> .siteorigin-widget-field-repeater"),r=i.data("repeaterName"),a=t.hasOwnProperty(r)?t[r]:null;if(a&&Array.isArray(a)&&0!==a.length){var s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item"),o=a.length,d=s.length;if(o>d)for(var l=0;l<o-d;l++)i.find("> .siteorigin-widget-field-repeater-add").click();else if(o<d)for(var g=o;g<d;g++){var f=e(s.eq(g));f.find("> .siteorigin-widget-field-repeater-item-top").find(".siteorigin-widget-field-remove").trigger("click",{silent:!0})}s=i.find("> .siteorigin-widget-field-repeater-items > .siteorigin-widget-field-repeater-item");for(var c=0;c<s.length;c++)s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),n(s.eq(c).find("> .siteorigin-widget-field-repeater-item-form"),a[c])}})};n(i,t),i.find("*[name]").each(function(){var i=e(this),r=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===r)return!0;r=r[1];var n=r.split("][");n=n.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var a,s=t,o=0;o<n.length;o++)o===n.length-1?a=s[n[o]]:s=s[n[o]];if("checkbox"===i.attr("type"))i.prop("checked",a);else if("radio"===i.attr("type"))i.prop("checked",a===i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var d=null;"undefined"!=typeof tinyMCE&&(d=tinyMCE.get(i.attr("id"))),null===d||"function"!=typeof d.getContent||d.isHidden()?i.val(a):d.setContent(a)}else i.val(a);i.trigger("change")})},e(".widgets-holder-wrap").on("click",".widget:has(.siteorigin-widget-form-main) .widget-top",function(){var i=e(this).closest(".widget").find(".siteorigin-widget-form-main");setTimeout(function(){i.sowSetupForm()},200)}),e("body").hasClass("wp-customizer")&&e(document).on("widget-added",function(e,i){i.find(".siteorigin-widget-form").sowSetupForm()}),e(document).on("open_dialog",function(i,t){if(t.$el.find(".so-panels-dialog").is(".so-panels-dialog-edit-widget")){e(i.target).find(".siteorigin-widget-form-main").find("> .siteorigin-widget-field").trigger("sowsetupformfield")}}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){void 0===i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *quot;),r=t.exec(e);if(null===r)return!1;var n="",a="default";return void 0!==r[3]?(a=r[1],n=r[3]):n=r[1],{match:r[4].trim(),group:a,state:n}},_checker:function(e,i,t,r){var n={};void 0===i.length&&(i=[i]);for(var a,s=0;s<i.length;s++)!1!==(a=sowEmitters._match(i[s],t))&&("_true"===a.match||r(e,i,a.match))&&(n[a.group]=a.state);return n},select:function(e,i){void 0===i.length&&(i=[i]);for(var t={},r=0;r<i.length;r++)""===i[r]&&(i[r]="default"),t[i[r]]=e;return t},conditional:function(val,args){return sowEmitters._checker(val,args,"[^;{}]*",function(val,args,match){return eval(match)})},in:function(e,i){return sowEmitters._checker(e,i,"[^;{}]*",function(e,i,t){return-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};window.sowbForms=sowbForms;
base/siteorigin-widget.class.php CHANGED
@@ -1003,7 +1003,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1003
* @return array
1004
*/
1005
function get_google_font_fields( $instance ) {
1006
- return array();
1007
}
1008
1009
/**
@@ -1218,8 +1218,15 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1218
/**
1219
* Enqueue all the registered scripts
1220
*/
1221
- function enqueue_registered_scripts() {
1222
- foreach ( $this->frontend_scripts as $f_script ) {
1223
if ( ! wp_script_is( $f_script[0] ) ) {
1224
wp_enqueue_script(
1225
$f_script[0],
@@ -1248,8 +1255,15 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1248
/**
1249
* Enqueue any frontend styles that were registered
1250
*/
1251
- function enqueue_registered_styles() {
1252
- foreach ( $this->frontend_styles as $f_style ) {
1253
if ( ! wp_style_is( $f_style[0] ) ) {
1254
wp_enqueue_style(
1255
$f_style[0],
@@ -1268,8 +1282,8 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1268
* will then ensure that the scripts are not enqueued more than once.
1269
*/
1270
function enqueue_frontend_scripts( $instance ) {
1271
- $this->enqueue_registered_scripts();
1272
- $this->enqueue_registered_styles();
1273
1274
// Give plugins a chance to enqueue additional frontend scripts
1275
do_action('siteorigin_widgets_enqueue_frontend_scripts_' . $this->id_base, $instance, $this);
1003
* @return array
1004
*/
1005
function get_google_font_fields( $instance ) {
1006
+ return apply_filters( 'siteorigin_widgets_google_font_fields_' . $this->id_base, array(), $instance, $this );
1007
}
1008
1009
/**
1218
/**
1219
* Enqueue all the registered scripts
1220
*/
1221
+ function enqueue_registered_scripts( $instance ) {
1222
+ $f_scripts = apply_filters(
1223
+ 'siteorigin_widgets_frontend_scripts_' . $this->id_base,
1224
+ $this->frontend_scripts,
1225
+ $instance,
1226
+ $this
1227
+ );
1228
+
1229
+ foreach ( $f_scripts as $f_script ) {
1230
if ( ! wp_script_is( $f_script[0] ) ) {
1231
wp_enqueue_script(
1232
$f_script[0],
1255
/**
1256
* Enqueue any frontend styles that were registered
1257
*/
1258
+ function enqueue_registered_styles( $instance ) {
1259
+ $f_styles = apply_filters(
1260
+ 'siteorigin_widgets_frontend_styles_' . $this->id_base,
1261
+ $this->frontend_styles,
1262
+ $instance,
1263
+ $this
1264
+ );
1265
+
1266
+ foreach ( $f_styles as $f_style ) {
1267
if ( ! wp_style_is( $f_style[0] ) ) {
1268
wp_enqueue_style(
1269
$f_style[0],
1282
* will then ensure that the scripts are not enqueued more than once.
1283
*/
1284
function enqueue_frontend_scripts( $instance ) {
1285
+ $this->enqueue_registered_scripts( $instance );
1286
+ $this->enqueue_registered_styles( $instance );
1287
1288
// Give plugins a chance to enqueue additional frontend scripts
1289
do_action('siteorigin_widgets_enqueue_frontend_scripts_' . $this->id_base, $instance, $this);
compat/elementor/styles.css CHANGED
@@ -1,12 +1,3 @@
1
- body #elementor-editor-wrapper .elementor-panel {
2
- min-width: 400px;
3
- }
4
- body.elementor-editor-preview #elementor-editor-wrapper #elementor-panel {
5
- left: -400px;
6
- }
7
- body.elementor-editor-active #elementor-editor-wrapper #elementor-preview {
8
- left: 400px;
9
- }
10
.elementor-panel #elementor-panel-page-editor .elementor-control-content .siteorigin-widget-form {
11
min-width: inherit;
12
/* Button styles copied from wp-core for default UI look. */
1
.elementor-panel #elementor-panel-page-editor .elementor-control-content .siteorigin-widget-form {
2
min-width: inherit;
3
/* Button styles copied from wp-core for default UI look. */
js/slider/jquery.slider.js CHANGED
@@ -82,15 +82,18 @@ jQuery( function($){
82
83
$slide.click(function(event) {
84
85
- if( urlData !== undefined ) {
86
- var $t = $(event.target);
87
- // If this isn't a link, we'll use the URL of the frame
88
- if( $t.prop("tagName") !== 'A' ) {
89
- event.preventDefault();
90
- window.open(urlData.url, urlData.new_window ? '_blank' : '_self');
91
- }
92
}
93
} );
94
});
95
96
var setupSlider = function(){
82
83
$slide.click(function(event) {
84
85
+ if( urlData !== undefined && urlData.hasOwnProperty( 'url' ) ) {
86
+ event.preventDefault();
87
+ window.open(
88
+ urlData.url,
89
+ urlData.hasOwnProperty( 'new_window' ) && urlData.new_window ? '_blank' : '_self'
90
+ );
91
}
92
} );
93
+
94
+ $slide.find( 'a' ).click( function ( event ) {
95
+ event.stopPropagation();
96
+ } );
97
});
98
99
var setupSlider = function(){
js/slider/jquery.slider.min.js CHANGED
@@ -1 +1 @@
1
- var sowb=window.sowb||{};sowb.SiteOriginSlider=function(e){return{playSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.play&&this.play()})},pauseSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.pause&&this.pause()})},setupActiveSlide:function(i,t,s){var n=e(i).find(".cycle-sentinel"),o=e(t),d=o.find("video.sow-background-element");if(void 0==s?n.css("height",o.outerHeight()):n.animate({height:o.outerHeight()},s),d.length){o.outerWidth()/o.outerHeight()>d.outerWidth()/d.outerHeight()?d.css({width:"100%",height:"auto"}):d.css({width:"auto",height:"100%"}),d.css({"margin-left":-Math.ceil(d.width()/2),"margin-top":-Math.ceil(d.height()/2)})}}}},jQuery(function(e){sowb.setupSliders=sowb.setupSlider=function(){var i=new sowb.SiteOriginSlider(e);e(".sow-slider-images").each(function(){var t=e(this),s=t.siblings(".sow-slider-pagination"),n=t.closest(".sow-slider-base"),o=n.find(".sow-slide-nav"),d=t.find(".sow-slider-image"),c=t.data("settings");d.each(function(i,t){var s=e(t),n=s.data("url");s.click(function(i){if(void 0!==n){"A"!==e(i.target).prop("tagName")&&(i.preventDefault(),window.open(n.url,n.new_window?"_blank":"_self"))}})});var l=function(){var a=t.closest(".so-widget-fittext-wrapper");if(a.length>0&&!a.data("fitTextDone"))return void a.on("fitTextDone",function(){l()});if(n.show(),t.find(".sow-slider-image").each(function(){var i=e(this);e(window).on("resize panelsStretchRows",function(){i.css("height",i.find(".sow-slider-image-wrapper").outerHeight())}).resize()}),t.on({"cycle-after":function(t,s,n,o,d){var c=e(this);i.playSlideVideo(o),i.setupActiveSlide(c,o),e(o).trigger("sowSlideCycleAfter")},"cycle-before":function(t,n,o,d,c){var l=e(this);s.find("> li").removeClass("sow-active").eq(n.slideNum-1).addClass("sow-active"),i.pauseSlideVideo(o),i.setupActiveSlide(l,d,n.speed),e(d).trigger("sowSlideCycleBefore")},"cycle-initialized":function(n,d){i.playSlideVideo(e(this).find(".cycle-slide-active")),i.setupActiveSlide(t,d.slides[0]),s.find(">li").removeClass("sow-active").eq(0).addClass("sow-active"),e(this).find(".cycle-slide-active").trigger("sowSlideInitial"),d.slideCount<=1&&(s.hide(),o.hide()),e(window).resize(),setTimeout(function(){i.setupActiveSlide(t,d.slides[0]),t.find(".cycle-sentinel").empty()},200)}}).cycle({slides:"> .sow-slider-image",speed:c.speed,timeout:c.timeout,swipe:c.swipe,"swipe-fx":"scrollHorz"}),t.find("video.sow-background-element").on("loadeddata",function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.add(o).hide(),!n.hasClass("sow-slider-is-mobile")&&d.length>1){var r=!1;n.mouseenter(function(){s.add(o).clearQueue().fadeIn(150),r=!1}).mouseleave(function(){r=!0,setTimeout(function(){r&&s.add(o).clearQueue().fadeOut(150),r=!1},750)})}e(window).resize(function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.find("> li > a").click(function(i){i.preventDefault(),t.cycle("goto",e(this).data("goto"))}),o.find("> a").click(function(i){i.preventDefault(),t.cycle(e(this).data("action"))}),n.keydown(function(e){37===e.which?t.cycle("prev"):39===e.which&&t.cycle("next")})},a=t.find("img"),r=0,u=!1;a.each(function(){e(this);this.complete?r++:e(this).one("load",function(){++r!==a.length||u||(l(),u=!0)}).attr("src",e(this).attr("src")),r!==a.length||u||(l(),u=!0)}),0===a.length&&l()})},sowb.setupSliders(),e(sowb).on("setup_widgets",sowb.setupSliders)}),window.sowb=sowb;
1
+ var sowb=window.sowb||{};sowb.SiteOriginSlider=function(e){return{playSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.play&&this.play()})},pauseSlideVideo:function(i){e(i).find("video").each(function(){void 0!==this.pause&&this.pause()})},setupActiveSlide:function(i,t,s){var n=e(i).find(".cycle-sentinel"),o=e(t),d=o.find("video.sow-background-element");if(void 0==s?n.css("height",o.outerHeight()):n.animate({height:o.outerHeight()},s),d.length){o.outerWidth()/o.outerHeight()>d.outerWidth()/d.outerHeight()?d.css({width:"100%",height:"auto"}):d.css({width:"auto",height:"100%"}),d.css({"margin-left":-Math.ceil(d.width()/2),"margin-top":-Math.ceil(d.height()/2)})}}}},jQuery(function(e){sowb.setupSliders=sowb.setupSlider=function(){var i=new sowb.SiteOriginSlider(e);e(".sow-slider-images").each(function(){var t=e(this),s=t.siblings(".sow-slider-pagination"),n=t.closest(".sow-slider-base"),o=n.find(".sow-slide-nav"),d=t.find(".sow-slider-image"),c=t.data("settings");d.each(function(i,t){var s=e(t),n=s.data("url");s.click(function(e){void 0!==n&&n.hasOwnProperty("url")&&(e.preventDefault(),window.open(n.url,n.hasOwnProperty("new_window")&&n.new_window?"_blank":"_self"))}),s.find("a").click(function(e){e.stopPropagation()})});var l=function(){var a=t.closest(".so-widget-fittext-wrapper");if(a.length>0&&!a.data("fitTextDone"))return void a.on("fitTextDone",function(){l()});if(n.show(),t.find(".sow-slider-image").each(function(){var i=e(this);e(window).on("resize panelsStretchRows",function(){i.css("height",i.find(".sow-slider-image-wrapper").outerHeight())}).resize()}),t.on({"cycle-after":function(t,s,n,o,d){var c=e(this);i.playSlideVideo(o),i.setupActiveSlide(c,o),e(o).trigger("sowSlideCycleAfter")},"cycle-before":function(t,n,o,d,c){var l=e(this);s.find("> li").removeClass("sow-active").eq(n.slideNum-1).addClass("sow-active"),i.pauseSlideVideo(o),i.setupActiveSlide(l,d,n.speed),e(d).trigger("sowSlideCycleBefore")},"cycle-initialized":function(n,d){i.playSlideVideo(e(this).find(".cycle-slide-active")),i.setupActiveSlide(t,d.slides[0]),s.find(">li").removeClass("sow-active").eq(0).addClass("sow-active"),e(this).find(".cycle-slide-active").trigger("sowSlideInitial"),d.slideCount<=1&&(s.hide(),o.hide()),e(window).resize(),setTimeout(function(){i.setupActiveSlide(t,d.slides[0]),t.find(".cycle-sentinel").empty()},200)}}).cycle({slides:"> .sow-slider-image",speed:c.speed,timeout:c.timeout,swipe:c.swipe,"swipe-fx":"scrollHorz"}),t.find("video.sow-background-element").on("loadeddata",function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.add(o).hide(),!n.hasClass("sow-slider-is-mobile")&&d.length>1){var r=!1;n.mouseenter(function(){s.add(o).clearQueue().fadeIn(150),r=!1}).mouseleave(function(){r=!0,setTimeout(function(){r&&s.add(o).clearQueue().fadeOut(150),r=!1},750)})}e(window).resize(function(){i.setupActiveSlide(t,t.find(".cycle-slide-active"))}),s.find("> li > a").click(function(i){i.preventDefault(),t.cycle("goto",e(this).data("goto"))}),o.find("> a").click(function(i){i.preventDefault(),t.cycle(e(this).data("action"))}),n.keydown(function(e){37===e.which?t.cycle("prev"):39===e.which&&t.cycle("next")})},a=t.find("img"),r=0,u=!1;a.each(function(){e(this);this.complete?r++:e(this).one("load",function(){++r!==a.length||u||(l(),u=!0)}).attr("src",e(this).attr("src")),r!==a.length||u||(l(),u=!0)}),0===a.length&&l()})},sowb.setupSliders(),e(sowb).on("setup_widgets",sowb.setupSliders)}),window.sowb=sowb;
lang/so-widgets-bundle.pot CHANGED
@@ -37,35 +37,35 @@ msgstr ""
37
msgid "Disabled"
38
msgstr ""
39
40
- #: tmp/admin/tpl/admin.php:44
41
msgid "Active"
42
msgstr ""
43
44
- #: tmp/admin/tpl/admin.php:66
45
msgid "Activate"
46
msgstr ""
47
48
- #: tmp/admin/tpl/admin.php:67
49
msgid "Deactivate"
50
msgstr ""
51
52
- #: tmp/admin/tpl/admin.php:86, tmp/widgets/contact/contact.php:58, tmp/widgets/google-map/google-map.php:70, tmp/widgets/testimonial/testimonial.php:99
53
msgid "Settings"
54
msgstr ""
55
56
- #: tmp/admin/tpl/admin.php:100
57
msgid "Developers - create your own widgets for the Widgets Bundle."
58
msgstr ""
59
60
- #: tmp/admin/tpl/admin.php:101
61
msgid "Read More"
62
msgstr ""
63
64
- #: tmp/admin/tpl/admin.php:108
65
msgid "Widget Settings"
66
msgstr ""
67
68
- #: tmp/admin/tpl/admin.php:119
69
msgid "Save"
70
msgstr ""
71
@@ -233,6 +233,22 @@ msgstr ""
233
msgid "Sponsored"
234
msgstr ""
235
236
#: tmp/base/inc/fields/posts.class.php:22
237
msgid "Post type"
238
msgstr ""
@@ -281,7 +297,7 @@ msgstr ""
281
msgid "Author"
282
msgstr ""
283
284
- #: tmp/base/inc/fields/posts.class.php:82, tmp/widgets/contact/contact.php:47, tmp/widgets/cta/cta.php:63, tmp/widgets/editor/editor.php:32, tmp/widgets/features/features.php:132, tmp/widgets/post-carousel/post-carousel.php:97, tmp/widgets/price-table/price-table.php:41, tmp/widgets/price-table/price-table.php:60, tmp/widgets/simple-masonry/simple-masonry.php:43, tmp/widgets/simple-masonry/simple-masonry.php:74, tmp/widgets/social-media-buttons/social-media-buttons.php:42, tmp/widgets/taxonomy/taxonomy.php:33, tmp/widgets/testimonial/testimonial.php:40, tmp/widgets/video/video.php:32
285
msgid "Title"
286
msgstr ""
287
@@ -373,11 +389,11 @@ msgstr ""
373
msgid "Add"
374
msgstr ""
375
376
- #: tmp/base/inc/fields/widget.class.php:36
377
msgid "%s does not exist"
378
msgstr ""
379
380
- #: tmp/base/inc/fields/widget.class.php:46
381
msgid "%s is not a SiteOrigin Widget"
382
msgstr ""
383
@@ -597,14 +613,94 @@ msgstr ""
597
msgid "Deactivated"
598
msgstr ""
599
600
- #: tmp/so-widgets-bundle.php:728
601
msgid "Manage Widgets"
602
msgstr ""
603
604
- #: tmp/so-widgets-bundle.php:729
605
msgid "Support"
606
msgstr ""
607
608
#: tmp/widgets/button/button.php:14
609
msgid "SiteOrigin Button"
610
msgstr ""
@@ -1041,26 +1137,10 @@ msgstr ""
1041
msgid "How to handle submissions that are identified as spam."
1042
msgstr ""
1043
1044
- #: tmp/widgets/contact/contact.php:276, tmp/widgets/cta/cta.php:73, tmp/widgets/testimonial/testimonial.php:182
1045
- msgid "Design"
1046
- msgstr ""
1047
-
1048
#: tmp/widgets/contact/contact.php:282
1049
msgid "Container"
1050
msgstr ""
1051
1052
- #: tmp/widgets/contact/contact.php:286, tmp/widgets/contact/contact.php:515, tmp/widgets/cta/cta.php:77, tmp/widgets/hero/hero.php:113, tmp/widgets/layout-slider/layout-slider.php:81, tmp/widgets/social-media-buttons/social-media-buttons.php:74
1053
- msgid "Background color"
1054
- msgstr ""
1055
-
1056
- #: tmp/widgets/contact/contact.php:296, tmp/widgets/contact/contact.php:409, tmp/widgets/contact/contact.php:525, tmp/widgets/cta/cta.php:81
1057
- msgid "Border color"
1058
- msgstr ""
1059
-
1060
- #: tmp/widgets/contact/contact.php:301, tmp/widgets/contact/contact.php:414, tmp/widgets/contact/contact.php:541
1061
- msgid "Border width"
1062
- msgstr ""
1063
-
1064
#: tmp/widgets/contact/contact.php:306, tmp/widgets/contact/contact.php:530
1065
msgid "Border style"
1066
msgstr ""
@@ -1305,10 +1385,6 @@ msgstr ""
1305
msgid "Subtitle"
1306
msgstr ""
1307
1308
- #: tmp/widgets/cta/cta.php:85
1309
- msgid "Title color"
1310
- msgstr ""
1311
-
1312
#: tmp/widgets/cta/cta.php:89
1313
msgid "Subtitle color"
1314
msgstr ""
@@ -1941,10 +2017,6 @@ msgstr ""
1941
msgid "Frame"
1942
msgstr ""
1943
1944
- #: tmp/widgets/hero/hero.php:59, tmp/widgets/layout-slider/layout-slider.php:47
1945
- msgid "Content"
1946
- msgstr ""
1947
-
1948
#: tmp/widgets/hero/hero.php:64, tmp/widgets/taxonomy/taxonomy.php:49
1949
msgid "Buttons"
1950
msgstr ""
@@ -2732,3 +2804,11 @@ msgstr ""
2732
#: tmp/widgets/video/video.php:106
2733
msgid "Always use the embedded video rather than the MediaElement player."
2734
msgstr ""
37
msgid "Disabled"
38
msgstr ""
39
40
+ #: tmp/admin/tpl/admin.php:48
41
msgid "Active"
42
msgstr ""
43
44
+ #: tmp/admin/tpl/admin.php:70
45
msgid "Activate"
46
msgstr ""
47
48
+ #: tmp/admin/tpl/admin.php:71
49
msgid "Deactivate"
50
msgstr ""
51
52
+ #: tmp/admin/tpl/admin.php:90, tmp/widgets/contact/contact.php:58, tmp/widgets/google-map/google-map.php:70, tmp/widgets/testimonial/testimonial.php:99
53
msgid "Settings"
54
msgstr ""
55
56
+ #: tmp/admin/tpl/admin.php:104
57
msgid "Developers - create your own widgets for the Widgets Bundle."
58
msgstr ""
59
60
+ #: tmp/admin/tpl/admin.php:105
61
msgid "Read More"
62
msgstr ""
63
64
+ #: tmp/admin/tpl/admin.php:112
65
msgid "Widget Settings"
66
msgstr ""
67
68
+ #: tmp/admin/tpl/admin.php:123
69
msgid "Save"
70
msgstr ""
71
233
msgid "Sponsored"
234
msgstr ""
235
236
+ #: tmp/base/inc/fields/multi-measurement.class.php:12
237
+ msgid "Padding left"
238
+ msgstr ""
239
+
240
+ #: tmp/base/inc/fields/multi-measurement.class.php:15
241
+ msgid "Padding right"
242
+ msgstr ""
243
+
244
+ #: tmp/base/inc/fields/multi-measurement.class.php:16
245
+ msgid "Padding bottom"
246
+ msgstr ""
247
+
248
+ #: tmp/base/inc/fields/multi-measurement.class.php:17
249
+ msgid "Padding top"
250
+ msgstr ""
251
+
252
#: tmp/base/inc/fields/posts.class.php:22
253
msgid "Post type"
254
msgstr ""
297
msgid "Author"
298
msgstr ""
299
300
+ #: tmp/base/inc/fields/posts.class.php:82, tmp/widgets/accordion/accordion.php:50, tmp/widgets/contact/contact.php:47, tmp/widgets/cta/cta.php:63, tmp/widgets/editor/editor.php:32, tmp/widgets/features/features.php:132, tmp/widgets/post-carousel/post-carousel.php:97, tmp/widgets/price-table/price-table.php:41, tmp/widgets/price-table/price-table.php:60, tmp/widgets/simple-masonry/simple-masonry.php:43, tmp/widgets/simple-masonry/simple-masonry.php:74, tmp/widgets/social-media-buttons/social-media-buttons.php:42, tmp/widgets/taxonomy/taxonomy.php:33, tmp/widgets/testimonial/testimonial.php:40, tmp/widgets/video/video.php:32
301
msgid "Title"
302
msgstr ""
303
389
msgid "Add"
390
msgstr ""
391
392
+ #: tmp/base/inc/fields/widget.class.php:37
393
msgid "%s does not exist"
394
msgstr ""
395
396
+ #: tmp/base/inc/fields/widget.class.php:47
397
msgid "%s is not a SiteOrigin Widget"
398
msgstr ""
399
613
msgid "Deactivated"
614
msgstr ""
615
616
+ #: tmp/so-widgets-bundle.php:729
617
msgid "Manage Widgets"
618
msgstr ""
619
620
+ #: tmp/so-widgets-bundle.php:730
621
msgid "Support"
622
msgstr ""
623
624
+ #: tmp/widgets/accordion/accordion.php:14
625
+ msgid "SiteOrigin Accordion"
626
+ msgstr ""
627
+
628
+ #: tmp/widgets/accordion/accordion.php:16
629
+ msgid "An accordion widget."
630
+ msgstr ""
631
+
632
+ #: tmp/widgets/accordion/accordion.php:46, tmp/widgets/accordion/accordion.php:113
633
+ msgid "Panels"
634
+ msgstr ""
635
+
636
+ #: tmp/widgets/accordion/accordion.php:54, tmp/widgets/hero/hero.php:59, tmp/widgets/layout-slider/layout-slider.php:47
637
+ msgid "Content"
638
+ msgstr ""
639
+
640
+ #: tmp/widgets/accordion/accordion.php:58
641
+ msgid "Initial state"
642
+ msgstr ""
643
+
644
+ #: tmp/widgets/accordion/accordion.php:59
645
+ msgid "Whether this panel should be open or closed when the page first loads."
646
+ msgstr ""
647
+
648
+ #: tmp/widgets/accordion/accordion.php:61
649
+ msgid "Open"
650
+ msgstr ""
651
+
652
+ #: tmp/widgets/accordion/accordion.php:62
653
+ msgid "Closed"
654
+ msgstr ""
655
+
656
+ #: tmp/widgets/accordion/accordion.php:70, tmp/widgets/contact/contact.php:276, tmp/widgets/cta/cta.php:73, tmp/widgets/testimonial/testimonial.php:182
657
+ msgid "Design"
658
+ msgstr ""
659
+
660
+ #: tmp/widgets/accordion/accordion.php:75
661
+ msgid "Headings"
662
+ msgstr ""
663
+
664
+ #: tmp/widgets/accordion/accordion.php:80, tmp/widgets/accordion/accordion.php:118, tmp/widgets/contact/contact.php:286, tmp/widgets/contact/contact.php:515, tmp/widgets/cta/cta.php:77, tmp/widgets/hero/hero.php:113, tmp/widgets/layout-slider/layout-slider.php:81, tmp/widgets/social-media-buttons/social-media-buttons.php:74
665
+ msgid "Background color"
666
+ msgstr ""
667
+
668
+ #: tmp/widgets/accordion/accordion.php:85
669
+ msgid "Background hover color"
670
+ msgstr ""
671
+
672
+ #: tmp/widgets/accordion/accordion.php:90, tmp/widgets/cta/cta.php:85
673
+ msgid "Title color"
674
+ msgstr ""
675
+
676
+ #: tmp/widgets/accordion/accordion.php:95
677
+ msgid "Title hover color"
678
+ msgstr ""
679
+
680
+ #: tmp/widgets/accordion/accordion.php:99, tmp/widgets/accordion/accordion.php:127, tmp/widgets/contact/contact.php:296, tmp/widgets/contact/contact.php:409, tmp/widgets/contact/contact.php:525, tmp/widgets/cta/cta.php:81
681
+ msgid "Border color"
682
+ msgstr ""
683
+
684
+ #: tmp/widgets/accordion/accordion.php:103
685
+ msgid "Border hover color"
686
+ msgstr ""
687
+
688
+ #: tmp/widgets/accordion/accordion.php:107, tmp/widgets/accordion/accordion.php:131, tmp/widgets/contact/contact.php:301, tmp/widgets/contact/contact.php:414, tmp/widgets/contact/contact.php:541
689
+ msgid "Border width"
690
+ msgstr ""
691
+
692
+ #: tmp/widgets/accordion/accordion.php:123
693
+ msgid "Font color"
694
+ msgstr ""
695
+
696
+ #: tmp/widgets/accordion/accordion.php:135
697
+ msgid "Bottom margin"
698
+ msgstr ""
699
+
700
+ #: tmp/widgets/accordion/accordion.php:204
701
+ msgid "Get more customization options and the ability to use widgets and layouts as your accordion content with %sSiteOrigin Premium%s"
702
+ msgstr ""
703
+
704
#: tmp/widgets/button/button.php:14
705
msgid "SiteOrigin Button"
706
msgstr ""
1137
msgid "How to handle submissions that are identified as spam."
1138
msgstr ""
1139
1140
#: tmp/widgets/contact/contact.php:282
1141
msgid "Container"
1142
msgstr ""
1143
1144
#: tmp/widgets/contact/contact.php:306, tmp/widgets/contact/contact.php:530
1145
msgid "Border style"
1146
msgstr ""
1385
msgid "Subtitle"
1386
msgstr ""
1387
1388
#: tmp/widgets/cta/cta.php:89
1389
msgid "Subtitle color"
1390
msgstr ""
2017
msgid "Frame"
2018
msgstr ""
2019
2020
#: tmp/widgets/hero/hero.php:64, tmp/widgets/taxonomy/taxonomy.php:49
2021
msgid "Buttons"
2022
msgstr ""
2804
#: tmp/widgets/video/video.php:106
2805
msgid "Always use the embedded video rather than the MediaElement player."
2806
msgstr ""
2807
+
2808
+ #: tmp/widgets/video/video.php:115
2809
+ msgid "Show related videos."
2810
+ msgstr ""
2811
+
2812
+ #: tmp/widgets/video/video.php:116
2813
+ msgid "If the external host supports it."
2814
+ msgstr ""
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.8.1
5
- Stable tag: 1.9.10
6
- Build time: 2017-09-14T08:47:54+02:00
7
License: GPLv3 or later
8
Contributors: gpriday, braam-genis
9
Donate link: https://siteorigin.com/downloads/contribution/
@@ -54,6 +54,17 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
54
55
== Changelog ==
56
57
= 1.9.10 - 14 September 2017 =
58
* TinyMCE field: fixed issue with filter for TinyMCE plugins.
59
* Added teaser messages for SiteOrigin Premium addons.
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.8.1
5
+ Stable tag: 1.10.0
6
+ Build time: 2017-10-11T09:35:25+02:00
7
License: GPLv3 or later
8
Contributors: gpriday, braam-genis
9
Donate link: https://siteorigin.com/downloads/contribution/
54
55
== Changelog ==
56
57
+ = 1.10.0 - 11 October 2017 =
58
+ * New Accordion widget!
59
+ * Prevent multiple initialization of media field.
60
+ * Use correct path for widget banner when defined in a theme.
61
+ * Video: Added option to show/hide related YouTube videos at end of video.
62
+ * Slider: Handle links inside slider frames first and then allow processing of frame background clicks.
63
+ * Give repeated fields in widget fields unique ids for state handling.
64
+ * New multi-measurement field.
65
+ * Widget Manager Path Comparison fix. (allows for settings to work)
66
+ * Button: Use `esc_js` instead of `esc_attr` for onclick.
67
+
68
= 1.9.10 - 14 September 2017 =
69
* TinyMCE field: fixed issue with filter for TinyMCE plugins.
70
* Added teaser messages for SiteOrigin Premium addons.
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.9.10
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.9.10');
16
define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
18
// Allow JS suffix to be pre-set
@@ -382,7 +382,7 @@ class SiteOrigin_Widgets_Bundle {
382
383
$widget_objects = $this->get_widget_objects();
384
385
- $widget_path = empty( $_GET['id'] ) ? false : WP_PLUGIN_DIR . $_GET['id'];
386
387
$widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
388
@@ -424,7 +424,7 @@ class SiteOrigin_Widgets_Bundle {
424
}
425
426
$widget_objects = $this->get_widget_objects();
427
- $widget_path = empty( $_GET['id'] ) ? false : WP_PLUGIN_DIR . $_GET['id'];
428
$widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
429
430
if ( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) {
@@ -640,8 +640,9 @@ class SiteOrigin_Widgets_Bundle {
640
641
foreach( $folders as $folder ) {
642
643
- $files = glob( $folder . '*/*.php' );
644
foreach ($files as $file) {
645
include_once $file;
646
647
$widget_class = $manager->get_class_from_path( $file );
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.10.0
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.10.0');
16
define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
18
// Allow JS suffix to be pre-set
382
383
$widget_objects = $this->get_widget_objects();
384
385
+ $widget_path = empty( $_GET['id'] ) ? false : wp_normalize_path( WP_PLUGIN_DIR ) . $_GET['id'];
386
387
$widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
388
424
}
425
426
$widget_objects = $this->get_widget_objects();
427
+ $widget_path = empty( $_GET['id'] ) ? false : wp_normalize_path( WP_PLUGIN_DIR ) . $_GET['id'];
428
$widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
429
430
if ( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) {
640
641
foreach( $folders as $folder ) {
642
643
+ $files = glob( wp_normalize_path( $folder ) . '*/*.php' );
644
foreach ($files as $file) {
645
+ $file = wp_normalize_path( $file );
646
include_once $file;
647
648
$widget_class = $manager->get_class_from_path( $file );
widgets/accordion/accordion.php ADDED
@@ -0,0 +1,211 @@
1
+ <?php
2
+ /*
3
+ Widget Name: Accordion
4
+ Description: An accordion to squeeze a lot of content into a small space.
5
+ Author: SiteOrigin
6
+ Author URI: https://siteorigin.com
7
+ */
8
+
9
+ class SiteOrigin_Widget_Accordion_Widget extends SiteOrigin_Widget {
10
+ function __construct() {
11
+
12
+ parent::__construct(
13
+ 'sow-accordion',
14
+ __( 'SiteOrigin Accordion', 'so-widgets-bundle' ),
15
+ array(
16
+ 'description' => __( 'An accordion widget.', 'so-widgets-bundle' ),
17
+ 'help' => 'https://siteorigin.com/widgets-bundle/accordion-widget/',
18
+ ),
19
+ array(),
20
+ false,
21
+ plugin_dir_path( __FILE__ )
22
+ );
23
+ }
24
+
25
+ /**
26
+ * Initialize the accordion widget.
27
+ */
28
+ function initialize() {
29
+ $this->register_frontend_scripts(
30
+ array(
31
+ array(
32
+ 'sow-accordion',
33
+ plugin_dir_url( __FILE__ ) . 'js/accordion' . SOW_BUNDLE_JS_SUFFIX . '.js',
34
+ array( 'jquery' ),
35
+ SOW_BUNDLE_VERSION
36
+ )
37
+ )
38
+ );
39
+ }
40
+
41
+ function get_widget_form() {
42
+
43
+ return array(
44
+ 'panels' => array(
45
+ 'type' => 'repeater',
46
+ 'label' => __( 'Panels', 'so-widgets-bundle' ),
47
+ 'fields' => array(
48
+ 'title' => array(
49
+ 'type' => 'text',
50
+ 'label' => __( 'Title', 'so-widgets-bundle' ),
51
+ ),
52
+ 'content_text' => array(
53
+ 'type' => 'tinymce',
54
+ 'label' => __( 'Content', 'so-widgets-bundle' ),
55
+ ),
56
+ 'initial_state' => array(
57
+ 'type' => 'radio',
58
+ 'label' => __( 'Initial state', 'so-widgets-bundle' ),
59
+ 'description' => __( 'Whether this panel should be open or closed when the page first loads.', 'so-widgets-bundle' ),
60
+ 'options' => array(
61
+ 'open' => __( 'Open', 'so-widgets-bundle' ),
62
+ 'closed' => __( 'Closed', 'so-widgets-bundle' ),
63
+ ),
64
+ 'default' => 'closed',
65
+ ),
66
+ ),
67
+ ),
68
+ 'design' => array(
69
+ 'type' => 'section',
70
+ 'label' => __( 'Design', 'so-widgets-bundle' ),
71
+ 'hide' => true,
72
+ 'fields' => array(
73
+ 'heading' => array(
74
+ 'type' => 'section',
75
+ 'label' => __( 'Headings', 'so-widgets-bundle' ),
76
+ 'hide' => true,
77
+ 'fields' => array(
78
+ 'background_color' => array(
79
+ 'type' => 'color',
80
+ 'label' => __( 'Background color', 'so-widgets-bundle' ),
81
+ 'default' => '#828282',
82
+ ),
83
+ 'background_hover_color' => array(
84
+ 'type' => 'color',
85
+ 'label' => __( 'Background hover color', 'so-widgets-bundle' ),
86
+ 'default' => '#8C8C8C',
87
+ ),
88
+ 'title_color' => array(
89
+ 'type' => 'color',
90
+ 'label' => __( 'Title color', 'so-widgets-bundle' ),
91
+ 'default' => '#FFFFFF',
92
+ ),
93
+ 'title_hover_color' => array(
94
+ 'type' => 'color',
95
+ 'label' => __( 'Title hover color', 'so-widgets-bundle' ),
96
+ ),
97
+ 'border_color' => array(
98
+ 'type' => 'color',
99
+ 'label' => __( 'Border color', 'so-widgets-bundle' ),
100
+ ),
101
+ 'border_hover_color' => array(
102
+ 'type' => 'color',
103
+ 'label' => __( 'Border hover color', 'so-widgets-bundle' ),
104
+ ),
105
+ 'border_width' => array(
106
+ 'type' => 'measurement',
107
+ 'label' => __( 'Border width', 'so-widgets-bundle' ),
108
+ ),
109
+ ),
110
+ ),
111
+ 'panels' => array(
112
+ 'type' => 'section',
113
+ 'label' => __( 'Panels', 'so-widgets-bundle' ),
114
+ 'hide' => true,
115
+ 'fields' => array(
116
+ 'background_color' => array(
117
+ 'type' => 'color',
118
+ 'label' => __( 'Background color', 'so-widgets-bundle' ),
119
+ 'default' => '#F9F9F9',
120
+ ),
121
+ 'font_color' => array(
122
+ 'type' => 'color',
123
+ 'label' => __( 'Font color', 'so-widgets-bundle' ),
124
+ ),
125
+ 'border_color' => array(
126
+ 'type' => 'color',
127
+ 'label' => __( 'Border color', 'so-widgets-bundle' ),
128
+ ),
129
+ 'border_width' => array(
130
+ 'type' => 'measurement',
131
+ 'label' => __( 'Border width', 'so-widgets-bundle' ),
132
+ ),
133
+ 'margin_bottom' => array(
134
+ 'type' => 'measurement',
135
+ 'label' => __( 'Bottom margin', 'so-widgets-bundle' ),
136
+ 'default' => '10px',
137
+ ),
138
+ ),
139
+ ),
140
+ ),
141
+ ),
142
+ );
143
+ }
144
+
145
+ public function get_less_variables( $instance ) {
146
+ $design = $instance['design'];
147
+
148
+ return array(
149
+ 'heading_background_color' => $design['heading']['background_color'],
150
+ 'heading_background_hover_color' => $design['heading']['background_hover_color'],
151
+ 'title_color' => $design['heading']['title_color'],
152
+ 'title_hover_color' => $design['heading']['title_hover_color'],
153
+ 'heading_border_color' => $design['heading']['border_color'],
154
+ 'heading_border_hover_color' => $design['heading']['border_hover_color'],
155
+ 'heading_border_width' => $design['heading']['border_width'],
156
+ 'has_heading_border_width' => empty( $design['heading']['border_width'] ) ? 'false' : 'true',
157
+ 'panels_background_color' => $design['panels']['background_color'],
158
+ 'panels_font_color' => $design['panels']['font_color'],
159
+ 'panels_border_color' => $design['panels']['border_color'],
160
+ 'panels_border_width' => $design['panels']['border_width'],
161
+ 'has_panels_border_width' => empty( $design['panels']['border_width'] ) ? 'false' : 'true',
162
+ 'panels_margin_bottom' => $design['panels']['margin_bottom'],
163
+ );
164
+ }
165
+
166
+ public function get_template_variables( $instance, $args ) {
167
+ if( empty( $instance ) ) return array();
168
+
169
+ $panels = empty( $instance['panels'] ) ? array() : $instance['panels'];
170
+
171
+ foreach ( $panels as &$panel ) {
172
+ if ( empty( $panel['before_title'] ) ) {
173
+ $panel['before_title'] = '';
174
+ }
175
+ if ( empty( $panel['after_title'] ) ) {
176
+ $panel['after_title'] = '';
177
+ }
178
+ }
179
+
180
+ if ( empty( $instance['design']['heading']['icon_open'] ) ) {
181
+ $instance['design']['heading']['icon_open'] = 'ionicons-plus';
182
+ }
183
+
184
+ if ( empty( $instance['design']['heading']['icon_close'] ) ) {
185
+ $instance['design']['heading']['icon_close'] = 'ionicons-minus';
186
+ }
187
+
188
+ return array(
189
+ 'panels' => $panels,
190
+ 'icon_open' => $instance['design']['heading']['icon_open'],
191
+ 'icon_close' => $instance['design']['heading']['icon_close'],
192
+ );
193
+ }
194
+
195
+ public function render_panel_content( $panel, $instance ) {
196
+ $content = wp_kses_post( $panel['content_text'] );
197
+
198
+ echo apply_filters( 'siteorigin_widgets_accordion_render_panel_content', $content, $panel, $instance );
199
+ }
200
+
201
+ function get_form_teaser(){
202
+ if( class_exists( 'SiteOrigin_Premium' ) ) return false;
203
+ return sprintf(
204
+ __( 'Get more customization options and the ability to use widgets and layouts as your accordion content with %sSiteOrigin Premium%s', 'so-widgets-bundle' ),
205
+ '<a href="https://siteorigin.com/downloads/premium/?featured_addon=plugin/accordion" target="_blank">',
206
+ '</a>'
207
+ );
208
+ }
209
+ }
210
+
211
+ siteorigin_widget_register('sow-accordion', __FILE__, 'SiteOrigin_Widget_Accordion_Widget');
widgets/accordion/js/accordion.js ADDED
@@ -0,0 +1,37 @@
1
+ jQuery( function ( $ ) {
2
+
3
+ $( '.sow-accordion' ).each( function ( index, element ) {
4
+ var $accordionPanels = $( element ).find( '> .sow-accordion-panel' );
5
+
6
+ $accordionPanels.not( '.sow-accordion-panel-open' ).find( '.sow-accordion-panel-content' ).hide();
7
+
8
+ var openPanels = $accordionPanels.filter( '.sow-accordion-panel-open' ).toArray();
9
+
10
+ var openPanel = function ( panel ) {
11
+ $( panel ).find( '> .sow-accordion-panel-content' ).slideDown();
12
+ $( panel ).addClass( 'sow-accordion-panel-open' );
13
+ openPanels.push( panel );
14
+ };
15
+
16
+ var closePanel = function ( panel ) {
17
+ $( panel ).find( '> .sow-accordion-panel-content' ).slideUp();
18
+ $( panel ).removeClass( 'sow-accordion-panel-open' );
19
+ openPanels.splice( openPanels.indexOf( panel ), 1 );
20
+ };
21
+
22
+ $accordionPanels.find( '> .sow-accordion-panel-header' ).click( function () {
23
+ var $this = $( this );
24
+ var $widget = $this.closest( '.so-widget-sow-accordion' );
25
+ var maxOpenPanels = $widget.data( 'maxOpenPanels' );
26
+ var $panel = $this.closest( '.sow-accordion-panel' );
27
+ if ( $panel.is( '.sow-accordion-panel-open' ) ) {
28
+ closePanel( $panel.get( 0 ) );
29
+ } else {
30
+ openPanel( $panel.get( 0 ) );
31
+ }
32
+ if ( ! isNaN( maxOpenPanels ) && maxOpenPanels > 0 && openPanels.length > maxOpenPanels ) {
33
+ closePanel( openPanels[ 0 ] );
34
+ }
35
+ } );
36
+ } );
37
+ } );
widgets/accordion/js/accordion.min.js ADDED
@@ -0,0 +1 @@
1
+ jQuery(function(o){o(".sow-accordion").each(function(n,c){var e=o(c).find("> .sow-accordion-panel");e.not(".sow-accordion-panel-open").find(".sow-accordion-panel-content").hide();var a=e.filter(".sow-accordion-panel-open").toArray(),i=function(n){o(n).find("> .sow-accordion-panel-content").slideDown(),o(n).addClass("sow-accordion-panel-open"),a.push(n)},s=function(n){o(n).find("> .sow-accordion-panel-content").slideUp(),o(n).removeClass("sow-accordion-panel-open"),a.splice(a.indexOf(n),1)};e.find("> .sow-accordion-panel-header").click(function(){var n=o(this),c=n.closest(".so-widget-sow-accordion"),e=c.data("maxOpenPanels"),d=n.closest(".sow-accordion-panel");d.is(".sow-accordion-panel-open")?s(d.get(0)):i(d.get(0)),!isNaN(e)&&e>0&&a.length>e&&s(a[0])})})});
widgets/accordion/styles/default.less ADDED
@@ -0,0 +1,97 @@
1
+ @import "../../../base/less/mixins";
2
+
3
+ .widget-function('import_google_font');
4
+
5
+ @heading_background_color: default;
6
+ @heading_background_hover_color: default;
7
+ @title_color: default;
8
+ @title_hover_color: default;
9
+ @heading_title_align: left;
10
+ @heading_title_font_family: default;
11
+ @heading_title_font_weight: default;
12
+ @heading_title_font_size: default;
13
+ @heading_border_color: default;
14
+ @heading_border_hover_color: default;
15
+ @has_heading_border_width: default;
16
+ @heading_border_width: default;
17
+ @heading_border_radius: default;
18
+ @heading_padding: 15px 30px 15px 30px;
19
+ @show_open_close_icon: true;
20
+ @open_close_location: right;
21
+
22
+ @panels_background_color: default;
23
+ @panels_font_color: default;
24
+ @panels_border_color: default;
25
+ @has_panels_border_width: default;
26
+ @panels_border_width: default;
27
+ @panels_border_radius: default;
28
+ @panels_padding: 15px 30px 15px 30px;
29
+ @panels_margin_bottom: 10px;
30
+
31
+ .sow-accordion {
32
+ .sow-accordion-panel {
33
+ .sow-accordion-panel-header {
34
+ position: relative;
35
+ cursor: pointer;
36
+ padding: @heading_padding;
37
+ background-color: @heading_background_color;
38
+ color: @title_color;
39
+ text-align: @heading_title_align;
40
+ font-family: @heading_title_font_family;
41
+ font-weight: @heading_title_font_weight;
42
+ font-size: @heading_title_font_size;
43
+
44
+ & when( @has_heading_border_width = true ) {
45
+ border-style: solid;
46
+ border-color: @heading_border_color;
47
+ border-width: @heading_border_width;
48
+ border-radius: @heading_border_radius;
49
+ }
50
+
51
+ &:hover {
52
+ background-color: @heading_background_hover_color;
53
+ color: @title_hover_color;
54
+ border-color: @heading_border_hover_color;
55
+ }
56
+
57
+ .sow-accordion-title {
58
+ display: inline-block;
59
+ & when ( @show_open_close_icon = true ) and ( @heading_title_align = @open_close_location ) {
60
+ margin-@{open_close_location}: 5px;
61
+ }
62
+ }
63
+
64
+ .sow-accordion-open-close-button {
65
+ float: @open_close_location;
66
+
67
+ & when ( @show_open_close_icon = false ) {
68
+ display: none;
69
+ }
70
+ }
71
+ }
72
+ &:not(.sow-accordion-panel-open) > .sow-accordion-panel-header {
73
+ .sow-accordion-close-button {
74
+ display: none;
75
+ }
76
+ }
77
+ &.sow-accordion-panel-open > .sow-accordion-panel-header {
78
+ .sow-accordion-open-button {
79
+ display: none;
80
+ }
81
+ }
82
+ .sow-accordion-panel-content {
83
+ .sow-accordion-panel-border {
84
+ background-color: @panels_background_color;
85
+ & when ( @has_panels_border_width = true ) {
86
+ border-style: solid;
87
+ border-color: @panels_border_color;
88
+ border-width: @panels_border_width;
89
+ border-radius: @panels_border_radius;
90
+ }
91
+ padding: @panels_padding;
92
+ color: @panels_font_color;
93
+ }
94
+ }
95
+ margin-bottom: @panels_margin_bottom;
96
+ }
97
+ }
widgets/accordion/tpl/default.php ADDED
@@ -0,0 +1,37 @@
1
+ <?php
2
+ /**
3
+ * @var array $instance
4
+ * @var array $panels
5
+ * @var string $icon_open
6
+ * @var string $icon_close
7
+ */
8
+
9
+ ?>
10
+ <div>
11
+ <div class="sow-accordion">
12
+ <?php foreach ( $panels as $panel ) : ?>
13
+ <div class="sow-accordion-panel<?php if ( $panel['initial_state'] == 'open' ) echo ' sow-accordion-panel-open'; ?>">
14
+ <div class="sow-accordion-panel-header">
15
+ <div class="sow-accordion-title">
16
+ <?php echo $panel['before_title']; ?>
17
+ <?php echo wp_kses_post( $panel['title'] ); ?>
18
+ <?php echo $panel['after_title']; ?>
19
+ </div>
20
+ <div class="sow-accordion-open-close-button">
21
+ <div class="sow-accordion-open-button">
22
+ <?php echo siteorigin_widget_get_icon( $icon_open ); ?>
23
+ </div>
24
+ <div class="sow-accordion-close-button">
25
+ <?php echo siteorigin_widget_get_icon( $icon_close ); ?>
26
+ </div>
27
+ </div>
28
+ </div>
29
+ <div class="sow-accordion-panel-content">
30
+ <div class="sow-accordion-panel-border">
31
+ <?php $this->render_panel_content( $panel, $instance ); ?>
32
+ </div>
33
+ </div>
34
+ </div>
35
+ <?php endforeach; ?>
36
+ </div>
37
+ </div>
widgets/button/button.php CHANGED
@@ -250,9 +250,6 @@ class SiteOrigin_Widget_Button_Widget extends SiteOrigin_Widget {
250
if ( ! empty( $attributes['title'] ) ) {
251
$button_attributes['title'] = $attributes['title'];
252
}
253
- if ( ! empty( $attributes['onclick'] ) ) {
254
- $button_attributes['onclick'] = $attributes['onclick'];
255
- }
256
if ( ! empty( $attributes['rel'] ) ) {
257
$button_attributes['rel'] = $attributes['rel'];
258
}
@@ -269,6 +266,7 @@ class SiteOrigin_Widget_Button_Widget extends SiteOrigin_Widget {
269
return array(
270
'button_attributes' => $button_attributes,
271
'href' => !empty( $instance['url'] ) ? $instance['url'] : '#',
272
'align' => $instance['design']['align'],
273
'icon_image_url' => $icon_image_url,
274
'icon' => $instance['button_icon']['icon_selected'],
250
if ( ! empty( $attributes['title'] ) ) {
251
$button_attributes['title'] = $attributes['title'];
252
}
253
if ( ! empty( $attributes['rel'] ) ) {
254
$button_attributes['rel'] = $attributes['rel'];
255
}
266
return array(
267
'button_attributes' => $button_attributes,
268
'href' => !empty( $instance['url'] ) ? $instance['url'] : '#',
269
+ 'onclick' => ! empty( $attributes['onclick'] ) ? $attributes['onclick'] : '',
270
'align' => $instance['design']['align'],
271
'icon_image_url' => $icon_image_url,
272
'icon' => $instance['button_icon']['icon_selected'],
widgets/button/tpl/default.php CHANGED
@@ -1,6 +1,8 @@
1
<?php
2
/**
3
* @var array $button_attributes
4
* @var string $align
5
* @var string $icon_image_url
6
* @var string $icon
@@ -10,7 +12,8 @@
10
11
?>
12
<div class="ow-button-base ow-button-align-<?php echo esc_attr( $align ) ?>">
13
- <a href="<?php echo sow_esc_url( $href ) ?>" <?php foreach( $button_attributes as $name => $val ) echo $name . '="' . esc_attr( $val ) . '" ' ?>>
14
<span>
15
<?php
16
if( ! empty( $icon_image_url ) ) {
1
<?php
2
/**
3
* @var array $button_attributes
4
+ * @var string $href
5
+ * @var string $onclick
6
* @var string $align
7
* @var string $icon_image_url
8
* @var string $icon
12
13
?>
14
<div class="ow-button-base ow-button-align-<?php echo esc_attr( $align ) ?>">
15
+ <a href="<?php echo sow_esc_url( $href ) ?>" <?php foreach( $button_attributes as $name => $val ) echo $name . '="' . esc_attr( $val ) . '" ' ?>
16
+ <?php if ( ! empty( $onclick ) ) echo 'onclick="' . esc_js( $onclick ) . '"'; ?>>
17
<span>
18
<?php
19
if( ! empty( $icon_image_url ) ) {
widgets/post-carousel/post-carousel.php CHANGED
@@ -146,20 +146,20 @@ class SiteOrigin_Widget_PostCarousel_Widget extends SiteOrigin_Widget {
146
if ( ! empty( $instance['default_thumbnail'] ) ) {
147
$default_thumbnail = wp_get_attachment_image_src( $instance['default_thumbnail'], 'sow-carousel-default' );
148
}
149
-
150
- $query = wp_parse_args(
151
- siteorigin_widget_post_selector_process_query( $instance['posts'] ),
152
- array(
153
- 'paged' => empty( $instance['paged'] ) ? 1 : $instance['paged']
154
- )
155
- );
156
- $posts = new WP_Query( $query );
157
-
158
- return array(
159
- 'title' => $instance['title'],
160
- 'posts' => $posts,
161
- 'default_thumbnail' => ! empty( $default_thumbnail ) ? $default_thumbnail[0] : '',
162
- );
163
}
164
165
function get_template_name($instance){
146
if ( ! empty( $instance['default_thumbnail'] ) ) {
147
$default_thumbnail = wp_get_attachment_image_src( $instance['default_thumbnail'], 'sow-carousel-default' );
148
}
149
+
150
+ $query = wp_parse_args(
151
+ siteorigin_widget_post_selector_process_query( $instance['posts'] ),
152
+ array(
153
+ 'paged' => empty( $instance['paged'] ) ? 1 : $instance['paged']
154
+ )
155
+ );
156
+ $posts = new WP_Query( $query );
157
+
158
+ return array(
159
+ 'title' => $instance['title'],
160
+ 'posts' => $posts,
161
+ 'default_thumbnail' => ! empty( $default_thumbnail ) ? $default_thumbnail[0] : '',
162
+ );
163
}
164
165
function get_template_name($instance){
widgets/video/tpl/default.php CHANGED
@@ -4,6 +4,7 @@
4
* @var $args
5
* @var $player_id
6
* @var $autoplay
7
* @var $skin_class
8
* @var $is_skinnable_video_host
9
* @var $sources
@@ -46,7 +47,7 @@ do_action( 'siteorigin_widgets_sow-video_before_video', $instance );
46
<?php endforeach; ?>
47
</video>
48
<?php else : ?>
49
- <?php echo $this->get_video_oembed( $src, $autoplay ); ?>
50
<?php endif; ?>
51
</div>
52
<?php do_action( 'siteorigin_widgets_sow-video_after_video', $instance ); ?>
4
* @var $args
5
* @var $player_id
6
* @var $autoplay
7
+ * @var $related_videos
8
* @var $skin_class
9
* @var $is_skinnable_video_host
10
* @var $sources
47
<?php endforeach; ?>
48
</video>
49
<?php else : ?>
50
+ <?php echo $this->get_video_oembed( $src, $autoplay, $related_videos ); ?>
51
<?php endif; ?>
52
</div>
53
<?php do_action( 'siteorigin_widgets_sow-video_after_video', $instance ); ?>
widgets/video/video.php CHANGED
@@ -108,7 +108,17 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
108
'video_type[external]' => array( 'show' ),
109
'video_type[self]' => array( 'hide' ),
110
)
111
- )
112
),
113
),
114
);
@@ -195,6 +205,7 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
195
'is_skinnable_video_host' => $this->is_skinnable_video_host( $video_host ),
196
'poster' => $poster,
197
'autoplay' => ! empty( $instance['playback']['autoplay'] ),
198
'skin_class' => 'default'
199
);
200
@@ -214,7 +225,7 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
214
/**
215
* Gets a video source embed
216
*/
217
- function get_video_oembed( $src, $autoplay = false ) {
218
if ( empty( $src ) ) {
219
return '';
220
}
@@ -239,6 +250,13 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
239
'autoplay_callback'
240
), $html );
241
}
242
243
if ( ! empty( $html ) ) {
244
set_transient( 'sow-vid-embed[' . $hash . ']', $html, 30 * 86400 );
@@ -259,6 +277,17 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
259
return str_replace( $match[1], add_query_arg( 'autoplay', 1, $match[1] ), $match[0] );
260
}
261
262
/**
263
* Get the video host from the URL
264
*
108
'video_type[external]' => array( 'show' ),
109
'video_type[self]' => array( 'hide' ),
110
)
111
+ ),
112
+ 'related_videos' => array(
113
+ 'type' => 'checkbox',
114
+ 'default' => true,
115
+ 'label' => __( 'Show related videos.', 'so-widgets-bundle' ),
116
+ 'description' => __( 'If the external host supports it.', 'so-widgets-bundle' ),
117
+ 'state_handler' => array(
118
+ 'video_type[external]' => array( 'show' ),
119
+ 'video_type[self]' => array( 'hide' ),
120
+ )
121
+ ),
122
),
123
),
124
);
205
'is_skinnable_video_host' => $this->is_skinnable_video_host( $video_host ),
206
'poster' => $poster,
207
'autoplay' => ! empty( $instance['playback']['autoplay'] ),
208
+ 'related_videos' => ! empty( $instance['playback']['related_videos'] ),
209
'skin_class' => 'default'
210
);
211
225
/**
226
* Gets a video source embed
227
*/
228
+ function get_video_oembed( $src, $autoplay = false, $related_videos = true ) {
229
if ( empty( $src ) ) {
230
return '';
231
}
250
'autoplay_callback'
251
), $html );
252
}
253
+
254
+ if ( empty( $related_videos ) ) {
255
+ $html = preg_replace_callback( '/src=["\'](http[^"\']*)["\']/', array(
256
+ $this,
257
+ 'remove_related_videos'
258
+ ), $html );
259
+ }
260
261
if ( ! empty( $html ) ) {
262
set_transient( 'sow-vid-embed[' . $hash . ']', $html, 30 * 86400 );
277
return str_replace( $match[1], add_query_arg( 'autoplay', 1, $match[1] ), $match[0] );
278
}
279
280
+ /**
281
+ * The preg_replace callback that adds the rel param for YouTube videos.
282
+ *
283
+ * @param $match
284
+ *
285
+ * @return mixed
286
+ */
287
+ function remove_related_videos( $match ) {
288
+ return str_replace( $match[1], add_query_arg( 'rel', 0, $match[1] ), $match[0] );
289
+ }
290
+
291
/**
292
* Get the video host from the URL
293
*