SiteOrigin Widgets Bundle - Version 1.7

Version Description

  • 20 September 2016 =
  • Added mechanism for creating global widget setting.
  • Added mechanism for adding dismissible notices to widget forms.
  • Unified Google Maps JS working for maps widget and contact form location field.
  • Added icon search for icon field.
  • Added remove button to icon field.
  • Contact Form: Fixed clash with Firefox field validation.
  • Properly display remove button after importing Pixabay image.
Download this release

Release Info

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

Code changes from version 1.6.5 to 1.7

Files changed (51) hide show
  1. admin/admin.css +178 -0
  2. admin/admin.js +44 -3
  3. admin/admin.min.js +1 -1
  4. admin/images/wpspin_light-2x.gif +0 -0
  5. admin/images/wpspin_light.gif +0 -0
  6. admin/tpl/admin.php +42 -2
  7. base/base.php +1 -1
  8. base/css/admin.css +15 -101
  9. base/inc/actions.php +20 -0
  10. base/inc/fields/container-base.class.php +2 -2
  11. base/inc/fields/css/icon-field.css +122 -0
  12. base/inc/fields/factory.class.php +6 -6
  13. base/inc/fields/icon.class.php +11 -0
  14. base/inc/fields/js/icon-field.js +168 -0
  15. base/inc/fields/js/icon-field.min.js +1 -0
  16. base/inc/fields/js/media-field.js +2 -0
  17. base/inc/fields/js/media-field.min.js +1 -1
  18. base/inc/fields/media.class.php +2 -3
  19. base/inc/meta-box-manager.php +7 -29
  20. base/inc/widget-manager.class.php +40 -13
  21. base/js/admin.js +21 -130
  22. base/js/admin.min.js +1 -1
  23. base/siteorigin-widget.class.php +156 -23
  24. readme.txt +11 -2
  25. so-widgets-bundle.php +98 -12
  26. widgets/button/button.php +1 -1
  27. widgets/contact/contact.php +15 -1
  28. widgets/contact/js/contact.js +2 -4
  29. widgets/contact/js/contact.min.js +1 -1
  30. widgets/contact/styles/default.less +4 -0
  31. widgets/cta/cta.php +1 -1
  32. widgets/editor/editor.php +1 -1
  33. widgets/features/features.php +1 -1
  34. widgets/google-map/google-map.php +1 -1
  35. widgets/google-map/js/js-map.js +224 -53
  36. widgets/google-map/js/js-map.min.js +1 -1
  37. widgets/headline/headline.php +1 -1
  38. widgets/hero/hero.php +1 -1
  39. widgets/icon/icon.php +1 -1
  40. widgets/image-grid/image-grid.php +1 -1
  41. widgets/image/image.php +1 -1
  42. widgets/layout-slider/layout-slider.php +1 -1
  43. widgets/post-carousel/post-carousel.php +1 -1
  44. widgets/price-table/price-table.php +1 -1
  45. widgets/simple-masonry/simple-masonry.php +1 -1
  46. widgets/slider/slider.php +1 -1
  47. widgets/social-media-buttons/data/networks.php +1 -1
  48. widgets/social-media-buttons/social-media-buttons.php +1 -1
  49. widgets/taxonomy/taxonomy.php +1 -1
  50. widgets/testimonial/testimonial.php +1 -1
  51. widgets/video/video.php +1 -1
admin/admin.css CHANGED
@@ -229,6 +229,7 @@
229
}
230
#sow-widgets-page #widgets-list .so-widget .so-widget-toggle-active {
231
margin-top: 15px;
232
}
233
#sow-widgets-page #widgets-list .so-widget .so-widget-toggle-active button:focus {
234
outline: none;
@@ -252,6 +253,10 @@
252
-webkit-filter: grayscale(1);
253
opacity: 0.7;
254
}
255
#sow-widgets-page #widgets-list.so-animated img,
256
#sow-widgets-page #widgets-list.so-animated svg {
257
-webkit-transition: all 0.45s ease;
@@ -265,6 +270,179 @@
265
color: #777;
266
font-style: italic;
267
}
268
body.plugins_page_so-widgets-plugins #contextual-help-link-wrap {
269
z-index: 10;
270
}
229
}
230
#sow-widgets-page #widgets-list .so-widget .so-widget-toggle-active {
231
margin-top: 15px;
232
+ display: inline-block;
233
}
234
#sow-widgets-page #widgets-list .so-widget .so-widget-toggle-active button:focus {
235
outline: none;
253
-webkit-filter: grayscale(1);
254
opacity: 0.7;
255
}
256
+ #sow-widgets-page #widgets-list .so-widget .so-widget-settings {
257
+ margin-top: 15px;
258
+ display: inline-block;
259
+ }
260
#sow-widgets-page #widgets-list.so-animated img,
261
#sow-widgets-page #widgets-list.so-animated svg {
262
-webkit-transition: all 0.45s ease;
270
color: #777;
271
font-style: italic;
272
}
273
+ #sow-widgets-page #sow-settings-dialog {
274
+ display: none;
275
+ }
276
+ #sow-widgets-page #sow-settings-dialog .so-overlay,
277
+ #sow-widgets-page #sow-settings-dialog .so-content,
278
+ #sow-widgets-page #sow-settings-dialog .so-title-bar,
279
+ #sow-widgets-page #sow-settings-dialog .so-toolbar,
280
+ #sow-widgets-page #sow-settings-dialog .so-left-sidebar,
281
+ #sow-widgets-page #sow-settings-dialog .so-right-sidebar {
282
+ z-index: 100001;
283
+ position: fixed;
284
+ -ms-box-sizing: border-box;
285
+ -moz-box-sizing: border-box;
286
+ -webkit-box-sizing: border-box;
287
+ box-sizing: border-box;
288
+ padding: 15px;
289
+ }
290
+ #sow-widgets-page #sow-settings-dialog .so-overlay {
291
+ top: 0;
292
+ left: 0;
293
+ right: 0;
294
+ bottom: 0;
295
+ background: rgba(0, 0, 0, 0.5);
296
+ }
297
+ #sow-widgets-page #sow-settings-dialog .so-content {
298
+ overflow-y: auto;
299
+ top: 80px;
300
+ left: 30px;
301
+ right: 30px;
302
+ bottom: 88px;
303
+ background-color: #fdfdfd;
304
+ overflow-x: hidden;
305
+ -webkit-box-shadow: inset 0 2px 2px rgba(0,0,0,0.03);
306
+ -moz-box-shadow: inset 0 2px 2px rgba(0,0,0,0.03);
307
+ box-shadow: inset 0 2px 2px rgba(0,0,0,0.03);
308
+ }
309
+ #sow-widgets-page #sow-settings-dialog .so-content > *:first-child,
310
+ #sow-widgets-page #sow-settings-dialog .so-content form > *:first-child {
311
+ margin-top: 0;
312
+ }
313
+ #sow-widgets-page #sow-settings-dialog .so-content > *:last-child,
314
+ #sow-widgets-page #sow-settings-dialog .so-content form > *:last-child {
315
+ margin-bottom: 0;
316
+ }
317
+ #sow-widgets-page #sow-settings-dialog .so-content .so-content-tabs > * {
318
+ display: none;
319
+ }
320
+ #sow-widgets-page #sow-settings-dialog .so-content.so-loading {
321
+ background-image: url("images/wpspin_light.gif");
322
+ background-position: center center;
323
+ background-repeat: no-repeat;
324
+ }
325
+ @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
326
+ #sow-widgets-page #sow-settings-dialog .so-content.so-loading {
327
+ background-image: url(images/wpspin_light-2x.gif);
328
+ background-size: 16px 16px;
329
+ }
330
+ }
331
+ #sow-widgets-page #sow-settings-dialog .so-title-bar {
332
+ left: 30px;
333
+ right: 30px;
334
+ top: 30px;
335
+ height: 50px;
336
+ background-color: #fafafa;
337
+ border-bottom: 1px solid #D8D8D8;
338
+ /* These are the action buttons in the title bar */
339
+ }
340
+ #sow-widgets-page #sow-settings-dialog .so-title-bar h3.so-title {
341
+ margin: 0 !important;
342
+ padding: 0 !important;
343
+ }
344
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a {
345
+ cursor: pointer;
346
+ position: absolute;
347
+ box-sizing: border-box;
348
+ width: 50px;
349
+ height: 50px;
350
+ display: block;
351
+ top: 0;
352
+ right: 0;
353
+ -webkit-transition: all 0.2s ease;
354
+ -moz-transition: all 0.2s ease;
355
+ -o-transition: all 0.2s ease;
356
+ transition: all 0.2s ease;
357
+ background: #fafafa;
358
+ border-left: 1px solid #d8d8d8;
359
+ border-bottom: 1px solid #d8d8d8;
360
+ }
361
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a:hover {
362
+ background: #e9e9e9;
363
+ }
364
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a:hover .so-dialog-icon {
365
+ color: #333333;
366
+ }
367
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a .so-dialog-icon {
368
+ position: absolute;
369
+ top: 50%;
370
+ left: 50%;
371
+ text-decoration: none;
372
+ width: 20px;
373
+ height: 20px;
374
+ margin-left: -10px;
375
+ margin-top: -10px;
376
+ color: #666666;
377
+ text-align: center;
378
+ }
379
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a .so-dialog-icon:before {
380
+ font: 400 20px/1em dashicons;
381
+ top: 7px;
382
+ left: 13px;
383
+ }
384
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a.so-close {
385
+ right: 0;
386
+ }
387
+ #sow-widgets-page #sow-settings-dialog .so-title-bar a.so-close .so-dialog-icon:before {
388
+ content: "\f335";
389
+ }
390
+ #sow-widgets-page #sow-settings-dialog .so-toolbar {
391
+ left: 30px;
392
+ right: 30px;
393
+ bottom: 30px;
394
+ height: 58px;
395
+ background-color: #fafafa;
396
+ border-top: 1px solid #D8D8D8;
397
+ z-index: 100002;
398
+ }
399
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-status {
400
+ float: left;
401
+ padding-top: 6px;
402
+ padding-bottom: 6px;
403
+ font-style: italic;
404
+ color: #999999;
405
+ line-height: 1em;
406
+ }
407
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-status.so-panels-loading {
408
+ padding-left: 26px;
409
+ background-position: left center;
410
+ }
411
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons {
412
+ float: right;
413
+ }
414
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons .action-buttons {
415
+ position: absolute;
416
+ left: 15px;
417
+ top: 50%;
418
+ margin-top: -0.65em;
419
+ }
420
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons .action-buttons a {
421
+ cursor: pointer;
422
+ display: inline;
423
+ padding: 0.2em 0.5em;
424
+ line-height: 1em;
425
+ margin-right: 0.5em;
426
+ text-decoration: none;
427
+ }
428
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons .action-buttons .so-delete {
429
+ color: #a00;
430
+ }
431
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons .action-buttons .so-delete:hover {
432
+ background: #a00;
433
+ color: #FFFFFF;
434
+ }
435
+ #sow-widgets-page #sow-settings-dialog .so-toolbar .so-buttons .action-buttons .so-duplicate:hover {
436
+ text-decoration: underline;
437
+ }
438
+ #sow-widgets-page #sow-settings-dialog .siteorigin-widget-help-link {
439
+ display: none;
440
+ }
441
+ #sow-widgets-page #so-widget-settings-save {
442
+ width: 0;
443
+ height: 0;
444
+ border: none;
445
+ }
446
body.plugins_page_so-widgets-plugins #contextual-help-link-wrap {
447
z-index: 10;
448
}
admin/admin.js CHANGED
@@ -1,6 +1,6 @@
1
/* globals jQuery, soWidgetsAdmin */
2
3
- jQuery(function($){
4
5
$('.so-widget-toggle-active button').click( function(){
6
var $ = $(this),
@@ -122,6 +122,47 @@ jQuery(function($){
122
$(window).resize();
123
});
124
125
- // Finally enable css3 animations on the widgets list
126
$('#widgets-list').addClass('so-animated');
127
- });
1
/* globals jQuery, soWidgetsAdmin */
2
3
+ jQuery( function( $ ){
4
5
$('.so-widget-toggle-active button').click( function(){
6
var $ = $(this),
122
$(window).resize();
123
});
124
125
+ // Enable css3 animations on the widgets list
126
$('#widgets-list').addClass('so-animated');
127
+
128
+ // Handle the dialog
129
+ var dialog = $('#sow-settings-dialog');
130
+
131
+ $( '#widgets-list .so-widget-settings' ).click( function( e ){
132
+ var $ = $(this);
133
+ e.preventDefault();
134
+
135
+ dialog.find('.so-content')
136
+ .empty()
137
+ .addClass('so-loading')
138
+ .load( $.data('form-url'), function(){
139
+ $(this).removeClass('so-loading');
140
+ } );
141
+
142
+ dialog.show();
143
+ } );
144
+
145
+ dialog.find('.so-close').click( function( e ){
146
+ e.preventDefault();
147
+ dialog.hide();
148
+ } );
149
+
150
+ dialog.find('.so-save').click( function( e ){
151
+ e.preventDefault();
152
+
153
+ var $ = $(this);
154
+ $.prop('disabled', true);
155
+ $( '#widgets-list .so-widget-settings' ).prop('disabled', true);
156
+
157
+ dialog.find( 'form' ).submit( function( ){
158
+ $.prop('disabled', false);
159
+ dialog.hide();
160
+ } ).submit();
161
+ } );
162
+
163
+ // Enable all widget settings button after the save iframe has loaded.
164
+ $('#so-widget-settings-save').load( function(){
165
+ $( '#widgets-list .so-widget-settings' ).prop('disabled', false);
166
+ } );
167
+
168
+ } );
admin/admin.min.js CHANGED
@@ -1 +1 @@
1
- jQuery(function(e){e(".so-widget-toggle-active button").click(function(){var i=e(this),s=i.data("status"),t=i.closest(".so-widget");s?t.addClass("so-widget-is-active").removeClass("so-widget-is-inactive"):t.removeClass("so-widget-is-active").addClass("so-widget-is-inactive"),e.post(soWidgetsAdmin.toggleUrl,{widget:t.data("id"),active:s},function(e){})}),e(".so-widget-banner").each(function(){var i=e(this),s=i.find("img");if(s.length)s.width()>128&&s.css("margin-left",-(s.width()-128)/2);else{var t=Trianglify({width:128,height:128,variance:1,cell_size:32,seed:i.data("seed")});i.append(t.svg())}});var i=function(){var i=e(this).val().toLowerCase();""===i?e(".so-widget-wrap").show():e(".so-widget").each(function(){var s=e(this);s.find("h3").html().toLowerCase().indexOf(i)>-1?s.parent().show():s.parent().hide()})};e("#sow-widget-search input").on({keyup:i,search:i}),e(window).resize(function(){var i=e(".so-widget-text").css("height","auto"),s=0;i.each(function(){s=Math.max(s,e(this).height())}),i.each(function(){e(this).css("height",s)})}).resize(),e("#sow-widgets-page .page-nav a").click(function(i){i.preventDefault();var s=e(this),t=s.attr("href"),a=s.closest("li");switch(e("#sow-widgets-page .page-nav li").not(a).removeClass("active"),a.addClass("active"),t){case"#all":e(".so-widget-wrap").show();break;case"#enabled":e(".so-widget-wrap").hide(),e(".so-widget-wrap .so-widget-is-active").each(function(){e(this).closest(".so-widget-wrap").show()}),e(".so-widget-wrap .so-widget-is-inactive").each(function(){e(this).closest(".so-widget-wrap").hide()});break;case"#disabled":e(".so-widget-wrap .so-widget-is-active").each(function(){e(this).closest(".so-widget-wrap").hide()}),e(".so-widget-wrap .so-widget-is-inactive").each(function(){e(this).closest(".so-widget-wrap").show()})}e(window).resize()}),e("#widgets-list").addClass("so-animated")});
1
+ jQuery(function(i){i(".so-widget-toggle-active button").click(function(){var e=i(this),s=e.data("status"),t=e.closest(".so-widget");s?t.addClass("so-widget-is-active").removeClass("so-widget-is-inactive"):t.removeClass("so-widget-is-active").addClass("so-widget-is-inactive"),i.post(soWidgetsAdmin.toggleUrl,{widget:t.data("id"),active:s},function(i){})}),i(".so-widget-banner").each(function(){var e=i(this),s=e.find("img");if(s.length)s.width()>128&&s.css("margin-left",-(s.width()-128)/2);else{var t=Trianglify({width:128,height:128,variance:1,cell_size:32,seed:e.data("seed")});e.append(t.svg())}});var e=function(){var e=i(this).val().toLowerCase();""===e?i(".so-widget-wrap").show():i(".so-widget").each(function(){var s=i(this);s.find("h3").html().toLowerCase().indexOf(e)>-1?s.parent().show():s.parent().hide()})};i("#sow-widget-search input").on({keyup:e,search:e}),i(window).resize(function(){var e=i(".so-widget-text").css("height","auto"),s=0;e.each(function(){s=Math.max(s,i(this).height())}),e.each(function(){i(this).css("height",s)})}).resize(),i("#sow-widgets-page .page-nav a").click(function(e){e.preventDefault();var s=i(this),t=s.attr("href"),a=s.closest("li");switch(i("#sow-widgets-page .page-nav li").not(a).removeClass("active"),a.addClass("active"),t){case"#all":i(".so-widget-wrap").show();break;case"#enabled":i(".so-widget-wrap").hide(),i(".so-widget-wrap .so-widget-is-active").each(function(){i(this).closest(".so-widget-wrap").show()}),i(".so-widget-wrap .so-widget-is-inactive").each(function(){i(this).closest(".so-widget-wrap").hide()});break;case"#disabled":i(".so-widget-wrap .so-widget-is-active").each(function(){i(this).closest(".so-widget-wrap").hide()}),i(".so-widget-wrap .so-widget-is-inactive").each(function(){i(this).closest(".so-widget-wrap").show()})}i(window).resize()}),i("#widgets-list").addClass("so-animated");var s=i("#sow-settings-dialog");i("#widgets-list .so-widget-settings").click(function(e){var t=i(this);e.preventDefault(),s.find(".so-content").empty().addClass("so-loading").load(t.data("form-url"),function(){i(this).removeClass("so-loading")}),s.show()}),s.find(".so-close").click(function(i){i.preventDefault(),s.hide()}),s.find(".so-save").click(function(e){e.preventDefault();var t=i(this);t.prop("disabled",!0),i("#widgets-list .so-widget-settings").prop("disabled",!0),s.find("form").submit(function(){t.prop("disabled",!1),s.hide()}).submit()}),i("#so-widget-settings-save").load(function(){i("#widgets-list .so-widget-settings").prop("disabled",!1)})});
admin/images/wpspin_light-2x.gif ADDED
Binary file
admin/images/wpspin_light.gif ADDED
Binary file
admin/tpl/admin.php CHANGED
@@ -22,7 +22,7 @@
22
23
<div id="widgets-list">
24
25
- <?php foreach( $widgets as $id => $widget ): ?>
26
<div class="so-widget-wrap">
27
<div class="so-widget so-widget-is-<?php echo $widget['Active'] ? 'active' : 'inactive' ?>" data-id="<?php echo esc_attr( $widget['ID'] ) ?>">
28
@@ -67,6 +67,24 @@
67
<button class="button-secondary so-widget-deactivate" data-status="0"><?php esc_html_e( 'Deactivate', 'so-widgets-bundle' ) ?></button>
68
</div>
69
70
</div>
71
72
</div>
@@ -80,4 +98,26 @@
80
<a href="https://siteorigin.com/docs/widgets-bundle/" target="_blank"><?php _e('Read More', 'so-widgets-bundle') ?></a>.
81
</div>
82
83
- </div>
22
23
<div id="widgets-list">
24
25
+ <?php foreach( $widgets as $file => $widget ): ?>
26
<div class="so-widget-wrap">
27
<div class="so-widget so-widget-is-<?php echo $widget['Active'] ? 'active' : 'inactive' ?>" data-id="<?php echo esc_attr( $widget['ID'] ) ?>">
28
67
<button class="button-secondary so-widget-deactivate" data-status="0"><?php esc_html_e( 'Deactivate', 'so-widgets-bundle' ) ?></button>
68
</div>
69
70
+ <?php
71
+ $widget_object = !empty( $widget_objects[ $file ] ) ? $widget_objects[ $file ] : false;
72
+ if( !empty( $widget_object ) && $widget_object->has_form( 'settings' ) ) {
73
+ $form_url = add_query_arg( array(
74
+ 'id' => $file,
75
+ 'action' => 'so_widgets_setting_form',
76
+ ),
77
+ admin_url( 'admin-ajax.php' )
78
+ );
79
+ $form_url = wp_nonce_url( $form_url, 'display-widget-form' );
80
+
81
+ ?>
82
+ <button class="button-secondary so-widget-settings" data-form-url="<?php echo esc_url( $form_url ) ?>">
83
+ <?php esc_html_e( 'Settings', 'so-widgets-bundle' ) ?>
84
+ </button>
85
+ <?php
86
+ }
87
+ ?>
88
</div>
89
90
</div>
98
<a href="https://siteorigin.com/docs/widgets-bundle/" target="_blank"><?php _e('Read More', 'so-widgets-bundle') ?></a>.
99
</div>
100
101
+ <div id="sow-settings-dialog">
102
+ <div class="so-overlay"></div>
103
+
104
+ <div class="so-title-bar">
105
+ <h3 class="so-title">Widget Settings</h3>
106
+ <a class="so-close">
107
+ <span class="so-dialog-icon"></span>
108
+ </a>
109
+ </div>
110
+
111
+ <div class="so-content so-loading">
112
+ </div>
113
+
114
+ <div class="so-toolbar">
115
+ <div class="so-buttons">
116
+ <button class="button-primary so-save"><?php _e( 'Save', 'so-widgets-bundle' ) ?></button>
117
+ </div>
118
+ </div>
119
+ </div>
120
+
121
+ <iframe id="so-widget-settings-save" name="so-widget-settings-save"></iframe>
122
+
123
+ </div>
base/base.php CHANGED
@@ -232,4 +232,4 @@ function siteorigin_widgets_get_measurements_list() {
232
233
// Allow themes and plugins to trim or enhance the list.
234
return apply_filters('siteorigin_widgets_get_measurements_list', $measurements);
235
- }
232
233
// Allow themes and plugins to trim or enhance the list.
234
return apply_filters('siteorigin_widgets_get_measurements_list', $measurements);
235
+ }
base/css/admin.css CHANGED
@@ -1,6 +1,21 @@
1
.siteorigin-widget-form-no-styles {
2
display: none !important;
3
}
4
.siteorigin-widget-form {
5
display: block !important;
6
margin: 15px 0;
@@ -379,107 +394,6 @@
379
width: 120px;
380
text-align: center;
381
}
382
- .siteorigin-widget-form .siteorigin-widget-icon-selector-current {
383
- display: inline-block;
384
- background: #f9f9f9;
385
- background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #f2f2f2), color-stop(1, #f9f9f9));
386
- background: -ms-linear-gradient(bottom, #f2f2f2, #f9f9f9);
387
- background: -moz-linear-gradient(center bottom, #f2f2f2 0%, #f9f9f9 100%);
388
- background: -o-linear-gradient(#f9f9f9, #f2f2f2);
389
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#f2f2f2', GradientType=0);
390
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
391
- -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
392
- box-shadow: 0 1px 2px rgba(0,0,0,0.1);
393
- -webkit-border-radius: 3px;
394
- -moz-border-radius: 3px;
395
- border-radius: 3px;
396
- border: 1px solid #bbbbbb;
397
- height: 35px;
398
- }
399
- .siteorigin-widget-form .siteorigin-widget-icon-selector-current:hover {
400
- background: #ffffff;
401
- background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #f7f7f7), color-stop(1, #ffffff));
402
- background: -ms-linear-gradient(bottom, #f7f7f7, #ffffff);
403
- background: -moz-linear-gradient(center bottom, #f7f7f7 0%, #ffffff 100%);
404
- background: -o-linear-gradient(#ffffff, #f7f7f7);
405
- filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f7f7f7', GradientType=0);
406
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.15);
407
- -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.15);
408
- box-shadow: 0 1px 2px rgba(0,0,0,0.15);
409
- }
410
- .siteorigin-widget-form .siteorigin-widget-icon-selector-current .siteorigin-widget-icon {
411
- -ms-box-sizing: border-box;
412
- -moz-box-sizing: border-box;
413
- -webkit-box-sizing: border-box;
414
- box-sizing: border-box;
415
- float: left;
416
- margin: 4px;
417
- padding: 3px;
418
- border: 1px solid #999;
419
- background: #f3f3f3;
420
- height: 27px;
421
- width: 32px;
422
- text-align: center;
423
- }
424
- .siteorigin-widget-form .siteorigin-widget-icon-selector-current .siteorigin-widget-icon span {
425
- color: #333;
426
- font-size: 20px;
427
- }
428
- .siteorigin-widget-form .siteorigin-widget-icon-selector-current label {
429
- display: block;
430
- float: left;
431
- color: #666;
432
- text-decoration: none;
433
- text-shadow: 0 1px 0 #FFF;
434
- font-weight: 600;
435
- font-size: 11px;
436
- padding: 9px 10px 7px 7px;
437
- outline: none;
438
- cursor: pointer;
439
- }
440
- .siteorigin-widget-form .siteorigin-widget-icon-selector {
441
- display: none;
442
- padding: 10px;
443
- border: 1px solid #D8D8D8;
444
- background: #FFFFFF;
445
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
446
- -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
447
- box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
448
- margin-top: 10px;
449
- }
450
- .siteorigin-widget-form .siteorigin-widget-icon-selector select.siteorigin-widget-icon-family {
451
- font-size: 11px;
452
- }
453
- .siteorigin-widget-form .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons {
454
- height: 160px;
455
- overflow-y: scroll;
456
- margin-top: 10px;
457
- }
458
- .siteorigin-widget-form .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons .siteorigin-widget-icon-icons-icon {
459
- -ms-box-sizing: border-box;
460
- -moz-box-sizing: border-box;
461
- -webkit-box-sizing: border-box;
462
- box-sizing: border-box;
463
- float: left;
464
- width: 58px;
465
- height: 48px;
466
- margin: 3px;
467
- padding: 4px 0;
468
- border: 1px solid #D0D0D0;
469
- background: #FFFFFF;
470
- font-size: 40px;
471
- overflow: hidden;
472
- cursor: pointer;
473
- text-align: center;
474
- }
475
- .siteorigin-widget-form .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons .siteorigin-widget-icon-icons-icon.siteorigin-widget-active {
476
- background: #f6fafc;
477
- border: 1px solid #43aaec;
478
- color: #078dce;
479
- -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.25);
480
- -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.25);
481
- box-shadow: 0 1px 2px rgba(0,0,0,0.25);
482
- }
483
.siteorigin-widget-form .siteorigin-widget-description {
484
clear: both;
485
}
1
.siteorigin-widget-form-no-styles {
2
display: none !important;
3
}
4
+ .siteorigin-widget-teaser {
5
+ padding: 10px 12px;
6
+ border: 1px solid #5fc133;
7
+ background: #edfbe7;
8
+ color: #394a3a;
9
+ margin-bottom: 20px;
10
+ }
11
+ .siteorigin-widget-teaser .dashicons {
12
+ float: right;
13
+ margin: 1px 2px 6px 10px;
14
+ cursor: pointer;
15
+ font-size: 18px;
16
+ width: 18px;
17
+ height: 18px;
18
+ }
19
.siteorigin-widget-form {
20
display: block !important;
21
margin: 15px 0;
394
width: 120px;
395
text-align: center;
396
}
397
.siteorigin-widget-form .siteorigin-widget-description {
398
clear: both;
399
}
base/inc/actions.php CHANGED
@@ -189,3 +189,23 @@ function siteorigin_widget_image_import(){
189
exit();
190
}
191
add_action('wp_ajax_so_widgets_image_import', 'siteorigin_widget_image_import');
189
exit();
190
}
191
add_action('wp_ajax_so_widgets_image_import', 'siteorigin_widget_image_import');
192
+
193
+ /**
194
+ * Action to handle a user dismissing a teaser notice.
195
+ */
196
+ function siteorigin_widgets_dismiss_widget_action(){
197
+ if( empty( $_GET[ '_wpnonce' ] ) || ! wp_verify_nonce( $_GET[ '_wpnonce' ], 'dismiss-widget-teaser' ) ) exit();
198
+ if( empty( $_GET[ 'widget' ] ) ) exit();
199
+
200
+ $dismissed = get_user_meta( get_current_user_id(), 'teasers_dismissed', true );
201
+ if( empty( $dismissed ) ) {
202
+ $dismissed = array();
203
+ }
204
+
205
+ $dismissed[ $_GET[ 'widget' ] ] = true;
206
+
207
+ update_user_meta( get_current_user_id(), 'teasers_dismissed', $dismissed );
208
+
209
+ exit();
210
+ }
211
+ add_action( 'wp_ajax_so_dismiss_widget_teaser', 'siteorigin_widgets_dismiss_widget_action' );
base/inc/fields/container-base.class.php CHANGED
@@ -74,7 +74,7 @@ abstract class SiteOrigin_Widget_Field_Container_Base extends SiteOrigin_Widget_
74
}
75
}
76
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
77
- $field_factory = SiteOrigin_Widget_Field_Factory::getInstance();
78
foreach( $this->fields as $sub_field_name => $sub_field_options ) {
79
/* @var $field SiteOrigin_Widget_Field_Base */
80
$field = $field_factory->create_field(
@@ -97,7 +97,7 @@ abstract class SiteOrigin_Widget_Field_Container_Base extends SiteOrigin_Widget_
97
98
protected function sanitize_field_input( $value, $instance ) {
99
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
100
- $field_factory = SiteOrigin_Widget_Field_Factory::getInstance();
101
foreach( $this->fields as $sub_field_name => $sub_field_options ) {
102
103
/* @var $sub_field SiteOrigin_Widget_Field_Base */
74
}
75
}
76
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
77
+ $field_factory = SiteOrigin_Widget_Field_Factory::single();
78
foreach( $this->fields as $sub_field_name => $sub_field_options ) {
79
/* @var $field SiteOrigin_Widget_Field_Base */
80
$field = $field_factory->create_field(
97
98
protected function sanitize_field_input( $value, $instance ) {
99
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
100
+ $field_factory = SiteOrigin_Widget_Field_Factory::single();
101
foreach( $this->fields as $sub_field_name => $sub_field_options ) {
102
103
/* @var $sub_field SiteOrigin_Widget_Field_Base */
base/inc/fields/css/icon-field.css ADDED
@@ -0,0 +1,122 @@
1
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector-current {
2
+ display: inline-block;
3
+ background: #f9f9f9;
4
+ background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #f2f2f2), color-stop(1, #f9f9f9));
5
+ background: -ms-linear-gradient(bottom, #f2f2f2, #f9f9f9);
6
+ background: -moz-linear-gradient(center bottom, #f2f2f2 0%, #f9f9f9 100%);
7
+ background: -o-linear-gradient(#f9f9f9, #f2f2f2);
8
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#f2f2f2', GradientType=0);
9
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
10
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.1);
11
+ box-shadow: 0 1px 2px rgba(0,0,0,0.1);
12
+ -webkit-border-radius: 3px;
13
+ -moz-border-radius: 3px;
14
+ border-radius: 3px;
15
+ float: left;
16
+ border: 1px solid #bbbbbb;
17
+ height: 35px;
18
+ }
19
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector-current:hover {
20
+ background: #ffffff;
21
+ background: -webkit-gradient(linear, left bottom, left top, color-stop(0, #f7f7f7), color-stop(1, #ffffff));
22
+ background: -ms-linear-gradient(bottom, #f7f7f7, #ffffff);
23
+ background: -moz-linear-gradient(center bottom, #f7f7f7 0%, #ffffff 100%);
24
+ background: -o-linear-gradient(#ffffff, #f7f7f7);
25
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#f7f7f7', GradientType=0);
26
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.15);
27
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.15);
28
+ box-shadow: 0 1px 2px rgba(0,0,0,0.15);
29
+ }
30
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector-current .siteorigin-widget-icon {
31
+ -ms-box-sizing: border-box;
32
+ -moz-box-sizing: border-box;
33
+ -webkit-box-sizing: border-box;
34
+ box-sizing: border-box;
35
+ float: left;
36
+ margin: 4px;
37
+ padding: 3px;
38
+ border: 1px solid #999;
39
+ background: #f3f3f3;
40
+ height: 27px;
41
+ width: 32px;
42
+ text-align: center;
43
+ }
44
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector-current .siteorigin-widget-icon span {
45
+ color: #333;
46
+ font-size: 20px;
47
+ }
48
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector-current label {
49
+ display: block;
50
+ float: left;
51
+ color: #666;
52
+ text-decoration: none;
53
+ text-shadow: 0 1px 0 #FFF;
54
+ font-weight: 600;
55
+ font-size: 11px;
56
+ padding: 9px 10px 7px 7px;
57
+ outline: none;
58
+ cursor: pointer;
59
+ }
60
+ .siteorigin-widget-form .siteorigin-widget-field-icon .so-icon-remove {
61
+ cursor: pointer;
62
+ display: block;
63
+ text-decoration: none;
64
+ float: left;
65
+ color: #AAA;
66
+ font-size: 11px;
67
+ line-height: 1em;
68
+ padding: 11px 0 11px 6px;
69
+ }
70
+ .siteorigin-widget-form .siteorigin-widget-field-icon.siteorigin-widget-active .so-icon-remove {
71
+ display: none;
72
+ }
73
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector {
74
+ display: none;
75
+ padding: 10px;
76
+ border: 1px solid #D8D8D8;
77
+ background: #FFFFFF;
78
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
79
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
80
+ box-shadow: 0 1px 2px rgba(0,0,0,0.0275);
81
+ margin-top: 10px;
82
+ }
83
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector select.siteorigin-widget-icon-family {
84
+ font-size: 11px;
85
+ display: inline-block;
86
+ }
87
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector .siteorigin-widget-icon-search {
88
+ font-size: 11px;
89
+ display: inline-block;
90
+ width: 260px;
91
+ padding: 6px 8px;
92
+ }
93
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons {
94
+ height: 160px;
95
+ overflow-y: scroll;
96
+ margin-top: 10px;
97
+ }
98
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons .siteorigin-widget-icon-icons-icon {
99
+ -ms-box-sizing: border-box;
100
+ -moz-box-sizing: border-box;
101
+ -webkit-box-sizing: border-box;
102
+ box-sizing: border-box;
103
+ float: left;
104
+ width: 58px;
105
+ height: 48px;
106
+ margin: 3px;
107
+ padding: 4px 0;
108
+ border: 1px solid #D0D0D0;
109
+ background: #FFFFFF;
110
+ font-size: 40px;
111
+ overflow: hidden;
112
+ cursor: pointer;
113
+ text-align: center;
114
+ }
115
+ .siteorigin-widget-form .siteorigin-widget-field-icon .siteorigin-widget-icon-selector .siteorigin-widget-icon-icons .siteorigin-widget-icon-icons-icon.siteorigin-widget-active {
116
+ background: #f6fafc;
117
+ border: 1px solid #43aaec;
118
+ color: #078dce;
119
+ -webkit-box-shadow: 0 1px 2px rgba(0,0,0,0.25);
120
+ -moz-box-shadow: 0 1px 2px rgba(0,0,0,0.25);
121
+ box-shadow: 0 1px 2px rgba(0,0,0,0.25);
122
+ }
base/inc/fields/factory.class.php CHANGED
@@ -4,14 +4,14 @@
4
* Class SiteOrigin_Widget_Field_Factory
5
*/
6
class SiteOrigin_Widget_Field_Factory {
7
8
- private static $instance;
9
-
10
- public static function getInstance() {
11
- if( ! isset( SiteOrigin_Widget_Field_Factory::$instance ) ) {
12
- SiteOrigin_Widget_Field_Factory::$instance = new SiteOrigin_Widget_Field_Factory();
13
}
14
- return SiteOrigin_Widget_Field_Factory::$instance;
15
}
16
17
public function create_field( $field_name, $field_options, SiteOrigin_Widget $for_widget, $for_repeater = array(), $is_template = false ) {
4
* Class SiteOrigin_Widget_Field_Factory
5
*/
6
class SiteOrigin_Widget_Field_Factory {
7
+ public static function single(){
8
+ static $single;
9
10
+ if( empty( $single ) ) {
11
+ $single = new self();
12
}
13
+
14
+ return $single;
15
}
16
17
public function create_field( $field_name, $field_options, SiteOrigin_Widget $for_widget, $for_repeater = array(), $is_template = false ) {
base/inc/fields/icon.class.php CHANGED
@@ -18,6 +18,10 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
18
<label><?php _e('Choose Icon', 'so-widgets-bundle') ?></label>
19
</div>
20
21
<div class="siteorigin-widget-icon-selector siteorigin-widget-field-subcontainer">
22
<select class="siteorigin-widget-icon-family" >
23
<?php foreach( $widget_icon_families as $family_id => $family_info ) : ?>
@@ -30,6 +34,8 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
30
<?php endforeach; ?>
31
</select>
32
33
<input type="hidden" name="<?php echo esc_attr( $this->element_name ) ?>" value="<?php echo esc_attr( $value ) ?>"
34
class="siteorigin-widget-icon-icon siteorigin-widget-input" />
35
@@ -71,4 +77,9 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
71
return $widget_icon_families;
72
}
73
74
}
18
<label><?php _e('Choose Icon', 'so-widgets-bundle') ?></label>
19
</div>
20
21
+ <a class="so-icon-remove" style="display: <?php echo !empty( $value ) ? 'block' : 'none' ?>;"><?php esc_html_e( 'Remove', 'so-widgets-bundle' ) ?></a>
22
+
23
+ <div class="clear"></div>
24
+
25
<div class="siteorigin-widget-icon-selector siteorigin-widget-field-subcontainer">
26
<select class="siteorigin-widget-icon-family" >
27
<?php foreach( $widget_icon_families as $family_id => $family_info ) : ?>
34
<?php endforeach; ?>
35
</select>
36
37
+ <input type="search" class="siteorigin-widget-icon-search" placeholder="<?php esc_attr_e( 'Search Icons' ) ?>" />
38
+
39
<input type="hidden" name="<?php echo esc_attr( $this->element_name ) ?>" value="<?php echo esc_attr( $value ) ?>"
40
class="siteorigin-widget-icon-icon siteorigin-widget-input" />
41
77
return $widget_icon_families;
78
}
79
80
+ public function enqueue_scripts(){
81
+ wp_enqueue_script( 'so-icon-field', plugin_dir_url( __FILE__ ) . '/js/icon-field' . SOW_BUNDLE_JS_SUFFIX . '.js', array( 'jquery' ), SOW_BUNDLE_VERSION );
82
+ wp_enqueue_style( 'so-icon-field', plugin_dir_url( __FILE__ ) . '/css/icon-field.css', array( ), SOW_BUNDLE_VERSION );
83
+ }
84
+
85
}
base/inc/fields/js/icon-field.js ADDED
@@ -0,0 +1,168 @@
1
+ ( function( $ ) {
2
+
3
+ var iconWidgetCache = {};
4
+
5
+ $(document).on( 'sowsetupformfield', '.siteorigin-widget-field-type-icon', function(e) {
6
+ var $ = $(this),
7
+ $is = $.find('.siteorigin-widget-icon-selector'),
8
+ $v = $is.find('.siteorigin-widget-icon-icon'),
9
+ $b = $.find('.siteorigin-widget-icon-selector-current'),
10
+ $remove = $.find( '.so-icon-remove' ),
11
+ $search = $.find( '.siteorigin-widget-icon-search' );
12
+
13
+ // Clicking on the button should display the icon selector
14
+ $b.click( function(){
15
+ $is.slideToggle();
16
+ $search.val( '' );
17
+ searchIcons();
18
+ } );
19
+
20
+ // Clicking on the remove button
21
+ $remove.click( function( e ){
22
+ e.preventDefault();
23
+
24
+ // Trigger a click on the existing icon to remove it.
25
+ $.find('.siteorigin-widget-active').click();
26
+ } );
27
+
28
+ var searchIcons = function(){
29
+ var q = $search.val().toLowerCase();
30
+ if( q === '' ) {
31
+ $is.find('.siteorigin-widget-icon-icons-icon').show();
32
+ }
33
+ else {
34
+ $is.find('.siteorigin-widget-icon-icons-icon').each( function(){
35
+ var $ = $( this ),
36
+ value = $.attr( 'data-value' );
37
+
38
+ value = value.replace( /-/, ' ' );
39
+ if( value.indexOf( q ) === -1 ) {
40
+ $.hide();
41
+ }
42
+ else {
43
+ $.show();
44
+ }
45
+ } );
46
+ }
47
+ };
48
+
49
+ $search.keyup( searchIcons ).change( searchIcons );
50
+
51
+ var rerenderIcons = function(){
52
+ var family = $is.find('select.siteorigin-widget-icon-family').val();
53
+ var container = $is.find('.siteorigin-widget-icon-icons');
54
+
55
+ if(typeof iconWidgetCache[family] === 'undefined') {
56
+ return;
57
+ }
58
+
59
+ container.empty();
60
+
61
+ if( $('#'+'siteorigin-widget-font-'+family).length === 0) {
62
+
63
+ $("<link rel='stylesheet' type='text/css'>")
64
+ .attr('id', 'siteorigin-widget-font-' + family)
65
+ .attr('href', iconWidgetCache[family].style_uri)
66
+ .appendTo('head');
67
+ }
68
+
69
+ for ( var i in iconWidgetCache[family].icons ) {
70
+
71
+ var icon = $('<div data-sow-icon="' + iconWidgetCache[family].icons[i] + '"/>')
72
+ .attr('data-value', family + '-' + i)
73
+ .addClass( 'sow-icon-' + family )
74
+ .addClass( 'siteorigin-widget-icon-icons-icon' )
75
+ .click(function(){
76
+ var $ = $(this);
77
+
78
+ if( $.hasClass('siteorigin-widget-active') ) {
79
+ // This is being unselected
80
+ $.removeClass('siteorigin-widget-active');
81
+ $v.val( '' );
82
+
83
+ // Hide the button icon
84
+ $b.find('span').hide();
85
+
86
+ $remove.hide();
87
+ }
88
+ else {
89
+ // This is being selected
90
+ container.find('.siteorigin-widget-icon-icons-icon').removeClass('siteorigin-widget-active');
91
+ $.addClass('siteorigin-widget-active');
92
+ $v.val( $.data('value') );
93
+
94
+ // Also add this to the button
95
+ $b.find('span')
96
+ .show()
97
+ .attr( 'data-sow-icon', $.attr('data-sow-icon') )
98
+ .attr( 'class', '' )
99
+ .addClass( 'sow-icon-' + family );
100
+
101
+ $remove.show();
102
+ }
103
+ $v.trigger('change');
104
+
105
+ // Hide the icon selector
106
+ $is.slideUp();
107
+ });
108
+
109
+ container.append(icon);
110
+
111
+ if( $v.val() === family + '-' + i ) {
112
+ // Add selected icon to the button.
113
+ $b.find('span')
114
+ .show()
115
+ .attr( 'data-sow-icon', icon.attr('data-sow-icon') )
116
+ .attr( 'class', '' )
117
+ .addClass( 'sow-icon-' + family );
118
+ icon.addClass('siteorigin-widget-active');
119
+ }
120
+ }
121
+
122
+ // Move a selected item to the first position
123
+ container.prepend( container.find('.siteorigin-widget-active') );
124
+
125
+ searchIcons();
126
+ };
127
+
128
+ // Create the function for changing the icon family and call it once
129
+ var changeIconFamily = function(){
130
+ // Fetch the family icons from the server
131
+ var family = $is.find('select.siteorigin-widget-icon-family').val();
132
+
133
+ var dataIcons = $is.find('select.siteorigin-widget-icon-family option:selected' ).data('icons');
134
+ if( dataIcons !== null ) {
135
+ iconWidgetCache[family] = dataIcons;
136
+ }
137
+
138
+
139
+ if(typeof family === 'undefined' || family === '') {
140
+ return;
141
+ }
142
+
143
+ if(typeof iconWidgetCache[family] === 'undefined') {
144
+ $.getJSON(
145
+ soWidgets.ajaxurl,
146
+ {
147
+ 'action' : 'siteorigin_widgets_get_icons',
148
+ 'family' : $is.find('select.siteorigin-widget-icon-family').val()
149
+ },
150
+ function(data) {
151
+ iconWidgetCache[family] = data;
152
+ rerenderIcons();
153
+ }
154
+ );
155
+ }
156
+ else {
157
+ rerenderIcons();
158
+ }
159
+ };
160
+ changeIconFamily();
161
+
162
+ $is.find('select.siteorigin-widget-icon-family').change(function(){
163
+ $is.find('.siteorigin-widget-icon-icons').empty();
164
+ changeIconFamily();
165
+ });
166
+ } );
167
+
168
+ } )( jQuery );
base/inc/fields/js/icon-field.min.js ADDED
@@ -0,0 +1 @@
1
+ !function(i){var e={};i(document).on("sowsetupformfield",".siteorigin-widget-field-type-icon",function(t){var n=i(this),o=n.find(".siteorigin-widget-icon-selector"),s=o.find(".siteorigin-widget-icon-icon"),a=n.find(".siteorigin-widget-icon-selector-current"),d=n.find(".so-icon-remove"),c=n.find(".siteorigin-widget-icon-search");a.click(function(){o.slideToggle(),c.val(""),r()}),d.click(function(i){i.preventDefault(),n.find(".siteorigin-widget-active").click()});var r=function(){var e=c.val().toLowerCase();""===e?o.find(".siteorigin-widget-icon-icons-icon").show():o.find(".siteorigin-widget-icon-icons-icon").each(function(){var t=i(this),n=t.attr("data-value");n=n.replace(/-/," "),n.indexOf(e)===-1?t.hide():t.show()})};c.keyup(r).change(r);var g=function(){var t=o.find("select.siteorigin-widget-icon-family").val(),n=o.find(".siteorigin-widget-icon-icons");if("undefined"!=typeof e[t]){n.empty(),0===i("#siteorigin-widget-font-"+t).length&&i("<link rel='stylesheet' type='text/css'>").attr("id","siteorigin-widget-font-"+t).attr("href",e[t].style_uri).appendTo("head");for(var c in e[t].icons){var g=i('<div data-sow-icon="'+e[t].icons[c]+'"/>').attr("data-value",t+"-"+c).addClass("sow-icon-"+t).addClass("siteorigin-widget-icon-icons-icon").click(function(){var e=i(this);e.hasClass("siteorigin-widget-active")?(e.removeClass("siteorigin-widget-active"),s.val(""),a.find("span").hide(),d.hide()):(n.find(".siteorigin-widget-icon-icons-icon").removeClass("siteorigin-widget-active"),e.addClass("siteorigin-widget-active"),s.val(e.data("value")),a.find("span").show().attr("data-sow-icon",e.attr("data-sow-icon")).attr("class","").addClass("sow-icon-"+t),d.show()),s.trigger("change"),o.slideUp()});n.append(g),s.val()===t+"-"+c&&(a.find("span").show().attr("data-sow-icon",g.attr("data-sow-icon")).attr("class","").addClass("sow-icon-"+t),g.addClass("siteorigin-widget-active"))}n.prepend(n.find(".siteorigin-widget-active")),r()}},l=function(){var t=o.find("select.siteorigin-widget-icon-family").val(),n=o.find("select.siteorigin-widget-icon-family option:selected").data("icons");null!==n&&(e[t]=n),"undefined"!=typeof t&&""!==t&&("undefined"==typeof e[t]?i.getJSON(soWidgets.ajaxurl,{action:"siteorigin_widgets_get_icons",family:o.find("select.siteorigin-widget-icon-family").val()},function(i){e[t]=i,g()}):g())};l(),o.find("select.siteorigin-widget-icon-family").change(function(){o.find(".siteorigin-widget-icon-icons").empty(),l()})})}(jQuery);
base/inc/fields/js/media-field.js CHANGED
@@ -266,6 +266,8 @@
266
dialog.find( '.so-widgets-results-loading' ).hide();
267
$field.find( 'input[type=hidden]' ).val( response.attachment_id ).trigger('change');
268
$field.find('.current .thumbnail' ).attr('src', response.thumb ).fadeIn();
269
}
270
else {
271
alert( response.message );
266
dialog.find( '.so-widgets-results-loading' ).hide();
267
$field.find( 'input[type=hidden]' ).val( response.attachment_id ).trigger('change');
268
$field.find('.current .thumbnail' ).attr('src', response.thumb ).fadeIn();
269
+
270
+ $field.find('.media-remove-button').removeClass('remove-hide');
271
}
272
else {
273
alert( response.message );
base/inc/fields/js/media-field.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-media",function(t){var i=e(this).find("> .media-field-wrapper"),s=i.closest(".siteorigin-widget-field");i.find(".media-upload-button").click(function(t){if(t.preventDefault(),"undefined"!=typeof wp.media){var i=e(this),n=e(this).closest(".siteorigin-widget-field"),a=e(this).data("frame");if(a)return a.open(),!1;a=wp.media({title:i.data("choose"),library:{type:i.data("library").split(",").map(function(e){return e.trim()})},button:{text:i.data("update"),close:!1}}),i.data("frame",a),a.on("select",function(){var e=a.state().get("selection").first().attributes;n.find(".current .title").html(e.title);var t=n.find("input[type=hidden]");t.val(e.id),t.trigger("change"),"undefined"!=typeof e.sizes?"undefined"!=typeof e.sizes.thumbnail?n.find(".current .thumbnail").attr("src",e.sizes.thumbnail.url).fadeIn():n.find(".current .thumbnail").attr("src",e.sizes.full.url).fadeIn():n.find(".current .thumbnail").attr("src",e.icon).fadeIn(),s.find(".media-remove-button").removeClass("remove-hide"),a.close()}),a.open()}}),i.find(".current").mouseenter(function(){var t=e(this).find(".title");""!==t.html()&&t.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),s.find("a.media-remove-button").click(function(t){t.preventDefault(),s.find(".current .title").html(""),s.find("input[type=hidden]").val(""),s.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")});var n=!1,a=function(){if(n){var e=n.find(".so-widgets-image-results");if(0!==e.length){var t=e.width(),i=Math.floor(t/276),s=t-276*i,a=s/i+260;e.find(".so-widgets-result-image").css({width:a,height:a/1.4})}}};e(window).resize(a);var d=function(){if(!n){n=e(e("#so-widgets-bundle-tpl-image-search-dialog").html().trim()).appendTo("body"),n.find(".close").click(function(){n.hide()});var t=n.find(".so-widgets-image-results"),i=function(i,s){n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("loading")),n.find(".so-widgets-results-more").hide(),e.get(ajaxurl,{action:"so_widgets_image_search",q:i,page:s,_sononce:n.find('input[name="_sononce"]').val()},function(d){return d.error?void alert(d.message):(t.removeClass("so-loading"),e.each(d.items,function(i,s){var n=e(e("#so-widgets-bundle-tpl-image-search-result").html().trim()).appendTo(t).addClass("source-"+s.source),a=n.find(".so-widgets-result-image");a.css("background-image","url("+s.thumbnail+")"),a.data("thumbnail",s.thumbnail),a.data("preview",s.preview),s.url&&a.attr({href:s.url,target:"_blank"}),s.full_url&&(a.data({full_url:s.full_url,import_signature:s.import_signature}),a.attr("href",s.full_url)),"shutterstock"===s.source&&a.append(e("#so-widgets-bundle-tpl-image-search-result-sponsored").html())}),1===s&&(n.find("#so-widgets-image-search-suggestions ul").empty(),e.each(d.keywords,function(t,i){n.find("#so-widgets-image-search-suggestions").show(),n.find("#so-widgets-image-search-suggestions ul").append(e("<li></li>").append(e('<a href="#"></a>').html(i).data("keyword",i)))})),n.find(".so-widgets-results-loading").fadeOut("fast"),a(),void n.find(".so-widgets-results-more").show().find("button").data({query:i,page:s+1}))})};n.find("#so-widgets-image-search-form").submit(function(e){e.preventDefault();var s=n.find(".so-widgets-search-input").val();t.empty(),""!==s&&i(s,1)}),n.on("click",".so-keywords-list a",function(t){t.preventDefault();var i=e(this).blur();n.find(".so-widgets-search-input").val(i.data("keyword")),n.find("#so-widgets-image-search-form").submit()}),n.find(".so-widgets-results-more button").click(function(){var t=e(this);i(t.data("query"),t.data("page"))});var d;n.on("click",".so-widgets-result-image",function(t){var i=e(this);if(i.data("full_url")&&(t.preventDefault(),confirm(n.data("confirm-import")))){n.addClass("so-widgets-importing");var a=e("#post_ID").val();null===a&&(a=""),e.get(ajaxurl,{action:"so_widgets_image_import",full_url:i.data("full_url"),import_signature:i.data("import_signature"),post_id:a,_sononce:n.find('input[name="_sononce"]').val()},function(e){n.find("#so-widgets-image-search-frame").removeClass("so-widgets-importing"),e.error===!1?(n.hide(),n.find(".so-widgets-results-loading").hide(),s.find("input[type=hidden]").val(e.attachment_id).trigger("change"),s.find(".current .thumbnail").attr("src",e.thumb).fadeIn()):(alert(e.message),n.find(".so-widgets-results-loading").hide())}),n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("importing")),n.find(".so-widgets-results-more").hide(),n.find("#so-widgets-image-search-frame").addClass("so-widgets-importing")}});var r=n.find(".so-widgets-preview-window");n.on("mouseenter",".so-widgets-result-image",function(){var t=e(this),i=t.data("preview");clearTimeout(d),d=setTimeout(function(){var s=1,a=1;i[1]>.33*e(window).outerWidth()&&(s=.33*e(window).outerWidth()/i[1]),i[2]>.5*e(window).outerHeight()&&(a=.5*e(window).outerHeight()/i[2]);var d=Math.min(s,a);d>1&&(d=1),r.show().find(".so-widgets-preview-window-inside").css({"background-image":"url("+t.data("thumbnail")+")",width:i[1]*d,height:i[2]*d}).append(e("<img />").attr("src",i[0])),n.trigger("mousemove")},1e3)}).on("mouseleave",".so-widgets-result-image",function(){r.hide().find("img").remove(),clearTimeout(d)});var o,u;n.on("mousemove",function(t){if(t.clientX&&(o=t.clientX),t.clientY&&(u=t.clientY),r.is(":visible")){var i=r.outerHeight(),s=r.outerWidth(),n=e(window).outerHeight(),a=e(window).outerWidth(),d=u-i/2;d=Math.max(d,10),d=Math.min(d,n-10-i);var l=o<a/2?o+15:o-15-s;r.css({top:d,left:l})}})}n.show(),n.find(".so-widgets-search-input").focus()};i.find(".find-image-button").click(function(e){e.preventDefault(),d()})})}(jQuery);
1
+ !function(e){e(document).on("sowsetupformfield",".siteorigin-widget-field-type-media",function(t){var i=e(this).find("> .media-field-wrapper"),s=i.closest(".siteorigin-widget-field");i.find(".media-upload-button").click(function(t){if(t.preventDefault(),"undefined"!=typeof wp.media){var i=e(this),n=e(this).closest(".siteorigin-widget-field"),a=e(this).data("frame");if(a)return a.open(),!1;a=wp.media({title:i.data("choose"),library:{type:i.data("library").split(",").map(function(e){return e.trim()})},button:{text:i.data("update"),close:!1}}),i.data("frame",a),a.on("select",function(){var e=a.state().get("selection").first().attributes;n.find(".current .title").html(e.title);var t=n.find("input[type=hidden]");t.val(e.id),t.trigger("change"),"undefined"!=typeof e.sizes?"undefined"!=typeof e.sizes.thumbnail?n.find(".current .thumbnail").attr("src",e.sizes.thumbnail.url).fadeIn():n.find(".current .thumbnail").attr("src",e.sizes.full.url).fadeIn():n.find(".current .thumbnail").attr("src",e.icon).fadeIn(),s.find(".media-remove-button").removeClass("remove-hide"),a.close()}),a.open()}}),i.find(".current").mouseenter(function(){var t=e(this).find(".title");""!==t.html()&&t.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),s.find("a.media-remove-button").click(function(t){t.preventDefault(),s.find(".current .title").html(""),s.find("input[type=hidden]").val(""),s.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")});var n=!1,a=function(){if(n){var e=n.find(".so-widgets-image-results");if(0!==e.length){var t=e.width(),i=Math.floor(t/276),s=t-276*i,a=s/i+260;e.find(".so-widgets-result-image").css({width:a,height:a/1.4})}}};e(window).resize(a);var d=function(){if(!n){n=e(e("#so-widgets-bundle-tpl-image-search-dialog").html().trim()).appendTo("body"),n.find(".close").click(function(){n.hide()});var t=n.find(".so-widgets-image-results"),i=function(i,s){n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("loading")),n.find(".so-widgets-results-more").hide(),e.get(ajaxurl,{action:"so_widgets_image_search",q:i,page:s,_sononce:n.find('input[name="_sononce"]').val()},function(d){return d.error?void alert(d.message):(t.removeClass("so-loading"),e.each(d.items,function(i,s){var n=e(e("#so-widgets-bundle-tpl-image-search-result").html().trim()).appendTo(t).addClass("source-"+s.source),a=n.find(".so-widgets-result-image");a.css("background-image","url("+s.thumbnail+")"),a.data("thumbnail",s.thumbnail),a.data("preview",s.preview),s.url&&a.attr({href:s.url,target:"_blank"}),s.full_url&&(a.data({full_url:s.full_url,import_signature:s.import_signature}),a.attr("href",s.full_url)),"shutterstock"===s.source&&a.append(e("#so-widgets-bundle-tpl-image-search-result-sponsored").html())}),1===s&&(n.find("#so-widgets-image-search-suggestions ul").empty(),e.each(d.keywords,function(t,i){n.find("#so-widgets-image-search-suggestions").show(),n.find("#so-widgets-image-search-suggestions ul").append(e("<li></li>").append(e('<a href="#"></a>').html(i).data("keyword",i)))})),n.find(".so-widgets-results-loading").fadeOut("fast"),a(),void n.find(".so-widgets-results-more").show().find("button").data({query:i,page:s+1}))})};n.find("#so-widgets-image-search-form").submit(function(e){e.preventDefault();var s=n.find(".so-widgets-search-input").val();t.empty(),""!==s&&i(s,1)}),n.on("click",".so-keywords-list a",function(t){t.preventDefault();var i=e(this).blur();n.find(".so-widgets-search-input").val(i.data("keyword")),n.find("#so-widgets-image-search-form").submit()}),n.find(".so-widgets-results-more button").click(function(){var t=e(this);i(t.data("query"),t.data("page"))});var d;n.on("click",".so-widgets-result-image",function(t){var i=e(this);if(i.data("full_url")&&(t.preventDefault(),confirm(n.data("confirm-import")))){n.addClass("so-widgets-importing");var a=e("#post_ID").val();null===a&&(a=""),e.get(ajaxurl,{action:"so_widgets_image_import",full_url:i.data("full_url"),import_signature:i.data("import_signature"),post_id:a,_sononce:n.find('input[name="_sononce"]').val()},function(e){n.find("#so-widgets-image-search-frame").removeClass("so-widgets-importing"),e.error===!1?(n.hide(),n.find(".so-widgets-results-loading").hide(),s.find("input[type=hidden]").val(e.attachment_id).trigger("change"),s.find(".current .thumbnail").attr("src",e.thumb).fadeIn(),s.find(".media-remove-button").removeClass("remove-hide")):(alert(e.message),n.find(".so-widgets-results-loading").hide())}),n.find(".so-widgets-results-loading").fadeIn("fast"),n.find(".so-widgets-results-loading strong").html(n.find(".so-widgets-results-loading strong").data("importing")),n.find(".so-widgets-results-more").hide(),n.find("#so-widgets-image-search-frame").addClass("so-widgets-importing")}});var r=n.find(".so-widgets-preview-window");n.on("mouseenter",".so-widgets-result-image",function(){var t=e(this),i=t.data("preview");clearTimeout(d),d=setTimeout(function(){var s=1,a=1;i[1]>.33*e(window).outerWidth()&&(s=.33*e(window).outerWidth()/i[1]),i[2]>.5*e(window).outerHeight()&&(a=.5*e(window).outerHeight()/i[2]);var d=Math.min(s,a);d>1&&(d=1),r.show().find(".so-widgets-preview-window-inside").css({"background-image":"url("+t.data("thumbnail")+")",width:i[1]*d,height:i[2]*d}).append(e("<img />").attr("src",i[0])),n.trigger("mousemove")},1e3)}).on("mouseleave",".so-widgets-result-image",function(){r.hide().find("img").remove(),clearTimeout(d)});var o,u;n.on("mousemove",function(t){if(t.clientX&&(o=t.clientX),t.clientY&&(u=t.clientY),r.is(":visible")){var i=r.outerHeight(),s=r.outerWidth(),n=e(window).outerHeight(),a=e(window).outerWidth(),d=u-i/2;d=Math.max(d,10),d=Math.min(d,n-10-i);var l=o<a/2?o+15:o-15-s;r.css({top:d,left:l})}})}n.show(),n.find(".so-widgets-search-input").focus()};i.find(".find-image-button").click(function(e){e.preventDefault(),d()})})}(jQuery);
base/inc/fields/media.class.php CHANGED
@@ -186,9 +186,8 @@ class SiteOrigin_Widget_Field_Media extends SiteOrigin_Widget_Field_Base {
186
<div id="so-widgets-image-search-powered">
187
<?php
188
printf(
189
- __( 'Powered by %s - sponsored results from %s', 'so-widgets-bundle' ),
190
- '<a href="https://pixabay.com/" target="_blank">Pixabay</a>',
191
- '<a href="http://stock.siteorigin.com/?shutterstock=home" target="_blank">Shutterstock</a>'
192
);
193
?>
194
</div>
186
<div id="so-widgets-image-search-powered">
187
<?php
188
printf(
189
+ __( 'Powered by %s', 'so-widgets-bundle' ),
190
+ '<a href="https://pixabay.com/" target="_blank">Pixabay</a>'
191
);
192
?>
193
</div>
base/inc/meta-box-manager.php CHANGED
@@ -35,7 +35,7 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
35
__('SiteOrigin Meta Box Manager', 'so-widgets-bundle'),
36
array(
37
'has_preview' => false,
38
- 'help' => 'https://siteorigin.com/docs/widgets-bundle/advanced-concepts/widget-post-meta-box-forms/'
39
),
40
array(),
41
array()
@@ -71,7 +71,7 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
71
}
72
}
73
74
- if ( !empty( $this->form_options ) ) {
75
add_meta_box(
76
'siteorigin-widgets-meta-box',
77
__( 'Widgets Bundle Post Meta Data', 'so-widgets-bundle' ),
@@ -90,7 +90,7 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
90
*/
91
public function render_widgets_meta_box( $post ) {
92
wp_enqueue_script(
93
- 'sow-meta-box-manager',
94
plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/js/meta-box-manager' . SOW_BUNDLE_JS_SUFFIX . '.js',
95
array( 'jquery' ),
96
SOW_BUNDLE_VERSION,
@@ -140,14 +140,11 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
140
* @param $post_id
141
*/
142
public function save_widget_post_meta( $post_id ) {
143
- $nonce = filter_input( INPUT_POST, '_widget_post_meta_nonce', FILTER_SANITIZE_STRING );
144
- if ( !wp_verify_nonce( $nonce, 'widget_post_meta_save' ) ) return;
145
if ( !current_user_can( 'edit_post', $post_id ) ) return;
146
147
- $request = filter_input_array( INPUT_POST, array(
148
- 'widget_post_meta' => FILTER_DEFAULT
149
- ) );
150
- $widget_post_meta = json_decode( $request['widget_post_meta'], true);
151
152
update_post_meta( $post_id, self::POST_META_KEY, $widget_post_meta );
153
@@ -159,6 +156,7 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
159
* @param $post_id string The id of the post for which the meta data is stored.
160
* @param $widget_id string The id of the widget for which the meta data is stored.
161
* @param $meta_key string The key of the meta data value which is to be retrieved.
162
* @return mixed An empty string if the meta data is not found, else the meta data in whatever format it was stored.
163
*/
164
public function get_widget_post_meta( $post_id, $widget_id, $meta_key ) {
@@ -168,24 +166,4 @@ class SiteOrigin_Widget_Meta_Box_Manager extends SiteOrigin_Widget {
168
if( ! isset( $widget_post_meta[$widget_post_meta_field] ) ) return '';
169
return $widget_post_meta[$widget_post_meta_field];
170
}
171
-
172
- /**
173
- * Unused override.
174
- *
175
- * @param $instance
176
- * @return string
177
- */
178
- function get_style_name( $instance ) {
179
- return '';
180
- }
181
-
182
- /**
183
- * Unused override.
184
- *
185
- * @param $instance
186
- * @return string
187
- */
188
- function get_template_name( $instance ) {
189
- return '';
190
- }
191
}
35
__('SiteOrigin Meta Box Manager', 'so-widgets-bundle'),
36
array(
37
'has_preview' => false,
38
+ 'help' => false
39
),
40
array(),
41
array()
71
}
72
}
73
74
+ if ( ! empty( $this->form_options ) ) {
75
add_meta_box(
76
'siteorigin-widgets-meta-box',
77
__( 'Widgets Bundle Post Meta Data', 'so-widgets-bundle' ),
90
*/
91
public function render_widgets_meta_box( $post ) {
92
wp_enqueue_script(
93
+ 'sow-meta-box-manager-js',
94
plugin_dir_url(SOW_BUNDLE_BASE_FILE).'base/js/meta-box-manager' . SOW_BUNDLE_JS_SUFFIX . '.js',
95
array( 'jquery' ),
96
SOW_BUNDLE_VERSION,
140
* @param $post_id
141
*/
142
public function save_widget_post_meta( $post_id ) {
143
+ if ( empty( $_POST['_widget_post_meta_nonce'] ) || !wp_verify_nonce( $_POST['_widget_post_meta_nonce'], 'widget_post_meta_save' ) ) return;
144
if ( !current_user_can( 'edit_post', $post_id ) ) return;
145
146
+ $widget_post_meta = isset( $_POST['widget_post_meta'] ) ? stripslashes_deep( $_POST['widget_post_meta'] ) : '';
147
+ $widget_post_meta = json_decode( $widget_post_meta, true);
148
149
update_post_meta( $post_id, self::POST_META_KEY, $widget_post_meta );
150
156
* @param $post_id string The id of the post for which the meta data is stored.
157
* @param $widget_id string The id of the widget for which the meta data is stored.
158
* @param $meta_key string The key of the meta data value which is to be retrieved.
159
+ *
160
* @return mixed An empty string if the meta data is not found, else the meta data in whatever format it was stored.
161
*/
162
public function get_widget_post_meta( $post_id, $widget_id, $meta_key ) {
166
if( ! isset( $widget_post_meta[$widget_post_meta_field] ) ) return '';
167
return $widget_post_meta[$widget_post_meta_field];
168
}
169
}
base/inc/widget-manager.class.php CHANGED
@@ -11,10 +11,10 @@ class SiteOrigin_Widgets_Widget_Manager {
11
*
12
* @var
13
*/
14
- private $regisrered;
15
16
function __construct(){
17
- $this->regisrered = array();
18
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
19
}
20
@@ -45,19 +45,19 @@ class SiteOrigin_Widgets_Widget_Manager {
45
$class = 'SiteOrigin_Widget_' . str_replace( ' ', '', ucwords( str_replace('-', ' ', $id) ) ) . '_Widget';
46
}
47
48
- $this->regisrered[$id] = new stdClass();
49
- $this->regisrered[$id]->path = $path;
50
- $this->regisrered[$id]->class = $class;
51
- $this->regisrered[$id]->registered = false;
52
53
- return $this->regisrered[$id];
54
}
55
56
/**
57
* Initialize all the widgets.
58
*/
59
public function widgets_init(){
60
- foreach( $this->regisrered as $id => & $info ) {
61
if( $info->registered ) continue;
62
register_widget( $info->class );
63
$info->registered = true;
@@ -72,13 +72,13 @@ class SiteOrigin_Widgets_Widget_Manager {
72
* @return bool
73
*/
74
public function get_plugin_path( $id ) {
75
- if( empty($this->regisrered[$id]) ) {
76
- // This call might be using the incorrect ID convention
77
if( substr($id, 0, 4) == 'sow-' ) $id = substr($id, 4);
78
else $id = 'sow-' . $id;
79
}
80
81
- return !empty($this->regisrered[$id]) ? $this->regisrered[$id]->path : false;
82
}
83
84
/**
@@ -95,6 +95,33 @@ class SiteOrigin_Widgets_Widget_Manager {
95
function get_plugin_dir_url( $id ){
96
return plugin_dir_url( $this->get_plugin_path( $id ) );
97
}
98
}
99
SiteOrigin_Widgets_Widget_Manager::single();
100
@@ -126,7 +153,7 @@ function siteorigin_widget_get_plugin_path($id){
126
* @return string
127
*/
128
function siteorigin_widget_get_plugin_dir_path($id){
129
- return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_path($id);
130
}
131
132
/**
@@ -136,5 +163,5 @@ function siteorigin_widget_get_plugin_dir_path($id){
136
* @return string
137
*/
138
function siteorigin_widget_get_plugin_dir_url($id){
139
- return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_url($id);
140
}
11
*
12
* @var
13
*/
14
+ private $registered;
15
16
function __construct(){
17
+ $this->registered = array();
18
add_action( 'widgets_init', array( $this, 'widgets_init' ) );
19
}
20
45
$class = 'SiteOrigin_Widget_' . str_replace( ' ', '', ucwords( str_replace('-', ' ', $id) ) ) . '_Widget';
46
}
47
48
+ $this->registered[ $id ] = new stdClass();
49
+ $this->registered[ $id ]->path = $path;
50
+ $this->registered[ $id ]->class = $class;
51
+ $this->registered[ $id ]->registered = false;
52
53
+ return $this->registered[ $id ];
54
}
55
56
/**
57
* Initialize all the widgets.
58
*/
59
public function widgets_init(){
60
+ foreach( $this->registered as $id => & $info ) {
61
if( $info->registered ) continue;
62
register_widget( $info->class );
63
$info->registered = true;
72
* @return bool
73
*/
74
public function get_plugin_path( $id ) {
75
+ if( empty( $this->registered[ $id ] ) ) {
76
+ // This call might be using the incorrect ID convention.
77
if( substr($id, 0, 4) == 'sow-' ) $id = substr($id, 4);
78
else $id = 'sow-' . $id;
79
}
80
81
+ return !empty($this->registered[$id]) ? $this->registered[$id]->path : false;
82
}
83
84
/**
95
function get_plugin_dir_url( $id ){
96
return plugin_dir_url( $this->get_plugin_path( $id ) );
97
}
98
+
99
+ /**
100
+ * Get a widget ID from a file path
101
+ *
102
+ * @param string $path The file path.
103
+ *
104
+ * @return string The ID.
105
+ */
106
+ function get_id_from_path( $path ){
107
+ foreach( $this->registered as $id => $r ) {
108
+ if( $r->path == $path ) return $id;
109
+ }
110
+ return false;
111
+ }
112
+
113
+ /**
114
+ * Get the class name of a widget from the
115
+ *
116
+ * @param $path
117
+ * @return mixed
118
+ */
119
+ function get_class_from_path( $path ) {
120
+ foreach( $this->registered as $id => $r ) {
121
+ if( $r->path == $path ) return $r->class;
122
+ }
123
+ return false;
124
+ }
125
}
126
SiteOrigin_Widgets_Widget_Manager::single();
127
153
* @return string
154
*/
155
function siteorigin_widget_get_plugin_dir_path($id){
156
+ return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_path( $id );
157
}
158
159
/**
163
* @return string
164
*/
165
function siteorigin_widget_get_plugin_dir_url($id){
166
+ return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_url( $id );
167
}
base/js/admin.js CHANGED
@@ -135,6 +135,17 @@
135
// Lets set up the preview
136
$el.sowSetupPreview();
137
$mainForm = $el;
138
}
139
else {
140
$mainForm = $el.closest('.siteorigin-widget-form-main');
@@ -178,130 +189,6 @@
178
});
179
});
180
181
- ///////////////////////////////////////
182
- // Handle the icon selection
183
-
184
- var iconWidgetCache = {};
185
- $fields.filter('.siteorigin-widget-field-type-icon').each(function(){
186
- var $ = $(this),
187
- $is = $.find('.siteorigin-widget-icon-selector'),
188
- $v = $is.find('.siteorigin-widget-icon-icon'),
189
- $b = $.find('.siteorigin-widget-icon-selector-current');
190
-
191
- // Clicking on the button should display the icon selector
192
- $b.click(function(){
193
- $is.slideToggle();
194
- });
195
-
196
- var rerenderIcons = function(){
197
- var family = $is.find('select.siteorigin-widget-icon-family').val();
198
- var container = $is.find('.siteorigin-widget-icon-icons');
199
-
200
- if(typeof iconWidgetCache[family] === 'undefined') {
201
- return;
202
- }
203
-
204
- container.empty();
205
-
206
- if( $('#'+'siteorigin-widget-font-'+family).length === 0) {
207
-
208
- $("<link rel='stylesheet' type='text/css'>")
209
- .attr('id', 'siteorigin-widget-font-' + family)
210
- .attr('href', iconWidgetCache[family].style_uri)
211
- .appendTo('head');
212
- }
213
-
214
-
215
- for ( var i in iconWidgetCache[family].icons ) {
216
-
217
- var icon = $('<div data-sow-icon="' + iconWidgetCache[family].icons[i] + '"/>')
218
- .attr('data-value', family + '-' + i)
219
- .addClass( 'sow-icon-' + family )
220
- .addClass( 'siteorigin-widget-icon-icons-icon' )
221
- .click(function(){
222
- var $ = $(this);
223
- if( $.hasClass('siteorigin-widget-active') ) {
224
- // This is being unselected
225
- $.removeClass('siteorigin-widget-active');
226
- $v.val( '' );
227
-
228
- // Hide the button icon
229
- $b.find('span').hide();
230
- }
231
- else {
232
- // This is being selected
233
- container.find('.siteorigin-widget-icon-icons-icon').removeClass('siteorigin-widget-active');
234
- $.addClass('siteorigin-widget-active');
235
- $v.val( $.data('value') );
236
-
237
- // Also add this to the button
238
- $b.find('span')
239
- .show()
240
- .attr( 'data-sow-icon', $.attr('data-sow-icon') )
241
- .attr( 'class', '' )
242
- .addClass( 'sow-icon-' + family );
243
- }
244
- $v.trigger('change');
245
-
246
- // Hide the icon selector
247
- $is.slideUp();
248
- });
249
-
250
- container.append(icon);
251
-
252
- if( $v.val() === family + '-' + i ) {
253
- // Add selected icon to the button.
254
- $b.find('span')
255
- .show()
256
- .attr( 'data-sow-icon', icon.attr('data-sow-icon') )
257
- .attr( 'class', '' )
258
- .addClass( 'sow-icon-' + family );
259
- icon.addClass('siteorigin-widget-active');
260
- }
261
- }
262
-
263
- // Move a selcted item to the first position
264
- container.prepend( container.find('.siteorigin-widget-active') );
265
- };
266
-
267
- // Create the function for changing the icon family and call it once
268
- var changeIconFamily = function(){
269
- // Fetch the family icons from the server
270
- var family = $is.find('select.siteorigin-widget-icon-family').val();
271
-
272
- var dataIcons = $is.find('select.siteorigin-widget-icon-family option:selected' ).data('icons');
273
- if( dataIcons !== null ) {
274
- iconWidgetCache[family] = dataIcons;
275
- }
276
-
277
-
278
- if(typeof family === 'undefined' || family === '') {
279
- return;
280
- }
281
-
282
- if(typeof iconWidgetCache[family] === 'undefined') {
283
- $.getJSON(
284
- soWidgets.ajaxurl,
285
- { 'action' : 'siteorigin_widgets_get_icons', 'family' : $is.find('select.siteorigin-widget-icon-family').val() },
286
- function(data) {
287
- iconWidgetCache[family] = data;
288
- rerenderIcons();
289
- }
290
- );
291
- }
292
- else {
293
- rerenderIcons();
294
- }
295
- };
296
-
297
- changeIconFamily();
298
-
299
- $is.find('select.siteorigin-widget-icon-family').change(function(){
300
- $is.find('.siteorigin-widget-icon-icons').empty();
301
- changeIconFamily();
302
- });
303
- });
304
-
305
///////////////////////////////////////
306
// Handle the slider fields
307
@@ -596,6 +483,7 @@
596
$items.bind('updateFieldPositions', function(){
597
var $ = $(this);
598
var $rptrItems = $.find('> .siteorigin-widget-field-repeater-item');
599
// Set the position for the repeater items
600
$rptrItems.each(function(i, el){
601
$(el).find('.siteorigin-widget-input').each(function(j, input){
@@ -615,19 +503,22 @@
615
var $in = $(input);
616
617
if(typeof pos !== 'undefined') {
618
- var newName = $in.data('original-name');
619
620
- if(typeof newName === 'undefined') {
621
- $in.data( 'original-name', $in.attr('name') );
622
newName = $in.attr('name');
623
}
624
if( ! newName ) {
625
return;
626
}
627
- for(var k in pos) {
628
- newName = newName.replace('#' + k + '#', pos[k] );
629
}
630
- $(input).attr('name', newName);
631
}
632
});
633
135
// Lets set up the preview
136
$el.sowSetupPreview();
137
$mainForm = $el;
138
+
139
+ var $teaser = $el.find( '.siteorigin-widget-teaser' );
140
+ $teaser.find('.dashicons-dismiss').click( function(){
141
+ var $ = $(this);
142
+ $.get( $.data( 'dismiss-url' ) );
143
+ console.log( $.data( 'dismiss-url' ) );
144
+
145
+ $teaser.slideUp( 'normal', function(){
146
+ $teaser.remove();
147
+ } );
148
+ } );
149
}
150
else {
151
$mainForm = $el.closest('.siteorigin-widget-form-main');
189
});
190
});
191
192
///////////////////////////////////////
193
// Handle the slider fields
194
483
$items.bind('updateFieldPositions', function(){
484
var $ = $(this);
485
var $rptrItems = $.find('> .siteorigin-widget-field-repeater-item');
486
+
487
// Set the position for the repeater items
488
$rptrItems.each(function(i, el){
489
$(el).find('.siteorigin-widget-input').each(function(j, input){
503
var $in = $(input);
504
505
if(typeof pos !== 'undefined') {
506
+ var newName = $in.attr('data-original-name');
507
508
+ if( ! newName ) {
509
+ $in.attr( 'data-original-name', $in.attr('name') );
510
newName = $in.attr('name');
511
}
512
if( ! newName ) {
513
return;
514
}
515
+
516
+ if( pos ) {
517
+ for( var k in pos ) {
518
+ newName = newName.replace('#' + k + '#', pos[k] );
519
+ }
520
}
521
+ $in.attr('name', newName);
522
}
523
});
524
base/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- !function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var n,a,r=e(t),s=!0,o=r.find("input[name]");if(o.length&&o.attr("name").indexOf("__i__")!==-1)return this;if(r.is(".siteorigin-widget-form-main")){if(r.data("sow-form-setup")===!0)return!0;if(e("body").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),a=e.extend({},i.data("state-handler"),s?i.data("state-handler-initial"):{});if(0===Object.keys(a).length)return!0;var r,o,d,l,f,g,c={},p=window.sowForms.getRepeaterId(i);if(p!==!1){var u={};for(var w in a)u[w.replace("{$repeater}",p)]=a[w];a=u}for(var w in a)if(f=!1,r=w.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?#x2F;),null!==r){if(o={group:"default",name:"",multi:!1},void 0!==r[2]?(o.group=r[1],o.name=r[3]):o.name=r[0],o.multi=void 0!==r[4],"_else"===o.group)o.group=o.name,o.name="",f=o.group===t&&"undefined"==typeof c[o.group];else{g=o.name.split(",").map(function(e){return e.trim()});for(var m=0;m<g.length&&!(f=o.group===t&&g[m]===n);m++);}if(f){d=a[w],o.multi||(d=[d]);for(var m=0;m<d.length;m++)l="undefined"!=typeof d[m][1]&&Boolean(d[m][1])?i.find(d[m][1]):i,l[d[m][0]].apply(l,"undefined"!=typeof d[m][2]?d[m][2]:[]);c[o.group]=!0}}})}),r.sowSetupPreview(),n=r}else n=r.closest(".siteorigin-widget-form-main");a=n.find("> .siteorigin-widgets-form-id").val();var d=r.find("> .siteorigin-widget-field");d.find("> .siteorigin-widget-section").sowSetupForm(),d.filter(".siteorigin-widget-field-type-widget:not(:has(> .siteorigin-widget-section))").sowSetupForm(),d.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),d.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),r.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),d.find("> .siteorigin-widget-input-color").wpColorPicker(),d.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(function(){e(this);e(this).toggleClass("siteorigin-widget-section-visible"),e(this).siblings(".siteorigin-widget-section").slideToggle(function(){e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed")})});var l={};d.filter(".siteorigin-widget-field-type-icon").each(function(){var i=e(this),t=i.find(".siteorigin-widget-icon-selector"),n=t.find(".siteorigin-widget-icon-icon"),a=i.find(".siteorigin-widget-icon-selector-current");a.click(function(){t.slideToggle()});var r=function(){var i=t.find("select.siteorigin-widget-icon-family").val(),r=t.find(".siteorigin-widget-icon-icons");if("undefined"!=typeof l[i]){r.empty(),0===e("#siteorigin-widget-font-"+i).length&&e("<link rel='stylesheet' type='text/css'>").attr("id","siteorigin-widget-font-"+i).attr("href",l[i].style_uri).appendTo("head");for(var s in l[i].icons){var o=e('<div data-sow-icon="'+l[i].icons[s]+'"/>').attr("data-value",i+"-"+s).addClass("sow-icon-"+i).addClass("siteorigin-widget-icon-icons-icon").click(function(){var s=e(this);s.hasClass("siteorigin-widget-active")?(s.removeClass("siteorigin-widget-active"),n.val(""),a.find("span").hide()):(r.find(".siteorigin-widget-icon-icons-icon").removeClass("siteorigin-widget-active"),s.addClass("siteorigin-widget-active"),n.val(s.data("value")),a.find("span").show().attr("data-sow-icon",s.attr("data-sow-icon")).attr("class","").addClass("sow-icon-"+i)),n.trigger("change"),t.slideUp()});r.append(o),n.val()===i+"-"+s&&(a.find("span").show().attr("data-sow-icon",o.attr("data-sow-icon")).attr("class","").addClass("sow-icon-"+i),o.addClass("siteorigin-widget-active"))}r.prepend(r.find(".siteorigin-widget-active"))}},s=function(){var i=t.find("select.siteorigin-widget-icon-family").val(),n=t.find("select.siteorigin-widget-icon-family option:selected").data("icons");null!==n&&(l[i]=n),"undefined"!=typeof i&&""!==i&&("undefined"==typeof l[i]?e.getJSON(soWidgets.ajaxurl,{action:"siteorigin_widgets_get_icons",family:t.find("select.siteorigin-widget-icon-family").val()},function(e){l[i]=e,r()}):r())};s(),t.find("select.siteorigin-widget-icon-family").change(function(){t.find(".siteorigin-widget-icon-icons").empty(),s()})}),d.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,n){t.val(parseInt(n.value)),i.find(".siteorigin-widget-slider-value").html(n.value)}})}),d.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").val(),a=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:n},function(i){for(var t=0;t<i.length;t++)""===i[t].post_title&&(i[t].post_title="&nbsp;"),a.append(e("<li>").addClass("post").html(i[t].post_title+"<span>("+i[t].post_type+")</span>").data(i[t]));a.removeClass("loading")})};i.find(".select-content-button, .button-close").click(function(t){t.preventDefault(),e(this).blur();var a=i.find(".existing-content-selector");a.toggle(),a.is(":visible")&&0===a.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("ID")),i.find(".existing-content-selector").toggle()});var a=null;i.find(".content-text-search").keyup(function(){null!==a&&clearTimeout(a),a=setTimeout(function(){n()},500)})}),"undefined"!=typeof jQuery.fn.soPanelsSetupBuilderWidget&&d.filter(".siteorigin-widget-field-type-builder").each(function(){var i=e(this);i.find("> .siteorigin-page-builder-field").soPanelsSetupBuilderWidget()});var f=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if("undefined"!=typeof t){var a=function(t,n){if("undefined"==typeof sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return n;var a=window.sowForms.getRepeaterId(i);return a!==!1&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",a)})),e.extend(n,sowEmitters[t.callback](i.val(),t.args))},r={"default":""};"undefined"==typeof t.length&&(t=[t]);for(var s=0;s<t.length;s++)r=a(t[s],r);var o=n.data("states");"undefined"==typeof o&&(o={"default":""});for(var d in r)"undefined"!=typeof o[d]&&r[d]===o[d]||(o[d]=r[d],n.trigger("sowstatechange",[d,r[d]]));n.data("states",o)}};d.filter("[data-state-emitter]").each(function(){e(this).find(".siteorigin-widget-input").on("keyup change",f),e(this).find(".siteorigin-widget-input").each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&f.call(i[0]):f.call(i[0])})}),r.trigger("sowsetupform",d).data("sow-form-setup",!0),d.trigger("sowsetupformfield"),r.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),s=!1})},e.fn.sowSetupPreview=function(){var i=e(this),t=i.siblings(".siteorigin-widget-preview");t.find("> a").click(function(t){t.preventDefault();var n={};i.find("*[name]").each(function(){var i=e(this),t=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===t)return!0;t=t[1];var a=t.split("][");a=a.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var r=n,s=0;s<a.length;s++)if(s===a.length-1)if("checkbox"===i.attr("type"))i.is(":checked")?r[a[s]]=""===i.val()||i.val():r[a[s]]=!1;else if("radio"===i.attr("type"))i.is(":checked")&&(r[a[s]]=""===i.val()||i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var o=null;"undefined"!=typeof tinyMCE&&(o=tinyMCE.get(i.attr("id"))),null===o||"function"!=typeof o.getContent||o.isHidden()?r[a[s]]=i.val():r[a[s]]=o.getContent()}else r[a[s]]=i.val();else"undefined"==typeof r[a[s]]&&(r[a[s]]={}),r=r[a[s]]});var a=e(e("#so-widgets-bundle-tpl-preview-dialog").html().trim()).appendTo("body");a.find('input[name="data"]').val(JSON.stringify(n)),a.find('input[name="class"]').val(i.data("class")),a.find("iframe").on("load",function(){e(this).css("visibility","visible")}),a.find("form").submit(),a.find(".close").click(function(){a.remove()})})},e.fn.sowSetupRepeater=function(){return e(this).each(function(i,t){var n=e(t),a=n.find(".siteorigin-widget-field-repeater-items"),r=n.data("repeater-name");a.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 a=e(n).data("repeater-positions");"undefined"==typeof a&&(a={}),a[r]=i,e(n).data("repeater-positions",a)})}),i.find(".siteorigin-widget-input").each(function(i,t){var n=e(t).data("repeater-positions"),a=e(t);if("undefined"!=typeof n){var r=a.data("original-name");if("undefined"==typeof r&&(a.data("original-name",a.attr("name")),r=a.attr("name")),!r)return;for(var s in n)r=r.replace("#"+s+"#",n[s]);e(t).attr("name",r)}});var a=n.data("scroll-count")?parseInt(n.data("scroll-count")):0;if(a>0&&t.length>a){var s=t.first().outerHeight();i.css("max-height",s*a).css("overflow","auto")}else i.css("max-height","").css("overflow","")}),a.sortable({handle:".siteorigin-widget-field-repeater-item-top",items:"> .siteorigin-widget-field-repeater-item",update:function(){a.trigger("updateFieldPositions")}}),a.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),a=n.find("> .siteorigin-widget-field-repeater-items").children().length+1,r=e("<div>"+n.find("> .siteorigin-widget-field-repeater-item-html").html()+"</div>");r.find("[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=r.html().replace(/_id_/g,a),o="undefined"!=typeof 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("undefined"==typeof n.data("sowrepeater-actions-setup")){var a=n.closest(".siteorigin-widget-field-repeater"),r=n.find("> .siteorigin-widget-field-repeater-item-top"),s=a.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)+"..."),r.find("h4").text(i))};o();var d=s.hasOwnProperty("updateEvent")&&s.updateEvent?s.updateEvent:"change";n.bind(d,o)}r.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(){e(window).resize(),e(this).is(":visible")?e(this).trigger("slideToggleOpenComplete"):e(this).trigger("slideToggleCloseComplete")}))}),r.find(".siteorigin-widget-field-remove").click(function(i){if(i.preventDefault(),confirm(soWidgets.sure)){var t=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).closest(".siteorigin-widget-field-repeater-item").slideUp("fast",function(){e(this).remove(),t.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()})}}),r.find(".siteorigin-widget-field-copy").click(function(i){i.preventDefault();var t=e(this).closest(".siteorigin-widget-form-main"),a=e(this).closest(".siteorigin-widget-field-repeater-item"),r=a.clone(),s=a.closest(".siteorigin-widget-field-repeater-items"),o=s.children().length,d={};r.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=a.find('[name="'+l+'"]');p.length&&null!=p.val()&&i.val(p.val())}if(s){var u=s.replace(/-\d+#x2F;,"");d[u]||(d[u]=t.find(".siteorigin-widget-input[id^="+u+"]").not("[id*=_id_]").length+1);var w=u+"-"+d[u]++;i.attr("id",w),r.find("label[for="+s+"]").attr("for",w),r.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 m=a.parents(".siteorigin-widget-field-repeater").length,v=e("body");(v.hasClass("wp-customizer")||v.hasClass("widgets-php"))&&0==n.closest(".panel-dialog").length&&(m+=1);var h=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(m-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",h),i.data("original-name",h)}),s.append(r).sortable("refresh").trigger("updateFieldPositions"),r.sowSetupRepeaterItems(),r.hide().slideDown("fast",function(){e(window).resize()})}),n.find("> .siteorigin-widget-field-repeater-item-form").sowSetupForm(),n.data("sowrepeater-actions-setup",!0)}})};var i={getRepeaterId:function(e){"undefined"==typeof 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},getWidgetFieldVariable:function(e,i,t){var n=window.sow_field_javascript_variables[e];i=i.replace(/\[#.*?#\]/g,"");for(var a=/[a-zA-Z0-9\-]+(?:\[c?[0-9]+\])?\[(.*)\]/.exec(i)[1],r=a.split("]["),s=r.length?n:null;r.length;)s=s[r.shift()];return s[t]},fetchWidgetVariable:function(i,t,n){window.sowVars=window.sowVars||{},"undefined"==typeof 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])}};window.sowForms=i,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("dialogopen",function(i){e(i.target).find(".siteorigin-widget-form-main").sowSetupForm()}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){"undefined"==typeof i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *quot;),n=t.exec(e);if(null===n)return!1;var a="",r="default";return void 0!==n[3]?(r=n[1],a=n[3]):a=n[1],{match:n[4].trim(),group:r,state:a}},_checker:function(e,i,t,n){var a={};"undefined"==typeof i.length&&(i=[i]);for(var r,s=0;s<i.length;s++)r=sowEmitters._match(i[s],t),r!==!1&&("_true"===r.match||n(e,i,r.match))&&(a[r.group]=r.state);return a},select:function(e,i){"undefined"==typeof 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 t.split(",").map(function(e){return e.trim()}).indexOf(e)!==-1})}};
1
+ !function(e){e.fn.sowSetupForm=function(){return e(this).each(function(i,t){var n,r,a=e(t),s=!0,o=a.find("input[name]");if(o.length&&o.attr("name").indexOf("__i__")!==-1)return this;if(a.is(".siteorigin-widget-form-main")){if(a.data("sow-form-setup")===!0)return!0;if(e("body").hasClass("widgets-php")&&!a.is(":visible")&&0===a.closest(".panel-dialog").length)return!0;a.on("sowstatechange",function(i,t,n){a.find("[data-state-handler]").each(function(){var i=e(this),r=e.extend({},i.data("state-handler"),s?i.data("state-handler-initial"):{});if(0===Object.keys(r).length)return!0;var a,o,d,l,f,g,p={},c=window.sowForms.getRepeaterId(i);if(c!==!1){var u={};for(var w in r)u[w.replace("{$repeater}",c)]=r[w];r=u}for(var w in r)if(f=!1,a=w.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?#x2F;),null!==a){if(o={group:"default",name:"",multi:!1},void 0!==a[2]?(o.group=a[1],o.name=a[3]):o.name=a[0],o.multi=void 0!==a[4],"_else"===o.group)o.group=o.name,o.name="",f=o.group===t&&"undefined"==typeof p[o.group];else{g=o.name.split(",").map(function(e){return e.trim()});for(var m=0;m<g.length&&!(f=o.group===t&&g[m]===n);m++);}if(f){d=r[w],o.multi||(d=[d]);for(var m=0;m<d.length;m++)l="undefined"!=typeof d[m][1]&&Boolean(d[m][1])?i.find(d[m][1]):i,l[d[m][0]].apply(l,"undefined"!=typeof d[m][2]?d[m][2]:[]);p[o.group]=!0}}})}),a.sowSetupPreview(),n=a;var d=a.find(".siteorigin-widget-teaser");d.find(".dashicons-dismiss").click(function(){var i=e(this);e.get(i.data("dismiss-url")),console.log(i.data("dismiss-url")),d.slideUp("normal",function(){d.remove()})})}else n=a.closest(".siteorigin-widget-form-main");r=n.find("> .siteorigin-widgets-form-id").val();var l=a.find("> .siteorigin-widget-field");l.find("> .siteorigin-widget-section").sowSetupForm(),l.filter(".siteorigin-widget-field-type-widget:not(:has(> .siteorigin-widget-section))").sowSetupForm(),l.find(".siteorigin-widget-input").each(function(i,t){null===e(t).data("original-name")&&e(t).data("original-name",e(t).attr("name"))}),l.find("> .siteorigin-widget-field-repeater").sowSetupRepeater(),a.find(".siteorigin-widget-field-repeater-item").sowSetupRepeaterItems(),l.find("> .siteorigin-widget-input-color").wpColorPicker(),l.filter(".siteorigin-widget-field-type-widget, .siteorigin-widget-field-type-section").find("> label").click(function(){e(this);e(this).toggleClass("siteorigin-widget-section-visible"),e(this).siblings(".siteorigin-widget-section").slideToggle(function(){e(window).resize(),e(this).find("> .siteorigin-widget-field-container-state").val(e(this).is(":visible")?"open":"closed")})}),l.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,n){t.val(parseInt(n.value)),i.find(".siteorigin-widget-slider-value").html(n.value)}})}),l.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").val(),r=i.find("ul.posts").empty().addClass("loading");e.get(soWidgets.ajaxurl,{action:"so_widgets_search_posts",query:n},function(i){for(var t=0;t<i.length;t++)""===i[t].post_title&&(i[t].post_title="&nbsp;"),r.append(e("<li>").addClass("post").html(i[t].post_title+"<span>("+i[t].post_type+")</span>").data(i[t]));r.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("ID")),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)})}),"undefined"!=typeof jQuery.fn.soPanelsSetupBuilderWidget&&l.filter(".siteorigin-widget-field-type-builder").each(function(){var i=e(this);i.find("> .siteorigin-page-builder-field").soPanelsSetupBuilderWidget()});var f=function(){var i=e(this),t=i.closest("[data-state-emitter]").data("state-emitter");if("undefined"!=typeof t){var r=function(t,n){if("undefined"==typeof sowEmitters[t.callback]||"_"===t.callback.substr(0,1))return n;var r=window.sowForms.getRepeaterId(i);return r!==!1&&(t.args=t.args.map(function(e){return e.replace("{$repeater}",r)})),e.extend(n,sowEmitters[t.callback](i.val(),t.args))},a={"default":""};"undefined"==typeof t.length&&(t=[t]);for(var s=0;s<t.length;s++)a=r(t[s],a);var o=n.data("states");"undefined"==typeof o&&(o={"default":""});for(var d in a)"undefined"!=typeof o[d]&&a[d]===o[d]||(o[d]=a[d],n.trigger("sowstatechange",[d,a[d]]));n.data("states",o)}};l.filter("[data-state-emitter]").each(function(){e(this).find(".siteorigin-widget-input").on("keyup change",f),e(this).find(".siteorigin-widget-input").each(function(){var i=e(this);i.is(":radio")?i.is(":checked")&&f.call(i[0]):f.call(i[0])})}),a.trigger("sowsetupform",l).data("sow-form-setup",!0),l.trigger("sowsetupformfield"),a.find(".siteorigin-widget-field-repeater-item").trigger("updateFieldPositions"),s=!1})},e.fn.sowSetupPreview=function(){var i=e(this),t=i.siblings(".siteorigin-widget-preview");t.find("> a").click(function(t){t.preventDefault();var n={};i.find("*[name]").each(function(){var i=e(this),t=/[a-zA-Z0-9\-]+\[[a-zA-Z0-9]+\]\[(.*)\]/.exec(i.attr("name"));if(void 0===t)return!0;t=t[1];var r=t.split("][");r=r.map(function(e){return!isNaN(parseFloat(e))&&isFinite(e)?parseInt(e):e});for(var a=n,s=0;s<r.length;s++)if(s===r.length-1)if("checkbox"===i.attr("type"))i.is(":checked")?a[r[s]]=""===i.val()||i.val():a[r[s]]=!1;else if("radio"===i.attr("type"))i.is(":checked")&&(a[r[s]]=""===i.val()||i.val());else if("TEXTAREA"===i.prop("tagName")&&i.hasClass("wp-editor-area")){var o=null;"undefined"!=typeof tinyMCE&&(o=tinyMCE.get(i.attr("id"))),null===o||"function"!=typeof o.getContent||o.isHidden()?a[r[s]]=i.val():a[r[s]]=o.getContent()}else a[r[s]]=i.val();else"undefined"==typeof a[r[s]]&&(a[r[s]]={}),a=a[r[s]]});var 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");"undefined"==typeof 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("undefined"!=typeof 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)}});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")}}),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("[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="undefined"!=typeof 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("undefined"==typeof 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(){e(window).resize(),e(this).is(":visible")?e(this).trigger("slideToggleOpenComplete"):e(this).trigger("slideToggleCloseComplete")}))}),a.find(".siteorigin-widget-field-remove").click(function(i){if(i.preventDefault(),confirm(soWidgets.sure)){var t=e(this).closest(".siteorigin-widget-field-repeater-items");e(this).closest(".siteorigin-widget-field-repeater-item").slideUp("fast",function(){e(this).remove(),t.sortable("refresh").trigger("updateFieldPositions"),e(window).resize()})}}),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"),p=i.closest(".siteorigin-widget-field");g.remove(),p.append(i.remove())}else{var c=r.find('[name="'+l+'"]');c.length&&null!=c.val()&&i.val(c.val())}if(s){var u=s.replace(/-\d+#x2F;,"");d[u]||(d[u]=t.find(".siteorigin-widget-input[id^="+u+"]").not("[id*=_id_]").length+1);var w=u+"-"+d[u]++;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 m=r.parents(".siteorigin-widget-field-repeater").length,h=e("body");(h.hasClass("wp-customizer")||h.hasClass("widgets-php"))&&0==n.closest(".panel-dialog").length&&(m+=1);var v=l.replace(new RegExp("((?:.*?\\[\\d+\\]){"+(m-1).toString()+"})?(.*?\\[)\\d+(\\])"),"$1$2"+o.toString()+"$3");i.attr("name",v),i.data("original-name",v)}),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)}})};var i={getRepeaterId:function(e){"undefined"==typeof 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},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]},fetchWidgetVariable:function(i,t,n){window.sowVars=window.sowVars||{},"undefined"==typeof 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])}};window.sowForms=i,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("dialogopen",function(i){e(i.target).find(".siteorigin-widget-form-main").sowSetupForm()}),e(function(){e(document).trigger("sowadminloaded")})}(jQuery);var sowEmitters={_match:function(e,i){"undefined"==typeof i&&(i=".*");var t=new RegExp("^([a-zA-Z0-9_-]+)(\\[([a-zA-Z0-9_-]+)\\])? *: *("+i+") *quot;),n=t.exec(e);if(null===n)return!1;var r="",a="default";return void 0!==n[3]?(a=n[1],r=n[3]):r=n[1],{match:n[4].trim(),group:a,state:r}},_checker:function(e,i,t,n){var r={};"undefined"==typeof i.length&&(i=[i]);for(var a,s=0;s<i.length;s++)a=sowEmitters._match(i[s],t),a!==!1&&("_true"===a.match||n(e,i,a.match))&&(r[a.group]=a.state);return r},select:function(e,i){"undefined"==typeof 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 t.split(",").map(function(e){return e.trim()}).indexOf(e)!==-1})}};
base/siteorigin-widget.class.php CHANGED
@@ -38,7 +38,6 @@ abstract class SiteOrigin_Widget extends WP_Widget {
38
static $css_expire = 604800; // 7 days
39
40
/**
41
- *
42
* @param string $id
43
* @param string $name
44
* @param array $widget_options Optional Normal WP_Widget widget options and a few extras.
@@ -61,7 +60,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
61
'has_preview' => true,
62
) );
63
64
- $control_options = wp_parse_args($widget_options, array(
65
'width' => 800,
66
) );
67
@@ -84,16 +83,36 @@ abstract class SiteOrigin_Widget extends WP_Widget {
84
}
85
86
/**
87
- * Return the form array. Widgets should implement this if they don't have a form in the form array.
88
*
89
* @return array
90
*/
91
- function initialize_form( ){
92
- return array();
93
}
94
95
/**
96
- * Get the form options and allow child widgets to modify that form.
97
*
98
* @param bool|SiteOrigin_Widget $parent
99
*
@@ -101,7 +120,8 @@ abstract class SiteOrigin_Widget extends WP_Widget {
101
*/
102
function form_options( $parent = false ) {
103
if( empty( $this->form_options ) ) {
104
- $this->form_options = $this->initialize_form();
105
}
106
107
$form_options = $this->modify_form( $this->form_options );
@@ -123,7 +143,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
123
*/
124
public function widget( $args, $instance ) {
125
if( empty( $this->form_options ) ) {
126
- $this->form_options = $this->initialize_form();
127
}
128
129
$instance = $this->modify_instance( $instance );
@@ -209,7 +229,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
209
*/
210
function generate_and_enqueue_instance_styles( $instance ) {
211
if( empty( $this->form_options ) ) {
212
- $this->form_options = $this->initialize_form();
213
}
214
215
// We'll assume empty instances don't have styles
@@ -309,7 +329,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
309
* @param $form
310
* @param $instance
311
*/
312
- function add_defaults($form, $instance, $level = 0){
313
if( $level > 10 ) return $instance;
314
315
foreach($form as $id => $field) {
@@ -341,11 +361,23 @@ abstract class SiteOrigin_Widget extends WP_Widget {
341
* Display the widget form.
342
*
343
* @param array $instance
344
* @return string|void
345
*/
346
- public function form( $instance ) {
347
$instance = $this->modify_instance($instance);
348
- $instance = $this->add_defaults( $this->form_options(), $instance );
349
350
if( empty( $this->number ) ) {
351
// Compatibility with form widgets.
@@ -361,14 +393,14 @@ abstract class SiteOrigin_Widget extends WP_Widget {
361
if( empty( $instance['_sow_form_id'] ) ) {
362
$instance['_sow_form_id'] = uniqid();
363
}
364
-
365
?>
366
<div class="siteorigin-widget-form siteorigin-widget-form-main siteorigin-widget-form-main-<?php echo esc_attr($class_name) ?>" id="<?php echo $form_id ?>" data-class="<?php echo esc_attr( $this->widget_class ) ?>" style="display: none">
367
<?php
368
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
369
- $field_factory = SiteOrigin_Widget_Field_Factory::getInstance();
370
$fields_javascript_variables = array();
371
- foreach( $this->form_options() as $field_name => $field_options ) {
372
/* @var $field SiteOrigin_Widget_Field_Base */
373
$field = $field_factory->create_field( $field_name, $field_options, $this );
374
$field->render( isset( $instance[$field_name] ) ? $instance[$field_name] : null, $instance );
@@ -414,7 +446,43 @@ abstract class SiteOrigin_Widget extends WP_Widget {
414
</script>
415
<?php
416
417
- $this->enqueue_scripts();
418
}
419
420
function scripts_loading_message(){
@@ -426,8 +494,10 @@ abstract class SiteOrigin_Widget extends WP_Widget {
426
427
/**
428
* Enqueue the admin scripts for the widget form.
429
*/
430
- function enqueue_scripts(){
431
432
if( ! wp_script_is('siteorigin-widget-admin') ) {
433
wp_enqueue_style( 'wp-color-picker' );
@@ -455,11 +525,32 @@ abstract class SiteOrigin_Widget extends WP_Widget {
455
siteorigin_widget_post_selector_enqueue_admin_scripts();
456
}
457
458
// This lets the widget enqueue any specific admin scripts
459
$this->enqueue_admin_scripts();
460
do_action( 'siteorigin_widgets_enqueue_admin_scripts_' . $this->id_base, $this );
461
}
462
463
/**
464
* Display all the admin stuff for the footer
465
*/
@@ -470,7 +561,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
470
<div class="so-widgets-dialog-overlay"></div>
471
472
<div class="so-widgets-toolbar">
473
- <h3><?php _e('Widget Preview', 'so-widgets-bundle') ?></h3>
474
<div class="close"><span class="dashicons dashicons-arrow-left-alt2"></span></div>
475
</div>
476
@@ -493,13 +584,13 @@ abstract class SiteOrigin_Widget extends WP_Widget {
493
}
494
495
/**
496
- * Checks if the current widget is using a posts selector
497
*
498
* @return bool
499
*/
500
function using_posts_selector(){
501
if( empty( $this->form_options ) ) {
502
- $this->form_options = $this->initialize_form();
503
}
504
505
foreach($this->form_options as $field) {
@@ -513,15 +604,25 @@ abstract class SiteOrigin_Widget extends WP_Widget {
513
*
514
* @param array $new_instance
515
* @param array $old_instance
516
* @return array|void
517
*/
518
- public function update( $new_instance, $old_instance ) {
519
if( !class_exists('SiteOrigin_Widgets_Color_Object') ) require plugin_dir_path( __FILE__ ).'inc/color.php';
520
521
- $form_options = $this->form_options();
522
if( ! empty( $form_options ) ) {
523
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
524
- $field_factory = SiteOrigin_Widget_Field_Factory::getInstance();
525
foreach ( $form_options as $field_name => $field_options ) {
526
/* @var $field SiteOrigin_Widget_Field_Base */
527
if ( !empty( $this->fields ) && !empty( $this->fields[$field_name] ) ) {
@@ -1120,4 +1221,36 @@ abstract class SiteOrigin_Widget extends WP_Widget {
1120
( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ); // Is this a Page Builder content ajax request
1121
}
1122
1123
}
38
static $css_expire = 604800; // 7 days
39
40
/**
41
* @param string $id
42
* @param string $name
43
* @param array $widget_options Optional Normal WP_Widget widget options and a few extras.
60
'has_preview' => true,
61
) );
62
63
+ $control_options = wp_parse_args( $control_options, array(
64
'width' => 800,
65
) );
66
83
}
84
85
/**
86
+ * Get the main widget form. This should be overwritten by child widgets.
87
*
88
* @return array
89
*/
90
+ function get_widget_form(){
91
+ return method_exists( $this, 'initialize_form' ) ? $this->initialize_form() : array();
92
+ }
93
+
94
+ /**
95
+ * Check if a child widget implements a specific form type.
96
+ *
97
+ * @param string $form_type
98
+ * @return bool
99
+ */
100
+ function has_form( $form_type = 'widget' ){
101
+ return method_exists( $this, 'get_' . $form_type . '_form' );
102
}
103
104
/**
105
+ * Get a specific type of form.
106
+ *
107
+ * @param $form_type
108
+ * @return array The form array, or an empty array if the form doesn't exist.
109
+ */
110
+ function get_form( $form_type ) {
111
+ return $this->has_form( $form_type ) ? call_user_func( array( $this, 'get_' . $form_type . '_form' ) ) : array();
112
+ }
113
+
114
+ /**
115
+ * Get the main form options and allow child widgets to modify that form.
116
*
117
* @param bool|SiteOrigin_Widget $parent
118
*
120
*/
121
function form_options( $parent = false ) {
122
if( empty( $this->form_options ) ) {
123
+ // If the widget doesn't have form_options defined from the constructor, then it might be defining them in the get_widget_form function
124
+ $this->form_options = $this->get_widget_form();
125
}
126
127
$form_options = $this->modify_form( $this->form_options );
143
*/
144
public function widget( $args, $instance ) {
145
if( empty( $this->form_options ) ) {
146
+ $this->form_options = $this->get_widget_form();
147
}
148
149
$instance = $this->modify_instance( $instance );
229
*/
230
function generate_and_enqueue_instance_styles( $instance ) {
231
if( empty( $this->form_options ) ) {
232
+ $this->form_options = $this->get_widget_form();
233
}
234
235
// We'll assume empty instances don't have styles
329
* @param $form
330
* @param $instance
331
*/
332
+ function add_defaults( $form, $instance, $level = 0 ){
333
if( $level > 10 ) return $instance;
334
335
foreach($form as $id => $field) {
361
* Display the widget form.
362
*
363
* @param array $instance
364
+ * @param string $form_type Which type of form we're using
365
+ *
366
* @return string|void
367
*/
368
+ public function form( $instance, $form_type = 'widget' ) {
369
+ if( $form_type == 'widget' ) {
370
+ if( empty( $this->form_options ) ) {
371
+ $this->form_options = $this->form_options();
372
+ }
373
+ $form_options = $this->form_options;
374
+ }
375
+ else {
376
+ $form_options = $this->get_form( $form_type );
377
+ }
378
+
379
$instance = $this->modify_instance($instance);
380
+ $instance = $this->add_defaults( $form_options, $instance );
381
382
if( empty( $this->number ) ) {
383
// Compatibility with form widgets.
393
if( empty( $instance['_sow_form_id'] ) ) {
394
$instance['_sow_form_id'] = uniqid();
395
}
396
?>
397
<div class="siteorigin-widget-form siteorigin-widget-form-main siteorigin-widget-form-main-<?php echo esc_attr($class_name) ?>" id="<?php echo $form_id ?>" data-class="<?php echo esc_attr( $this->widget_class ) ?>" style="display: none">
398
<?php
399
+ $this->display_teaser_message();
400
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
401
+ $field_factory = SiteOrigin_Widget_Field_Factory::single();
402
$fields_javascript_variables = array();
403
+ foreach( $form_options as $field_name => $field_options ) {
404
/* @var $field SiteOrigin_Widget_Field_Base */
405
$field = $field_factory->create_field( $field_name, $field_options, $this );
406
$field->render( isset( $instance[$field_name] ) ? $instance[$field_name] : null, $instance );
446
</script>
447
<?php
448
449
+ $this->enqueue_scripts( );
450
+ }
451
+
452
+ /**
453
+ * Display the teaser message.
454
+ */
455
+ function display_teaser_message(){
456
+ if(
457
+ method_exists( $this, 'get_form_teaser' ) &&
458
+ ( $teaser = $this->get_form_teaser() )
459
+ ) {
460
+ $dismissed = get_user_meta( get_current_user_id(), 'teasers_dismissed', true );
461
+ if( empty( $dismissed[ $this->id_base ] ) ) {
462
+ $dismiss_url = add_query_arg( array(
463
+ 'action' => 'so_dismiss_widget_teaser',
464
+ 'widget' => $this->id_base,
465
+ ), admin_url( 'admin-ajax.php' ) );
466
+ $dismiss_url = wp_nonce_url( $dismiss_url, 'dismiss-widget-teaser' );
467
+
468
+ ?>
469
+ <div class="siteorigin-widget-teaser">
470
+ <?php echo wp_kses_post( $teaser ) ?>
471
+ <span class="dashicons dashicons-dismiss" data-dismiss-url="<?php echo esc_url( $dismiss_url ) ?>"></span>
472
+ </div>
473
+ <?php
474
+ }
475
+ }
476
+ }
477
+
478
+ /**
479
+ * Should we display the teaser for SiteOrigin Premium
480
+ *
481
+ * @return bool
482
+ */
483
+ function display_siteorigin_premium_teaser(){
484
+ return apply_filters( 'siteorigin_premium_upgrade_teaser', true ) &&
485
+ ! defined( 'SITEORIGIN_PREMIUM_VERSION' );
486
}
487
488
function scripts_loading_message(){
494
495
/**
496
* Enqueue the admin scripts for the widget form.
497
+ *
498
+ * @param bool|string $form_type Should we enqueue the field scripts too?
499
*/
500
+ function enqueue_scripts( $form_type = false ){
501
502
if( ! wp_script_is('siteorigin-widget-admin') ) {
503
wp_enqueue_style( 'wp-color-picker' );
525
siteorigin_widget_post_selector_enqueue_admin_scripts();
526
}
527
528
+ if( !empty( $form_type ) && $this->has_form( $form_type ) ) {
529
+ // Enqueue field scripts for the given form type
530
+ $form_options = $this->get_form( $form_type );
531
+ $this->enqueue_field_scripts( $form_options );
532
+ }
533
+
534
// This lets the widget enqueue any specific admin scripts
535
$this->enqueue_admin_scripts();
536
do_action( 'siteorigin_widgets_enqueue_admin_scripts_' . $this->id_base, $this );
537
}
538
539
+ function enqueue_field_scripts( $fields ){
540
+ /* @var $field_factory SiteOrigin_Widget_Field_Factory */
541
+ $field_factory = SiteOrigin_Widget_Field_Factory::single();
542
+
543
+ foreach( $fields as $field_name => $field_options ) {
544
+ /* @var $field SiteOrigin_Widget_Field_Base */
545
+ $field = $field_factory->create_field( $field_name, $field_options, $this );
546
+ $field->enqueue_scripts();
547
+
548
+ if( !empty( $field_options['fields'] ) ) {
549
+ $this->enqueue_field_scripts( $field_options['fields'] );
550
+ }
551
+ }
552
+ }
553
+
554
/**
555
* Display all the admin stuff for the footer
556
*/
561
<div class="so-widgets-dialog-overlay"></div>
562
563
<div class="so-widgets-toolbar">
564
+ <h3><?php _e( 'Widget Preview', 'so-widgets-bundle' ) ?></h3>
565
<div class="close"><span class="dashicons dashicons-arrow-left-alt2"></span></div>
566
</div>
567
584
}
585
586
/**
587
+ * Checks if the current widget is using a posts selector in the main form.
588
*
589
* @return bool
590
*/
591
function using_posts_selector(){
592
if( empty( $this->form_options ) ) {
593
+ $this->form_options = $this->form_options();
594
}
595
596
foreach($this->form_options as $field) {
604
*
605
* @param array $new_instance
606
* @param array $old_instance
607
+ * @param string $form_type The type of form we're using.
608
* @return array|void
609
*/
610
+ public function update( $new_instance, $old_instance, $form_type = 'widget' ) {
611
if( !class_exists('SiteOrigin_Widgets_Color_Object') ) require plugin_dir_path( __FILE__ ).'inc/color.php';
612
613
+ if( $form_type == 'widget' ) {
614
+ if( empty( $this->form_options ) ) {
615
+ $this->form_options = $this->form_options();
616
+ }
617
+ $form_options = $this->form_options;
618
+ }
619
+ else {
620
+ $form_options = $this->get_form( $form_type );
621
+ }
622
+
623
if( ! empty( $form_options ) ) {
624
/* @var $field_factory SiteOrigin_Widget_Field_Factory */
625
+ $field_factory = SiteOrigin_Widget_Field_Factory::single();
626
foreach ( $form_options as $field_name => $field_options ) {
627
/* @var $field SiteOrigin_Widget_Field_Base */
628
if ( !empty( $this->fields ) && !empty( $this->fields[$field_name] ) ) {
1221
( !empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'so_panels_builder_content' ); // Is this a Page Builder content ajax request
1222
}
1223
1224
+ /**
1225
+ * Get the global settings from the options table.
1226
+ *
1227
+ * @return mixed|void
1228
+ */
1229
+ function get_global_settings( ){
1230
+ $values = get_option( 'so_widget_settings[' . $this->widget_class . ']', array() );
1231
+
1232
+ // Add in the defaults
1233
+ if( $this->has_form( 'settings' ) ) {
1234
+ $values = $this->add_defaults( $this->get_settings_form(), $values );
1235
+ }
1236
+
1237
+ return $values;
1238
+ }
1239
+
1240
+ /**
1241
+ * Save the global settings. Handles validation too.
1242
+ *
1243
+ * @param array $values The new values
1244
+ * @return array The sanitized values.
1245
+ */
1246
+ function save_global_settings( $values ){
1247
+ $current = $this->get_global_settings();
1248
+
1249
+ $values = $this->update( $values, $current, 'settings' );
1250
+
1251
+ unset( $values['_sow_form_id'] );
1252
+ update_option( 'so_widget_settings[' . $this->widget_class . ']', $values );
1253
+
1254
+ return $values;
1255
+ }
1256
}
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: 3.9
4
Tested up to: 4.6
5
- Stable tag: 1.6.5
6
- Build time: 2016-08-14T09:48:53+02:00
7
License: GPLv3 or later
8
Contributors: gpriday, braam-genis
9
@@ -51,6 +51,15 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
51
52
== Changelog ==
53
54
= 1.6.5 - 15 August 2016 =
55
* Fixed dialog z-index.
56
* Added field required argument.
2
Tags: bundle, widget, button, slider, image, carousel, price table, google maps, tinymce, social links
3
Requires at least: 3.9
4
Tested up to: 4.6
5
+ Stable tag: 1.7
6
+ Build time: 2016-09-20T13:29:48+02:00
7
License: GPLv3 or later
8
Contributors: gpriday, braam-genis
9
51
52
== Changelog ==
53
54
+ = 1.7 - 20 September 2016 =
55
+ * Added mechanism for creating global widget setting.
56
+ * Added mechanism for adding dismissible notices to widget forms.
57
+ * Unified Google Maps JS working for maps widget and contact form location field.
58
+ * Added icon search for icon field.
59
+ * Added remove button to icon field.
60
+ * Contact Form: Fixed clash with Firefox field validation.
61
+ * Properly display remove button after importing Pixabay image.
62
+
63
= 1.6.5 - 15 August 2016 =
64
* Fixed dialog z-index.
65
* Added field required argument.
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.6.5
6
Text Domain: so-widgets-bundle
7
Domain Path: /languages
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.6.5');
16
define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
18
// Allow JS suffix to be pre-set
@@ -45,9 +45,14 @@ class SiteOrigin_Widgets_Bundle {
45
add_action('admin_init', array($this, 'admin_activate_widget') );
46
add_action('admin_menu', array($this, 'admin_menu_init') );
47
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts') );
48
add_action('wp_ajax_so_widgets_bundle_manage', array($this, 'admin_ajax_manage_handler') );
49
add_action('wp_ajax_sow_get_javascript_variables', array($this, 'admin_ajax_get_javascript_variables') );
50
51
// Initialize the widgets, but do it fairly late
52
add_action( 'plugins_loaded', array($this, 'set_plugin_textdomain'), 1 );
53
add_action( 'after_setup_theme', array($this, 'get_widget_folders'), 11 );
@@ -219,7 +224,7 @@ class SiteOrigin_Widgets_Bundle {
219
if( empty($this->widget_folders) ) {
220
// We can use this filter to add more folders to use for widgets
221
$this->widget_folders = apply_filters('siteorigin_widgets_widget_folders', array(
222
- plugin_dir_path(__FILE__).'widgets/'
223
) );
224
}
225
@@ -350,6 +355,58 @@ class SiteOrigin_Widgets_Bundle {
350
exit();
351
}
352
353
/**
354
* Add the admin menu page.
355
*
@@ -369,9 +426,8 @@ class SiteOrigin_Widgets_Bundle {
369
* Display the admin page.
370
*/
371
function admin_page(){
372
-
373
- $bundle = SiteOrigin_Widgets_Bundle::single();
374
- $widgets = $bundle->get_widgets_list();
375
376
if(
377
isset($_GET['widget_action_done'])
@@ -379,7 +435,6 @@ class SiteOrigin_Widgets_Bundle {
379
&& !empty($_GET['widget'])
380
&& !empty( $widgets[ $_GET['widget'].'/'.$_GET['widget'].'.php' ] )
381
) {
382
-
383
?>
384
<div class="updated">
385
<p>
@@ -395,6 +450,11 @@ class SiteOrigin_Widgets_Bundle {
395
<?php
396
}
397
398
include plugin_dir_path(__FILE__).'admin/tpl/admin.php';
399
}
400
@@ -408,7 +468,7 @@ class SiteOrigin_Widgets_Bundle {
408
global $wp_widget_factory;
409
if ( ! empty( $wp_widget_factory->widgets[ $widget_class ] ) ) {
410
$widget = $wp_widget_factory->widgets[ $widget_class ];
411
- if( method_exists($widget, 'get_javascript_variables') ) $result = $widget->get_javascript_variables();
412
}
413
414
header('content-type: application/json');
@@ -509,7 +569,7 @@ class SiteOrigin_Widgets_Bundle {
509
$widgets = array();
510
foreach( $folders as $folder ) {
511
512
- $files = glob( $folder.'*/*.php' );
513
foreach($files as $file) {
514
$widget = get_file_data( $file, $default_headers, 'siteorigin-widget' );
515
//skip the file if it's missing a name
@@ -520,10 +580,10 @@ class SiteOrigin_Widgets_Bundle {
520
$id = $f['filename'];
521
522
$widget['ID'] = $id;
523
- $widget['Active'] = !empty($active[$id]);
524
$widget['File'] = $file;
525
526
- $widgets[$file] = $widget;
527
}
528
529
}
@@ -533,6 +593,32 @@ class SiteOrigin_Widgets_Bundle {
533
return $widgets;
534
}
535
536
/**
537
* Sorting function to sort widgets by name
538
*
@@ -642,4 +728,4 @@ SiteOrigin_Widgets_Bundle::single();
642
643
// Initialize the Meta Box Manager
644
global $sow_meta_box_manager;
645
- $sow_meta_box_manager = SiteOrigin_Widget_Meta_Box_Manager::single();
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.7
6
Text Domain: so-widgets-bundle
7
Domain Path: /languages
8
Author: SiteOrigin
12
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
13
*/
14
15
+ define('SOW_BUNDLE_VERSION', '1.7');
16
define('SOW_BUNDLE_BASE_FILE', __FILE__);
17
18
// Allow JS suffix to be pre-set
45
add_action('admin_init', array($this, 'admin_activate_widget') );
46
add_action('admin_menu', array($this, 'admin_menu_init') );
47
add_action('admin_enqueue_scripts', array($this, 'admin_enqueue_scripts') );
48
+
49
+ // All the ajax actions
50
add_action('wp_ajax_so_widgets_bundle_manage', array($this, 'admin_ajax_manage_handler') );
51
add_action('wp_ajax_sow_get_javascript_variables', array($this, 'admin_ajax_get_javascript_variables') );
52
53
+ add_action('wp_ajax_so_widgets_setting_form', array($this, 'admin_ajax_settings_form') );
54
+ add_action('wp_ajax_so_widgets_setting_save', array($this, 'admin_ajax_settings_save') );
55
+
56
// Initialize the widgets, but do it fairly late
57
add_action( 'plugins_loaded', array($this, 'set_plugin_textdomain'), 1 );
58
add_action( 'after_setup_theme', array($this, 'get_widget_folders'), 11 );
224
if( empty($this->widget_folders) ) {
225
// We can use this filter to add more folders to use for widgets
226
$this->widget_folders = apply_filters('siteorigin_widgets_widget_folders', array(
227
+ plugin_dir_path(__FILE__) . 'widgets/'
228
) );
229
}
230
355
exit();
356
}
357
358
+ /**
359
+ * Handler for displaying the Widget settings form.
360
+ *
361
+ * @action wp_ajax_so_widgets_setting_form
362
+ */
363
+ function admin_ajax_settings_form(){
364
+ if( ! wp_verify_nonce($_GET['_wpnonce'], 'display-widget-form') ) exit();
365
+ if( ! current_user_can( apply_filters( 'siteorigin_widgets_admin_menu_capability', 'manage_options' ) ) ) exit();
366
+
367
+ $widget_objects = $this->get_widget_objects();
368
+ $widget_object = !empty( $widget_objects[ $_GET['id'] ] ) ? $widget_objects[ $_GET['id'] ] : false;
369
+
370
+ if( empty( $widget_object ) || ! $widget_object->has_form( 'settings' ) ) exit();
371
+
372
+ unset( $widget_object->widget_options['has_preview'] );
373
+
374
+ $action_url = admin_url( 'admin-ajax.php' );
375
+ $action_url = add_query_arg( array(
376
+ 'id' => $_GET['id'],
377
+ 'action' => 'so_widgets_setting_save',
378
+ ), $action_url );
379
+ $action_url = wp_nonce_url( $action_url, 'save-widget-settings' );
380
+
381
+ $value = $widget_object->get_global_settings();
382
+
383
+ ?>
384
+ <form method="post" action="<?php echo esc_url( $action_url ) ?>" target="so-widget-settings-save">
385
+ <?php $widget_object->form( $value, 'settings' ) ?>
386
+ </form>
387
+ <?php
388
+
389
+ exit();
390
+ }
391