SiteOrigin Widgets Bundle - Version 1.9.8

Version Description

  • 21 August 2017 =
  • Use WordPress functions to exit AJAX actions.
  • TinyMCE field: Initialized once.
  • TinyMCE field: Simplified switching between TinyMCE and QuickTags.
  • TinyMCE field: Check if individual TinyMCE settings are encoded as JSON and decode before re-encoding all settings.
  • Some compat fixes for Elementor.
  • TinyMCE field: Temporarily disable Jetpack Grunion editor.
  • Use correct JS dependencies for Beaver Builder compatibility when WP_DEBUG not defined.
  • Removed unnecessary enqueues in Beaver Builder compat for dashicons and wp media scripts.
  • Post carousel: Only handle horizontal swipes.
Download this release

Release Info

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

Code changes from version 1.9.7 to 1.9.8

base/inc/actions.php CHANGED
@@ -4,14 +4,21 @@
4
  * Action for displaying the widget preview.
5
  */
6
  function siteorigin_widget_preview_widget_action() {
7
- if( empty( $_POST['class'] ) ) exit();
8
- if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
 
 
 
 
 
9
 
10
  // Get the widget from the widget factory
11
  global $wp_widget_factory;
12
  $widget = ! empty( $wp_widget_factory->widgets[ $_POST['class'] ] ) ? $wp_widget_factory->widgets[ $_POST['class'] ] : false;
13
 
14
- if( !is_a($widget, 'SiteOrigin_Widget') ) exit();
 
 
15
 
16
  $instance = json_decode( stripslashes_deep($_POST['data']), true);
17
  /* @var $widget SiteOrigin_Widget */
@@ -54,7 +61,7 @@ function siteorigin_widget_preview_widget_action() {
54
  </html>
55
 
56
  <?php
57
- exit();
58
  }
59
  add_action('wp_ajax_so_widgets_preview', 'siteorigin_widget_preview_widget_action');
60
 
@@ -62,7 +69,9 @@ add_action('wp_ajax_so_widgets_preview', 'siteorigin_widget_preview_widget_actio
62
  * Action to handle searching posts
63
  */
64
  function siteorigin_widget_action_search_posts() {
65
- if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
 
 
66
 
67
  // Get all public post types, besides attachments
68
  $post_types = (array) get_post_types( array(
@@ -95,10 +104,8 @@ function siteorigin_widget_action_search_posts() {
95
  ORDER BY post_modified DESC
96
  LIMIT 20
97
  ", ARRAY_A );
98
-
99
- header('content-type: application/json');
100
- echo json_encode( apply_filters( 'siteorigin_widgets_search_posts_results', $results ) );
101
- exit();
102
  }
103
  add_action('wp_ajax_so_widgets_search_posts', 'siteorigin_widget_action_search_posts');
104
 
@@ -106,9 +113,12 @@ add_action('wp_ajax_so_widgets_search_posts', 'siteorigin_widget_action_search_p
106
  * Action to handle searching taxonomy terms.
107
  */
108
  function siteorigin_widget_action_search_terms() {
109
- if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
 
 
 
110
  global $wpdb;
111
- $term = !empty($_GET['term']) ? stripslashes($_GET['term']) : '';
112
  $term = trim($term, '%');
113
 
114
  $query = $wpdb->prepare("
@@ -118,7 +128,7 @@ function siteorigin_widget_action_search_terms() {
118
  WHERE
119
  terms.name LIKE '%s'
120
  LIMIT 20
121
- ", '%'.$term.'%');
122
 
123
  $results = array();
124
 
@@ -130,9 +140,7 @@ function siteorigin_widget_action_search_terms() {
130
  );
131
  }
132
 
133
- header('content-type:application/json');
134
- echo json_encode( $results );
135
- exit();
136
  }
137
  add_action('wp_ajax_so_widgets_search_terms', 'siteorigin_widget_action_search_terms');
138
 
@@ -141,15 +149,13 @@ add_action('wp_ajax_so_widgets_search_terms', 'siteorigin_widget_action_search_t
141
  */
142
  function siteorigin_widget_get_posts_count_action() {
143
 
144
- if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
 
 
145
 
146
  $query = stripslashes( $_POST['query'] );
147
-
148
- header('content-type: application/json');
149
-
150
- echo json_encode( array( 'posts_count' => siteorigin_widget_post_selector_count_posts( $query ) ) );
151
-
152
- exit();
153
  }
154
 
155
  add_action( 'wp_ajax_sow_get_posts_count', 'siteorigin_widget_get_posts_count_action' );
@@ -157,11 +163,11 @@ add_action( 'wp_ajax_sow_get_posts_count', 'siteorigin_widget_get_posts_count_ac
157
 
158
  function siteorigin_widget_remote_image_search(){
159
  if( empty( $_GET[ '_sononce' ] ) || ! wp_verify_nonce( $_GET[ '_sononce' ], 'so-image' ) ) {
160
- exit();
161
  }
162
 
163
  if( empty( $_GET['q'] ) ) {
164
- exit();
165
  }
166
 
167
  // Send the query to stock search server
@@ -183,17 +189,16 @@ function siteorigin_widget_remote_image_search(){
183
  }
184
  }
185
  }
 
186
  }
187
  else {
188
  $result = array(
189
  'error' => true,
190
  'message' => $result->get_error_message()
191
  );
 
192
  }
193
 
194
- header( 'content-type:application/json' );
195
- echo json_encode( $result );
196
- exit();
197
  }
198
  add_action('wp_ajax_so_widgets_image_search', 'siteorigin_widget_remote_image_search');
199
 
@@ -244,9 +249,7 @@ function siteorigin_widget_image_import(){
244
  }
245
 
246
  // Return the result
247
- header( 'content-type:application/json' );
248
- echo json_encode( $result );
249
- exit();
250
  }
251
  add_action('wp_ajax_so_widgets_image_import', 'siteorigin_widget_image_import');
252
 
@@ -254,8 +257,12 @@ add_action('wp_ajax_so_widgets_image_import', 'siteorigin_widget_image_import');
254
  * Action to handle a user dismissing a teaser notice.
255
  */
256
  function siteorigin_widgets_dismiss_widget_action(){
257
- if( empty( $_GET[ '_wpnonce' ] ) || ! wp_verify_nonce( $_GET[ '_wpnonce' ], 'dismiss-widget-teaser' ) ) exit();
258
- if( empty( $_GET[ 'widget' ] ) ) exit();
 
 
 
 
259
 
260
  $dismissed = get_user_meta( get_current_user_id(), 'teasers_dismissed', true );
261
  if( empty( $dismissed ) ) {
@@ -265,7 +272,7 @@ function siteorigin_widgets_dismiss_widget_action(){
265
  $dismissed[ $_GET[ 'widget' ] ] = true;
266
 
267
  update_user_meta( get_current_user_id(), 'teasers_dismissed', $dismissed );
268
-
269
- exit();
270
  }
271
  add_action( 'wp_ajax_so_dismiss_widget_teaser', 'siteorigin_widgets_dismiss_widget_action' );
4
  * Action for displaying the widget preview.
5
  */
6
  function siteorigin_widget_preview_widget_action() {
7
+ if ( empty( $_REQUEST['_widgets_nonce'] ) ||
8
+ ! wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) {
9
+
10
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
11
+ } else if ( empty( $_POST['class'] ) ) {
12
+ wp_die( __( 'Invalid post.', 'so-widgets-bundle' ), 400 );
13
+ }
14
 
15
  // Get the widget from the widget factory
16
  global $wp_widget_factory;
17
  $widget = ! empty( $wp_widget_factory->widgets[ $_POST['class'] ] ) ? $wp_widget_factory->widgets[ $_POST['class'] ] : false;
18
 
19
+ if( ! is_a( $widget, 'SiteOrigin_Widget' ) ) {
20
+ wp_die( __( 'Invalid post.', 'so-widgets-bundle' ), 400 );
21
+ }
22
 
23
  $instance = json_decode( stripslashes_deep($_POST['data']), true);
24
  /* @var $widget SiteOrigin_Widget */
61
  </html>
62
 
63
  <?php
64
+ wp_die();
65
  }
66
  add_action('wp_ajax_so_widgets_preview', 'siteorigin_widget_preview_widget_action');
67
 
69
  * Action to handle searching posts
70
  */
71
  function siteorigin_widget_action_search_posts() {
72
+ if ( empty( $_REQUEST['_widgets_nonce'] ) || ! wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) {
73
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
74
+ }
75
 
76
  // Get all public post types, besides attachments
77
  $post_types = (array) get_post_types( array(
104
  ORDER BY post_modified DESC
105
  LIMIT 20
106
  ", ARRAY_A );
107
+
108
+ wp_send_json( apply_filters( 'siteorigin_widgets_search_posts_results', $results ) );
 
 
109
  }
110
  add_action('wp_ajax_so_widgets_search_posts', 'siteorigin_widget_action_search_posts');
111
 
113
  * Action to handle searching taxonomy terms.
114
  */
115
  function siteorigin_widget_action_search_terms() {
116
+ if ( empty( $_REQUEST['_widgets_nonce'] ) || ! wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) {
117
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
118
+ }
119
+
120
  global $wpdb;
121
+ $term = ! empty($_GET['term']) ? stripslashes($_GET['term']) : '';
122
  $term = trim($term, '%');
123
 
124
  $query = $wpdb->prepare("
128
  WHERE
129
  terms.name LIKE '%s'
130
  LIMIT 20
131
+ ", '%' . esc_sql( $term ) . '%');
132
 
133
  $results = array();
134
 
140
  );
141
  }
142
 
143
+ wp_send_json( $results );
 
 
144
  }
145
  add_action('wp_ajax_so_widgets_search_terms', 'siteorigin_widget_action_search_terms');
146
 
149
  */
150
  function siteorigin_widget_get_posts_count_action() {
151
 
152
+ if ( empty( $_REQUEST['_widgets_nonce'] ) || ! wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) {
153
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
154
+ }
155
 
156
  $query = stripslashes( $_POST['query'] );
157
+
158
+ wp_send_json( array( 'posts_count' => siteorigin_widget_post_selector_count_posts( $query ) ) );
 
 
 
 
159
  }
160
 
161
  add_action( 'wp_ajax_sow_get_posts_count', 'siteorigin_widget_get_posts_count_action' );
163
 
164
  function siteorigin_widget_remote_image_search(){
165
  if( empty( $_GET[ '_sononce' ] ) || ! wp_verify_nonce( $_GET[ '_sononce' ], 'so-image' ) ) {
166
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
167
  }
168
 
169
  if( empty( $_GET['q'] ) ) {
170
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 400 );
171
  }
172
 
173
  // Send the query to stock search server
189
  }
190
  }
191
  }
192
+ wp_send_json( $result );
193
  }
194
  else {
195
  $result = array(
196
  'error' => true,
197
  'message' => $result->get_error_message()
198
  );
199
+ wp_send_json_error( $result );
200
  }
201
 
 
 
 
202
  }
203
  add_action('wp_ajax_so_widgets_image_search', 'siteorigin_widget_remote_image_search');
204
 
249
  }
250
 
251
  // Return the result
252
+ wp_send_json( $result );
 
 
253
  }
254
  add_action('wp_ajax_so_widgets_image_import', 'siteorigin_widget_image_import');
255
 
257
  * Action to handle a user dismissing a teaser notice.
258
  */
259
  function siteorigin_widgets_dismiss_widget_action(){
260
+ if( empty( $_GET[ '_wpnonce' ] ) || ! wp_verify_nonce( $_GET[ '_wpnonce' ], 'dismiss-widget-teaser' ) ) {
261
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
262
+ }
263
+ if( empty( $_GET[ 'widget' ] ) ) {
264
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 400 );
265
+ }
266
 
267
  $dismissed = get_user_meta( get_current_user_id(), 'teasers_dismissed', true );
268
  if( empty( $dismissed ) ) {
272
  $dismissed[ $_GET[ 'widget' ] ] = true;
273
 
274
  update_user_meta( get_current_user_id(), 'teasers_dismissed', $dismissed );
275
+
276
+ wp_die();
277
  }
278
  add_action( 'wp_ajax_so_dismiss_widget_teaser', 'siteorigin_widgets_dismiss_widget_action' );
base/inc/fields/js/tinymce-field-pre48.js CHANGED
@@ -22,7 +22,7 @@
22
  var mceSettings = $container.data('mceSettings');
23
  var widgetIdBase = $container.data('widgetIdBase');
24
  var name = $textarea.attr('name').replace(/\[\d*\]/g, '');
25
- var fieldName = /[a-zA-Z0-9\-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(name)[1];
26
  var idPattern = new RegExp('widget-' + widgetIdBase + '-?.*-' + fieldName.replace(/\]\[/g, '-') + '[-\d]*');
27
  for (var initId in tinyMCEPreInit.mceInit) {
28
  if (initId.match(idPattern)) {
22
  var mceSettings = $container.data('mceSettings');
23
  var widgetIdBase = $container.data('widgetIdBase');
24
  var name = $textarea.attr('name').replace(/\[\d*\]/g, '');
25
+ var fieldName = /[a-zA-Z0-9-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(name)[1];
26
  var idPattern = new RegExp('widget-' + widgetIdBase + '-?.*-' + fieldName.replace(/\]\[/g, '-') + '[-\d]*');
27
  for (var initId in tinyMCEPreInit.mceInit) {
28
  if (initId.match(idPattern)) {
base/inc/fields/js/tinymce-field-pre48.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){var t=function(i){"undefined"!=typeof tinyMCEPreInit?(tinyMCEPreInit.mceInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.mceInit.undefined,tinyMCEPreInit.qtInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.qtInit.undefined,QTags.instances.hasOwnProperty("undefined")&&delete QTags.instances.undefined,e(i).find("> .siteorigin-widget-field-type-tinymce > .siteorigin-widget-tinymce-container").each(function(t,i){var n=e(i),r=n.find("textarea"),a=r.attr("id");if("undefined"!=typeof tinymce){if(a.indexOf("__i__")>-1)return;var s=n.data("mceSettings"),o=n.data("widgetIdBase"),c=r.attr("name").replace(/\[\d*\]/g,""),d=/[a-zA-Z0-9\-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(c)[1],f=new RegExp("widget-"+o+"-?.*-"+d.replace(/\]\[/g,"-")+"[-d]*");for(var g in tinyMCEPreInit.mceInit)g.match(f)&&(s=e.extend({},tinyMCEPreInit.mceInit[g],s));var l,m=tinymce.get(a);null!==m&&("undefined"==typeof vc&&0===n.closest(".vc_active").length&&(l=m.getContent()),m.remove());var u=function(e){e.on("change",function(){tinymce.get(a).save(),r.trigger("change"),r.val(window.switchEditors.pre_wpautop(e.getContent()))}),e.on("init",function(){l&&e.setContent(l)})};s=e.extend({},s,{selector:"#"+a,setup:u}),tinyMCEPreInit.mceInit[a]=s;if(n.find("div#wp-"+a+"-wrap").hasClass("tmce-active"))if(e("#"+a).is(":visible"))tinymce.init(tinyMCEPreInit.mceInit[a]);else var v=setInterval(function(){e("#"+a).is(":visible")&&(tinymce.init(tinyMCEPreInit.mceInit[a]),clearInterval(v))},500)}var y=n.data("qtSettings");y=e.extend({},tinyMCEPreInit.qtInit["siteorigin-widget-input-tinymce-field"],y,{id:a}),tinyMCEPreInit.qtInit[a]=y,n.find(".quicktags-toolbar").remove(),quicktags(tinyMCEPreInit.qtInit[a]),e(this).on("click",function(t){var i=e(t.target);if(i.hasClass("wp-switch-editor")){var n=i.hasClass("switch-tmce")?"tmce":"html";if("tmce"==n){var s=tinymce.get(a);if(null!=s){var o=r.val();-1!=o.search("<")&&-1==o.search(">")&&(o=o.replace(/</g,""),r.val(o)),s.setContent(window.switchEditors.wpautop(o))}}e(this).find("+ .siteorigin-widget-tinymce-selected-editor").val(n)}})}),QTags._buttonsInit()):setTimeout(function(){t(i)},500)};e(document).on("sowsetupform",function(i){var n=e(i.target);n.is(".siteorigin-widget-field-repeater-item-form")?n.is(":visible")?t(n):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(t(n),n.off("slideToggleOpenComplete"))}):t(n)}),e(document).on("sortstop",function(i,n){n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){t(e(this))}):t(n.item.find(".siteorigin-widget-form"))})}(jQuery);
1
+ !function(e){var t=function(i){"undefined"!=typeof tinyMCEPreInit?(tinyMCEPreInit.mceInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.mceInit.undefined,tinyMCEPreInit.qtInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.qtInit.undefined,QTags.instances.hasOwnProperty("undefined")&&delete QTags.instances.undefined,e(i).find("> .siteorigin-widget-field-type-tinymce > .siteorigin-widget-tinymce-container").each(function(t,i){var n=e(i),r=n.find("textarea"),a=r.attr("id");if("undefined"!=typeof tinymce){if(a.indexOf("__i__")>-1)return;var s=n.data("mceSettings"),o=n.data("widgetIdBase"),c=r.attr("name").replace(/\[\d*\]/g,""),d=/[a-zA-Z0-9-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(c)[1],f=new RegExp("widget-"+o+"-?.*-"+d.replace(/\]\[/g,"-")+"[-d]*");for(var g in tinyMCEPreInit.mceInit)g.match(f)&&(s=e.extend({},tinyMCEPreInit.mceInit[g],s));var l,m=tinymce.get(a);null!==m&&("undefined"==typeof vc&&0===n.closest(".vc_active").length&&(l=m.getContent()),m.remove());var u=function(e){e.on("change",function(){tinymce.get(a).save(),r.trigger("change"),r.val(window.switchEditors.pre_wpautop(e.getContent()))}),e.on("init",function(){l&&e.setContent(l)})};s=e.extend({},s,{selector:"#"+a,setup:u}),tinyMCEPreInit.mceInit[a]=s;if(n.find("div#wp-"+a+"-wrap").hasClass("tmce-active"))if(e("#"+a).is(":visible"))tinymce.init(tinyMCEPreInit.mceInit[a]);else var v=setInterval(function(){e("#"+a).is(":visible")&&(tinymce.init(tinyMCEPreInit.mceInit[a]),clearInterval(v))},500)}var y=n.data("qtSettings");y=e.extend({},tinyMCEPreInit.qtInit["siteorigin-widget-input-tinymce-field"],y,{id:a}),tinyMCEPreInit.qtInit[a]=y,n.find(".quicktags-toolbar").remove(),quicktags(tinyMCEPreInit.qtInit[a]),e(this).on("click",function(t){var i=e(t.target);if(i.hasClass("wp-switch-editor")){var n=i.hasClass("switch-tmce")?"tmce":"html";if("tmce"==n){var s=tinymce.get(a);if(null!=s){var o=r.val();-1!=o.search("<")&&-1==o.search(">")&&(o=o.replace(/</g,""),r.val(o)),s.setContent(window.switchEditors.wpautop(o))}}e(this).find("+ .siteorigin-widget-tinymce-selected-editor").val(n)}})}),QTags._buttonsInit()):setTimeout(function(){t(i)},500)};e(document).on("sowsetupform",function(i){var n=e(i.target);n.is(".siteorigin-widget-field-repeater-item-form")?n.is(":visible")?t(n):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(t(n),n.off("slideToggleOpenComplete"))}):t(n)}),e(document).on("sortstop",function(i,n){n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){t(e(this))}):t(n.item.find(".siteorigin-widget-form"))})}(jQuery);
base/inc/fields/js/tinymce-field.js CHANGED
@@ -3,7 +3,8 @@
3
  (function ( $ ) {
4
  $( document ).on( 'sowsetupformfield', '.siteorigin-widget-field-type-tinymce', function ( e ) {
5
  var $$ = $( this );
6
- if( $$.data( 'initialized' ) ) {
 
7
  return;
8
  }
9
 
@@ -52,22 +53,17 @@
52
 
53
  $$.on( 'click', function ( event ) {
54
  var $target = $( event.target );
55
- if ( $target.hasClass( 'wp-switch-editor' ) ) {
56
- var mode = $target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
57
- if ( mode === 'tmce' ) {
58
- // TODO: This might not be necessary anymore with the updated version of TinyMCE.
59
- // Quick bit of sanitization to prevent catastrophic backtracking in TinyMCE HTML parser regex
60
- var editor = window.tinymce.get( id );
61
- if ( editor !== null ) {
62
- var content = $textarea.val();
63
- if ( content.search( '<' ) !== -1 ) {
64
- if ( content.search( '>' ) === -1 ) {
65
- content = content.replace( /</g, '' );
66
- $textarea.val( content );
67
- }
68
- }
69
- editor.setContent( window.switchEditors.wpautop( content ) );
70
  }
 
71
  }
72
 
73
  $$.find( '.siteorigin-widget-tinymce-selected-editor' ).val( mode );
3
  (function ( $ ) {
4
  $( document ).on( 'sowsetupformfield', '.siteorigin-widget-field-type-tinymce', function ( e ) {
5
  var $$ = $( this );
6
+
7
+ if ( $$.data( 'initialized' ) ) {
8
  return;
9
  }
10
 
53
 
54
  $$.on( 'click', function ( event ) {
55
  var $target = $( event.target );
56
+ var mode = $target.hasClass( 'wp-switch-editor' ) ? 'tmce' : 'html';
57
+ if ( mode === 'tmce' ) {
58
+ var editor = window.tinymce.get( id );
59
+ // Quick bit of sanitization to prevent catastrophic backtracking in TinyMCE HTML parser regex
60
+ if ( $target.hasClass( 'switch-tmce' ) && editor !== null ) {
61
+ var content = $textarea.val();
62
+ if ( content.search( '<' ) !== -1 && content.search( '>' ) === -1) {
63
+ content = content.replace( /</g, '' );
64
+ $textarea.val( content );
 
 
 
 
 
 
65
  }
66
+ editor.setContent(window.switchEditors.wpautop(content));
67
  }
68
 
69
  $$.find( '.siteorigin-widget-tinymce-selected-editor' ).val( mode );
base/inc/fields/js/tinymce-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(i){i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(t){var e=i(this);if(!e.data("initialized")){var n=e.find(".siteorigin-widget-tinymce-container"),o=n.data("editorSettings"),a=n.find("textarea"),c=a.attr("id"),r=function(i){i.on("change",function(){window.tinymce.get(c).save(),a.trigger("change")})};if(o.tinymce=i.extend({},o.tinymce,{selector:"#"+c,setup:r}),i(document).one("wp-before-tinymce-init",function(i,t){if(t.selector===o.tinymce.selector){var a=n.data("mediaButtons");e.find(".wp-editor-tabs").before(a.html)}}),i(document).one("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(o.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(c)},10)}),wp.editor.remove(c),a.is(":visible"))wp.editor.initialize(c,o);else var s=setInterval(function(){a.is(":visible")&&(wp.editor.initialize(c,o),clearInterval(s))},500);e.on("click",function(t){var n=i(t.target);if(n.hasClass("wp-switch-editor")){var o=n.hasClass("switch-tmce")?"tmce":"html";if("tmce"===o){var r=window.tinymce.get(c);if(null!==r){var s=a.val();-1!==s.search("<")&&-1===s.search(">")&&(s=s.replace(/</g,""),a.val(s)),r.setContent(window.switchEditors.wpautop(s))}}e.find(".siteorigin-widget-tinymce-selected-editor").val(o)}}),e.data("initialized",!0)}})}(jQuery);
1
+ !function(i){i(document).on("sowsetupformfield",".siteorigin-widget-field-type-tinymce",function(t){var e=i(this);if(!e.data("initialized")){var n=e.find(".siteorigin-widget-tinymce-container"),o=n.data("editorSettings"),a=n.find("textarea"),c=a.attr("id"),r=function(i){i.on("change",function(){window.tinymce.get(c).save(),a.trigger("change")})};if(o.tinymce=i.extend({},o.tinymce,{selector:"#"+c,setup:r}),i(document).one("wp-before-tinymce-init",function(i,t){if(t.selector===o.tinymce.selector){var a=n.data("mediaButtons");e.find(".wp-editor-tabs").before(a.html)}}),i(document).one("tinymce-editor-setup",function(){e.find(".wp-editor-wrap").hasClass(o.selectedEditor+"-active")||setTimeout(function(){window.switchEditors.go(c)},10)}),wp.editor.remove(c),a.is(":visible"))wp.editor.initialize(c,o);else var s=setInterval(function(){a.is(":visible")&&(wp.editor.initialize(c,o),clearInterval(s))},500);e.on("click",function(t){var n=i(t.target),o=n.hasClass("wp-switch-editor")?"tmce":"html";if("tmce"===o){var r=window.tinymce.get(c);if(n.hasClass("switch-tmce")&&null!==r){var s=a.val();-1!==s.search("<")&&-1===s.search(">")&&(s=s.replace(/</g,""),a.val(s)),r.setContent(window.switchEditors.wpautop(s))}e.find(".siteorigin-widget-tinymce-selected-editor").val(o)}}),e.data("initialized",!0)}})}(jQuery);
base/inc/fields/tinymce.class.php CHANGED
@@ -383,7 +383,11 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
383
 
384
  foreach ( $tmce_settings as $name => $setting ) {
385
  if ( ! empty( $tmce_settings[ $name ] ) ) {
386
- $settings['tinymce'][$name] = $setting;
 
 
 
 
387
  }
388
  }
389
 
@@ -511,7 +515,16 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
511
 
512
  echo '<div id="wp-' . esc_attr( $editor_id ) . '-media-buttons" class="wp-media-buttons">';
513
 
 
 
 
 
 
514
  do_action( 'media_buttons', $editor_id );
 
 
 
 
515
 
516
  echo "</div>\n";
517
 
383
 
384
  foreach ( $tmce_settings as $name => $setting ) {
385
  if ( ! empty( $tmce_settings[ $name ] ) ) {
386
+ // Attempt to decode setting as JSON. For back compat with filters used by WP editor.
387
+ if ( is_string( $setting ) ) {
388
+ $jdec = json_decode( $setting, true );
389
+ }
390
+ $settings['tinymce'][ $name ] = empty( $jdec ) ? $setting : $jdec;
391
  }
392
  }
393
 
515
 
516
  echo '<div id="wp-' . esc_attr( $editor_id ) . '-media-buttons" class="wp-media-buttons">';
517
 
518
+ $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null;
519
+ // Temporarily disable the Jetpack Grunion contact form editor on the widgets screen.
520
+ if( ! is_null( $screen ) && $screen->id == 'widgets' ) {
521
+ remove_action( 'media_buttons', 'grunion_media_button', 999 );
522
+ }
523
  do_action( 'media_buttons', $editor_id );
524
+ // Temporarily disable the Jetpack Grunion contact form editor on the widgets screen.
525
+ if( ! is_null( $screen ) && $screen->id == 'widgets' ) {
526
+ add_action( 'media_buttons', 'grunion_media_button', 999 );
527
+ }
528
 
529
  echo "</div>\n";
530
 
base/js/admin.js CHANGED
@@ -51,8 +51,8 @@ var sowbForms = window.sowbForms || {};
51
  var repeaterIndex = sowbForms.getRepeaterId($$);
52
  if (repeaterIndex !== false) {
53
  var repeaterHandler = {};
54
- for (var state in handler) {
55
- repeaterHandler[state.replace('{$repeater}', repeaterIndex)] = handler[state];
56
  }
57
  handler = repeaterHandler;
58
  }
51
  var repeaterIndex = sowbForms.getRepeaterId($$);
52
  if (repeaterIndex !== false) {
53
  var repeaterHandler = {};
54
+ for ( var rptrState in handler) {
55
+ repeaterHandler[rptrState.replace('{$repeater}', repeaterIndex)] = handler[rptrState];
56
  }
57
  handler = repeaterHandler;
58
  }
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 m in r)if(f=!1,null!==(s=m.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?$/))){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 w=0;w<g.length&&!(f=o.group===t&&g[w]===n);w++);}if(f){d=r[m],o.multi||(d=[d]);for(var w=0;w<d.length;w++)l=void 0!==d[w][1]&&Boolean(d[w][1])?i.find(d[w][1]):i,l[d[w][0]].apply(l,void 0!==d[w][2]?d[w][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+$/,"");var v=s.replace(/-\d+$/,"");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+$/)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+$"),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+") *$"),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 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_\-,]+)\])?(\[\])?$/))){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+$/,"");var v=s.replace(/-\d+$/,"");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+$/)[0],a.find("label[for="+v+"]").attr("for",b)}else u=new RegExp("-\\d+$"),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+") *$"),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;
compat/beaver-builder/beaver-builder.php CHANGED
@@ -63,15 +63,13 @@ class SiteOrigin_Widgets_Bundle_Beaver_Builder {
63
  ) );
64
  }
65
 
66
- wp_enqueue_style( 'dashicons' );
67
- wp_enqueue_media();
68
-
69
  wp_enqueue_style( 'sowb-styles-for-beaver', plugin_dir_url( __FILE__ ) . 'styles.css' );
70
-
 
71
  wp_enqueue_script(
72
  'sowb-js-for-beaver',
73
  plugin_dir_url( __FILE__ ) . 'sowb-beaver-builder' . SOW_BUNDLE_JS_SUFFIX . '.js',
74
- array( 'jquery', 'fl-builder' )
75
  );
76
 
77
  wp_enqueue_style( 'siteorigin-widget-admin', plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/css/admin.css', array( 'media-views' ), SOW_BUNDLE_VERSION );
63
  ) );
64
  }
65
 
 
 
 
66
  wp_enqueue_style( 'sowb-styles-for-beaver', plugin_dir_url( __FILE__ ) . 'styles.css' );
67
+
68
+ $deps = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? array( 'jquery', 'fl-builder' ) : array( 'fl-builder-min' );
69
  wp_enqueue_script(
70
  'sowb-js-for-beaver',
71
  plugin_dir_url( __FILE__ ) . 'sowb-beaver-builder' . SOW_BUNDLE_JS_SUFFIX . '.js',
72
+ $deps
73
  );
74
 
75
  wp_enqueue_style( 'siteorigin-widget-admin', plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/css/admin.css', array( 'media-views' ), SOW_BUNDLE_VERSION );
compat/beaver-builder/sowb-beaver-builder.js CHANGED
@@ -2,6 +2,12 @@ var sowb = window.sowb || {};
2
 
3
  ( function($){
4
  if( typeof FLBuilder !== 'undefined') {
 
 
 
 
 
 
5
  sowb.orig_FLBuilder_getSettings = FLBuilder._getSettings;
6
 
7
  /**
2
 
3
  ( function($){
4
  if( typeof FLBuilder !== 'undefined') {
5
+ // If you're going to override jQuery's `ready` function, at least make sure it still works. :/
6
+ sowb.orig_FLBuilder_initJQueryReadyFix = FLBuilder._initJQueryReadyFix;
7
+ FLBuilder._initJQueryReadyFix = function() {
8
+ return;
9
+ };
10
+
11
  sowb.orig_FLBuilder_getSettings = FLBuilder._getSettings;
12
 
13
  /**
compat/beaver-builder/sowb-beaver-builder.min.js CHANGED
@@ -1 +1 @@
1
- var sowb=window.sowb||{};!function(e){"undefined"!=typeof FLBuilder&&(sowb.orig_FLBuilder_getSettings=FLBuilder._getSettings,FLBuilder._getSettings=function(i){FLBuilder._updateEditorFields(),i.find(".siteorigin-widget-input");var r=i.serializeArray(),n=0,t=0,l="",d="",u="",a=[],o=[],s={};for(n=0;n<r.length;n++)if(l=r[n].value.replace(/\r/gm,""),!(r[n].name.indexOf("flrich")>-1))if(r[n].name.indexOf("[")>-1){for(d=r[n].name.replace(/\[(.*)\]/,""),u=r[n].name.replace(d,""),a=[],o=u.match(/\[[^\]]*\]/g),t=0;t<o.length;t++)"[]"!=o[t]&&a.push(o[t].replace(/\[|\]/g,""));var f=function(e,i,r,n){0==n.length?e[r]=i:(void 0===e[r]&&(e[r]={}),f(e[r],i,n.shift(),n))};if(a.length>0){var g=a.slice();void 0===s[d]&&(s[d]={}),f(s[d],l,g.shift(),g)}else void 0===s[d]&&(s[d]=[]),s[d].push(l)}else s[r[n].name]=l;for(u in s)if(void 0!==s["as_values_"+u]){s[u]=e.grep(s["as_values_"+u].split(","),function(e){return""!==e}).join(",");try{delete s["as_values_"+u]}catch(e){}}return s}),e(document).on("fl-builder.preview-rendered fl-builder.layout-rendered",".fl-builder-content",function(){e(sowb).trigger("setup_widgets")})}(jQuery);
1
+ var sowb=window.sowb||{};!function(e){"undefined"!=typeof FLBuilder&&(sowb.orig_FLBuilder_initJQueryReadyFix=FLBuilder._initJQueryReadyFix,FLBuilder._initJQueryReadyFix=function(){},sowb.orig_FLBuilder_getSettings=FLBuilder._getSettings,FLBuilder._getSettings=function(i){FLBuilder._updateEditorFields(),i.find(".siteorigin-widget-input");var r=i.serializeArray(),n=0,t=0,d="",l="",u="",a=[],o=[],s={};for(n=0;n<r.length;n++)if(d=r[n].value.replace(/\r/gm,""),!(r[n].name.indexOf("flrich")>-1))if(r[n].name.indexOf("[")>-1){for(l=r[n].name.replace(/\[(.*)\]/,""),u=r[n].name.replace(l,""),a=[],o=u.match(/\[[^\]]*\]/g),t=0;t<o.length;t++)"[]"!=o[t]&&a.push(o[t].replace(/\[|\]/g,""));var f=function(e,i,r,n){0==n.length?e[r]=i:(void 0===e[r]&&(e[r]={}),f(e[r],i,n.shift(),n))};if(a.length>0){var g=a.slice();void 0===s[l]&&(s[l]={}),f(s[l],d,g.shift(),g)}else void 0===s[l]&&(s[l]=[]),s[l].push(d)}else s[r[n].name]=d;for(u in s)if(void 0!==s["as_values_"+u]){s[u]=e.grep(s["as_values_"+u].split(","),function(e){return""!==e}).join(",");try{delete s["as_values_"+u]}catch(e){}}return s}),e(document).on("fl-builder.preview-rendered fl-builder.layout-rendered",".fl-builder-content",function(){e(sowb).trigger("setup_widgets")})}(jQuery);
compat/elementor/elementor.php CHANGED
@@ -16,20 +16,23 @@ class SiteOrigin_Widgets_Bundle_Elementor {
16
  private $plugin;
17
 
18
  function __construct() {
19
- add_action( 'template_redirect', array( $this, 'init' ) );
 
20
 
21
  add_action( 'wp_ajax_elementor_render_widget', array( $this, 'ajax_render_widget_preview' ) );
22
  add_action( 'wp_ajax_elementor_editor_get_wp_widget_form', array( $this, 'ajax_render_widget_form' ) );
23
  }
24
 
25
- function init() {
 
 
 
 
26
  $this->plugin = Elementor\Plugin::instance();
27
  if ( !empty( $this->plugin->preview ) && method_exists( $this->plugin->preview, 'is_preview_mode' ) && $this->plugin->preview->is_preview_mode() ) {
28
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
29
  add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_preview_scripts' ) );
30
  }
31
-
32
- add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_active_widgets_scripts' ) );
33
  }
34
 
35
  function enqueue_frontend_scripts() {
@@ -103,10 +106,7 @@ class SiteOrigin_Widgets_Bundle_Elementor {
103
 
104
  function render_widget_preview( $widget_output ) {
105
 
106
- $wp_styles = wp_styles();
107
-
108
- // Print any styles we may have enqueued for live preview.
109
- wp_print_styles( $wp_styles->queue );
110
 
111
  return $widget_output;
112
  }
16
  private $plugin;
17
 
18
  function __construct() {
19
+ add_action( 'admin_action_elementor', array( $this, 'init_editor' ) );
20
+ add_action( 'template_redirect', array( $this, 'init_preview' ) );
21
 
22
  add_action( 'wp_ajax_elementor_render_widget', array( $this, 'ajax_render_widget_preview' ) );
23
  add_action( 'wp_ajax_elementor_editor_get_wp_widget_form', array( $this, 'ajax_render_widget_form' ) );
24
  }
25
 
26
+ function init_editor() {
27
+ add_action( 'elementor/editor/before_enqueue_scripts', array( $this, 'enqueue_active_widgets_scripts' ) );
28
+ }
29
+
30
+ function init_preview() {
31
  $this->plugin = Elementor\Plugin::instance();
32
  if ( !empty( $this->plugin->preview ) && method_exists( $this->plugin->preview, 'is_preview_mode' ) && $this->plugin->preview->is_preview_mode() ) {
33
  add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_frontend_scripts' ) );
34
  add_action( 'elementor/preview/enqueue_styles', array( $this, 'enqueue_preview_scripts' ) );
35
  }
 
 
36
  }
37
 
38
  function enqueue_frontend_scripts() {
106
 
107
  function render_widget_preview( $widget_output ) {
108
 
109
+ siteorigin_widget_print_styles();
 
 
 
110
 
111
  return $widget_output;
112
  }
lang/so-widgets-bundle.pot CHANGED
@@ -17,7 +17,7 @@ msgstr ""
17
  "X-Poedit-SearchPathExcluded-0: *.js\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
 
20
- #: tmp/admin/tpl/admin.php:9, tmp/so-widgets-bundle.php:196
21
  msgid "SiteOrigin Widgets Bundle"
22
  msgstr ""
23
 
@@ -69,19 +69,27 @@ msgstr ""
69
  msgid "Save"
70
  msgstr ""
71
 
72
- #: tmp/base/inc/actions.php:41, tmp/base/siteorigin-widget.class.php:635
 
 
 
 
 
 
 
 
73
  msgid "Widget Preview"
74
  msgstr ""
75
 
76
- #: tmp/base/inc/actions.php:204
77
  msgid "Nonce error"
78
  msgstr ""
79
 
80
- #: tmp/base/inc/actions.php:214
81
  msgid "Signature error"
82
  msgstr ""
83
 
84
- #: tmp/base/inc/actions.php:240
85
  msgid "Attachment error"
86
  msgstr ""
87
 
@@ -109,7 +117,7 @@ msgstr ""
109
  msgid "SiteOrigin Page Builder"
110
  msgstr ""
111
 
112
- #: tmp/base/inc/fields/date-range.class.php:31, tmp/base/inc/fields/date-range.class.php:45, tmp/widgets/contact/contact.php:1146
113
  msgid "From"
114
  msgstr ""
115
 
@@ -533,7 +541,7 @@ msgstr ""
533
  msgid "SiteOrigin Widget"
534
  msgstr ""
535
 
536
- #: tmp/compat/visual-composer/visual-composer.php:40, tmp/so-widgets-bundle.php:425, tmp/so-widgets-bundle.php:426
537
  msgid "SiteOrigin Widgets"
538
  msgstr ""
539
 
@@ -569,27 +577,31 @@ msgstr ""
569
  msgid "Ionicons"
570
  msgstr ""
571
 
572
- #: tmp/so-widgets-bundle.php:212
573
  msgid "A new widget!"
574
  msgstr ""
575
 
576
- #: tmp/so-widgets-bundle.php:451
 
 
 
 
577
  msgid "%s was %s"
578
  msgstr ""
579
 
580
- #: tmp/so-widgets-bundle.php:453
581
  msgid "Activated"
582
  msgstr ""
583
 
584
- #: tmp/so-widgets-bundle.php:453
585
  msgid "Deactivated"
586
  msgstr ""
587
 
588
- #: tmp/so-widgets-bundle.php:700
589
  msgid "Manage Widgets"
590
  msgstr ""
591
 
592
- #: tmp/so-widgets-bundle.php:701
593
  msgid "Support"
594
  msgstr ""
595
 
@@ -925,7 +937,7 @@ msgstr ""
925
  msgid "Required Field"
926
  msgstr ""
927
 
928
- #: tmp/widgets/contact/contact.php:164, tmp/widgets/contact/contact.php:962
929
  msgid "Required field"
930
  msgstr ""
931
 
@@ -1253,31 +1265,31 @@ msgstr ""
1253
  msgid "Please write something"
1254
  msgstr ""
1255
 
1256
- #: tmp/widgets/contact/contact.php:974
1257
  msgid "Invalid email address."
1258
  msgstr ""
1259
 
1260
- #: tmp/widgets/contact/contact.php:1048
1261
  msgid "Error sending email, please try again later."
1262
  msgstr ""
1263
 
1264
- #: tmp/widgets/contact/contact.php:1066
1265
  msgid "A valid email is required"
1266
  msgstr ""
1267
 
1268
- #: tmp/widgets/contact/contact.php:1068
1269
  msgid "The email address is invalid"
1270
  msgstr ""
1271
 
1272
- #: tmp/widgets/contact/contact.php:1072
1273
  msgid "Missing subject"
1274
  msgstr ""
1275
 
1276
- #: tmp/widgets/contact/contact.php:1106
1277
  msgid "Error validating your Captcha response."
1278
  msgstr ""
1279
 
1280
- #: tmp/widgets/contact/contact.php:1138
1281
  msgid "Unfortunately our system identified your message as spam."
1282
  msgstr ""
1283
 
17
  "X-Poedit-SearchPathExcluded-0: *.js\n"
18
  "Plural-Forms: nplurals=2; plural=(n != 1);\n"
19
 
20
+ #: tmp/admin/tpl/admin.php:9, tmp/so-widgets-bundle.php:199
21
  msgid "SiteOrigin Widgets Bundle"
22
  msgstr ""
23
 
69
  msgid "Save"
70
  msgstr ""
71
 
72
+ #: tmp/base/inc/actions.php:10, tmp/base/inc/actions.php:73, tmp/base/inc/actions.php:117, tmp/base/inc/actions.php:153, tmp/base/inc/actions.php:166, tmp/base/inc/actions.php:170, tmp/base/inc/actions.php:261, tmp/base/inc/actions.php:264, tmp/so-widgets-bundle.php:353, tmp/so-widgets-bundle.php:377, tmp/so-widgets-bundle.php:390, tmp/so-widgets-bundle.php:420, tmp/so-widgets-bundle.php:431, tmp/so-widgets-bundle.php:497, tmp/so-widgets-bundle.php:508
73
+ msgid "Invalid request."
74
+ msgstr ""
75
+
76
+ #: tmp/base/inc/actions.php:12, tmp/base/inc/actions.php:20, tmp/so-widgets-bundle.php:360, tmp/so-widgets-bundle.php:503
77
+ msgid "Invalid post."
78
+ msgstr ""
79
+
80
+ #: tmp/base/inc/actions.php:48, tmp/base/siteorigin-widget.class.php:635
81
  msgid "Widget Preview"
82
  msgstr ""
83
 
84
+ #: tmp/base/inc/actions.php:209
85
  msgid "Nonce error"
86
  msgstr ""
87
 
88
+ #: tmp/base/inc/actions.php:219
89
  msgid "Signature error"
90
  msgstr ""
91
 
92
+ #: tmp/base/inc/actions.php:245
93
  msgid "Attachment error"
94
  msgstr ""
95
 
117
  msgid "SiteOrigin Page Builder"
118
  msgstr ""
119
 
120
+ #: tmp/base/inc/fields/date-range.class.php:31, tmp/base/inc/fields/date-range.class.php:45, tmp/widgets/contact/contact.php:1150
121
  msgid "From"
122
  msgstr ""
123
 
541
  msgid "SiteOrigin Widget"
542
  msgstr ""
543
 
544
+ #: tmp/compat/visual-composer/visual-composer.php:40, tmp/so-widgets-bundle.php:447, tmp/so-widgets-bundle.php:448
545
  msgid "SiteOrigin Widgets"
546
  msgstr ""
547
 
577
  msgid "Ionicons"
578
  msgstr ""
579
 
580
+ #: tmp/so-widgets-bundle.php:215
581
  msgid "A new widget!"
582
  msgstr ""
583
 
584
+ #: tmp/so-widgets-bundle.php:357, tmp/so-widgets-bundle.php:380, tmp/so-widgets-bundle.php:423
585
+ msgid "Insufficient permissions."
586
+ msgstr ""
587
+
588
+ #: tmp/so-widgets-bundle.php:473
589
  msgid "%s was %s"
590
  msgstr ""
591
 
592
+ #: tmp/so-widgets-bundle.php:475
593
  msgid "Activated"
594
  msgstr ""
595
 
596
+ #: tmp/so-widgets-bundle.php:475
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
 
937
  msgid "Required Field"
938
  msgstr ""
939
 
940
+ #: tmp/widgets/contact/contact.php:164, tmp/widgets/contact/contact.php:966
941
  msgid "Required field"
942
  msgstr ""
943
 
1265
  msgid "Please write something"
1266
  msgstr ""
1267
 
1268
+ #: tmp/widgets/contact/contact.php:978
1269
  msgid "Invalid email address."
1270
  msgstr ""
1271
 
1272
+ #: tmp/widgets/contact/contact.php:1052
1273
  msgid "Error sending email, please try again later."
1274
  msgstr ""
1275
 
1276
+ #: tmp/widgets/contact/contact.php:1070
1277
  msgid "A valid email is required"
1278
  msgstr ""
1279
 
1280
+ #: tmp/widgets/contact/contact.php:1072
1281
  msgid "The email address is invalid"
1282
  msgstr ""
1283
 
1284
+ #: tmp/widgets/contact/contact.php:1076
1285
  msgid "Missing subject"
1286
  msgstr ""
1287
 
1288
+ #: tmp/widgets/contact/contact.php:1110
1289
  msgid "Error validating your Captcha response."
1290
  msgstr ""
1291
 
1292
+ #: tmp/widgets/contact/contact.php:1142
1293
  msgid "Unfortunately our system identified your message as spam."
1294
  msgstr ""
1295
 
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.7
6
- Build time: 2017-08-11T11:57: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.7 - 11 August 2017 =
58
  * Contact: Added user configurable field for 'From:' address.
59
  * TinyMCE field: Use editor stylesheets for new TinyMCE editor.
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.8
6
+ Build time: 2017-08-21T11:15:03+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.9.8 - 21 August 2017 =
58
+ * Use WordPress functions to exit AJAX actions.
59
+ * TinyMCE field: Initialized once.
60
+ * TinyMCE field: Simplified switching between TinyMCE and QuickTags.
61
+ * TinyMCE field: Check if individual TinyMCE settings are encoded as JSON and decode before re-encoding all settings.
62
+ * Some compat fixes for Elementor.
63
+ * TinyMCE field: Temporarily disable Jetpack Grunion editor.
64
+ * Use correct JS dependencies for Beaver Builder compatibility when `WP_DEBUG` not defined.
65
+ * Removed unnecessary enqueues in Beaver Builder compat for dashicons and wp media scripts.
66
+ * Post carousel: Only handle horizontal swipes.
67
+
68
  = 1.9.7 - 11 August 2017 =
69
  * Contact: Added user configurable field for 'From:' address.
70
  * TinyMCE field: Use editor stylesheets for new TinyMCE editor.
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.7
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
@@ -12,7 +12,7 @@ License: GPL3
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
- define('SOW_BUNDLE_VERSION', '1.9.7');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
@@ -80,6 +80,9 @@ class SiteOrigin_Widgets_Bundle {
80
 
81
  add_filter( 'wp_enqueue_scripts', array($this, 'register_general_scripts') );
82
  add_filter( 'wp_enqueue_scripts', array($this, 'enqueue_active_widgets_scripts') );
 
 
 
83
  }
84
 
85
  /**
@@ -346,17 +349,22 @@ class SiteOrigin_Widgets_Bundle {
346
  * @action wp_ajax_so_widgets_bundle_manage
347
  */
348
  function admin_ajax_manage_handler(){
349
- if( !wp_verify_nonce($_GET['_wpnonce'], 'manage_so_widget') ) exit();
350
- if( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) exit();
351
- if( empty($_POST['widget']) ) exit();
 
 
 
 
 
 
 
352
 
353
  if( !empty($_POST['active']) ) $this->activate_widget($_POST['widget']);
354
  else $this->deactivate_widget( $_POST['widget'] );
355
 
356
  // Send a kind of dummy response.
357
- header('content-type: application/json');
358
- echo json_encode( array('done' => true) );
359
- exit();
360
  }
361
 
362
  /**
@@ -365,16 +373,22 @@ class SiteOrigin_Widgets_Bundle {
365
  * @action wp_ajax_so_widgets_setting_form
366
  */
367
  function admin_ajax_settings_form(){
368
- if( ! wp_verify_nonce($_GET['_wpnonce'], 'display-widget-form') ) exit();
369
- if( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) exit();
 
 
 
 
370
 
371
  $widget_objects = $this->get_widget_objects();
372
 
373
  $widget_path = empty( $_GET['id'] ) ? false : WP_PLUGIN_DIR . $_GET['id'];
374
 
375
  $widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
376
-
377
- if( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) exit();
 
 
378
 
379
  unset( $widget_object->widget_options['has_preview'] );
380
 
@@ -392,8 +406,8 @@ class SiteOrigin_Widgets_Bundle {
392
  <?php $widget_object->form( $value, 'settings' ) ?>
393
  </form>
394
  <?php
395
-
396
- exit();
397
  }
398
 
399
  /**
@@ -402,17 +416,25 @@ class SiteOrigin_Widgets_Bundle {
402
  * @action wp_ajax_so_widgets_setting_save
403
  */
404
  function admin_ajax_settings_save(){
405
- if( ! wp_verify_nonce( $_GET['_wpnonce'], 'save-widget-settings' ) ) exit();
406
- if( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) exit();
 
 
 
 
407
 
408
  $widget_objects = $this->get_widget_objects();
409
  $widget_path = empty( $_GET['id'] ) ? false : WP_PLUGIN_DIR . $_GET['id'];
410
  $widget_object = empty( $widget_objects[ $widget_path ] ) ? false : $widget_objects[ $widget_path ];
411
-
412
- if( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) exit();
 
 
413
 
414
  $form_values = array_shift( array_shift( array_values( $_POST ) ) );
415
  $widget_object->save_global_settings( $form_values );
 
 
416
  }
417
 
418
  /**
@@ -470,19 +492,25 @@ class SiteOrigin_Widgets_Bundle {
470
  * Get javascript variables for admin.
471
  */
472
  function admin_ajax_get_javascript_variables() {
473
- if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
474
- $result = array();
 
 
 
475
  $widget_class = $_POST['widget'];
476
  global $wp_widget_factory;
477
- if ( ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ) {
478
- $widget = $wp_widget_factory->widgets[ $widget_class ];
479
- if( method_exists( $widget, 'get_javascript_variables' ) ) $result = $widget->get_javascript_variables();
480
  }
481
-
482
- header('content-type: application/json');
483
- echo json_encode($result);
484
-
485
- exit();
 
 
 
 
486
  }
487
 
488
  /**
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.8
6
  Text Domain: so-widgets-bundle
7
  Domain Path: /lang
8
  Author: SiteOrigin
12
  License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
  */
14
 
15
+ define('SOW_BUNDLE_VERSION', '1.9.8');
16
  define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
 
18
  // Allow JS suffix to be pre-set
80
 
81
  add_filter( 'wp_enqueue_scripts', array($this, 'register_general_scripts') );
82
  add_filter( 'wp_enqueue_scripts', array($this, 'enqueue_active_widgets_scripts') );
83
+
84
+ // This is a temporary filter to disable the new Jetpack Grunion contact form editor.
85
+ add_filter( 'tmp_grunion_allow_editor_view', '__return_false' );
86
  }
87
 
88
  /**
349
  * @action wp_ajax_so_widgets_bundle_manage
350
  */
351
  function admin_ajax_manage_handler(){
352
+ if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'manage_so_widget' ) ) {
353
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
354
+ }
355
+
356
+ if ( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) {
357
+ wp_die( __( 'Insufficient permissions.', 'so-widgets-bundle' ), 403 );
358
+ }
359
+ if ( empty( $_POST['widget'] ) ) {
360
+ wp_die( __( 'Invalid post.', 'so-widgets-bundle' ), 400 );
361
+ }
362
 
363
  if( !empty($_POST['active']) ) $this->activate_widget($_POST['widget']);
364
  else $this->deactivate_widget( $_POST['widget'] );
365
 
366
  // Send a kind of dummy response.
367
+ wp_send_json( array( 'done' => true ) );
 
 
368
  }
369
 
370
  /**
373
  * @action wp_ajax_so_widgets_setting_form
374
  */
375
  function admin_ajax_settings_form(){
376
+ if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'display-widget-form' ) ) {
377
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
378
+ }
379
+ if ( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) {
380
+ wp_die( __( 'Insufficient permissions.', 'so-widgets-bundle' ), 403 );
381
+ }
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
+
389
+ if ( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) {
390
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 400 );
391
+ }
392
 
393
  unset( $widget_object->widget_options['has_preview'] );
394
 
406
  <?php $widget_object->form( $value, 'settings' ) ?>
407
  </form>
408
  <?php
409
+
410
+ wp_die();
411
  }
412
 
413
  /**
416
  * @action wp_ajax_so_widgets_setting_save
417
  */
418
  function admin_ajax_settings_save(){
419
+ if ( ! wp_verify_nonce( $_GET['_wpnonce'], 'save-widget-settings' ) ) {
420
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
421
+ }
422
+ if ( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) {
423
+ wp_die( __( 'Insufficient permissions.', 'so-widgets-bundle' ), 403 );
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' ) ) {
431
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 400 );
432
+ }
433
 
434
  $form_values = array_shift( array_shift( array_values( $_POST ) ) );
435
  $widget_object->save_global_settings( $form_values );
436
+
437
+ wp_send_json_success();
438
  }
439
 
440
  /**
492
  * Get javascript variables for admin.
493
  */
494
  function admin_ajax_get_javascript_variables() {
495
+ if ( empty( $_REQUEST['_widgets_nonce'] ) ||
496
+ ! wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) {
497
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 403 );
498
+ }
499
+
500
  $widget_class = $_POST['widget'];
501
  global $wp_widget_factory;
502
+ if ( empty( $wp_widget_factory->widgets[ $widget_class ] ) ) {
503
+ wp_die( __( 'Invalid post.', 'so-widgets-bundle' ), 400 );
 
504
  }
505
+
506
+ $widget = $wp_widget_factory->widgets[ $widget_class ];
507
+ if ( ! method_exists( $widget, 'get_javascript_variables' ) ) {
508
+ wp_die( __( 'Invalid request.', 'so-widgets-bundle' ), 400 );
509
+ }
510
+
511
+ $result = $widget->get_javascript_variables();
512
+
513
+ wp_send_json( $result );
514
  }
515
 
516
  /**
widgets/contact/contact.php CHANGED
@@ -840,7 +840,7 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
840
  $field_id = 'sow-contact-form-field-' . $field_name;
841
 
842
  $value = '';
843
- if ( ! empty( $_POST[ $field_name ] ) && wp_verify_nonce( $_POST['_wpnonce'] ) ) {
844
  $value = stripslashes_deep( $_POST[ $field_name ] );
845
  }
846
 
@@ -922,7 +922,11 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
922
  * Ajax action handler to send the form
923
  */
924
  function contact_form_action( $instance, $storage_hash ) {
925
- if ( ! wp_verify_nonce( $_POST['_wpnonce'] ) ) {
 
 
 
 
926
  return false;
927
  }
928
  if ( empty( $_POST['instance_hash'] ) || $_POST['instance_hash'] != $storage_hash ) {
840
  $field_id = 'sow-contact-form-field-' . $field_name;
841
 
842
  $value = '';
843
+ if ( ! empty( $_POST[ $field_name ] ) && wp_verify_nonce( $_POST['_wpnonce'], '_contact_form_submit' ) ) {
844
  $value = stripslashes_deep( $_POST[ $field_name ] );
845
  }
846
 
922
  * Ajax action handler to send the form
923
  */
924
  function contact_form_action( $instance, $storage_hash ) {
925
+ if ( ! wp_verify_nonce( $_POST['_wpnonce'], '_contact_form_submit' ) ) {
926
+ // Using `return false;` instead of `wp_die` because this function may sometimes be called as a side effect
927
+ // of trying to enqueue scripts required for the front end. In those cases `$_POST['_wpnonce']` doesn't exist
928
+ // and calling `wp_die` will halt script execution and break things. Ideally it should be possible to enqueue
929
+ // front end scripts without calling widgets' render functions, but that will mean a fairly large refactor.
930
  return false;
931
  }
932
  if ( empty( $_POST['instance_hash'] ) || $_POST['instance_hash'] != $storage_hash ) {
widgets/contact/tpl/default.php CHANGED
@@ -40,7 +40,7 @@ else {
40
 
41
  <?php $this->render_form_fields( $instance['fields'], $result['errors'], $instance ) ?>
42
  <input type="hidden" name="instance_hash" value="<?php echo esc_attr( $instance_hash ) ?>" />
43
- <?php echo wp_nonce_field() ?>
44
 
45
  <?php if( $use_recaptcha ) : ?>
46
  <div class="sow-recaptcha"
40
 
41
  <?php $this->render_form_fields( $instance['fields'], $result['errors'], $instance ) ?>
42
  <input type="hidden" name="instance_hash" value="<?php echo esc_attr( $instance_hash ) ?>" />
43
+ <?php echo wp_nonce_field( '_contact_form_submit' ) ?>
44
 
45
  <?php if( $use_recaptcha ) : ?>
46
  <div class="sow-recaptcha"
widgets/image-grid/js/image-grid.js CHANGED
@@ -1,8 +1,8 @@
1
  /* globals jQuery, sowb */
2
  var sowb = window.sowb || {};
3
 
4
- jQuery( function($){
5
- sowb.setupImageGrids = function(){
6
  $('.sow-image-grid-wrapper').each( function(){
7
  var $$ = $(this);
8
  $$.imagesLoaded( function () {
1
  /* globals jQuery, sowb */
2
  var sowb = window.sowb || {};
3
 
4
+ jQuery( function($) {
5
+ sowb.setupImageGrids = function() {
6
  $('.sow-image-grid-wrapper').each( function(){
7
  var $$ = $(this);
8
  $$.imagesLoaded( function () {
widgets/post-carousel/js/carousel.js CHANGED
@@ -1,157 +1,163 @@
1
- jQuery( function($){
2
- // The carousel widget
3
- $('.sow-carousel-wrapper').each(function(){
4
 
5
- var $$ = $(this),
6
- $postsContainer = $$.closest('.sow-carousel-container'),
7
- $container = $$.closest('.sow-carousel-container').parent(),
8
- $itemsContainer = $$.find('.sow-carousel-items'),
9
- $items = $$.find('.sow-carousel-item'),
10
- $firstItem = $items.eq(0);
11
 
12
- var position = 0,
13
- page = 1,
14
- fetching = false,
15
- numItems = $items.length,
16
- totalPosts = $$.data('found-posts'),
17
- complete = numItems == totalPosts,
18
- itemWidth = ( $firstItem.width() + parseInt($firstItem.css('margin-right')) ),
19
- isRTL = $postsContainer.hasClass('js-rtl'),
20
- updateProp = isRTL ? 'margin-right' : 'margin-left';
21
 
22
- var updatePosition = function() {
23
- if ( position < 0 ) position = 0;
24
- if ( position >= $$.find('.sow-carousel-item').length - 1 ) {
25
- position = $$.find('.sow-carousel-item').length - 1;
26
- // Fetch the next batch
27
- if( !fetching && !complete ) {
28
- fetching = true;
29
- page++;
30
- $itemsContainer.append('<li class="sow-carousel-item sow-carousel-loading"></li>');
31
- var instanceHash = $container.find('input[name="instance_hash"]').val();
32
-
33
- $.get(
34
- $$.data('ajax-url'),
35
- {
36
- query : $$.data('query'),
37
- action : 'sow_carousel_load',
38
- paged : page,
39
- instance_hash : instanceHash,
40
- },
41
- function (data, status){
42
- var $items = $(data.html);
43
- $items.appendTo( $itemsContainer ).hide().fadeIn();
44
- $$.find('.sow-carousel-loading').remove();
45
- numItems = $$.find('.sow-carousel-item').length;
46
- complete = numItems == totalPosts;
47
- fetching = false;
48
- }
49
- )
50
- }
51
- }
52
- $itemsContainer.css('transition-duration', "0.45s");
53
- $itemsContainer.css(updateProp, -( itemWidth * position) + 'px' );
54
- };
55
 
56
- $container.on( 'click', 'a.sow-carousel-previous',
57
- function(e){
58
- e.preventDefault();
59
- position -= isRTL ? -1 : 1;
60
- updatePosition();
61
- }
62
- );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- $container.on( 'click', 'a.sow-carousel-next',
65
- function(e){
66
- e.preventDefault();
67
- position += isRTL ? -1 : 1;
68
- updatePosition();
69
- }
70
- );
71
- var validSwipe = false;
72
- var prevDistance = 0;
73
- var startPosition = 0;
74
- var velocity = 0;
75
- var prevTime = 0;
76
- var posInterval;
77
- var negativeDirection = isRTL ? 'right' : 'left';
78
-
79
- // Verify "swipe" method exists prior to invoking it.
80
- if( 'function' === typeof $$.swipe ) {
81
- $$.swipe( {
82
- excludedElements: "",
83
- triggerOnTouchEnd: true,
84
- threshold: 75,
85
- swipeStatus: function (event, phase, direction, distance, duration, fingerCount, fingerData) {
86
- if ( phase == "start" ) {
87
- startPosition = -( itemWidth * position);
88
- prevTime = new Date().getTime();
89
- clearInterval(posInterval);
90
- }
91
- else if ( phase == "move" ) {
92
- if( direction == negativeDirection ) distance *= -1;
93
- setNewPosition(startPosition + distance);
94
- var newTime = new Date().getTime();
95
- var timeDelta = (newTime - prevTime) / 1000;
96
- velocity = (distance - prevDistance) / timeDelta;
97
- prevTime = newTime;
98
- prevDistance = distance;
99
- }
100
- else if ( phase == "end" ) {
101
- validSwipe = true;
102
- if( direction == negativeDirection ) distance *= -1;
103
- if(Math.abs(velocity) > 400) {
104
- velocity *= 0.1;
105
- var startTime = new Date().getTime();
106
- var cumulativeDistance = 0;
107
- posInterval = setInterval(function () {
108
- var time = (new Date().getTime() - startTime) / 1000;
109
- cumulativeDistance += velocity * time;
110
- var newPos = startPosition + distance + cumulativeDistance;
111
- var decel = 30;
112
- var end = (Math.abs(velocity) - decel) < 0;
113
- if(direction == negativeDirection) {
114
- velocity += decel;
115
- } else {
116
- velocity -= decel;
117
- }
118
- if(end || !setNewPosition(newPos)) {
119
- clearInterval(posInterval);
120
- setFinalPosition();
121
- }
122
- }, 20);
123
- } else {
124
- setFinalPosition();
125
- }
126
- }
127
- else if( phase == "cancel") {
128
- updatePosition();
129
- }
130
- }
131
- } );
132
- }
133
-
134
-
135
- var setNewPosition = function(newPosition) {
136
- if(newPosition < 50 && newPosition > -( itemWidth * numItems )) {
137
- $itemsContainer.css('transition-duration', "0s");
138
- $itemsContainer.css(updateProp, newPosition + 'px' );
139
- return true;
140
- }
141
- return false;
142
- };
143
- var setFinalPosition = function() {
144
- var finalPosition = parseInt( $itemsContainer.css(updateProp) );
145
- position = Math.abs( Math.round( finalPosition / itemWidth ) );
146
- updatePosition();
147
- };
148
- $$.on('click', '.sow-carousel-item a',
149
- function (event) {
150
- if(validSwipe) {
151
- event.preventDefault();
152
- validSwipe = false;
153
- }
154
- }
155
- )
156
- } );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  } );
1
+ jQuery( function ( $ ) {
2
+ // The carousel widget
3
+ $( '.sow-carousel-wrapper' ).each( function () {
4
 
5
+ var $$ = $( this ),
6
+ $postsContainer = $$.closest( '.sow-carousel-container' ),
7
+ $container = $$.closest( '.sow-carousel-container' ).parent(),
8
+ $itemsContainer = $$.find( '.sow-carousel-items' ),
9
+ $items = $$.find( '.sow-carousel-item' ),
10
+ $firstItem = $items.eq( 0 );
11
 
12
+ var position = 0,
13
+ page = 1,
14
+ fetching = false,
15
+ numItems = $items.length,
16
+ totalPosts = $$.data( 'found-posts' ),
17
+ complete = numItems === totalPosts,
18
+ itemWidth = ( $firstItem.width() + parseInt( $firstItem.css( 'margin-right' ) ) ),
19
+ isRTL = $postsContainer.hasClass( 'js-rtl' ),
20
+ updateProp = isRTL ? 'margin-right' : 'margin-left';
21
 
22
+ var updatePosition = function () {
23
+ if ( position < 0 ) position = 0;
24
+ if ( position >= $$.find( '.sow-carousel-item' ).length - 1 ) {
25
+ position = $$.find( '.sow-carousel-item' ).length - 1;
26
+ // Fetch the next batch
27
+ if ( !fetching && !complete ) {
28
+ fetching = true;
29
+ page++;
30
+ $itemsContainer.append( '<li class="sow-carousel-item sow-carousel-loading"></li>' );
31
+ var instanceHash = $container.find( 'input[name="instance_hash"]' ).val();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
 
33
+ $.get(
34
+ $$.data( 'ajax-url' ),
35
+ {
36
+ query: $$.data( 'query' ),
37
+ action: 'sow_carousel_load',
38
+ paged: page,
39
+ instance_hash: instanceHash,
40
+ },
41
+ function ( data, status ) {
42
+ var $items = $( data.html );
43
+ $items.appendTo( $itemsContainer ).hide().fadeIn();
44
+ $$.find( '.sow-carousel-loading' ).remove();
45
+ numItems = $$.find( '.sow-carousel-item' ).length;
46
+ complete = numItems === totalPosts;
47
+ fetching = false;
48
+ }
49
+ )
50
+ }
51
+ }
52
+ $itemsContainer.css( 'transition-duration', "0.45s" );
53
+ $itemsContainer.css( updateProp, -( itemWidth * position) + 'px' );
54
+ };
55
 
56
+ $container.on( 'click', 'a.sow-carousel-previous',
57
+ function ( e ) {
58
+ e.preventDefault();
59
+ position -= isRTL ? -1 : 1;
60
+ updatePosition();
61
+ }
62
+ );
63
+
64
+ $container.on( 'click', 'a.sow-carousel-next',
65
+ function ( e ) {
66
+ e.preventDefault();
67
+ position += isRTL ? -1 : 1;
68
+ updatePosition();
69
+ }
70
+ );
71
+
72
+ // Verify "swipe" method exists prior to invoking it.
73
+ if ( 'function' === typeof $$.swipe ) {
74
+ var validSwipe = false;
75
+ var prevDistance = 0;
76
+ var startPosition = 0;
77
+ var velocity = 0;
78
+ var prevTime = 0;
79
+ var posInterval;
80
+ var negativeDirection = isRTL ? 'right' : 'left';
81
+
82
+ var setNewPosition = function ( newPosition ) {
83
+ if ( newPosition < 50 && newPosition > -( itemWidth * numItems ) ) {
84
+ $itemsContainer.css( 'transition-duration', "0s" );
85
+ $itemsContainer.css( updateProp, newPosition + 'px' );
86
+ return true;
87
+ }
88
+ return false;
89
+ };
90
+
91
+ var setFinalPosition = function () {
92
+ var finalPosition = parseInt( $itemsContainer.css( updateProp ) );
93
+ position = Math.abs( Math.round( finalPosition / itemWidth ) );
94
+ updatePosition();
95
+ };
96
+
97
+ $$.on( 'click', '.sow-carousel-item a',
98
+ function ( event ) {
99
+ if ( validSwipe ) {
100
+ event.preventDefault();
101
+ validSwipe = false;
102
+ }
103
+ }
104
+ );
105
+
106
+ $$.swipe( {
107
+ excludedElements: "",
108
+ triggerOnTouchEnd: true,
109
+ threshold: 75,
110
+ swipeStatus: function ( event, phase, direction, distance, duration, fingerCount, fingerData ) {
111
+ if ( direction === 'up' || direction === 'down' ) {
112
+ return false;
113
+ }
114
+
115
+ if ( phase === "start" ) {
116
+ startPosition = -( itemWidth * position);
117
+ prevTime = new Date().getTime();
118
+ clearInterval( posInterval );
119
+ }
120
+ else if ( phase === "move" ) {
121
+ if ( direction === negativeDirection ) distance *= -1;
122
+ setNewPosition( startPosition + distance );
123
+ var newTime = new Date().getTime();
124
+ var timeDelta = (newTime - prevTime) / 1000;
125
+ velocity = (distance - prevDistance) / timeDelta;
126
+ prevTime = newTime;
127
+ prevDistance = distance;
128
+ }
129
+ else if ( phase === "end" ) {
130
+ validSwipe = true;
131
+ if ( direction === negativeDirection ) distance *= -1;
132
+ if ( Math.abs( velocity ) > 400 ) {
133
+ velocity *= 0.1;
134
+ var startTime = new Date().getTime();
135
+ var cumulativeDistance = 0;
136
+ posInterval = setInterval( function () {
137
+ var time = (new Date().getTime() - startTime) / 1000;
138
+ cumulativeDistance += velocity * time;
139
+ var newPos = startPosition + distance + cumulativeDistance;
140
+ var decel = 30;
141
+ var end = (Math.abs( velocity ) - decel) < 0;
142
+ if ( direction === negativeDirection ) {
143
+ velocity += decel;
144
+ } else {
145
+ velocity -= decel;
146
+ }
147
+ if ( end || !setNewPosition( newPos ) ) {
148
+ clearInterval( posInterval );
149
+ setFinalPosition();
150
+ }
151
+ }, 20 );
152
+ } else {
153
+ setFinalPosition();
154
+ }
155
+ }
156
+ else if ( phase === "cancel" ) {
157
+ updatePosition();
158
+ }
159
+ }
160
+ } );
161
+ }
162
+ } );
163
  } );
widgets/post-carousel/js/carousel.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){e(".sow-carousel-wrapper").each(function(){var a=e(this),t=a.closest(".sow-carousel-container"),n=a.closest(".sow-carousel-container").parent(),s=a.find(".sow-carousel-items"),i=a.find(".sow-carousel-item"),o=i.eq(0),r=0,c=1,l=!1,u=i.length,f=a.data("found-posts"),d=u==f,h=o.width()+parseInt(o.css("margin-right")),w=t.hasClass("js-rtl"),p=w?"margin-right":"margin-left",g=function(){if(r<0&&(r=0),r>=a.find(".sow-carousel-item").length-1&&(r=a.find(".sow-carousel-item").length-1,!l&&!d)){l=!0,c++,s.append('<li class="sow-carousel-item sow-carousel-loading"></li>');var t=n.find('input[name="instance_hash"]').val();e.get(a.data("ajax-url"),{query:a.data("query"),action:"sow_carousel_load",paged:c,instance_hash:t},function(t,n){e(t.html).appendTo(s).hide().fadeIn(),a.find(".sow-carousel-loading").remove(),u=a.find(".sow-carousel-item").length,d=u==f,l=!1})}s.css("transition-duration","0.45s"),s.css(p,-h*r+"px")};n.on("click","a.sow-carousel-previous",function(e){e.preventDefault(),r-=w?-1:1,g()}),n.on("click","a.sow-carousel-next",function(e){e.preventDefault(),r+=w?-1:1,g()});var m,v=!1,D=0,I=0,T=0,x=0,y=w?"right":"left";"function"==typeof a.swipe&&a.swipe({excludedElements:"",triggerOnTouchEnd:!0,threshold:75,swipeStatus:function(e,a,t,n,s,i,o){if("start"==a)I=-h*r,x=(new Date).getTime(),clearInterval(m);else if("move"==a){t==y&&(n*=-1),M(I+n);var c=(new Date).getTime(),l=(c-x)/1e3;T=(n-D)/l,x=c,D=n}else if("end"==a)if(v=!0,t==y&&(n*=-1),Math.abs(T)>400){T*=.1;var u=(new Date).getTime(),f=0;m=setInterval(function(){var e=((new Date).getTime()-u)/1e3;f+=T*e;var a=I+n+f,s=Math.abs(T)-30<0;t==y?T+=30:T-=30,!s&&M(a)||(clearInterval(m),_())},20)}else _();else"cancel"==a&&g()}});var M=function(e){return e<50&&e>-h*u&&(s.css("transition-duration","0s"),s.css(p,e+"px"),!0)},_=function(){var e=parseInt(s.css(p));r=Math.abs(Math.round(e/h)),g()};a.on("click",".sow-carousel-item a",function(e){v&&(e.preventDefault(),v=!1)})})});
1
+ jQuery(function(e){e(".sow-carousel-wrapper").each(function(){var a=e(this),n=a.closest(".sow-carousel-container"),t=a.closest(".sow-carousel-container").parent(),s=a.find(".sow-carousel-items"),i=a.find(".sow-carousel-item"),o=i.eq(0),r=0,c=1,l=!1,u=i.length,f=a.data("found-posts"),d=u===f,w=o.width()+parseInt(o.css("margin-right")),h=n.hasClass("js-rtl"),p=h?"margin-right":"margin-left",g=function(){if(r<0&&(r=0),r>=a.find(".sow-carousel-item").length-1&&(r=a.find(".sow-carousel-item").length-1,!l&&!d)){l=!0,c++,s.append('<li class="sow-carousel-item sow-carousel-loading"></li>');var n=t.find('input[name="instance_hash"]').val();e.get(a.data("ajax-url"),{query:a.data("query"),action:"sow_carousel_load",paged:c,instance_hash:n},function(n,t){e(n.html).appendTo(s).hide().fadeIn(),a.find(".sow-carousel-loading").remove(),u=a.find(".sow-carousel-item").length,d=u===f,l=!1})}s.css("transition-duration","0.45s"),s.css(p,-w*r+"px")};if(t.on("click","a.sow-carousel-previous",function(e){e.preventDefault(),r-=h?-1:1,g()}),t.on("click","a.sow-carousel-next",function(e){e.preventDefault(),r+=h?-1:1,g()}),"function"==typeof a.swipe){var m,v=!1,D=0,I=0,T=0,x=0,y=h?"right":"left",M=function(e){return e<50&&e>-w*u&&(s.css("transition-duration","0s"),s.css(p,e+"px"),!0)},_=function(){var e=parseInt(s.css(p));r=Math.abs(Math.round(e/w)),g()};a.on("click",".sow-carousel-item a",function(e){v&&(e.preventDefault(),v=!1)}),a.swipe({excludedElements:"",triggerOnTouchEnd:!0,threshold:75,swipeStatus:function(e,a,n,t,s,i,o){if("up"===n||"down"===n)return!1;if("start"===a)I=-w*r,x=(new Date).getTime(),clearInterval(m);else if("move"===a){n===y&&(t*=-1),M(I+t);var c=(new Date).getTime(),l=(c-x)/1e3;T=(t-D)/l,x=c,D=t}else if("end"===a)if(v=!0,n===y&&(t*=-1),Math.abs(T)>400){T*=.1;var u=(new Date).getTime(),f=0;m=setInterval(function(){var e=((new Date).getTime()-u)/1e3;f+=T*e;var a=I+t+f,s=Math.abs(T)-30<0;n===y?T+=30:T-=30,!s&&M(a)||(clearInterval(m),_())},20)}else _();else"cancel"===a&&g()}})}})});