Version Description
- 21 June 2016 =
- Added builder field.
- Added new multi checkboxes field.
- Added Layout Slider widget.
- Added taxonomy widget.
- Added slider wrapper attributes and filter.
- Fix for measurement field inside a repeater.
- Modified base folder to work independently of Widgets Bundle.
- Added custom icon families callback argument to icon field.
- Properly handle attachments in post selector
- Contact Form: Refactored form fields.
- Hero Image: Added image type to Hero Image widget.
- Button: Handle empty width.
- Image: Added filter for SiteOrigin image attributes.
- Image: Add dimensions to sizes dropdown.
- Maps: Ensure maps widget works with API key.
- Hero Image: Added setting to disable swipe on mobile Hero Image Widget.
- Fixed title syntax in Image widget.
- Video: Correctly get video file mime-types.
- Video Widget: Allow specifying multiple self-hosted video sources to support various formats.
Download this release
Release Info
Developer | gpriday |
Plugin | SiteOrigin Widgets Bundle |
Version | 1.6 |
Comparing to | |
See all releases |
Code changes from version 1.5.11 to 1.6
- base/{inc.php → base.php} +0 -1
- base/css/admin.css +8 -2
- base/inc/fields/builder.class.php +60 -0
- base/inc/fields/checkbox.class.php +2 -2
- base/inc/fields/checkboxes.class.php +52 -0
- base/inc/fields/css/measurement-field.css +7 -0
- base/inc/fields/css/tinymce-field.css +3 -0
- base/inc/fields/icon.class.php +24 -9
- base/inc/fields/image-size.class.php +56 -0
- base/inc/fields/js/tinymce-field.js +132 -0
- base/inc/fields/js/tinymce-field.min.js +1 -0
- base/inc/fields/measurement.class.php +2 -2
- base/inc/fields/siteorigin-widget-field-class-loader.class.php +43 -16
- base/inc/fields/tinymce.class.php +2 -2
- base/inc/meta-box-manager.php +1 -1
- base/inc/post-selector.php +10 -23
- base/inc/widget-manager.class.php +8 -2
- base/inc/widgets/base-slider.class.php +46 -17
- base/js/admin.js +16 -0
- base/js/admin.min.js +1 -1
- base/js/posts-selector.js +2 -2
- base/js/posts-selector.min.js +1 -1
- base/siteorigin-widget.class.php +8 -2
- js/slider/jquery.slider.js +5 -1
- js/slider/jquery.slider.min.js +1 -1
- readme.txt +24 -3
- so-widgets-bundle.php +9 -5
- widgets/button/button.php +24 -20
- widgets/button/styles/atom.less +9 -1
- widgets/button/styles/flat.less +9 -1
- widgets/button/styles/wire.less +9 -1
- widgets/button/tpl/{base.php → default.php} +1 -2
- widgets/contact/contact.php +53 -51
- widgets/contact/fields/base.class.php +29 -0
- widgets/contact/fields/checkboxes.class.php +23 -0
- widgets/contact/fields/email.class.php +5 -0
- widgets/contact/fields/name.class.php +11 -0
- widgets/contact/fields/select.class.php +18 -0
- widgets/contact/fields/subject.class.php +11 -0
- widgets/contact/fields/text.class.php +11 -0
- widgets/contact/fields/textarea.class.php +11 -0
- widgets/cta/cta.php +0 -8
- widgets/cta/styles/{basic.less → default.less} +0 -0
- widgets/cta/tpl/{base.php → default.php} +0 -0
- widgets/editor/editor.php +0 -4
- widgets/editor/tpl/{editor.php → default.php} +0 -0
- widgets/features/features.php +1 -45
- widgets/features/styles/{features.less → default.less} +0 -0
- widgets/features/tpl/{base.php → default.php} +0 -0
- widgets/google-map/google-map.php +2 -1
- widgets/google-map/js/js-map.js +1 -1
- widgets/google-map/js/js-map.min.js +1 -1
- widgets/headline/headline.php +1 -16
- widgets/headline/styles/{sow-headline.less → default.less} +0 -0
- widgets/headline/tpl/{headline.php → default.php} +0 -0
- widgets/hero/hero.php +14 -3
- widgets/icon/icon.php +0 -16
- widgets/icon/styles/{sow-icon.less → default.less} +0 -0
- widgets/icon/tpl/{icon.php → default.php} +0 -0
- widgets/image-grid/image-grid.php +1 -8
- widgets/image/image.php +2 -24
- widgets/image/styles/{sow-image.less → default.less} +0 -0
- widgets/image/tpl/{base.php → default.php} +4 -7
- widgets/layout-slider/assets/banner.svg +40 -0
- widgets/layout-slider/layout-slider.php +300 -0
- widgets/layout-slider/styles/default.less +59 -0
- widgets/layout-slider/tpl/default.php +3 -0
- widgets/post-carousel/js/carousel.js +58 -52
- widgets/post-carousel/js/carousel.min.js +1 -1
- widgets/post-carousel/tpl/base.php +1 -1
- widgets/simple-masonry/simple-masonry.php +0 -8
- widgets/simple-masonry/styles/{simple-masonry.less → default.less} +0 -0
- widgets/simple-masonry/tpl/{simple-masonry.php → default.php} +0 -0
- widgets/slider/slider.php +3 -1
- widgets/social-media-buttons/social-media-buttons.php +0 -4
- widgets/social-media-buttons/tpl/{social-media-buttons.php → default.php} +0 -0
- widgets/taxonomy/styles/default.less +42 -0
- widgets/taxonomy/taxonomy.php +94 -0
- widgets/taxonomy/tpl/default.php +24 -0
- widgets/video/tpl/default.php +35 -11
- widgets/video/video.php +143 -93
base/{inc.php → base.php}
RENAMED
@@ -6,7 +6,6 @@ include plugin_dir_path(__FILE__).'siteorigin-widget.class.php';
|
|
6 |
include plugin_dir_path(__FILE__).'inc/widget-manager.class.php';
|
7 |
include plugin_dir_path(__FILE__).'inc/meta-box-manager.php';
|
8 |
include plugin_dir_path(__FILE__).'inc/post-selector.php';
|
9 |
-
include plugin_dir_path(__FILE__).'inc/fonts.php';
|
10 |
include plugin_dir_path(__FILE__).'inc/string-utils.php';
|
11 |
include plugin_dir_path(__FILE__).'inc/attachments.php';
|
12 |
|
6 |
include plugin_dir_path(__FILE__).'inc/widget-manager.class.php';
|
7 |
include plugin_dir_path(__FILE__).'inc/meta-box-manager.php';
|
8 |
include plugin_dir_path(__FILE__).'inc/post-selector.php';
|
|
|
9 |
include plugin_dir_path(__FILE__).'inc/string-utils.php';
|
10 |
include plugin_dir_path(__FILE__).'inc/attachments.php';
|
11 |
|
base/css/admin.css
CHANGED
@@ -24,6 +24,12 @@
|
|
24 |
.siteorigin-widget-form .siteorigin-widget-field label.siteorigin-widget-field-label {
|
25 |
font-weight: bold;
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
.siteorigin-widget-form .siteorigin-widget-field .siteorigin-widget-field-description {
|
28 |
font-size: 0.9em;
|
29 |
margin-top: 0.2em;
|
@@ -143,7 +149,7 @@
|
|
143 |
color: #999999;
|
144 |
}
|
145 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-expand {
|
146 |
-
right:
|
147 |
}
|
148 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-expand:before {
|
149 |
content: "\f140";
|
@@ -161,7 +167,7 @@
|
|
161 |
color: #50575D;
|
162 |
}
|
163 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-remove {
|
164 |
-
right:
|
165 |
}
|
166 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-remove:before {
|
167 |
content: '\f158';
|
24 |
.siteorigin-widget-form .siteorigin-widget-field label.siteorigin-widget-field-label {
|
25 |
font-weight: bold;
|
26 |
}
|
27 |
+
.siteorigin-widget-form .siteorigin-widget-field label.so-checkbox-label {
|
28 |
+
-webkit-user-select: none;
|
29 |
+
-moz-user-select: none;
|
30 |
+
-ms-user-select: none;
|
31 |
+
user-select: none;
|
32 |
+
}
|
33 |
.siteorigin-widget-form .siteorigin-widget-field .siteorigin-widget-field-description {
|
34 |
font-size: 0.9em;
|
35 |
margin-top: 0.2em;
|
149 |
color: #999999;
|
150 |
}
|
151 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-expand {
|
152 |
+
right: 48px;
|
153 |
}
|
154 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-expand:before {
|
155 |
content: "\f140";
|
167 |
color: #50575D;
|
168 |
}
|
169 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-remove {
|
170 |
+
right: 12px;
|
171 |
}
|
172 |
.siteorigin-widget-form .siteorigin-widget-field-repeater .siteorigin-widget-field-remove:before {
|
173 |
content: '\f158';
|
base/inc/fields/builder.class.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* A full instance of SiteOrigin Page Builder as a field.
|
5 |
+
*
|
6 |
+
* Class SiteOrigin_Widget_Field_Builder
|
7 |
+
*/
|
8 |
+
class SiteOrigin_Widget_Field_Builder extends SiteOrigin_Widget_Field_Base {
|
9 |
+
|
10 |
+
protected function render_field( $value, $instance ){
|
11 |
+
if( defined('SITEORIGIN_PANELS_VERSION') ) {
|
12 |
+
// Normal rendering code
|
13 |
+
?>
|
14 |
+
<div
|
15 |
+
class="siteorigin-page-builder-field"
|
16 |
+
data-mode="dialog"
|
17 |
+
data-type="<?php echo isset( $this->field_options['builder_type'] ) ? esc_attr( $this->field_options['builder_type'] ) : 'sow-builder-field' ?>"
|
18 |
+
>
|
19 |
+
<p>
|
20 |
+
<button class="button-secondary siteorigin-panels-display-builder" ><?php _e('Open Builder', 'siteorigin-panels') ?></button>
|
21 |
+
</p>
|
22 |
+
<input
|
23 |
+
type="hidden"
|
24 |
+
class="siteorigin-widget-input panels-data"
|
25 |
+
value="<?php echo esc_attr( json_encode( $value ) ) ?>"
|
26 |
+
name="<?php echo esc_attr( $this->element_name ) ?>"
|
27 |
+
id="<?php echo esc_attr( $this->element_id ) ?>"
|
28 |
+
/>
|
29 |
+
</div>
|
30 |
+
<?php
|
31 |
+
}
|
32 |
+
else {
|
33 |
+
// Let the user know that they need Page Builder installed
|
34 |
+
?>
|
35 |
+
<p>
|
36 |
+
<?php _e( 'This field requires: ', 'so-widgets-bundle' ) ?>
|
37 |
+
<a href="https://siteorigin.com/page-builder/" target="_blank"><?php _e( 'SiteOrigin Page Builder', 'so-widgets-bundle' ) ?></a>
|
38 |
+
</p>
|
39 |
+
<?php
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Process the panels_data
|
45 |
+
*
|
46 |
+
* @param mixed $value
|
47 |
+
* @param array $instance
|
48 |
+
*
|
49 |
+
* @return array|mixed|object
|
50 |
+
*/
|
51 |
+
protected function sanitize_field_input( $value, $instance ){
|
52 |
+
$panels_data = json_decode( $value, true );
|
53 |
+
if( function_exists('siteorigin_panels_process_raw_widgets') && !empty( $panels_data['widgets'] ) && is_array( $panels_data['widgets'] ) ) {
|
54 |
+
$panels_data['widgets'] = siteorigin_panels_process_raw_widgets( $panels_data['widgets'] );
|
55 |
+
}
|
56 |
+
|
57 |
+
return $panels_data;
|
58 |
+
}
|
59 |
+
|
60 |
+
}
|
base/inc/fields/checkbox.class.php
CHANGED
@@ -7,7 +7,7 @@ class SiteOrigin_Widget_Field_Checkbox extends SiteOrigin_Widget_Field_Base {
|
|
7 |
|
8 |
protected function render_field( $value, $instance ) {
|
9 |
?>
|
10 |
-
<label for="<?php echo esc_attr( $this->element_id ) ?>">
|
11 |
<input type="checkbox" name="<?php echo esc_attr( $this->element_name ) ?>" id="<?php echo esc_attr( $this->element_id ) ?>"
|
12 |
class="siteorigin-widget-input" <?php checked( !empty( $value ) ) ?> />
|
13 |
<?php echo esc_attr( $this->label ) ?>
|
@@ -23,4 +23,4 @@ class SiteOrigin_Widget_Field_Checkbox extends SiteOrigin_Widget_Field_Base {
|
|
23 |
return ! empty( $value );
|
24 |
}
|
25 |
|
26 |
-
}
|
7 |
|
8 |
protected function render_field( $value, $instance ) {
|
9 |
?>
|
10 |
+
<label for="<?php echo esc_attr( $this->element_id ) ?>" class="so-checkbox-label">
|
11 |
<input type="checkbox" name="<?php echo esc_attr( $this->element_name ) ?>" id="<?php echo esc_attr( $this->element_id ) ?>"
|
12 |
class="siteorigin-widget-input" <?php checked( !empty( $value ) ) ?> />
|
13 |
<?php echo esc_attr( $this->label ) ?>
|
23 |
return ! empty( $value );
|
24 |
}
|
25 |
|
26 |
+
}
|
base/inc/fields/checkboxes.class.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class SiteOrigin_Widget_Field_Checkbox
|
5 |
+
*/
|
6 |
+
class SiteOrigin_Widget_Field_Checkboxes extends SiteOrigin_Widget_Field_Base {
|
7 |
+
|
8 |
+
protected $options;
|
9 |
+
|
10 |
+
protected function render_field( $value, $instance ) {
|
11 |
+
if( empty($value) ) {
|
12 |
+
$value = array();
|
13 |
+
}
|
14 |
+
|
15 |
+
if( !is_array( $value ) ) {
|
16 |
+
$value = array( $value );
|
17 |
+
}
|
18 |
+
|
19 |
+
foreach( $this->options as $id => $label ) {
|
20 |
+
?>
|
21 |
+
<label for="<?php echo esc_attr( $this->element_id ) ?>-<?php echo esc_attr( $id ) ?>" class="so-checkbox-label">
|
22 |
+
<input
|
23 |
+
type="checkbox"
|
24 |
+
class="siteorigin-widget-input"
|
25 |
+
name="<?php echo esc_attr( $this->element_name ) ?>[]"
|
26 |
+
value="<?php echo esc_attr( $id ) ?>"
|
27 |
+
id="<?php echo esc_attr( $this->element_id ) ?>-<?php echo esc_attr( $id ) ?>"
|
28 |
+
<?php checked( in_array( $id, $value ) ) ?>
|
29 |
+
/>
|
30 |
+
<?php echo( $label ) ?>
|
31 |
+
</label>
|
32 |
+
<?php
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
protected function sanitize_field_input( $value, $instance ) {
|
37 |
+
$values = is_array( $value ) ? $value : array( $value );
|
38 |
+
$keys = array_keys( $this->options );
|
39 |
+
$sanitized_value = array();
|
40 |
+
foreach( $values as $value ) {
|
41 |
+
if ( !in_array( $value, $keys ) ) {
|
42 |
+
$sanitized_value[] = isset( $this->default ) ? $this->default : false;
|
43 |
+
}
|
44 |
+
else {
|
45 |
+
$sanitized_value[] = $value;
|
46 |
+
}
|
47 |
+
}
|
48 |
+
|
49 |
+
return count( $sanitized_value ) == 1 ? $sanitized_value[0] : $sanitized_value;
|
50 |
+
}
|
51 |
+
|
52 |
+
}
|
base/inc/fields/css/measurement-field.css
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.siteorigin-widget-form .siteorigin-widget-field input[type="text"].siteorigin-widget-input-measurement {
|
2 |
+
float: left;
|
3 |
+
max-width: 58px;
|
4 |
+
margin: 1px;
|
5 |
+
height: 28px;
|
6 |
+
vertical-align: middle;
|
7 |
+
}
|
base/inc/fields/css/tinymce-field.css
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
.wp-customizer .mce-floatpanel {
|
2 |
+
z-index: 1000000 !important;
|
3 |
+
}
|
base/inc/fields/icon.class.php
CHANGED
@@ -5,10 +5,10 @@
|
|
5 |
*/
|
6 |
class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
|
7 |
|
8 |
-
protected
|
9 |
-
static $widget_icon_families;
|
10 |
-
if( empty( $widget_icon_families ) ) $widget_icon_families = apply_filters('siteorigin_widgets_icon_families', array() );
|
11 |
|
|
|
|
|
12 |
list( $value_family, $null ) = !empty($value) ? explode('-', $value, 2) : array('fontawesome', '');
|
13 |
|
14 |
?>
|
@@ -22,7 +22,11 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
|
|
22 |
<select class="siteorigin-widget-icon-family" >
|
23 |
<?php foreach( $widget_icon_families as $family_id => $family_info ) : ?>
|
24 |
<option value="<?php echo esc_attr( $family_id ) ?>"
|
25 |
-
<?php selected( $value_family, $family_id )
|
|
|
|
|
|
|
|
|
26 |
<?php endforeach; ?>
|
27 |
</select>
|
28 |
|
@@ -45,10 +49,7 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
|
|
45 |
}
|
46 |
list( $value_family, $value_icon ) = ( ! empty( $sanitized_value ) && strpos( $sanitized_value, '-' ) !== false ) ? explode( '-', $sanitized_value, 2 ) : array('', '');
|
47 |
|
48 |
-
|
49 |
-
if( empty( $widget_icon_families ) ) {
|
50 |
-
$widget_icon_families = apply_filters( 'siteorigin_widgets_icon_families', array() );
|
51 |
-
}
|
52 |
if( ! ( isset( $widget_icon_families[$value_family] ) && isset( $widget_icon_families[$value_family]['icons'][$value_icon] ) ) ) {
|
53 |
$sanitized_value = isset( $this->default ) ? $this->default : '';
|
54 |
}
|
@@ -56,4 +57,18 @@ class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
|
|
56 |
return $sanitized_value;
|
57 |
}
|
58 |
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
*/
|
6 |
class SiteOrigin_Widget_Field_Icon extends SiteOrigin_Widget_Field_Base {
|
7 |
|
8 |
+
protected $icons_callback;
|
|
|
|
|
9 |
|
10 |
+
protected function render_field( $value, $instance ) {
|
11 |
+
$widget_icon_families = $this->get_widget_icon_families();
|
12 |
list( $value_family, $null ) = !empty($value) ? explode('-', $value, 2) : array('fontawesome', '');
|
13 |
|
14 |
?>
|
22 |
<select class="siteorigin-widget-icon-family" >
|
23 |
<?php foreach( $widget_icon_families as $family_id => $family_info ) : ?>
|
24 |
<option value="<?php echo esc_attr( $family_id ) ?>"
|
25 |
+
<?php selected( $value_family, $family_id ) ?>
|
26 |
+
<?php if( !empty( $this->icons_callback ) ) echo 'data-icons="' . esc_attr( json_encode( $family_info ) ) . '"' ?>
|
27 |
+
>
|
28 |
+
<?php echo esc_html( $family_info['name'] ) ?> (<?php echo count( $family_info['icons'] ) ?>)
|
29 |
+
</option>
|
30 |
<?php endforeach; ?>
|
31 |
</select>
|
32 |
|
49 |
}
|
50 |
list( $value_family, $value_icon ) = ( ! empty( $sanitized_value ) && strpos( $sanitized_value, '-' ) !== false ) ? explode( '-', $sanitized_value, 2 ) : array('', '');
|
51 |
|
52 |
+
$widget_icon_families = $this->get_widget_icon_families();
|
|
|
|
|
|
|
53 |
if( ! ( isset( $widget_icon_families[$value_family] ) && isset( $widget_icon_families[$value_family]['icons'][$value_icon] ) ) ) {
|
54 |
$sanitized_value = isset( $this->default ) ? $this->default : '';
|
55 |
}
|
57 |
return $sanitized_value;
|
58 |
}
|
59 |
|
60 |
+
private function get_widget_icon_families(){
|
61 |
+
if( !empty( $this->icons_callback ) ) {
|
62 |
+
// We'll get the icons from the callback function
|
63 |
+
$widget_icon_families = call_user_func( $this->icons_callback );
|
64 |
+
}
|
65 |
+
else {
|
66 |
+
// We'll get icons from the main filter
|
67 |
+
static $widget_icon_families;
|
68 |
+
if( empty( $widget_icon_families ) ) $widget_icon_families = apply_filters('siteorigin_widgets_icon_families', array() );
|
69 |
+
}
|
70 |
+
|
71 |
+
return $widget_icon_families;
|
72 |
+
}
|
73 |
+
|
74 |
+
}
|
base/inc/fields/image-size.class.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Class SiteOrigin_Widget_Field_Select
|
5 |
+
*/
|
6 |
+
class SiteOrigin_Widget_Field_Image_Size extends SiteOrigin_Widget_Field_Select {
|
7 |
+
|
8 |
+
protected function get_default_options() {
|
9 |
+
$image_size_configs = $this->get_image_sizes();
|
10 |
+
// Hardcoded 'full' and 'thumb' because they're not registered image sizes.
|
11 |
+
// 'full' will result in the original uploaded image size being used.
|
12 |
+
// 'thumb' is a small thumbnail image size defined by the current theme.
|
13 |
+
$sizes = array(
|
14 |
+
'full' => __( 'Full', 'so-widgets-bundle' ),
|
15 |
+
'thumb' => __( 'Thumbnail (Theme-defined)', 'so-widgets-bundle' ),
|
16 |
+
);
|
17 |
+
foreach( $image_size_configs as $name => $size_config) {
|
18 |
+
$sizes[$name] = ucwords(preg_replace('/[-_]/', ' ', $name)) . ' (' . $size_config['width'] . 'x' . $size_config['height'] . ')';
|
19 |
+
}
|
20 |
+
|
21 |
+
return array(
|
22 |
+
'options' => $sizes
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
/**
|
27 |
+
* Get size information for all currently-registered image sizes.
|
28 |
+
* From codex example here: https://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes
|
29 |
+
*
|
30 |
+
* @global $_wp_additional_image_sizes
|
31 |
+
* @uses get_intermediate_image_sizes()
|
32 |
+
* @return array $sizes Data for all currently-registered image sizes.
|
33 |
+
*/
|
34 |
+
private function get_image_sizes() {
|
35 |
+
global $_wp_additional_image_sizes;
|
36 |
+
|
37 |
+
$sizes = array();
|
38 |
+
|
39 |
+
foreach ( get_intermediate_image_sizes() as $_size ) {
|
40 |
+
if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
|
41 |
+
$sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" );
|
42 |
+
$sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
|
43 |
+
$sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" );
|
44 |
+
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
|
45 |
+
$sizes[ $_size ] = array(
|
46 |
+
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
|
47 |
+
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
|
48 |
+
'crop' => $_wp_additional_image_sizes[ $_size ]['crop'],
|
49 |
+
);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
|
53 |
+
return $sizes;
|
54 |
+
}
|
55 |
+
|
56 |
+
}
|
base/inc/fields/js/tinymce-field.js
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/* global tinyMCEPreInit, quicktags, QTags, tinymce */
|
2 |
+
|
3 |
+
(function( $ ) {
|
4 |
+
var setup = function(widgetForm) {
|
5 |
+
if(typeof tinyMCEPreInit !== 'undefined') {
|
6 |
+
//BS TinyMCE widget sometimes adds 'undefined' as an id when opening PB, which causes a JS error when using repeaters.
|
7 |
+
if (tinyMCEPreInit.mceInit.hasOwnProperty('undefined')) {
|
8 |
+
delete tinyMCEPreInit.mceInit['undefined'];
|
9 |
+
}
|
10 |
+
if (tinyMCEPreInit.qtInit.hasOwnProperty('undefined')) {
|
11 |
+
delete tinyMCEPreInit.qtInit['undefined'];
|
12 |
+
}
|
13 |
+
if (QTags.instances.hasOwnProperty('undefined')) {
|
14 |
+
delete QTags.instances['undefined'];
|
15 |
+
}
|
16 |
+
$(widgetForm).find('> .siteorigin-widget-field-type-tinymce > .siteorigin-widget-tinymce-container').each(function (index, element) {
|
17 |
+
var $container = $(element);
|
18 |
+
var $textarea = $container.find('textarea');
|
19 |
+
var id = $textarea.attr('id');
|
20 |
+
if( typeof tinymce != 'undefined') {
|
21 |
+
if (id.indexOf('__i__') > -1) return;
|
22 |
+
var mceSettings = $container.data('mceSettings');
|
23 |
+
var widgetIdBase = $container.data('widgetIdBase');
|
24 |
+
var name = $textarea.attr('name').replace(/\[\d+\]/g, '');
|
25 |
+
var fieldName = /[a-zA-Z0-9\-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(name)[1];
|
26 |
+
var idPattern = new RegExp('widget-' + widgetIdBase + '-.*-' + fieldName.replace(/\]\[/g, '-') + '[-\d]*');
|
27 |
+
for (var initId in tinyMCEPreInit.mceInit) {
|
28 |
+
if (initId.match(idPattern)) {
|
29 |
+
mceSettings = $.extend({}, tinyMCEPreInit.mceInit[initId], mceSettings);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
var content;
|
33 |
+
var curEd = tinymce.get(id);
|
34 |
+
if (curEd != null) {
|
35 |
+
content = curEd.getContent();
|
36 |
+
curEd.remove();
|
37 |
+
}
|
38 |
+
var setupEditor = function (editor) {
|
39 |
+
editor.on('change',
|
40 |
+
function () {
|
41 |
+
tinymce.get(id).save();
|
42 |
+
$textarea.trigger('change');
|
43 |
+
$textarea.val(window.switchEditors.pre_wpautop(editor.getContent()));
|
44 |
+
}
|
45 |
+
);
|
46 |
+
editor.on('init',
|
47 |
+
function () {
|
48 |
+
if (content) {
|
49 |
+
editor.setContent(content);
|
50 |
+
}
|
51 |
+
}
|
52 |
+
);
|
53 |
+
$textarea.on('keyup',
|
54 |
+
function () {
|
55 |
+
editor.setContent(window.switchEditors.wpautop($textarea.val()));
|
56 |
+
}
|
57 |
+
);
|
58 |
+
};
|
59 |
+
mceSettings = $.extend({}, mceSettings, {selector: '#' + id, setup: setupEditor});
|
60 |
+
tinyMCEPreInit.mceInit[id] = mceSettings;
|
61 |
+
var wrapDiv = $container.find('div#wp-' + id + '-wrap');
|
62 |
+
if (wrapDiv.hasClass('tmce-active')) {
|
63 |
+
// Add a small timeout to make sure everything is ready - mainly for customizer and widgets interface
|
64 |
+
if ($('#' + id).is(':visible')) {
|
65 |
+
tinymce.init(tinyMCEPreInit.mceInit[id]);
|
66 |
+
}
|
67 |
+
else {
|
68 |
+
var intervalId = setInterval(function () {
|
69 |
+
if ($('#' + id).is(':visible')) {
|
70 |
+
tinymce.init(tinyMCEPreInit.mceInit[id]);
|
71 |
+
clearInterval(intervalId);
|
72 |
+
}
|
73 |
+
}, 500);
|
74 |
+
}
|
75 |
+
}
|
76 |
+
}
|
77 |
+
var qtSettings = $container.data('qtSettings');
|
78 |
+
qtSettings = $.extend({}, tinyMCEPreInit.qtInit['siteorigin-widget-input-tinymce-field'], qtSettings, {id: id});
|
79 |
+
tinyMCEPreInit.qtInit[id] = qtSettings;
|
80 |
+
$container.find('.quicktags-toolbar').remove();
|
81 |
+
quicktags(tinyMCEPreInit.qtInit[id]);
|
82 |
+
|
83 |
+
$(this).on( 'click', function(event) {
|
84 |
+
|
85 |
+
var $target = $(event.target);
|
86 |
+
if ( $target.hasClass( 'wp-switch-editor' ) ) {
|
87 |
+
mode = $target.hasClass( 'switch-tmce' ) ? 'tmce' : 'html';
|
88 |
+
$(this).find('+ .siteorigin-widget-tinymce-selected-editor').val(mode);
|
89 |
+
}
|
90 |
+
});
|
91 |
+
});
|
92 |
+
QTags._buttonsInit();
|
93 |
+
}
|
94 |
+
else {
|
95 |
+
setTimeout(function(){
|
96 |
+
setup(widgetForm);
|
97 |
+
}, 500);
|
98 |
+
}
|
99 |
+
};
|
100 |
+
|
101 |
+
$(document).on( 'sowsetupform', function(e) {
|
102 |
+
var $f = $(e.target);
|
103 |
+
|
104 |
+
if($f.is('.siteorigin-widget-field-repeater-item-form')){
|
105 |
+
if($f.is(':visible')) {
|
106 |
+
setup( $f );
|
107 |
+
}
|
108 |
+
else {
|
109 |
+
$f.on('slideToggleOpenComplete', function onSlideToggleComplete() {
|
110 |
+
if( $f.is(':visible') ){
|
111 |
+
setup($f);
|
112 |
+
$f.off('slideToggleOpenComplete');
|
113 |
+
}
|
114 |
+
});
|
115 |
+
}
|
116 |
+
}
|
117 |
+
else {
|
118 |
+
setup($f);
|
119 |
+
}
|
120 |
+
});
|
121 |
+
$(document).on('sortstop', function (event, ui) {
|
122 |
+
if(ui.item.is('.siteorigin-widget-field-repeater-item')) {
|
123 |
+
ui.item.find('> .siteorigin-widget-field-repeater-item-form').each(function(){
|
124 |
+
setup( $(this) );
|
125 |
+
});
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
setup(ui.item.find('.siteorigin-widget-form'));
|
129 |
+
}
|
130 |
+
});
|
131 |
+
|
132 |
+
})( jQuery );
|
base/inc/fields/js/tinymce-field.min.js
ADDED
@@ -0,0 +1 @@
|
|
|
1 |
+
!function(e){var t=function(i){"undefined"!=typeof tinyMCEPreInit?(tinyMCEPreInit.mceInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.mceInit.undefined,tinyMCEPreInit.qtInit.hasOwnProperty("undefined")&&delete tinyMCEPreInit.qtInit.undefined,QTags.instances.hasOwnProperty("undefined")&&delete QTags.instances.undefined,e(i).find("> .siteorigin-widget-field-type-tinymce > .siteorigin-widget-tinymce-container").each(function(t,i){var n=e(i),r=n.find("textarea"),o=r.attr("id");if("undefined"!=typeof tinymce){if(o.indexOf("__i__")>-1)return;var d=n.data("mceSettings"),s=n.data("widgetIdBase"),a=r.attr("name").replace(/\[\d+\]/g,""),c=/[a-zA-Z0-9\-]+(?:\[[a-zA-Z0-9]+\])?\[(.*)\]/.exec(a)[1],f=new RegExp("widget-"+s+"-.*-"+c.replace(/\]\[/g,"-")+"[-d]*");for(var g in tinyMCEPreInit.mceInit)g.match(f)&&(d=e.extend({},tinyMCEPreInit.mceInit[g],d));var m,l=tinymce.get(o);null!=l&&(m=l.getContent(),l.remove());var u=function(e){e.on("change",function(){tinymce.get(o).save(),r.trigger("change"),r.val(window.switchEditors.pre_wpautop(e.getContent()))}),e.on("init",function(){m&&e.setContent(m)}),r.on("keyup",function(){e.setContent(window.switchEditors.wpautop(r.val()))})};d=e.extend({},d,{selector:"#"+o,setup:u}),tinyMCEPreInit.mceInit[o]=d;var y=n.find("div#wp-"+o+"-wrap");if(y.hasClass("tmce-active"))if(e("#"+o).is(":visible"))tinymce.init(tinyMCEPreInit.mceInit[o]);else var p=setInterval(function(){e("#"+o).is(":visible")&&(tinymce.init(tinyMCEPreInit.mceInit[o]),clearInterval(p))},500)}var I=n.data("qtSettings");I=e.extend({},tinyMCEPreInit.qtInit["siteorigin-widget-input-tinymce-field"],I,{id:o}),tinyMCEPreInit.qtInit[o]=I,n.find(".quicktags-toolbar").remove(),quicktags(tinyMCEPreInit.qtInit[o]),e(this).on("click",function(t){var i=e(t.target);i.hasClass("wp-switch-editor")&&(mode=i.hasClass("switch-tmce")?"tmce":"html",e(this).find("+ .siteorigin-widget-tinymce-selected-editor").val(mode))})}),QTags._buttonsInit()):setTimeout(function(){t(i)},500)};e(document).on("sowsetupform",function(i){var n=e(i.target);n.is(".siteorigin-widget-field-repeater-item-form")?n.is(":visible")?t(n):n.on("slideToggleOpenComplete",function(){n.is(":visible")&&(t(n),n.off("slideToggleOpenComplete"))}):t(n)}),e(document).on("sortstop",function(i,n){n.item.is(".siteorigin-widget-field-repeater-item")?n.item.find("> .siteorigin-widget-field-repeater-item-form").each(function(){t(e(this))}):t(n.item.find(".siteorigin-widget-form"))})}(jQuery);
|
base/inc/fields/measurement.class.php
CHANGED
@@ -47,7 +47,7 @@ class SiteOrigin_Widget_Field_Measurement extends SiteOrigin_Widget_Field_Text_I
|
|
47 |
}
|
48 |
}
|
49 |
?>
|
50 |
-
<select class="sow-measurement-select-unit"
|
51 |
name="<?php echo esc_attr( $this->for_widget->so_get_field_name( $this->base_name . '_unit', $this->parent_container ) ) ?>">
|
52 |
<?php foreach ( siteorigin_widgets_get_measurements_list() as $measurement ):?>
|
53 |
<option value="<?php echo esc_attr( $measurement ) ?>" <?php selected( $measurement, $unit, true ); ?>><?php echo esc_html( $measurement ) ?></option>
|
@@ -60,7 +60,7 @@ class SiteOrigin_Widget_Field_Measurement extends SiteOrigin_Widget_Field_Text_I
|
|
60 |
}
|
61 |
|
62 |
public function enqueue_scripts() {
|
63 |
-
wp_enqueue_style( 'so-measurement-field', plugin_dir_url(__FILE__) . 'css/
|
64 |
}
|
65 |
|
66 |
// This is doing sanitization and is being used to concatenate the numeric measurement value and the selected
|
47 |
}
|
48 |
}
|
49 |
?>
|
50 |
+
<select class="sow-measurement-select-unit siteorigin-widget-input"
|
51 |
name="<?php echo esc_attr( $this->for_widget->so_get_field_name( $this->base_name . '_unit', $this->parent_container ) ) ?>">
|
52 |
<?php foreach ( siteorigin_widgets_get_measurements_list() as $measurement ):?>
|
53 |
<option value="<?php echo esc_attr( $measurement ) ?>" <?php selected( $measurement, $unit, true ); ?>><?php echo esc_html( $measurement ) ?></option>
|
60 |
}
|
61 |
|
62 |
public function enqueue_scripts() {
|
63 |
+
wp_enqueue_style( 'so-measurement-field', plugin_dir_url(__FILE__) . 'css/measurement-field.css', array(), SOW_BUNDLE_VERSION );
|
64 |
}
|
65 |
|
66 |
// This is doing sanitization and is being used to concatenate the numeric measurement value and the selected
|
base/inc/fields/siteorigin-widget-field-class-loader.class.php
CHANGED
@@ -12,8 +12,9 @@ class SiteOrigin_Widget_Field_Class_Loader {
|
|
12 |
|
13 |
function __construct(){
|
14 |
// Setup the loader with default prefixes and paths
|
15 |
-
$this->add_class_prefixes( array( 'SiteOrigin_Widget_Field_' ) );
|
16 |
-
$this->add_class_paths( array( plugin_dir_path( __FILE__ ) ) );
|
|
|
17 |
spl_autoload_register( array( $this, 'load_field_class' ) );
|
18 |
}
|
19 |
|
@@ -29,21 +30,35 @@ class SiteOrigin_Widget_Field_Class_Loader {
|
|
29 |
/**
|
30 |
* Regsiter class prefixes to watch for in this loader
|
31 |
*
|
32 |
-
* @param $class_prefixes
|
|
|
33 |
*/
|
34 |
-
public function add_class_prefixes( $class_prefixes ) {
|
35 |
if( !isset( $this->class_prefixes ) ) $this->class_prefixes = array();
|
36 |
-
$this->class_prefixes
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
* Register paths where we'll look for these classes.
|
41 |
*
|
42 |
-
* @param $class_paths
|
|
|
43 |
*/
|
44 |
-
public function add_class_paths( $class_paths ) {
|
45 |
if( !isset( $this->class_paths ) ) $this->class_paths = array();
|
46 |
-
$this->class_paths
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
}
|
48 |
|
49 |
/**
|
@@ -54,18 +69,26 @@ class SiteOrigin_Widget_Field_Class_Loader {
|
|
54 |
public function load_field_class( $field_classname ) {
|
55 |
$valid_classname = false;
|
56 |
$class_prefix = '';
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
60 |
}
|
61 |
if ( ! $valid_classname ) return;
|
62 |
|
63 |
$filename = strtolower( str_replace( '_', '-', str_replace( $class_prefix, '', $field_classname ) ) );
|
64 |
|
65 |
-
|
|
|
|
|
66 |
$filepath = $class_path . $filename . '.class.php';
|
67 |
if ( file_exists( $filepath ) ) {
|
68 |
require_once $filepath;
|
|
|
69 |
}
|
70 |
}
|
71 |
}
|
@@ -74,11 +97,15 @@ class SiteOrigin_Widget_Field_Class_Loader {
|
|
74 |
* Initialize and register the class field loader
|
75 |
*/
|
76 |
public function extend(){
|
77 |
-
$
|
78 |
-
|
|
|
|
|
79 |
|
80 |
-
$
|
81 |
-
|
|
|
|
|
82 |
}
|
83 |
}
|
84 |
|
12 |
|
13 |
function __construct(){
|
14 |
// Setup the loader with default prefixes and paths
|
15 |
+
$this->add_class_prefixes( array( 'SiteOrigin_Widget_Field_' ), 'base' );
|
16 |
+
$this->add_class_paths( array( plugin_dir_path( __FILE__ ) ), 'base' );
|
17 |
+
|
18 |
spl_autoload_register( array( $this, 'load_field_class' ) );
|
19 |
}
|
20 |
|
30 |
/**
|
31 |
* Regsiter class prefixes to watch for in this loader
|
32 |
*
|
33 |
+
* @param string|array $class_prefixes
|
34 |
+
* @param string $group
|
35 |
*/
|
36 |
+
public function add_class_prefixes( $class_prefixes, $group = 'base' ) {
|
37 |
if( !isset( $this->class_prefixes ) ) $this->class_prefixes = array();
|
38 |
+
if( !isset( $this->class_prefixes[$group] ) ) $this->class_prefixes[$group] = array();
|
39 |
+
|
40 |
+
$this->class_prefixes[$group] = array_merge(
|
41 |
+
$this->class_prefixes[$group],
|
42 |
+
$class_prefixes
|
43 |
+
);
|
44 |
+
$this->class_prefixes[$group] = array_unique( $this->class_prefixes[$group] );
|
45 |
}
|
46 |
|
47 |
/**
|
48 |
* Register paths where we'll look for these classes.
|
49 |
*
|
50 |
+
* @param string|array $class_paths
|
51 |
+
* @param string $group
|
52 |
*/
|
53 |
+
public function add_class_paths( $class_paths, $group = 'base' ) {
|
54 |
if( !isset( $this->class_paths ) ) $this->class_paths = array();
|
55 |
+
if( !isset( $this->class_paths[$group] ) ) $this->class_paths[$group] = array();
|
56 |
+
|
57 |
+
$this->class_paths[$group] = array_merge(
|
58 |
+
$this->class_paths[$group],
|
59 |
+
$class_paths
|
60 |
+
);
|
61 |
+
$this->class_paths[$group] = array_unique( $this->class_paths[$group] );
|
62 |
}
|
63 |
|
64 |
/**
|
69 |
public function load_field_class( $field_classname ) {
|
70 |
$valid_classname = false;
|
71 |
$class_prefix = '';
|
72 |
+
$class_group = '';
|
73 |
+
foreach ( $this->class_prefixes as $class_group => $class_prefixes ) {
|
74 |
+
foreach( $class_prefixes as $class_prefix ) {
|
75 |
+
$valid_classname = strpos( $field_classname, $class_prefix ) !== false;
|
76 |
+
if( $valid_classname ) {
|
77 |
+
break 2;
|
78 |
+
}
|
79 |
+
}
|
80 |
}
|
81 |
if ( ! $valid_classname ) return;
|
82 |
|
83 |
$filename = strtolower( str_replace( '_', '-', str_replace( $class_prefix, '', $field_classname ) ) );
|
84 |
|
85 |
+
if( empty( $this->class_paths[$class_group] ) ) return;
|
86 |
+
|
87 |
+
foreach( $this->class_paths[$class_group] as $class_path ) {
|
88 |
$filepath = $class_path . $filename . '.class.php';
|
89 |
if ( file_exists( $filepath ) ) {
|
90 |
require_once $filepath;
|
91 |
+
continue;
|
92 |
}
|
93 |
}
|
94 |
}
|
97 |
* Initialize and register the class field loader
|
98 |
*/
|
99 |
public function extend(){
|
100 |
+
$this->add_class_prefixes(
|
101 |
+
apply_filters( 'siteorigin_widgets_field_class_prefixes', array() ),
|
102 |
+
'base'
|
103 |
+
);
|
104 |
|
105 |
+
$this->add_class_paths(
|
106 |
+
apply_filters( 'siteorigin_widgets_field_class_paths', array() ),
|
107 |
+
'base'
|
108 |
+
);
|
109 |
}
|
110 |
}
|
111 |
|
base/inc/fields/tinymce.class.php
CHANGED
@@ -209,8 +209,8 @@ class SiteOrigin_Widget_Field_TinyMCE extends SiteOrigin_Widget_Field_Text_Input
|
|
209 |
}
|
210 |
|
211 |
public function enqueue_scripts() {
|
212 |
-
wp_enqueue_script( 'so-tinymce-field', plugin_dir_url(__FILE__) . 'js/
|
213 |
-
wp_enqueue_style( 'so-tinymce-field', plugin_dir_url(__FILE__) . 'css/
|
214 |
}
|
215 |
|
216 |
protected function sanitize_field_input( $value, $instance ) {
|
209 |
}
|
210 |
|
211 |
public function enqueue_scripts() {
|
212 |
+
wp_enqueue_script( 'so-tinymce-field', plugin_dir_url(__FILE__) . 'js/tinymce-field' . SOW_BUNDLE_JS_SUFFIX . '.js', array( 'jquery', 'editor', 'quicktags' ), SOW_BUNDLE_VERSION );
|
213 |
+
wp_enqueue_style( 'so-tinymce-field', plugin_dir_url(__FILE__) . 'css/tinymce-field.css', array(), SOW_BUNDLE_VERSION );
|
214 |
}
|
215 |
|
216 |
protected function sanitize_field_input( $value, $instance ) {
|
base/inc/meta-box-manager.php
CHANGED
@@ -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,
|
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,
|
base/inc/post-selector.php
CHANGED
@@ -39,10 +39,14 @@ function siteorigin_widget_post_selector_process_query($query){
|
|
39 |
)
|
40 |
);
|
41 |
|
42 |
-
if(!empty($query['post_type'])) {
|
43 |
if($query['post_type'] == '_all') $query['post_type'] = siteorigin_widget_post_selector_all_post_types();
|
44 |
-
$query['post_type'] = explode(',', $query['post_type']);
|
45 |
}
|
|
|
|
|
|
|
|
|
46 |
|
47 |
if(!empty($query['post__in'])) {
|
48 |
$query['post__in'] = explode(',', $query['post__in']);
|
@@ -91,8 +95,7 @@ function siteorigin_widget_post_selector_process_query($query){
|
|
91 |
}
|
92 |
|
93 |
if ( ! empty( $query['additional'] ) ) {
|
94 |
-
$
|
95 |
-
$query = wp_parse_args( $additional, $query );
|
96 |
unset( $query['additional'] );
|
97 |
}
|
98 |
|
@@ -215,15 +218,7 @@ function siteorigin_widget_post_selector_all_post_types(){
|
|
215 |
* @return int
|
216 |
*/
|
217 |
function siteorigin_widget_post_selector_count_posts($query){
|
218 |
-
|
219 |
-
|
220 |
-
$query = wp_parse_args(
|
221 |
-
siteorigin_widget_post_selector_process_query($query),
|
222 |
-
array(
|
223 |
-
'post_status' => 'publish',
|
224 |
-
'posts_per_page' => 10,
|
225 |
-
)
|
226 |
-
);
|
227 |
$posts = new WP_Query($query);
|
228 |
return $posts->found_posts;
|
229 |
}
|
@@ -233,14 +228,8 @@ function siteorigin_widget_post_selector_count_posts($query){
|
|
233 |
*/
|
234 |
function siteorigin_widget_post_selector_get_posts_action(){
|
235 |
if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
|
236 |
-
|
237 |
-
$query =
|
238 |
-
siteorigin_widget_post_selector_process_query($query),
|
239 |
-
array(
|
240 |
-
'post_status' => 'publish',
|
241 |
-
'posts_per_page' => 10,
|
242 |
-
)
|
243 |
-
);
|
244 |
|
245 |
if(!empty($_POST['ignore_pagination'])) {
|
246 |
$query['posts_per_page'] = 100;
|
@@ -284,8 +273,6 @@ function siteorigin_widget_post_selector_post_search_action(){
|
|
284 |
$results = array();
|
285 |
$r = new WP_Query( array('s' => $term, 'post_status' => 'publish', 'posts_per_page' => 20, 'post_type' => $type) );
|
286 |
foreach($r->posts as $post) {
|
287 |
-
// $thumbnail = wp_get_attachment_image_src($post->ID);
|
288 |
-
|
289 |
$results[] = array(
|
290 |
'label' => $post->post_title,
|
291 |
'value' => $post->ID,
|
39 |
)
|
40 |
);
|
41 |
|
42 |
+
if( !empty( $query['post_type'] ) ) {
|
43 |
if($query['post_type'] == '_all') $query['post_type'] = siteorigin_widget_post_selector_all_post_types();
|
44 |
+
$query['post_type'] = strpos( $query['post_type'], ',' ) !== false ? explode( ',', $query['post_type'] ) : $query['post_type'];
|
45 |
}
|
46 |
+
if( $query['post_type'] == 'attachment' && $query['post_status'] == 'publish' ) {
|
47 |
+
$query['post_status'] = 'inherit';
|
48 |
+
}
|
49 |
+
|
50 |
|
51 |
if(!empty($query['post__in'])) {
|
52 |
$query['post__in'] = explode(',', $query['post__in']);
|
95 |
}
|
96 |
|
97 |
if ( ! empty( $query['additional'] ) ) {
|
98 |
+
$query = wp_parse_args( $query['additional'], $query );
|
|
|
99 |
unset( $query['additional'] );
|
100 |
}
|
101 |
|
218 |
* @return int
|
219 |
*/
|
220 |
function siteorigin_widget_post_selector_count_posts($query){
|
221 |
+
$query = siteorigin_widget_post_selector_process_query( $query );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
$posts = new WP_Query($query);
|
223 |
return $posts->found_posts;
|
224 |
}
|
228 |
*/
|
229 |
function siteorigin_widget_post_selector_get_posts_action(){
|
230 |
if ( empty( $_REQUEST['_widgets_nonce'] ) || !wp_verify_nonce( $_REQUEST['_widgets_nonce'], 'widgets_action' ) ) return;
|
231 |
+
|
232 |
+
$query = siteorigin_widget_post_selector_process_query( stripslashes( $_POST['query'] ) );
|
|
|
|
|
|
|
|
|
|
|
|
|
233 |
|
234 |
if(!empty($_POST['ignore_pagination'])) {
|
235 |
$query['posts_per_page'] = 100;
|
273 |
$results = array();
|
274 |
$r = new WP_Query( array('s' => $term, 'post_status' => 'publish', 'posts_per_page' => 20, 'post_type' => $type) );
|
275 |
foreach($r->posts as $post) {
|
|
|
|
|
276 |
$results[] = array(
|
277 |
'label' => $post->post_title,
|
278 |
'value' => $post->ID,
|
base/inc/widget-manager.class.php
CHANGED
@@ -1,5 +1,10 @@
|
|
1 |
<?php
|
2 |
|
|
|
|
|
|
|
|
|
|
|
3 |
class SiteOrigin_Widgets_Widget_Manager {
|
4 |
/**
|
5 |
* Regsitered widgets
|
@@ -22,7 +27,7 @@ class SiteOrigin_Widgets_Widget_Manager {
|
|
22 |
static $single;
|
23 |
|
24 |
if( empty($single) ) {
|
25 |
-
$single = new
|
26 |
}
|
27 |
|
28 |
return $single;
|
@@ -32,6 +37,7 @@ class SiteOrigin_Widgets_Widget_Manager {
|
|
32 |
* @param $id
|
33 |
* @param $path
|
34 |
* @param bool|false $class
|
|
|
35 |
*/
|
36 |
public function register( $id, $path, $class = false ){
|
37 |
$path = realpath( $path );
|
@@ -131,4 +137,4 @@ function siteorigin_widget_get_plugin_dir_path($id){
|
|
131 |
*/
|
132 |
function siteorigin_widget_get_plugin_dir_url($id){
|
133 |
return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_url($id);
|
134 |
-
}
|
1 |
<?php
|
2 |
|
3 |
+
/**
|
4 |
+
* Handles registering Widgets Bundle widgets.
|
5 |
+
*
|
6 |
+
* Class SiteOrigin_Widgets_Widget_Manager
|
7 |
+
*/
|
8 |
class SiteOrigin_Widgets_Widget_Manager {
|
9 |
/**
|
10 |
* Regsitered widgets
|
27 |
static $single;
|
28 |
|
29 |
if( empty($single) ) {
|
30 |
+
$single = new self();
|
31 |
}
|
32 |
|
33 |
return $single;
|
37 |
* @param $id
|
38 |
* @param $path
|
39 |
* @param bool|false $class
|
40 |
+
* @return mixed
|
41 |
*/
|
42 |
public function register( $id, $path, $class = false ){
|
43 |
$path = realpath( $path );
|
137 |
*/
|
138 |
function siteorigin_widget_get_plugin_dir_url($id){
|
139 |
return SiteOrigin_Widgets_Widget_Manager::single()->get_plugin_dir_url($id);
|
140 |
+
}
|
base/inc/widgets/base-slider.class.php
CHANGED
@@ -90,6 +90,13 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
90 |
'label' => __('Navigation size', 'so-widgets-bundle'),
|
91 |
'default' => '25',
|
92 |
),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
);
|
94 |
}
|
95 |
|
@@ -132,6 +139,7 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
132 |
'pagination' => true,
|
133 |
'speed' => $controls['speed'],
|
134 |
'timeout' => $controls['timeout'],
|
|
|
135 |
);
|
136 |
}
|
137 |
|
@@ -205,10 +213,11 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
205 |
* @param $frame
|
206 |
*/
|
207 |
function render_frame( $i, $frame ){
|
208 |
-
$background = $this->get_frame_background( $i, $frame )
|
209 |
-
$background = wp_parse_args($background, array(
|
210 |
'color' => false,
|
211 |
'image' => false,
|
|
|
|
|
212 |
'opacity' => 1,
|
213 |
'url' => false,
|
214 |
'new_window' => false,
|
@@ -217,33 +226,41 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
217 |
'videos-sizing' => 'background', // options for video sizing are background or full
|
218 |
) );
|
219 |
|
220 |
-
$
|
221 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
222 |
|
223 |
if( $background['opacity'] >= 1 ) {
|
224 |
-
if( !empty($background['image']) )
|
|
|
|
|
225 |
}
|
226 |
|
227 |
if( ! empty( $background['url'] ) ) {
|
228 |
-
$
|
229 |
}
|
230 |
|
231 |
-
$wrapper_attributes = array(
|
232 |
-
'class' => 'sow-slider-image'
|
233 |
-
);
|
234 |
-
|
235 |
if( !empty($background['image']) && !empty($background['image-sizing']) ) {
|
236 |
-
$wrapper_attributes['class']
|
237 |
}
|
238 |
if( !empty( $background['url'] ) ) {
|
239 |
-
$wrapper_attributes['data-url'] = json_encode(array(
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
}
|
|
|
|
|
|
|
|
|
244 |
|
245 |
?>
|
246 |
-
<li <?php foreach( $wrapper_attributes as $attr => $val ) echo $attr . '="' . esc_attr( $val ) . '" ';
|
247 |
<?php
|
248 |
$this->render_frame_contents( $i, $frame );
|
249 |
if( !empty( $background['videos'] ) ) {
|
@@ -251,7 +268,19 @@ abstract class SiteOrigin_Widget_Base_Slider extends SiteOrigin_Widget {
|
|
251 |
}
|
252 |
|
253 |
if( $background['opacity'] < 1 && !empty($background['image']) ) {
|
254 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
255 |
}
|
256 |
|
257 |
?>
|
90 |
'label' => __('Navigation size', 'so-widgets-bundle'),
|
91 |
'default' => '25',
|
92 |
),
|
93 |
+
|
94 |
+
'swipe' => array(
|
95 |
+
'type' => 'checkbox',
|
96 |
+
'label' => __( 'Swipe Control', 'so-widgets-bundle' ),
|
97 |
+
'description' => __( 'Allow users to swipe through frames on mobile devices.', 'so-widgets-bundle' ),
|
98 |
+
'default' => true,
|
99 |
+
)
|
100 |
);
|
101 |
}
|
102 |
|
139 |
'pagination' => true,
|
140 |
'speed' => $controls['speed'],
|
141 |
'timeout' => $controls['timeout'],
|
142 |
+
'swipe' => $controls['swipe'],
|
143 |
);
|
144 |
}
|
145 |
|
213 |
* @param $frame
|
214 |
*/
|
215 |
function render_frame( $i, $frame ){
|
216 |
+
$background = wp_parse_args( $this->get_frame_background( $i, $frame ), array(
|
|
|
217 |
'color' => false,
|
218 |
'image' => false,
|
219 |
+
'image-width' => 0,
|
220 |
+
'image-height' => 0,
|
221 |
'opacity' => 1,
|
222 |
'url' => false,
|
223 |
'new_window' => false,
|
226 |
'videos-sizing' => 'background', // options for video sizing are background or full
|
227 |
) );
|
228 |
|
229 |
+
$wrapper_attributes = array(
|
230 |
+
'class' => array( 'sow-slider-image' ),
|
231 |
+
'style' => array(),
|
232 |
+
);
|
233 |
+
|
234 |
+
if( !empty($background['color']) ) {
|
235 |
+
$wrapper_attributes['style'][] = 'background-color: ' . esc_attr($background['color']);
|
236 |
+
}
|
237 |
|
238 |
if( $background['opacity'] >= 1 ) {
|
239 |
+
if( !empty($background['image']) ) {
|
240 |
+
$wrapper_attributes['style'][] = 'background-image: url(' . esc_url($background['image']) . ')';
|
241 |
+
}
|
242 |
}
|
243 |
|
244 |
if( ! empty( $background['url'] ) ) {
|
245 |
+
$wrapper_attributes['style'][] = 'cursor: pointer;';
|
246 |
}
|
247 |
|
|
|
|
|
|
|
|
|
248 |
if( !empty($background['image']) && !empty($background['image-sizing']) ) {
|
249 |
+
$wrapper_attributes['class'][] = ' ' . 'sow-slider-image-' . $background['image-sizing'];
|
250 |
}
|
251 |
if( !empty( $background['url'] ) ) {
|
252 |
+
$wrapper_attributes['data-url'] = json_encode( array(
|
253 |
+
'url' => sow_esc_url($background['url']),
|
254 |
+
'new_window' => !empty( $background['new_window'] )
|
255 |
+
) );
|
256 |
}
|
257 |
+
$wrapper_attributes = apply_filters( 'siteorigin_widgets_slider_wrapper_attributes', $wrapper_attributes, $frame, $background );
|
258 |
+
|
259 |
+
$wrapper_attributes['class'] = implode( ' ', $wrapper_attributes['class'] );
|
260 |
+
$wrapper_attributes['style'] = implode( ';', $wrapper_attributes['style'] );
|
261 |
|
262 |
?>
|
263 |
+
<li <?php foreach( $wrapper_attributes as $attr => $val ) echo $attr . '="' . esc_attr( $val ) . '" '; ?>>
|
264 |
<?php
|
265 |
$this->render_frame_contents( $i, $frame );
|
266 |
if( !empty( $background['videos'] ) ) {
|
268 |
}
|
269 |
|
270 |
if( $background['opacity'] < 1 && !empty($background['image']) ) {
|
271 |
+
$overlay_attributes = array(
|
272 |
+
'class' => array( 'sow-slider-image-overlay', 'sow-slider-image-' . $background['image-sizing'] ),
|
273 |
+
'style' => array(
|
274 |
+
'background-image: url(' . $background['image'] . ')',
|
275 |
+
'opacity: ' . floatval( $background['opacity'] ),
|
276 |
+
)
|
277 |
+
);
|
278 |
+
$overlay_attributes = apply_filters( 'siteorigin_widgets_slider_overlay_attributes', $overlay_attributes, $frame, $background );
|
279 |
+
|
280 |
+
$overlay_attributes['class'] = implode( ' ', $overlay_attributes['class'] );
|
281 |
+
$overlay_attributes['style'] = implode( ';', $overlay_attributes['style'] );
|
282 |
+
|
283 |
+
?><div <?php foreach( $overlay_attributes as $attr => $val ) echo $attr . '="' . esc_attr( $val ) . '" '; ?> ></div><?php
|
284 |
}
|
285 |
|
286 |
?>
|
base/js/admin.js
CHANGED
@@ -369,6 +369,13 @@
|
|
369 |
var changeIconFamily = function(){
|
370 |
// Fetch the family icons from the server
|
371 |
var family = $is.find('select.siteorigin-widget-icon-family').val();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
if(typeof family === 'undefined' || family === '') {
|
373 |
return;
|
374 |
}
|
@@ -487,6 +494,15 @@
|
|
487 |
} );
|
488 |
} );
|
489 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
490 |
///////////////////////////////////////
|
491 |
// Now lets handle the state emitters
|
492 |
|
369 |
var changeIconFamily = function(){
|
370 |
// Fetch the family icons from the server
|
371 |
var family = $is.find('select.siteorigin-widget-icon-family').val();
|
372 |
+
|
373 |
+
var dataIcons = $is.find('select.siteorigin-widget-icon-family option:selected' ).data('icons');
|
374 |
+
if( dataIcons !== null ) {
|
375 |
+
iconWidgetCache[family] = dataIcons;
|
376 |
+
}
|
377 |
+
|
378 |
+
|
379 |
if(typeof family === 'undefined' || family === '') {
|
380 |
return;
|
381 |
}
|
494 |
} );
|
495 |
} );
|
496 |
|
497 |
+
///////////////////////////////////////
|
498 |
+
// Setup the Builder fields
|
499 |
+
if( typeof jQuery.fn.soPanelsSetupBuilderWidget !== 'undefined' ) {
|
500 |
+
$fields.filter( '.siteorigin-widget-field-type-builder' ).each( function(){
|
501 |
+
var $$ = $(this);
|
502 |
+
$$.find('> .siteorigin-page-builder-field' ).soPanelsSetupBuilderWidget();
|
503 |
+
} );
|
504 |
+
}
|
505 |
+
|
506 |
///////////////////////////////////////
|
507 |
// Now lets handle the state emitters
|
508 |
|
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&&-1!==o.attr("name").indexOf("__i__"))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,c,g={},u=window.sowForms.getRepeaterId(i);if(u!==!1){var p={};for(var w in a)p[w.replace("{$repeater}",u)]=a[w];a=p}for(var w in a)if(f=!1,r=w.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?$/),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 g[o.group];else{c=o.name.split(",").map(function(e){return e.trim()});for(var m=0;m<c.length&&!(f=o.group===t&&c[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]:[]);g[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.find("> .media-field-wrapper").each(function(){var i=e(this),t=i.closest(".siteorigin-widget-field");i.find("a.media-upload-button").click(function(i){if("undefined"!=typeof wp.media){var n=e(this),a=e(this).closest(".siteorigin-widget-field"),r=e(this).data("frame");return r?(r.open(),!1):(r=wp.media({title:n.data("choose"),library:{type:n.data("library").split(",").map(function(e){return e.trim()})},button:{text:n.data("update"),close:!1}}),n.data("frame",r),r.on("select",function(){var e=r.state().get("selection").first().attributes;a.find(".current .title").html(e.title);var i=a.find("input[type=hidden]");i.val(e.id),i.trigger("change"),"undefined"!=typeof e.sizes?"undefined"!=typeof e.sizes.thumbnail?a.find(".current .thumbnail").attr("src",e.sizes.thumbnail.url).fadeIn():a.find(".current .thumbnail").attr("src",e.sizes.full.url).fadeIn():a.find(".current .thumbnail").attr("src",e.icon).fadeIn(),t.find(".media-remove-button").removeClass("remove-hide"),r.close()}),r.open(),!1)}}),i.find(".current").mouseenter(function(){var i=e(this).find(".title");""!==i.html()&&i.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),t.find("a.media-remove-button").click(function(i){i.preventDefault(),t.find(".current .title").html(""),t.find("input[type=hidden]").val(""),t.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")})}),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();"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=" "),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)})});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),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():!0:r[a[s]]=!1;else if("radio"===i.attr("type"))i.is(":checked")&&(r[a[s]]=""!==i.val()?i.val():!0);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 c=i.closest(".wp-picker-container"),g=i.closest(".siteorigin-widget-field");c.remove(),g.append(i.remove())}else{var u=a.find('[name="'+l+'"]');u.length&&null!=u.val()&&i.val(u.val())}if(s){var p=s.replace(/-\d+$/,"");d[p]||(d[p]=t.find(".siteorigin-widget-input[id^="+p+"]").not("[id*=_id_]").length+1);var w=p+"-"+d[p]++;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(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+") *$"),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-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};
|
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&&-1!==o.attr("name").indexOf("__i__"))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={},u=window.sowForms.getRepeaterId(i);if(u!==!1){var p={};for(var w in a)p[w.replace("{$repeater}",u)]=a[w];a=p}for(var w in a)if(f=!1,r=w.match(/^([a-zA-Z0-9_-]+)(\[([a-zA-Z0-9_\-,]+)\])?(\[\])?$/),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.find("> .media-field-wrapper").each(function(){var i=e(this),t=i.closest(".siteorigin-widget-field");i.find("a.media-upload-button").click(function(i){if("undefined"!=typeof wp.media){var n=e(this),a=e(this).closest(".siteorigin-widget-field"),r=e(this).data("frame");return r?(r.open(),!1):(r=wp.media({title:n.data("choose"),library:{type:n.data("library").split(",").map(function(e){return e.trim()})},button:{text:n.data("update"),close:!1}}),n.data("frame",r),r.on("select",function(){var e=r.state().get("selection").first().attributes;a.find(".current .title").html(e.title);var i=a.find("input[type=hidden]");i.val(e.id),i.trigger("change"),"undefined"!=typeof e.sizes?"undefined"!=typeof e.sizes.thumbnail?a.find(".current .thumbnail").attr("src",e.sizes.thumbnail.url).fadeIn():a.find(".current .thumbnail").attr("src",e.sizes.full.url).fadeIn():a.find(".current .thumbnail").attr("src",e.icon).fadeIn(),t.find(".media-remove-button").removeClass("remove-hide"),r.close()}),r.open(),!1)}}),i.find(".current").mouseenter(function(){var i=e(this).find(".title");""!==i.html()&&i.fadeIn("fast")}).mouseleave(function(){e(this).find(".title").clearQueue().fadeOut("fast")}),t.find("a.media-remove-button").click(function(i){i.preventDefault(),t.find(".current .title").html(""),t.find("input[type=hidden]").val(""),t.find(".current .thumbnail").fadeOut("fast"),e(this).addClass("remove-hide")})}),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=" "),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),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():!0:r[a[s]]=!1;else if("radio"===i.attr("type"))i.is(":checked")&&(r[a[s]]=""!==i.val()?i.val():!0);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 u=a.find('[name="'+l+'"]');u.length&&null!=u.val()&&i.val(u.val())}if(s){var p=s.replace(/-\d+$/,"");d[p]||(d[p]=t.find(".siteorigin-widget-input[id^="+p+"]").not("[id*=_id_]").length+1);var w=p+"-"+d[p]++;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(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+") *$"),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-1!==t.split(",").map(function(e){return e.trim()}).indexOf(e)})}};
|
base/js/posts-selector.js
CHANGED
@@ -355,7 +355,7 @@ var soWidgetPostSelector = ( function ($, _) {
|
|
355 |
|
356 |
// The additional query arguments field
|
357 |
this.form.append('<div class="query-builder-form-field">' + sowPostsSelectorTpl.fields.additional + '</div>');
|
358 |
-
if( typeof this.model.get('additional') !== 'undefined' ) this.form.find('input[name="additional"]').val( this.model.get('additional')
|
359 |
|
360 |
|
361 |
var orderField = this.form.find('input[name="order"]');
|
@@ -468,7 +468,7 @@ var soWidgetPostSelector = ( function ($, _) {
|
|
468 |
this.model.set( 'order', this.$el.find('*[name="order"]').val() );
|
469 |
this.model.set( 'posts_per_page', this.$el.find('*[name="posts_per_page"]').val() );
|
470 |
this.model.set( 'sticky', this.$el.find('*[name="sticky"]').val() );
|
471 |
-
this.model.set( 'additional', this.$el.find('*[name="additional"]').val()
|
472 |
|
473 |
this.model.set( 'query', this.model.getQuery() );
|
474 |
|
355 |
|
356 |
// The additional query arguments field
|
357 |
this.form.append('<div class="query-builder-form-field">' + sowPostsSelectorTpl.fields.additional + '</div>');
|
358 |
+
if( typeof this.model.get('additional') !== 'undefined' ) this.form.find('input[name="additional"]').val( decodeURIComponent( this.model.get('additional') ) );
|
359 |
|
360 |
|
361 |
var orderField = this.form.find('input[name="order"]');
|
468 |
this.model.set( 'order', this.$el.find('*[name="order"]').val() );
|
469 |
this.model.set( 'posts_per_page', this.$el.find('*[name="posts_per_page"]').val() );
|
470 |
this.model.set( 'sticky', this.$el.find('*[name="sticky"]').val() );
|
471 |
+
this.model.set( 'additional', encodeURIComponent( this.$el.find('*[name="additional"]').val() ) );
|
472 |
|
473 |
this.model.set( 'query', this.model.getQuery() );
|
474 |
|
base/js/posts-selector.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var soWidgetPostSelector=function(e,t){var s,i,o,n,r,l,d,a;s=self.Post=Backbone.Model.extend({title:null,thumbnail:null,id:null}),i=self.PostCollection=Backbone.Collection.extend({model:s,foundPosts:null,updateWithQuery:function(t){if(""!==t){var s=this;e.post(sowPostsSelectorTpl.ajaxurl,{action:"sow_get_posts",query:t,ignore_pagination:!0},function(e){s.foundPosts=e.found_posts,s.reset(e.posts)})}}}),l=self.Query=Backbone.Model.extend({query:null,syncField:null,post_type:null,terms:null,post_status:null,posts_per_page:null,post__in:null,tax_query:null,date_range:null,orderby:null,order:null,sticky:null,defaults:{post_type:"post",orderby:"post_date",order:"DESC",posts_per_page:"",post_status:"publish",sticky:""},initialize:function(e,t){this.set(this.parseQuery(e.query))},getQuery:function(){var e=[];return"undefined"!=typeof this.get("post_type")&&e.push("post_type="+this.get("post_type")),"undefined"==typeof this.get("post__in")||t.isEmpty(this.get("post__in"))||e.push("post__in="+this.get("post__in").join(",")),"undefined"==typeof this.get("tax_query")||t.isEmpty(this.get("tax_query"))||e.push("tax_query="+this.get("tax_query").join(",")),"undefined"==typeof this.get("date_query")||t.isEmpty(this.get("date_query"))||e.push("date_query="+JSON.stringify(this.get("date_query"))),"undefined"!=typeof this.get("orderby")&&e.push("orderby="+this.get("orderby")),"undefined"!=typeof this.get("order")&&e.push("order="+this.get("order")),"undefined"!=typeof this.get("posts_per_page")&&e.push("posts_per_page="+this.get("posts_per_page")),"undefined"!=typeof this.get("sticky")&&e.push("sticky="+this.get("sticky")),"undefined"!=typeof this.get("additional")&&e.push("additional="+this.get("additional")),e.join("&")},setQuery:function(e){return this.set(this.parseQuery(e)),this},parseQuery:function(e){for(var t,s=/([^&=]+)=?([^&]*)/g,i=/\+/g,o=function(e){return decodeURIComponent(e.replace(i," "))},n={};t=s.exec(e);){var r=o(t[1]),l=o(t[2]);"[]"===r.substring(r.length-2)?(r=r.substring(0,r.length-2),(n[r]||(n[r]=[])).push(l)):n[r]=l}var d={};return n.hasOwnProperty("post_type")&&(d.post_type=n.post_type),n.hasOwnProperty("post__in")&&(d.post__in=n.post__in.split(",")),n.hasOwnProperty("tax_query")&&(d.tax_query=n.tax_query.split(",")),n.hasOwnProperty("date_query")&&(d.date_query=JSON.parse(n.date_query)),n.hasOwnProperty("orderby")&&(d.orderby=n.orderby),n.hasOwnProperty("order")&&(d.order=n.order),n.hasOwnProperty("posts_per_page")&&(d.posts_per_page=n.posts_per_page),n.hasOwnProperty("sticky")&&(d.sticky=n.sticky),n.hasOwnProperty("additional")&&(d.additional=n.additional),d.query=e,d},sync:function(e,t){if("create"===e){var s=this.syncField.val(),i=this.getQuery();s!==i&&(this.syncField.val(i),this.syncField.trigger("change"))}else this.setQuery(this.syncField.val())},setSyncField:function(e){this.syncField=e}}),a=self.QueryBuilder=Backbone.View.extend({attached:!1,rendered:!1,views:{},activeView:null,events:{"click .media-modal-backdrop, .media-modal-close":"escapeHandler","click .media-toolbar-primary .button":"buttonHandler"},initialize:function(){this.listenTo(this.model,"change",this.queryModelChange);var e=new i;this.views.postSummary=new o({posts:e,el:this.el}),this.views.postSummary.builder=this,this.views.postSummary.posts.updateWithQuery(this.model.getQuery()),this.addSubView("form",new d({el:this.el,model:this.model})),this.addSubView("postsView",new n({el:this.el,posts:e})),this.addSubView("postsSelect",new r({el:this.el,model:this.model})),this.views.form.bind("buttonHandler",this.close,this)},changeModel:function(e){this.model=e,this.render()},render:function(){return this.$el.html(sowPostsSelectorTpl.modal),this.$el.find(".media-toolbar-primary .button").html(this.views[this.activeView].buttonText),this.$el.find(".media-frame-title h1").html(this.views[this.activeView].modalTitle),this.rendered=!0,"postsSelect"!==this.activeView&&this.views.postSummary.render(),this.views[this.activeView].render(),this},close:function(){return this.$el.hide(),this.trigger("close"),this.model.save(),this},open:function(){this.show(),this.setActiveView("form"),this.trigger("open"),this.model.fetch()},save:function(){this.close(),this.model.save(),this.trigger("save")},attach:function(){return this.rendered||this.render(),this.attached||(this.$el.appendTo("body"),this.attached=!0),this},show:function(){this.attach(),this.$el.is(":visible")||this.$el.show()},escapeHandler:function(e){e.preventDefault(),this.close()},buttonHandler:function(e){e.preventDefault(),this.views[this.activeView].buttonHandler().trigger("buttonHandler")},addSubView:function(e,t){this.views[e]=t,t.builder=this,null===this.activeView&&(this.activeView=e)},setActiveView:function(e){this.activeView=e,this.render()},queryModelChange:function(){this.views.postSummary.posts.updateWithQuery(this.model.getQuery())}}),d=self.QueryForm=Backbone.View.extend({buttonText:"Save Query",modalTitle:"Build Posts Query",form:null,initialize:function(e){},render:function(){var t=this;if(this.form=e('<div class="query-builder-form>"></div>'),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.post_type+"</div>"),"undefined"!=typeof this.model.get("post_type")&&this.form.find('select[name="post_type"]').val(this.model.get("post_type")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.post__in+"</div>"),"undefined"!=typeof this.model.get("post__in")&&this.form.find('input[name="post__in"]').val(this.model.get("post__in").join(",")),this.form.append('<div class="query-builder-form-field ui-front">'+sowPostsSelectorTpl.fields.tax_query+"</div>"),"undefined"!=typeof this.model.get("tax_query")&&this.form.find('input[name="tax_query"]').val(this.model.get("tax_query")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.date_query+"</div>"),"undefined"!=typeof this.model.get("date_query")){var s=this.model.get("date_query");s.hasOwnProperty("after")&&this.form.find('input[name="after"]').val(s.after),s.hasOwnProperty("before")&&this.form.find('input[name="before"]').val(s.before)}this.form.append(e('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.orderby+"</div>").disableSelection()),"undefined"!=typeof this.model.get("orderby")&&this.form.find('select[name="orderby"]').val(this.model.get("orderby")),"undefined"!=typeof this.model.get("order")&&this.form.find('input[name="order"]').val(this.model.get("order")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.posts_per_page+"</div>"),"undefined"!=typeof this.model.get("posts_per_page")&&this.form.find('input[name="posts_per_page"]').val(this.model.get("posts_per_page")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.sticky+"</div>"),"undefined"!=typeof this.model.get("sticky")&&this.form.find('select[name="sticky"]').val(this.model.get("sticky")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.additional+"</div>"),"undefined"!=typeof this.model.get("additional")&&this.form.find('input[name="additional"]').val(this.model.get("additional").split(",").join("&"));var i=this.form.find('input[name="order"]'),o=i.closest(".query-builder-form-field").find(".sow-order-button"),n=function(){"DESC"===i.val()?(o.removeClass("sow-order-button-asc"),o.addClass("sow-order-button-desc")):(o.addClass("sow-order-button-asc"),o.removeClass("sow-order-button-desc"))};return n(),o.click(function(e){return e.preventDefault(),"DESC"===i.val()?i.val("ASC"):i.val("DESC"),n(),t.updateModel(),!1}),this.$el.find(".query-builder-content").empty().append(this.form),this.$el.find(".query-builder-form-field select, .query-builder-form-field input").change(function(){t.updateModel()}),this.$el.find(".query-builder-form-field .sow-select-posts").click(function(e){e.preventDefault(),t.builder.setActiveView("postsSelect")}),this.form.find('input[name="tax_query"]').autocomplete({source:function(t,s){e.getJSON(sowPostsSelectorTpl.ajaxurl,{term:t.term.split(/,\s*/).pop(),action:"sow_search_terms"},s)},search:function(){var e=this.value.split(/,\s*/).pop();return e.length<1?!1:void 0},focus:function(){return!1},select:function(e,s){var i=this.value.split(/,\s*/);return i.pop(),i.push(s.item.value),i.push(""),this.value=i.join(", "),t.updateModel(),!1}}),this},updateModel:function(){if(this.model.set("post_type",this.$el.find('*[name="post_type"]').val()),""!==this.$el.find('*[name="post__in"]').val().trim()?this.model.set("post__in",this.$el.find('*[name="post__in"]').val().split(",").map(function(e){return Number(e.trim())})):this.model.set("post__in",[]),""!==this.$el.find('*[name="tax_query"]').val().trim()){var e=this.$el.find('*[name="tax_query"]').val().split(",").map(function(e){return e.trim()});this.model.set("tax_query",t.compact(e))}else this.model.set("tax_query",[]);return this.model.set("date_query",{after:this.$el.find('*[name="after"]').val(),before:this.$el.find('*[name="before"]').val()}),this.model.set("orderby",this.$el.find('*[name="orderby"]').val()),this.model.set("order",this.$el.find('*[name="order"]').val()),this.model.set("posts_per_page",this.$el.find('*[name="posts_per_page"]').val()),this.model.set("sticky",this.$el.find('*[name="sticky"]').val()),this.model.set("additional",this.$el.find('*[name="additional"]').val().split("&").join(",")),this.model.set("query",this.model.getQuery()),this},buttonHandler:function(){return this.updateModel(),this}}),o=self.PostCollectionSummaryView=Backbone.View.extend({template:t.template(sowPostsSelectorTpl.foundPosts),posts:null,initialize:function(e){this.posts=e.posts,this.posts.bind("reset",this.render,this)},render:function(){this.$el.find(".media-toolbar-secondary").html(this.template({foundPosts:this.posts.foundPosts}));var e=this;this.$el.find(".media-toolbar-secondary .preview-query-posts").click(function(t){t.preventDefault(),e.builder.setActiveView("postsView")})}}),n=self.PostCollectionView=Backbone.View.extend({buttonText:"Back",modalTitle:"Current Posts",template:t.template(sowPostsSelectorTpl.postSummary),posts:null,initialize:function(e){this.posts=e.posts},render:function(){var e=this.$el.find(".query-builder-content").empty().append('<div class="sow-current-posts"></div>').find(".sow-current-posts");e=this.$el.find(".query-builder-content");var t=this.template;return this.posts.each(function(s){e.append(t(s.attributes))}),this},buttonHandler:function(){return this.builder.setActiveView("form"),this}}),r=self.PostSelectView=Backbone.View.extend({buttonText:"Finish Selection",modalTitle:"Select Posts",sortable:null,postCache:{},postTemplate:t.template(sowPostsSelectorTpl.postSummary),initialize:function(){this.postCache={}},render:function(){var t=this.model.get("post__in"),s=this.model.get("post_type");this.$el.find(".query-builder-content").empty().html(sowPostsSelectorTpl.selector),this.sortable=this.$el.find(".query-builder-content #sow-post-selector .sow-posts-sortable").sortable({placeholder:"ui-state-highlight",forcePlaceholderSize:!0,items:"> .sow-post-selector-summary"}),this.addPosts(t);var i=this,o=this.$el.find(".query-builder-content #sow-post-selector .sow-search-field");return o.autocomplete({source:function(t,i){t.type=s,t.action="sow_search_posts",e.get(sowPostsSelectorTpl.ajaxurl,t,i)},minLength:0,select:function(t,s){return t.preventDefault(),e(this).val(""),i.addPosts([s.item.value]),!1}}),o.focusin(function(){o.autocomplete("search",o.val())}),this.$el.find(".query-builder-content").on("click",".sow-remove",function(t){t.preventDefault();var s=e(this);s.closest(".sow-post-selector-summary").fadeOut("fast",function(){e(this).remove(),i.sortable.sortable("refresh")})}),this},addPosts:function(s){if("undefined"!=typeof s&&!t.isEmpty(s)){for(var i=[],o=0;o<s.length;o++)"undefined"==typeof this.postCache[s[o]]&&i.push(s[o]);var n=this;t.isEmpty(i)||e.post(sowPostsSelectorTpl.ajaxurl,{action:"sow_get_posts",query:"post_type=_all&posts_per_page=-1&post__in="+i.join(",")},function(e){console.log(e),"undefined"!=typeof e.posts&&t.each(e.posts,function(e,t){n.postCache[e.id]={id:e.id,title:e.title,thumbnail:e.thumbnail,editUrl:e.editUrl}}),n.refreshLoading()});for(var r,o=0;o<s.length;o++)r="undefined"==typeof this.postCache[s[o]]?e(this.postTemplate({id:s[o],title:"",thumbnail:"",editUrl:"#"})).addClass("sow-post-loading"):e(this.postTemplate(this.postCache[s[o]])),r.appendTo(this.sortable);return this.sortable.sortable("refresh"),this}},refreshLoading:function(){var t=this;this.sortable.find(".sow-post-selector-summary.sow-post-loading").each(function(){var s=e(this),i=s.data("id");if("undefined"!=typeof t.postCache[i]){s.removeClass("sow-post-loading");var o=e(t.postTemplate(t.postCache[i]));s.html(o.html())}})},buttonHandler:function(){var s=[];return this.sortable.find(".sow-post-selector-summary").each(function(){s.push(Number(e(this).data("id")))}),this.model.set("post__in",s),t.isEmpty(s)||(this.model.set("post_type","_all"),this.model.set("orderby","post__in")),this.builder.setActiveView("form"),this}});var u=new a({model:new l({query:""})});jQuery(function(e){e("body").on("click",".sow-select-posts",function(t){t.preventDefault();var s=e(this);u.model.setSyncField(s.siblings(".siteorigin-widget-input")),u.model.sync("update"),u.views.postSummary.posts.on("reset",function(e){s.find(".sow-current-count").text(e.foundPosts)}),u.open()})})}(jQuery,_);
|
1 |
+
var soWidgetPostSelector=function(e,t){var s,i,o,n,r,l,d,a;s=self.Post=Backbone.Model.extend({title:null,thumbnail:null,id:null}),i=self.PostCollection=Backbone.Collection.extend({model:s,foundPosts:null,updateWithQuery:function(t){if(""!==t){var s=this;e.post(sowPostsSelectorTpl.ajaxurl,{action:"sow_get_posts",query:t,ignore_pagination:!0},function(e){s.foundPosts=e.found_posts,s.reset(e.posts)})}}}),l=self.Query=Backbone.Model.extend({query:null,syncField:null,post_type:null,terms:null,post_status:null,posts_per_page:null,post__in:null,tax_query:null,date_range:null,orderby:null,order:null,sticky:null,defaults:{post_type:"post",orderby:"post_date",order:"DESC",posts_per_page:"",post_status:"publish",sticky:""},initialize:function(e,t){this.set(this.parseQuery(e.query))},getQuery:function(){var e=[];return"undefined"!=typeof this.get("post_type")&&e.push("post_type="+this.get("post_type")),"undefined"==typeof this.get("post__in")||t.isEmpty(this.get("post__in"))||e.push("post__in="+this.get("post__in").join(",")),"undefined"==typeof this.get("tax_query")||t.isEmpty(this.get("tax_query"))||e.push("tax_query="+this.get("tax_query").join(",")),"undefined"==typeof this.get("date_query")||t.isEmpty(this.get("date_query"))||e.push("date_query="+JSON.stringify(this.get("date_query"))),"undefined"!=typeof this.get("orderby")&&e.push("orderby="+this.get("orderby")),"undefined"!=typeof this.get("order")&&e.push("order="+this.get("order")),"undefined"!=typeof this.get("posts_per_page")&&e.push("posts_per_page="+this.get("posts_per_page")),"undefined"!=typeof this.get("sticky")&&e.push("sticky="+this.get("sticky")),"undefined"!=typeof this.get("additional")&&e.push("additional="+this.get("additional")),e.join("&")},setQuery:function(e){return this.set(this.parseQuery(e)),this},parseQuery:function(e){for(var t,s=/([^&=]+)=?([^&]*)/g,i=/\+/g,o=function(e){return decodeURIComponent(e.replace(i," "))},n={};t=s.exec(e);){var r=o(t[1]),l=o(t[2]);"[]"===r.substring(r.length-2)?(r=r.substring(0,r.length-2),(n[r]||(n[r]=[])).push(l)):n[r]=l}var d={};return n.hasOwnProperty("post_type")&&(d.post_type=n.post_type),n.hasOwnProperty("post__in")&&(d.post__in=n.post__in.split(",")),n.hasOwnProperty("tax_query")&&(d.tax_query=n.tax_query.split(",")),n.hasOwnProperty("date_query")&&(d.date_query=JSON.parse(n.date_query)),n.hasOwnProperty("orderby")&&(d.orderby=n.orderby),n.hasOwnProperty("order")&&(d.order=n.order),n.hasOwnProperty("posts_per_page")&&(d.posts_per_page=n.posts_per_page),n.hasOwnProperty("sticky")&&(d.sticky=n.sticky),n.hasOwnProperty("additional")&&(d.additional=n.additional),d.query=e,d},sync:function(e,t){if("create"===e){var s=this.syncField.val(),i=this.getQuery();s!==i&&(this.syncField.val(i),this.syncField.trigger("change"))}else this.setQuery(this.syncField.val())},setSyncField:function(e){this.syncField=e}}),a=self.QueryBuilder=Backbone.View.extend({attached:!1,rendered:!1,views:{},activeView:null,events:{"click .media-modal-backdrop, .media-modal-close":"escapeHandler","click .media-toolbar-primary .button":"buttonHandler"},initialize:function(){this.listenTo(this.model,"change",this.queryModelChange);var e=new i;this.views.postSummary=new o({posts:e,el:this.el}),this.views.postSummary.builder=this,this.views.postSummary.posts.updateWithQuery(this.model.getQuery()),this.addSubView("form",new d({el:this.el,model:this.model})),this.addSubView("postsView",new n({el:this.el,posts:e})),this.addSubView("postsSelect",new r({el:this.el,model:this.model})),this.views.form.bind("buttonHandler",this.close,this)},changeModel:function(e){this.model=e,this.render()},render:function(){return this.$el.html(sowPostsSelectorTpl.modal),this.$el.find(".media-toolbar-primary .button").html(this.views[this.activeView].buttonText),this.$el.find(".media-frame-title h1").html(this.views[this.activeView].modalTitle),this.rendered=!0,"postsSelect"!==this.activeView&&this.views.postSummary.render(),this.views[this.activeView].render(),this},close:function(){return this.$el.hide(),this.trigger("close"),this.model.save(),this},open:function(){this.show(),this.setActiveView("form"),this.trigger("open"),this.model.fetch()},save:function(){this.close(),this.model.save(),this.trigger("save")},attach:function(){return this.rendered||this.render(),this.attached||(this.$el.appendTo("body"),this.attached=!0),this},show:function(){this.attach(),this.$el.is(":visible")||this.$el.show()},escapeHandler:function(e){e.preventDefault(),this.close()},buttonHandler:function(e){e.preventDefault(),this.views[this.activeView].buttonHandler().trigger("buttonHandler")},addSubView:function(e,t){this.views[e]=t,t.builder=this,null===this.activeView&&(this.activeView=e)},setActiveView:function(e){this.activeView=e,this.render()},queryModelChange:function(){this.views.postSummary.posts.updateWithQuery(this.model.getQuery())}}),d=self.QueryForm=Backbone.View.extend({buttonText:"Save Query",modalTitle:"Build Posts Query",form:null,initialize:function(e){},render:function(){var t=this;if(this.form=e('<div class="query-builder-form>"></div>'),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.post_type+"</div>"),"undefined"!=typeof this.model.get("post_type")&&this.form.find('select[name="post_type"]').val(this.model.get("post_type")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.post__in+"</div>"),"undefined"!=typeof this.model.get("post__in")&&this.form.find('input[name="post__in"]').val(this.model.get("post__in").join(",")),this.form.append('<div class="query-builder-form-field ui-front">'+sowPostsSelectorTpl.fields.tax_query+"</div>"),"undefined"!=typeof this.model.get("tax_query")&&this.form.find('input[name="tax_query"]').val(this.model.get("tax_query")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.date_query+"</div>"),"undefined"!=typeof this.model.get("date_query")){var s=this.model.get("date_query");s.hasOwnProperty("after")&&this.form.find('input[name="after"]').val(s.after),s.hasOwnProperty("before")&&this.form.find('input[name="before"]').val(s.before)}this.form.append(e('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.orderby+"</div>").disableSelection()),"undefined"!=typeof this.model.get("orderby")&&this.form.find('select[name="orderby"]').val(this.model.get("orderby")),"undefined"!=typeof this.model.get("order")&&this.form.find('input[name="order"]').val(this.model.get("order")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.posts_per_page+"</div>"),"undefined"!=typeof this.model.get("posts_per_page")&&this.form.find('input[name="posts_per_page"]').val(this.model.get("posts_per_page")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.sticky+"</div>"),"undefined"!=typeof this.model.get("sticky")&&this.form.find('select[name="sticky"]').val(this.model.get("sticky")),this.form.append('<div class="query-builder-form-field">'+sowPostsSelectorTpl.fields.additional+"</div>"),"undefined"!=typeof this.model.get("additional")&&this.form.find('input[name="additional"]').val(decodeURIComponent(this.model.get("additional")));var i=this.form.find('input[name="order"]'),o=i.closest(".query-builder-form-field").find(".sow-order-button"),n=function(){"DESC"===i.val()?(o.removeClass("sow-order-button-asc"),o.addClass("sow-order-button-desc")):(o.addClass("sow-order-button-asc"),o.removeClass("sow-order-button-desc"))};return n(),o.click(function(e){return e.preventDefault(),"DESC"===i.val()?i.val("ASC"):i.val("DESC"),n(),t.updateModel(),!1}),this.$el.find(".query-builder-content").empty().append(this.form),this.$el.find(".query-builder-form-field select, .query-builder-form-field input").change(function(){t.updateModel()}),this.$el.find(".query-builder-form-field .sow-select-posts").click(function(e){e.preventDefault(),t.builder.setActiveView("postsSelect")}),this.form.find('input[name="tax_query"]').autocomplete({source:function(t,s){e.getJSON(sowPostsSelectorTpl.ajaxurl,{term:t.term.split(/,\s*/).pop(),action:"sow_search_terms"},s)},search:function(){var e=this.value.split(/,\s*/).pop();return e.length<1?!1:void 0},focus:function(){return!1},select:function(e,s){var i=this.value.split(/,\s*/);return i.pop(),i.push(s.item.value),i.push(""),this.value=i.join(", "),t.updateModel(),!1}}),this},updateModel:function(){if(this.model.set("post_type",this.$el.find('*[name="post_type"]').val()),""!==this.$el.find('*[name="post__in"]').val().trim()?this.model.set("post__in",this.$el.find('*[name="post__in"]').val().split(",").map(function(e){return Number(e.trim())})):this.model.set("post__in",[]),""!==this.$el.find('*[name="tax_query"]').val().trim()){var e=this.$el.find('*[name="tax_query"]').val().split(",").map(function(e){return e.trim()});this.model.set("tax_query",t.compact(e))}else this.model.set("tax_query",[]);return this.model.set("date_query",{after:this.$el.find('*[name="after"]').val(),before:this.$el.find('*[name="before"]').val()}),this.model.set("orderby",this.$el.find('*[name="orderby"]').val()),this.model.set("order",this.$el.find('*[name="order"]').val()),this.model.set("posts_per_page",this.$el.find('*[name="posts_per_page"]').val()),this.model.set("sticky",this.$el.find('*[name="sticky"]').val()),this.model.set("additional",encodeURIComponent(this.$el.find('*[name="additional"]').val())),this.model.set("query",this.model.getQuery()),this},buttonHandler:function(){return this.updateModel(),this}}),o=self.PostCollectionSummaryView=Backbone.View.extend({template:t.template(sowPostsSelectorTpl.foundPosts),posts:null,initialize:function(e){this.posts=e.posts,this.posts.bind("reset",this.render,this)},render:function(){this.$el.find(".media-toolbar-secondary").html(this.template({foundPosts:this.posts.foundPosts}));var e=this;this.$el.find(".media-toolbar-secondary .preview-query-posts").click(function(t){t.preventDefault(),e.builder.setActiveView("postsView")})}}),n=self.PostCollectionView=Backbone.View.extend({buttonText:"Back",modalTitle:"Current Posts",template:t.template(sowPostsSelectorTpl.postSummary),posts:null,initialize:function(e){this.posts=e.posts},render:function(){var e=this.$el.find(".query-builder-content").empty().append('<div class="sow-current-posts"></div>').find(".sow-current-posts");e=this.$el.find(".query-builder-content");var t=this.template;return this.posts.each(function(s){e.append(t(s.attributes))}),this},buttonHandler:function(){return this.builder.setActiveView("form"),this}}),r=self.PostSelectView=Backbone.View.extend({buttonText:"Finish Selection",modalTitle:"Select Posts",sortable:null,postCache:{},postTemplate:t.template(sowPostsSelectorTpl.postSummary),initialize:function(){this.postCache={}},render:function(){var t=this.model.get("post__in"),s=this.model.get("post_type");this.$el.find(".query-builder-content").empty().html(sowPostsSelectorTpl.selector),this.sortable=this.$el.find(".query-builder-content #sow-post-selector .sow-posts-sortable").sortable({placeholder:"ui-state-highlight",forcePlaceholderSize:!0,items:"> .sow-post-selector-summary"}),this.addPosts(t);var i=this,o=this.$el.find(".query-builder-content #sow-post-selector .sow-search-field");return o.autocomplete({source:function(t,i){t.type=s,t.action="sow_search_posts",e.get(sowPostsSelectorTpl.ajaxurl,t,i)},minLength:0,select:function(t,s){return t.preventDefault(),e(this).val(""),i.addPosts([s.item.value]),!1}}),o.focusin(function(){o.autocomplete("search",o.val())}),this.$el.find(".query-builder-content").on("click",".sow-remove",function(t){t.preventDefault();var s=e(this);s.closest(".sow-post-selector-summary").fadeOut("fast",function(){e(this).remove(),i.sortable.sortable("refresh")})}),this},addPosts:function(s){if("undefined"!=typeof s&&!t.isEmpty(s)){for(var i=[],o=0;o<s.length;o++)"undefined"==typeof this.postCache[s[o]]&&i.push(s[o]);var n=this;t.isEmpty(i)||e.post(sowPostsSelectorTpl.ajaxurl,{action:"sow_get_posts",query:"post_type=_all&posts_per_page=-1&post__in="+i.join(",")},function(e){console.log(e),"undefined"!=typeof e.posts&&t.each(e.posts,function(e,t){n.postCache[e.id]={id:e.id,title:e.title,thumbnail:e.thumbnail,editUrl:e.editUrl}}),n.refreshLoading()});for(var r,o=0;o<s.length;o++)r="undefined"==typeof this.postCache[s[o]]?e(this.postTemplate({id:s[o],title:"",thumbnail:"",editUrl:"#"})).addClass("sow-post-loading"):e(this.postTemplate(this.postCache[s[o]])),r.appendTo(this.sortable);return this.sortable.sortable("refresh"),this}},refreshLoading:function(){var t=this;this.sortable.find(".sow-post-selector-summary.sow-post-loading").each(function(){var s=e(this),i=s.data("id");if("undefined"!=typeof t.postCache[i]){s.removeClass("sow-post-loading");var o=e(t.postTemplate(t.postCache[i]));s.html(o.html())}})},buttonHandler:function(){var s=[];return this.sortable.find(".sow-post-selector-summary").each(function(){s.push(Number(e(this).data("id")))}),this.model.set("post__in",s),t.isEmpty(s)||(this.model.set("post_type","_all"),this.model.set("orderby","post__in")),this.builder.setActiveView("form"),this}});var u=new a({model:new l({query:""})});jQuery(function(e){e("body").on("click",".sow-select-posts",function(t){t.preventDefault();var s=e(this);u.model.setSyncField(s.siblings(".siteorigin-widget-input")),u.model.sync("update"),u.views.postSummary.posts.on("reset",function(e){s.find(".sow-current-count").text(e.foundPosts)}),u.open()})})}(jQuery,_);
|
base/siteorigin-widget.class.php
CHANGED
@@ -353,8 +353,7 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
353 |
<input type="hidden" name="<?php echo $this->get_field_name('_sow_form_id') ?>" value="<?php echo esc_attr( $instance['_sow_form_id'] ) ?>" class="siteorigin-widgets-form-id" />
|
354 |
</div>
|
355 |
<div class="siteorigin-widget-form-no-styles">
|
356 |
-
|
357 |
-
<p><strong><?php _e('You will only need to do this once.', 'so-widgets-bundle') ?></strong></p>
|
358 |
</div>
|
359 |
|
360 |
<?php if( $this->widget_options['has_preview'] && ! $this->is_customize_preview() ) : ?>
|
@@ -386,6 +385,13 @@ abstract class SiteOrigin_Widget extends WP_Widget {
|
|
386 |
<?php
|
387 |
}
|
388 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
/**
|
390 |
* Enqueue the admin scripts for the widget form.
|
391 |
*/
|
353 |
<input type="hidden" name="<?php echo $this->get_field_name('_sow_form_id') ?>" value="<?php echo esc_attr( $instance['_sow_form_id'] ) ?>" class="siteorigin-widgets-form-id" />
|
354 |
</div>
|
355 |
<div class="siteorigin-widget-form-no-styles">
|
356 |
+
<?php $this->scripts_loading_message() ?>
|
|
|
357 |
</div>
|
358 |
|
359 |
<?php if( $this->widget_options['has_preview'] && ! $this->is_customize_preview() ) : ?>
|
385 |
<?php
|
386 |
}
|
387 |
|
388 |
+
function scripts_loading_message(){
|
389 |
+
?>
|
390 |
+
<p><strong><?php _e('This widget has scripts and styles that need to be loaded before you can use it. Please save and reload your current page.', 'so-widgets-bundle') ?></strong></p>
|
391 |
+
<p><strong><?php _e('You will only need to do this once.', 'so-widgets-bundle') ?></strong></p>
|
392 |
+
<?php
|
393 |
+
}
|
394 |
+
|
395 |
/**
|
396 |
* Enqueue the admin scripts for the widget form.
|
397 |
*/
|
js/slider/jquery.slider.js
CHANGED
@@ -112,6 +112,7 @@ jQuery( function($){
|
|
112 |
var $$ = $(this);
|
113 |
playSlideVideo(incomingSlideEl);
|
114 |
setupActiveSlide( $$, incomingSlideEl );
|
|
|
115 |
},
|
116 |
|
117 |
'cycle-before' : function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
|
@@ -119,6 +120,7 @@ jQuery( function($){
|
|
119 |
$p.find('> li').removeClass('sow-active').eq(optionHash.slideNum-1).addClass('sow-active');
|
120 |
pauseSlideVideo(outgoingSlideEl);
|
121 |
setupActiveSlide($$, incomingSlideEl, optionHash.speed);
|
|
|
122 |
},
|
123 |
|
124 |
'cycle-initialized' : function(event, optionHash){
|
@@ -126,6 +128,8 @@ jQuery( function($){
|
|
126 |
setupActiveSlide( $$, optionHash.slides[0] );
|
127 |
|
128 |
$p.find('>li').removeClass('sow-active').eq(0).addClass('sow-active');
|
|
|
|
|
129 |
if(optionHash.slideCount <= 1) {
|
130 |
// Special case when there is only one slide
|
131 |
$p.hide();
|
@@ -139,7 +143,7 @@ jQuery( function($){
|
|
139 |
'slides' : '> .sow-slider-image',
|
140 |
'speed' : settings.speed,
|
141 |
'timeout' : settings.timeout,
|
142 |
-
'swipe' :
|
143 |
'swipe-fx' : 'scrollHorz'
|
144 |
} );
|
145 |
|
112 |
var $$ = $(this);
|
113 |
playSlideVideo(incomingSlideEl);
|
114 |
setupActiveSlide( $$, incomingSlideEl );
|
115 |
+
$( incomingSlideEl ).trigger('sowSlideCycleAfter');
|
116 |
},
|
117 |
|
118 |
'cycle-before' : function(event, optionHash, outgoingSlideEl, incomingSlideEl, forwardFlag) {
|
120 |
$p.find('> li').removeClass('sow-active').eq(optionHash.slideNum-1).addClass('sow-active');
|
121 |
pauseSlideVideo(outgoingSlideEl);
|
122 |
setupActiveSlide($$, incomingSlideEl, optionHash.speed);
|
123 |
+
$( incomingSlideEl ).trigger('sowSlideCycleBefore');
|
124 |
},
|
125 |
|
126 |
'cycle-initialized' : function(event, optionHash){
|
128 |
setupActiveSlide( $$, optionHash.slides[0] );
|
129 |
|
130 |
$p.find('>li').removeClass('sow-active').eq(0).addClass('sow-active');
|
131 |
+
$( this ).find('.cycle-slide-active').trigger( 'sowSlideInitial' );
|
132 |
+
|
133 |
if(optionHash.slideCount <= 1) {
|
134 |
// Special case when there is only one slide
|
135 |
$p.hide();
|
143 |
'slides' : '> .sow-slider-image',
|
144 |
'speed' : settings.speed,
|
145 |
'timeout' : settings.timeout,
|
146 |
+
'swipe' : settings.swipe,
|
147 |
'swipe-fx' : 'scrollHorz'
|
148 |
} );
|
149 |
|
js/slider/jquery.slider.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
var siteoriginSlider={};jQuery(function(e){var i=siteoriginSlider.playSlideVideo=function(i){e(i).find("video").each(function(){"undefined"!=typeof this.play&&this.play()})},t=siteoriginSlider.pauseSlideVideo=function(i){e(i).find("video").each(function(){"undefined"!=typeof this.pause&&this.pause()})},n=siteoriginSlider.setupActiveSlide=function(i,t,n){var s=e(i).find(".cycle-sentinel"),o=e(t),
|
1 |
+
var siteoriginSlider={};jQuery(function(e){var i=siteoriginSlider.playSlideVideo=function(i){e(i).find("video").each(function(){"undefined"!=typeof this.play&&this.play()})},t=siteoriginSlider.pauseSlideVideo=function(i){e(i).find("video").each(function(){"undefined"!=typeof this.pause&&this.pause()})},n=siteoriginSlider.setupActiveSlide=function(i,t,n){var s=e(i).find(".cycle-sentinel"),o=e(t),d=o.find("video.sow-background-element");if(void 0==n?s.css("height",o.outerHeight()):s.animate({height:o.outerHeight()},n),d.length){var a=o.outerWidth()/o.outerHeight(),c=d.outerWidth()/d.outerHeight();a>c?d.css({width:"100%",height:"auto"}):d.css({width:"auto",height:"100%"}),d.css({"margin-left":-Math.ceil(d.width()/2),"margin-top":-Math.ceil(d.height()/2)})}};e(".sow-slider-images").each(function(){var s=e(this),o=s.siblings(".sow-slider-pagination"),d=s.closest(".sow-slider-base"),a=d.find(".sow-slide-nav"),c=s.find(".sow-slider-image"),l=s.data("settings");c.each(function(i,t){var n=e(t),s=n.data("url");n.click(function(i){if(void 0!==s){var t=e(i.target);"A"!==t.prop("tagName")&&(i.preventDefault(),window.open(s.url,s.new_window?"_blank":"_self"))}})});var r=function(){if(d.show(),s.find(".sow-slider-image").each(function(){var i=e(this);e(window).on("resize panelsStretchRows",function(){i.css("height",i.find(".sow-slider-image-wrapper").outerHeight())}).resize()}),s.on({"cycle-after":function(t,s,o,d,a){var c=e(this);i(d),n(c,d),e(d).trigger("sowSlideCycleAfter")},"cycle-before":function(i,s,d,a,c){var l=e(this);o.find("> li").removeClass("sow-active").eq(s.slideNum-1).addClass("sow-active"),t(d),n(l,a,s.speed),e(a).trigger("sowSlideCycleBefore")},"cycle-initialized":function(t,d){i(e(this).find(".cycle-slide-active")),n(s,d.slides[0]),o.find(">li").removeClass("sow-active").eq(0).addClass("sow-active"),e(this).find(".cycle-slide-active").trigger("sowSlideInitial"),d.slideCount<=1&&(o.hide(),a.hide()),e(window).resize()}}).cycle({slides:"> .sow-slider-image",speed:l.speed,timeout:l.timeout,swipe:l.swipe,"swipe-fx":"scrollHorz"}),s.find("video.sow-background-element").on("loadeddata",function(){n(s,s.find(".cycle-slide-active"))}),o.add(a).hide(),!d.hasClass("sow-slider-is-mobile")&&c.length>1){var r=!1;d.mouseenter(function(){o.add(a).clearQueue().fadeIn(150),r=!1}).mouseleave(function(){r=!0,setTimeout(function(){r&&o.add(a).clearQueue().fadeOut(150),r=!1},750)})}e(window).resize(function(){n(s,s.find(".cycle-slide-active"))}),o.find("> li > a").click(function(i){i.preventDefault(),s.cycle("goto",e(this).data("goto"))}),a.find("> a").click(function(i){i.preventDefault(),s.cycle(e(this).data("action"))}),d.keydown(function(e){37===e.which?s.cycle("prev"):39===e.which&&s.cycle("next")})},f=s.find("img"),h=0,u=!1;f.each(function(){e(this);this.complete?h++:e(this).one("load",function(){h++,h!==f.length||u||(r(),u=!0)}).attr("src",e(this).attr("src")),h!==f.length||u||(r(),u=!0)}),0===f.length&&r()})});
|
readme.txt
CHANGED
@@ -1,9 +1,9 @@
|
|
1 |
=== SiteOrigin Widgets Bundle ===
|
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.
|
5 |
-
Stable tag: 1.
|
6 |
-
Build time: 2016-
|
7 |
License: GPLv3 or later
|
8 |
Contributors: gpriday, braam-genis
|
9 |
|
@@ -51,6 +51,27 @@ The SiteOrigin Widgets Bundle is the perfect platform to build widgets for your
|
|
51 |
|
52 |
== Changelog ==
|
53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
= 1.5.11 - April 11 2016 =
|
55 |
* Fixed features widget container shape setting.
|
56 |
|
1 |
=== SiteOrigin Widgets Bundle ===
|
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.5.2
|
5 |
+
Stable tag: 1.6
|
6 |
+
Build time: 2016-06-21T15:53:26+02:00
|
7 |
License: GPLv3 or later
|
8 |
Contributors: gpriday, braam-genis
|
9 |
|
51 |
|
52 |
== Changelog ==
|
53 |
|
54 |
+
= 1.6 - 21 June 2016 =
|
55 |
+
* Added builder field.
|
56 |
+
* Added new multi checkboxes field.
|
57 |
+
* Added Layout Slider widget.
|
58 |
+
* Added taxonomy widget.
|
59 |
+
* Added slider wrapper attributes and filter.
|
60 |
+
* Fix for measurement field inside a repeater.
|
61 |
+
* Modified base folder to work independently of Widgets Bundle.
|
62 |
+
* Added custom icon families callback argument to icon field.
|
63 |
+
* Properly handle attachments in post selector
|
64 |
+
* Contact Form: Refactored form fields.
|
65 |
+
* Hero Image: Added image type to Hero Image widget.
|
66 |
+
* Button: Handle empty width.
|
67 |
+
* Image: Added filter for SiteOrigin image attributes.
|
68 |
+
* Image: Add dimensions to sizes dropdown.
|
69 |
+
* Maps: Ensure maps widget works with API key.
|
70 |
+
* Hero Image: Added setting to disable swipe on mobile Hero Image Widget.
|
71 |
+
* Fixed title syntax in Image widget.
|
72 |
+
* Video: Correctly get video file mime-types.
|
73 |
+
* Video Widget: Allow specifying multiple self-hosted video sources to support various formats.
|
74 |
+
|
75 |
= 1.5.11 - April 11 2016 =
|
76 |
* Fixed features widget container shape setting.
|
77 |
|
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 |
Text Domain: so-widgets-bundle
|
7 |
Domain Path: /languages
|
8 |
Author: SiteOrigin
|
@@ -12,12 +12,16 @@ License: GPL3
|
|
12 |
License URI: https://www.gnu.org/licenses/gpl-3.0.txt
|
13 |
*/
|
14 |
|
15 |
-
define('SOW_BUNDLE_VERSION', '1.
|
16 |
-
define('SOW_BUNDLE_JS_SUFFIX', '.min');
|
17 |
define('SOW_BUNDLE_BASE_FILE', __FILE__);
|
18 |
|
|
|
|
|
|
|
|
|
|
|
19 |
if( !function_exists('siteorigin_widget_get_plugin_path') ) {
|
20 |
-
include plugin_dir_path(__FILE__).'base/
|
21 |
include plugin_dir_path(__FILE__).'icons/icons.php';
|
22 |
}
|
23 |
|
@@ -235,7 +239,7 @@ class SiteOrigin_Widgets_Bundle {
|
|
235 |
foreach( $active_widgets as $widget_id => $active ) {
|
236 |
if( empty($active) ) continue;
|
237 |
|
238 |
-
foreach( $
|
239 |
if ( !file_exists($folder . $widget_id.'/'.$widget_id.'.php') ) continue;
|
240 |
|
241 |
// Include this widget file
|
2 |
/*
|
3 |
Plugin Name: SiteOrigin Widgets Bundle
|
4 |
Description: A collection of all widgets, neatly bundled into a single plugin. It's also a framework to code your own widgets on top of.
|
5 |
+
Version: 1.6
|
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.6');
|
|
|
16 |
define('SOW_BUNDLE_BASE_FILE', __FILE__);
|
17 |
|
18 |
+
// Allow JS suffix to be pre-set
|
19 |
+
if( !defined( 'SOW_BUNDLE_JS_SUFFIX' ) ) {
|
20 |
+
define('SOW_BUNDLE_JS_SUFFIX', '.min');
|
21 |
+
}
|
22 |
+
|
23 |
if( !function_exists('siteorigin_widget_get_plugin_path') ) {
|
24 |
+
include plugin_dir_path(__FILE__).'base/base.php';
|
25 |
include plugin_dir_path(__FILE__).'icons/icons.php';
|
26 |
}
|
27 |
|
239 |
foreach( $active_widgets as $widget_id => $active ) {
|
240 |
if( empty($active) ) continue;
|
241 |
|
242 |
+
foreach( $widget_folders as $folder ) {
|
243 |
if ( !file_exists($folder . $widget_id.'/'.$widget_id.'.php') ) continue;
|
244 |
|
245 |
// Include this widget file
|
widgets/button/button.php
CHANGED
@@ -78,22 +78,29 @@ class SiteOrigin_Widget_Button_Widget extends SiteOrigin_Widget {
|
|
78 |
),
|
79 |
),
|
80 |
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
'
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
),
|
96 |
-
),
|
97 |
|
98 |
'theme' => array(
|
99 |
'type' => 'select',
|
@@ -188,10 +195,6 @@ class SiteOrigin_Widget_Button_Widget extends SiteOrigin_Widget {
|
|
188 |
);
|
189 |
}
|
190 |
|
191 |
-
function get_template_name($instance) {
|
192 |
-
return 'base';
|
193 |
-
}
|
194 |
-
|
195 |
function get_style_name($instance) {
|
196 |
if(empty($instance['design']['theme'])) return 'atom';
|
197 |
return $instance['design']['theme'];
|
@@ -206,8 +209,9 @@ class SiteOrigin_Widget_Button_Widget extends SiteOrigin_Widget {
|
|
206 |
*/
|
207 |
function get_less_variables($instance){
|
208 |
if( empty( $instance ) || empty( $instance['design'] ) ) return array();
|
209 |
-
|
210 |
return array(
|
|
|
|
|
211 |
'button_color' => $instance['design']['button_color'],
|
212 |
'text_color' => $instance['design']['text_color'],
|
213 |
|
78 |
),
|
79 |
),
|
80 |
|
81 |
+
'design' => array(
|
82 |
+
'type' => 'section',
|
83 |
+
'label' => __('Design and layout', 'so-widgets-bundle'),
|
84 |
+
'hide' => true,
|
85 |
+
'fields' => array(
|
86 |
+
|
87 |
+
'width' => array(
|
88 |
+
'type' => 'measurement',
|
89 |
+
'label' => __( 'Width', 'so-widgets-bundle' ),
|
90 |
+
'description' => __( 'Leave blank to let the button resize according to content.', 'so-widgets-bundle' )
|
91 |
+
),
|
92 |
+
|
93 |
+
'align' => array(
|
94 |
+
'type' => 'select',
|
95 |
+
'label' => __('Align', 'so-widgets-bundle'),
|
96 |
+
'default' => 'center',
|
97 |
+
'options' => array(
|
98 |
+
'left' => __('Left', 'so-widgets-bundle'),
|
99 |
+
'right' => __('Right', 'so-widgets-bundle'),
|
100 |
+
'center' => __('Center', 'so-widgets-bundle'),
|
101 |
+
'justify' => __('Justify', 'so-widgets-bundle'),
|
102 |
+
),
|
103 |
),
|
|
|
104 |
|
105 |
'theme' => array(
|
106 |
'type' => 'select',
|
195 |
);
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
198 |
function get_style_name($instance) {
|
199 |
if(empty($instance['design']['theme'])) return 'atom';
|
200 |
return $instance['design']['theme'];
|
209 |
*/
|
210 |
function get_less_variables($instance){
|
211 |
if( empty( $instance ) || empty( $instance['design'] ) ) return array();
|
|
|
212 |
return array(
|
213 |
+
'button_width' => isset( $instance['design']['width'] ) ? $instance['design']['width'] : '',
|
214 |
+
'has_button_width' => empty( $instance['design']['width'] ) ? 'false' : 'true',
|
215 |
'button_color' => $instance['design']['button_color'],
|
216 |
'text_color' => $instance['design']['text_color'],
|
217 |
|
widgets/button/styles/atom.less
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
|
|
|
|
3 |
@button_color: #41a9d5;
|
4 |
@border_color: darken(@button_color, 15%);
|
5 |
@text_color: #FFFFFF;
|
@@ -12,6 +14,12 @@
|
|
12 |
.ow-button-base {
|
13 |
|
14 |
a {
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
font-size: @font_size;
|
16 |
padding: @padding @padding*2;
|
17 |
.gradient(@button_color, darken(@button_color, 10%), @button_color);
|
@@ -48,4 +56,4 @@
|
|
48 |
color: lighten(@text_color, 2%);
|
49 |
}
|
50 |
}
|
51 |
-
}
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
3 |
+
@button_width: '';
|
4 |
+
@has_button_width: false;
|
5 |
@button_color: #41a9d5;
|
6 |
@border_color: darken(@button_color, 15%);
|
7 |
@text_color: #FFFFFF;
|
14 |
.ow-button-base {
|
15 |
|
16 |
a {
|
17 |
+
.box-sizing(border-box);
|
18 |
+
.btn_width() when( @has_button_width = true) {
|
19 |
+
width: @button_width;
|
20 |
+
}
|
21 |
+
.btn_width();
|
22 |
+
|
23 |
font-size: @font_size;
|
24 |
padding: @padding @padding*2;
|
25 |
.gradient(@button_color, darken(@button_color, 10%), @button_color);
|
56 |
color: lighten(@text_color, 2%);
|
57 |
}
|
58 |
}
|
59 |
+
}
|
widgets/button/styles/flat.less
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
|
|
|
|
3 |
@button_color: #41a9d5;
|
4 |
@border_color: darken(@button_color, 5%);
|
5 |
@text_color: #FFFFFF;
|
@@ -13,6 +15,12 @@
|
|
13 |
.clearfix();
|
14 |
|
15 |
a {
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
font-size: @font_size;
|
17 |
padding: @padding @padding*2;
|
18 |
background: @button_color;
|
@@ -48,4 +56,4 @@
|
|
48 |
color: lighten(@text_color, 4%);
|
49 |
}
|
50 |
}
|
51 |
-
}
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
3 |
+
@button_width: '';
|
4 |
+
@has_button_width: false;
|
5 |
@button_color: #41a9d5;
|
6 |
@border_color: darken(@button_color, 5%);
|
7 |
@text_color: #FFFFFF;
|
15 |
.clearfix();
|
16 |
|
17 |
a {
|
18 |
+
.box-sizing(border-box);
|
19 |
+
.btn_width() when( @has_button_width = true) {
|
20 |
+
width: @button_width;
|
21 |
+
}
|
22 |
+
.btn_width();
|
23 |
+
|
24 |
font-size: @font_size;
|
25 |
padding: @padding @padding*2;
|
26 |
background: @button_color;
|
56 |
color: lighten(@text_color, 4%);
|
57 |
}
|
58 |
}
|
59 |
+
}
|
widgets/button/styles/wire.less
CHANGED
@@ -1,5 +1,7 @@
|
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
|
|
|
|
3 |
@button_color: #41a9d5;
|
4 |
@text_color: #FFFFFF;
|
5 |
|
@@ -12,6 +14,12 @@
|
|
12 |
.clearfix();
|
13 |
|
14 |
a {
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
font-size: @font_size;
|
16 |
padding: @padding @padding*2;
|
17 |
background: transparent;
|
@@ -45,4 +53,4 @@
|
|
45 |
color: @text_color !important;
|
46 |
}
|
47 |
}
|
48 |
-
}
|
1 |
@import "../../../base/less/mixins";
|
2 |
|
3 |
+
@button_width: '';
|
4 |
+
@has_button_width: false;
|
5 |
@button_color: #41a9d5;
|
6 |
@text_color: #FFFFFF;
|
7 |
|
14 |
.clearfix();
|
15 |
|
16 |
a {
|
17 |
+
.box-sizing(border-box);
|
18 |
+
.btn_width() when( @has_button_width = true) {
|
19 |
+
width: @button_width;
|
20 |
+
}
|
21 |
+
.btn_width();
|
22 |
+
|
23 |
font-size: @font_size;
|
24 |
padding: @padding @padding*2;
|
25 |
background: transparent;
|
53 |
color: @text_color !important;
|
54 |
}
|
55 |
}
|
56 |
+
}
|
widgets/button/tpl/{base.php → default.php}
RENAMED
@@ -14,7 +14,6 @@ if( !empty($instance['design']['hover']) ) $classes[] = 'ow-button-hover';
|
|
14 |
if(!empty($instance['attributes']['title'])) $button_attributes['title'] = esc_attr($instance['attributes']['title']);
|
15 |
if(!empty($instance['attributes']['onclick'])) $button_attributes['onclick'] = esc_attr($instance['attributes']['onclick']);
|
16 |
?>
|
17 |
-
|
18 |
<a <?php foreach($button_attributes as $name => $val) echo $name . '="' . $val . '" ' ?>>
|
19 |
<span>
|
20 |
<?php
|
@@ -35,4 +34,4 @@ if( !empty($instance['design']['hover']) ) $classes[] = 'ow-button-hover';
|
|
35 |
<?php echo wp_kses_post($instance['text']) ?>
|
36 |
</span>
|
37 |
</a>
|
38 |
-
</div>
|
14 |
if(!empty($instance['attributes']['title'])) $button_attributes['title'] = esc_attr($instance['attributes']['title']);
|
15 |
if(!empty($instance['attributes']['onclick'])) $button_attributes['onclick'] = esc_attr($instance['attributes']['onclick']);
|
16 |
?>
|
|
|
17 |
<a <?php foreach($button_attributes as $name => $val) echo $name . '="' . $val . '" ' ?>>
|
18 |
<span>
|
19 |
<?php
|
34 |
<?php echo wp_kses_post($instance['text']) ?>
|
35 |
</span>
|
36 |
</a>
|
37 |
+
</div>
|
widgets/contact/contact.php
CHANGED
@@ -715,50 +715,23 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
|
|
715 |
<?php
|
716 |
}
|
717 |
?><span class="sow-field-container"><?php
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
-
|
728 |
-
|
729 |
-
|
730 |
-
|
731 |
-
|
732 |
-
|
733 |
-
|
734 |
-
|
735 |
-
if( !empty($field['options']) ) {
|
736 |
-
if( empty($value) || !is_array( $value ) ) {
|
737 |
-
$value = array();
|
738 |
-
}
|
739 |
-
|
740 |
-
echo '<ul>';
|
741 |
-
foreach ( $field['options'] as $i => $option ) {
|
742 |
-
echo '<li>';
|
743 |
-
echo '<label>';
|
744 |
-
echo '<input type="checkbox" value="' . esc_attr($option['value']) . '" name="' . esc_attr( $field_name ) . '[]" id="' . esc_attr( $field_id ) . '-' . $i . '" ' . checked( in_array($option['value'], $value) , true, false) . ' /> ';
|
745 |
-
echo esc_html( $option['value'] );
|
746 |
-
echo '</li>';
|
747 |
-
}
|
748 |
-
echo '</ul>';
|
749 |
-
}
|
750 |
-
break;
|
751 |
-
|
752 |
-
case 'textarea':
|
753 |
-
echo '<textarea name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" rows="10"' . ( $show_placeholder ? 'placeholder="' . esc_attr( $field['label'] ) . '"' : '' ) . '>' . esc_textarea($value) . '</textarea>';
|
754 |
-
break;
|
755 |
-
|
756 |
-
case 'subject':
|
757 |
-
case 'name':
|
758 |
-
default:
|
759 |
-
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr($value) . '" class="sow-text-field" ' . ( $show_placeholder ? 'placeholder="' . esc_attr( $field['label'] ) . '"' : '' ) . '/>';
|
760 |
-
break;
|
761 |
-
|
762 |
}
|
763 |
?></span><?php
|
764 |
|
@@ -818,8 +791,13 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
|
|
818 |
$value = !empty( $post_vars[$field_name] ) ? $post_vars[$field_name] : '';
|
819 |
|
820 |
if( $field['required']['required'] && empty($value) ) {
|
821 |
-
|
822 |
-
|
|
|
|
|
|
|
|
|
|
|
823 |
}
|
824 |
|
825 |
switch( $field['type'] ) {
|
@@ -854,17 +832,19 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
|
|
854 |
}
|
855 |
}
|
856 |
|
857 |
-
// Add in the default subject
|
858 |
-
if( empty($email_fields['subject']) && !empty($instance['settings']['
|
859 |
-
$email_fields['subject'] = $instance['settings']['default_subject'];
|
860 |
-
}
|
861 |
-
if( !empty($instance['settings']['subject_prefix']) ) {
|
862 |
$email_fields['subject'] = $instance['settings']['subject_prefix'] . ' ' . $email_fields['subject'];
|
863 |
}
|
864 |
|
865 |
// Now we do some email message validation
|
866 |
if( empty($errors) ) {
|
867 |
$email_errors = $this->validate_mail( $email_fields );
|
|
|
|
|
|
|
|
|
|
|
868 |
if( !empty($email_errors) ) {
|
869 |
$errors['_general'] = $email_errors;
|
870 |
}
|
@@ -1060,3 +1040,25 @@ class SiteOrigin_Widgets_ContactForm_Widget extends SiteOrigin_Widget {
|
|
1060 |
|
1061 |
}
|
1062 |
siteorigin_widget_register( 'sow-contact-form', __FILE__, 'SiteOrigin_Widgets_ContactForm_Widget' );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
715 |
<?php
|
716 |
}
|
717 |
?><span class="sow-field-container"><?php
|
718 |
+
$class_name = empty( $field['type'] ) ? '' : 'SiteOrigin_Widget_ContactForm_Field_' . ucwords( $field['type'] );
|
719 |
+
// This does autoloading if required.
|
720 |
+
if ( class_exists( $class_name ) ) {
|
721 |
+
/**
|
722 |
+
* @var $contact_field SiteOrigin_Widget_ContactForm_Field_Base
|
723 |
+
*/
|
724 |
+
$field_input_options = array(
|
725 |
+
'field' => $field,
|
726 |
+
'field_id' => $field_id,
|
727 |
+
'field_name' => $field_name,
|
728 |
+
'value' => $value,
|
729 |
+
'show_placeholder' => $show_placeholder
|
730 |
+
);
|
731 |
+
$contact_field = new $class_name( $field_input_options );
|
732 |
+
$contact_field->render();
|
733 |
+
} else {
|
734 |
+
echo '<input type="text" name="' . esc_attr( $field_name ) . '" id="' . esc_attr( $field_id ) . '" value="' . esc_attr( $value ) . '" class="sow-text-field" ' . ( $show_placeholder ? 'placeholder="' . esc_attr( $field['label'] ) . '"' : '' ) . '/>';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
735 |
}
|
736 |
?></span><?php
|
737 |
|
791 |
$value = !empty( $post_vars[$field_name] ) ? $post_vars[$field_name] : '';
|
792 |
|
793 |
if( $field['required']['required'] && empty($value) ) {
|
794 |
+
// Add in the default subject
|
795 |
+
if( $field['type'] == 'subject' && !empty($instance['settings']['default_subject'] ) ) {
|
796 |
+
$value = $instance['settings']['default_subject'];
|
797 |
+
} else {
|
798 |
+
$errors[ $field_name ] = ! empty( $field['required']['missing_message'] ) ? $field['required']['missing_message'] : __( 'Required field', 'so-widgets-bundle' );
|
799 |
+
continue;
|
800 |
+
}
|
801 |
}
|
802 |
|
803 |
switch( $field['type'] ) {
|
832 |
}
|
833 |
}
|
834 |
|
835 |
+
// Add in the default subject prefix
|
836 |
+
if( !empty( $email_fields['subject'] ) && !empty($instance['settings']['subject_prefix']) ) {
|
|
|
|
|
|
|
837 |
$email_fields['subject'] = $instance['settings']['subject_prefix'] . ' ' . $email_fields['subject'];
|
838 |
}
|
839 |
|
840 |
// Now we do some email message validation
|
841 |
if( empty($errors) ) {
|
842 |
$email_errors = $this->validate_mail( $email_fields );
|
843 |
+
// Missing subject input and no default subject set. Revert to using a generic default 'SiteName Contact Form'
|
844 |
+
if ( ! isset( $email_fields['subject'] ) && ! empty( $email_errors['subject'] ) ) {
|
845 |
+
unset($email_errors['subject']);
|
846 |
+
$email_fields['subject'] = get_bloginfo() . ' ' . __( 'Contact Form', 'siteorigin-widgets' );
|
847 |
+
}
|
848 |
if( !empty($email_errors) ) {
|
849 |
$errors['_general'] = $email_errors;
|
850 |
}
|
1040 |
|
1041 |
}
|
1042 |
siteorigin_widget_register( 'sow-contact-form', __FILE__, 'SiteOrigin_Widgets_ContactForm_Widget' );
|
1043 |
+
|
1044 |
+
// Tell the autoloader where to look for contactform field classes.
|
1045 |
+
function contactform_fields_class_paths( $class_paths ) {
|
1046 |
+
$loader = SiteOrigin_Widget_Field_Class_Loader::single();
|
1047 |
+
|
1048 |
+
$loader->add_class_prefixes(
|
1049 |
+
apply_filters( 'siteorigin_widgets_contact_form_field_class_prefixes', array(
|
1050 |
+
'SiteOrigin_Widget_ContactForm_Field_'
|
1051 |
+
) ),
|
1052 |
+
'contact-form'
|
1053 |
+
);
|
1054 |
+
|
1055 |
+
$loader->add_class_paths(
|
1056 |
+
apply_filters( 'siteorigin_widgets_contact_form_field_class_paths', array(
|
1057 |
+
plugin_dir_path( __FILE__ ) . 'fields/'
|
1058 |
+
) ),
|
1059 |
+
'contact-form'
|
1060 |
+
);
|
1061 |
+
|
1062 |
+
return $class_paths;
|
1063 |
+
}
|
1064 |
+
add_filter( 'init', 'contactform_fields_class_paths' );
|
widgets/contact/fields/base.class.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
abstract class SiteOrigin_Widget_ContactForm_Field_Base {
|
3 |
+
|
4 |
+
/**
|
5 |
+
* The options for this field. Used when enqueueing styles and scripts and rendering the field.
|
6 |
+
*
|
7 |
+
* @access protected
|
8 |
+
* @var array
|
9 |
+
*/
|
10 |
+
protected $options;
|
11 |
+
|
12 |
+
public function __construct( $options ) {
|
13 |
+
$this->options = $options;
|
14 |
+
$this->init();
|
15 |
+
}
|
16 |
+
|
17 |
+
private function init() {
|
18 |
+
$this->initialize( $this->options );
|
19 |
+
}
|
20 |
+
|
21 |
+
protected function initialize( $options ) {
|
22 |
+
}
|
23 |
+
|
24 |
+
abstract protected function render_field( $options );
|
25 |
+
|
26 |
+
public function render() {
|
27 |
+
$this->render_field( $this->options );
|
28 |
+
}
|
29 |
+
}
|
widgets/contact/fields/checkboxes.class.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Checkboxes extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
|
7 |
+
if ( ! empty( $options['field']['options'] ) ) {
|
8 |
+
if ( empty( $options['value'] ) || ! is_array( $options['value'] ) ) {
|
9 |
+
$options['value'] = array();
|
10 |
+
}
|
11 |
+
|
12 |
+
?><ul><?php
|
13 |
+
foreach ( $options['field']['options'] as $i => $option ) {
|
14 |
+
?><li>
|
15 |
+
<label>
|
16 |
+
<input type="checkbox" value="<?php echo esc_attr( $option['value'] ) ?>" name="<?php echo esc_attr( $options['field_name'] ) ?>[]" id="<?php echo esc_attr( $options['field_id'] ) . '-' . $i ?>"<?php echo checked( in_array( $option['value'], $options['value'] ), true, false ) ?>/>
|
17 |
+
<?php echo esc_html( $option['value'] ); ?>
|
18 |
+
</li>
|
19 |
+
<?php } ?>
|
20 |
+
</ul><?php
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
widgets/contact/fields/email.class.php
ADDED
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Email extends SiteOrigin_Widget_ContactForm_Field_Text {
|
4 |
+
// This class just exists for autoloading purposes, but is the same as the text field.
|
5 |
+
}
|
widgets/contact/fields/name.class.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Name extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
|
7 |
+
?>
|
8 |
+
<input type="text" name="<?php echo esc_attr( $options['field_name'] ) ?>" id="<?php echo esc_attr( $options['field_id'] ) ?>" value="<?php echo esc_attr( $options['value'] ) ?>" class="sow-text-field"<?php echo ( $options['show_placeholder'] ? 'placeholder="' . esc_attr( $options['field']['label'] ) . '"' : '' ) ?>/>
|
9 |
+
<?php
|
10 |
+
}
|
11 |
+
}
|
widgets/contact/fields/select.class.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Select extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
?><select name="<?php echo esc_attr( $options['field_name'] ) ?>"
|
7 |
+
id="<?php echo esc_attr( $options['field_id'] ) ?>">
|
8 |
+
<?php if ( ! empty( $options['field']['options'] ) ) {
|
9 |
+
foreach ( $options['field']['options'] as $option ) { ?>
|
10 |
+
<option
|
11 |
+
value="<?php echo esc_attr( $option['value'] ) ?>"<?php echo selected( $option['value'], $options['value'], false ) ?>>
|
12 |
+
<?php echo esc_html( $option['value'] ) ?>
|
13 |
+
</option>
|
14 |
+
<?php }
|
15 |
+
} ?>
|
16 |
+
</select><?php
|
17 |
+
}
|
18 |
+
}
|
widgets/contact/fields/subject.class.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Subject extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
|
7 |
+
?>
|
8 |
+
<input type="text" name="<?php echo esc_attr( $options['field_name'] ) ?>" id="<?php echo esc_attr( $options['field_id'] ) ?>" value="<?php echo esc_attr( $options['value'] ) ?>" class="sow-text-field"<?php echo ( $options['show_placeholder'] ? 'placeholder="' . esc_attr( $options['field']['label'] ) . '"' : '' ) ?>/>
|
9 |
+
<?php
|
10 |
+
}
|
11 |
+
}
|
widgets/contact/fields/text.class.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_Text extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
|
7 |
+
?>
|
8 |
+
<input type="<?php echo $options['field']['type'] ?>" name="<?php echo esc_attr( $options['field_name'] ) ?>" id="<?php echo esc_attr( $options['field_id'] ) ?>" value="<?php echo esc_attr( $options['value'] ) ?>" class="sow-text-field"<?php echo ( $options['show_placeholder'] ? 'placeholder="' . esc_attr( $options['field']['label'] ) . '"' : '' ) ?>/>
|
9 |
+
<?php
|
10 |
+
}
|
11 |
+
}
|
widgets/contact/fields/textarea.class.php
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class SiteOrigin_Widget_ContactForm_Field_TextArea extends SiteOrigin_Widget_ContactForm_Field_Base {
|
4 |
+
|
5 |
+
public function render_field( $options ) {
|
6 |
+
?>
|
7 |
+
<textarea name="<?php echo esc_attr( $options['field_name'] ) ?>" id="<?php echo esc_attr( $options['field_id'] ) ?>" rows="10"<?php echo ( $options['show_placeholder'] ? 'placeholder="' . esc_attr( $options['field']['label'] ) . '"' : '' ) ?>><?php echo esc_textarea($options['value'])
|
8 |
+
?></textarea>
|
9 |
+
<?php
|
10 |
+
}
|
11 |
+
}
|
widgets/cta/cta.php
CHANGED
@@ -101,14 +101,6 @@ class SiteOrigin_Widget_Cta_Widget extends SiteOrigin_Widget {
|
|
101 |
);
|
102 |
}
|
103 |
|
104 |
-
function get_template_name($instance) {
|
105 |
-
return 'base';
|
106 |
-
}
|
107 |
-
|
108 |
-
function get_style_name($instance) {
|
109 |
-
return 'basic';
|
110 |
-
}
|
111 |
-
|
112 |
function get_less_variables($instance) {
|
113 |
if( empty( $instance ) ) return array();
|
114 |
|
101 |
);
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
function get_less_variables($instance) {
|
105 |
if( empty( $instance ) ) return array();
|
106 |
|
widgets/cta/styles/{basic.less → default.less}
RENAMED
File without changes
|
widgets/cta/tpl/{base.php → default.php}
RENAMED
File without changes
|
widgets/editor/editor.php
CHANGED
@@ -77,10 +77,6 @@ class SiteOrigin_Widget_Editor_Widget extends SiteOrigin_Widget {
|
|
77 |
}
|
78 |
|
79 |
|
80 |
-
function get_template_name($instance) {
|
81 |
-
return 'editor';
|
82 |
-
}
|
83 |
-
|
84 |
function get_style_name($instance) {
|
85 |
// We're not using a style
|
86 |
return false;
|
77 |
}
|
78 |
|
79 |
|
|
|
|
|
|
|
|
|
80 |
function get_style_name($instance) {
|
81 |
// We're not using a style
|
82 |
return false;
|
widgets/editor/tpl/{editor.php → default.php}
RENAMED
File without changes
|
widgets/features/features.php
CHANGED
@@ -35,11 +35,6 @@ class SiteOrigin_Widget_Features_Widget extends SiteOrigin_Widget {
|
|
35 |
}
|
36 |
|
37 |
function initialize_form(){
|
38 |
-
$image_size_configs = $this->get_image_sizes();
|
39 |
-
$sizes = array();
|
40 |
-
foreach( $image_size_configs as $name => $size_config) {
|
41 |
-
$sizes[$name] = ucwords(preg_replace('/[-_]/', ' ', $name)) . ' (' . $size_config['width'] . 'x' . $size_config['height'] . ')';
|
42 |
-
}
|
43 |
|
44 |
return array(
|
45 |
'features' => array(
|
@@ -82,9 +77,8 @@ class SiteOrigin_Widget_Features_Widget extends SiteOrigin_Widget {
|
|
82 |
),
|
83 |
|
84 |
'icon_image_size' => array(
|
85 |
-
'type' => '
|
86 |
'label' => __('Icon image size', 'so-widgets-bundle'),
|
87 |
-
'options' => $sizes,
|
88 |
),
|
89 |
|
90 |
// The text under the icon
|
@@ -233,40 +227,6 @@ class SiteOrigin_Widget_Features_Widget extends SiteOrigin_Widget {
|
|
233 |
);
|
234 |
}
|
235 |
|
236 |
-
/**
|
237 |
-
* Get size information for all currently-registered image sizes.
|
238 |
-
* From codex example here: https://codex.wordpress.org/Function_Reference/get_intermediate_image_sizes
|
239 |
-
*
|
240 |
-
* @global $_wp_additional_image_sizes
|
241 |
-
* @uses get_intermediate_image_sizes()
|
242 |
-
* @return array $sizes Data for all currently-registered image sizes.
|
243 |
-
*/
|
244 |
-
function get_image_sizes() {
|
245 |
-
global $_wp_additional_image_sizes;
|
246 |
-
|
247 |
-
$sizes = array();
|
248 |
-
|
249 |
-
foreach ( get_intermediate_image_sizes() as $_size ) {
|
250 |
-
if ( in_array( $_size, array('thumbnail', 'medium', 'medium_large', 'large') ) ) {
|
251 |
-
$sizes[ $_size ]['width'] = get_option( "{$_size}_size_w" );
|
252 |
-
$sizes[ $_size ]['height'] = get_option( "{$_size}_size_h" );
|
253 |
-
$sizes[ $_size ]['crop'] = (bool) get_option( "{$_size}_crop" );
|
254 |
-
} elseif ( isset( $_wp_additional_image_sizes[ $_size ] ) ) {
|
255 |
-
$sizes[ $_size ] = array(
|
256 |
-
'width' => $_wp_additional_image_sizes[ $_size ]['width'],
|
257 |
-
'height' => $_wp_additional_image_sizes[ $_size ]['height'],
|
258 |
-
'crop' => $_wp_additional_image_sizes[ $_size ]['crop'],
|
259 |
-
);
|
260 |
-
}
|
261 |
-
}
|
262 |
-
|
263 |
-
return $sizes;
|
264 |
-
}
|
265 |
-
|
266 |
-
function get_style_name($instance){
|
267 |
-
return 'features';
|
268 |
-
}
|
269 |
-
|
270 |
function get_less_variables( $instance ) {
|
271 |
$less_vars = array();
|
272 |
|
@@ -306,10 +266,6 @@ class SiteOrigin_Widget_Features_Widget extends SiteOrigin_Widget {
|
|
306 |
$fonts['more_text_options']['font'],
|
307 |
);
|
308 |
}
|
309 |
-
|
310 |
-
function get_template_name($instance) {
|
311 |
-
return 'base';
|
312 |
-
}
|
313 |
}
|
314 |
|
315 |
siteorigin_widget_register('sow-features', __FILE__, 'SiteOrigin_Widget_Features_Widget');
|
35 |
}
|
36 |
|
37 |
function initialize_form(){
|
|
|
|
|
|
|
|
|
|
|
38 |
|
39 |
return array(
|
40 |
'features' => array(
|
77 |
),
|
78 |
|
79 |
'icon_image_size' => array(
|
80 |
+
'type' => 'image-size',
|
81 |
'label' => __('Icon image size', 'so-widgets-bundle'),
|
|
|
82 |
),
|
83 |
|
84 |
// The text under the icon
|
227 |
);
|
228 |
}
|
229 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
230 |
function get_less_variables( $instance ) {
|
231 |
$less_vars = array();
|
232 |
|
266 |
$fonts['more_text_options']['font'],
|
267 |
);
|
268 |
}
|
|
|
|
|
|
|
|
|
269 |
}
|
270 |
|
271 |
siteorigin_widget_register('sow-features', __FILE__, 'SiteOrigin_Widget_Features_Widget');
|
widgets/features/styles/{features.less → default.less}
RENAMED
File without changes
|
widgets/features/tpl/{base.php → default.php}
RENAMED
File without changes
|
widgets/google-map/google-map.php
CHANGED
@@ -394,7 +394,8 @@ class SiteOrigin_Widget_GoogleMap_Widget extends SiteOrigin_Widget {
|
|
394 |
}
|
395 |
|
396 |
function get_style_name( $instance ) {
|
397 |
-
|
|
|
398 |
}
|
399 |
|
400 |
function get_template_variables( $instance, $args ) {
|
394 |
}
|
395 |
|
396 |
function get_style_name( $instance ) {
|
397 |
+
// We aren't using a LESS style for this widget.
|
398 |
+
return false;
|
399 |
}
|
400 |
|
401 |
function get_template_variables( $instance, $args ) {
|
widgets/google-map/js/js-map.js
CHANGED
@@ -197,7 +197,7 @@ jQuery(function ($) {
|
|
197 |
if (window.google && window.google.maps) {
|
198 |
new SiteOriginGoogleMap($).loadMaps();
|
199 |
} else {
|
200 |
-
var apiKey = $('.sow-google-map-canvas').data('
|
201 |
|
202 |
var apiUrl = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback=soGoogleMapInitialize';
|
203 |
if(apiKey) {
|
197 |
if (window.google && window.google.maps) {
|
198 |
new SiteOriginGoogleMap($).loadMaps();
|
199 |
} else {
|
200 |
+
var apiKey = $('.sow-google-map-canvas').data('options').apiKey;
|
201 |
|
202 |
var apiUrl = 'https://maps.googleapis.com/maps/api/js?v=3.exp&callback=soGoogleMapInitialize';
|
203 |
if(apiKey) {
|
widgets/google-map/js/js-map.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
function soGoogleMapInitialize(){new SiteOriginGoogleMap(window.jQuery).loadMaps()}var SiteOriginGoogleMap=function(e){return{showMap:function(e,o,a){var i=Number(a.zoom);i||(i=14);var n="user_map_style",t={zoom:i,scrollwheel:a.scrollZoom,draggable:a.draggable,disableDefaultUI:a.disableUi,center:o,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,n]}},s=new google.maps.Map(e,t),r={name:a.mapName},p=a.mapStyles;if(p){var l=new google.maps.StyledMapType(p,r);s.mapTypes.set(n,l),s.setMapTypeId(n)}if(a.markerAtCenter&&new google.maps.Marker({position:o,map:s,draggable:a.markersDraggable,icon:a.markerIcon,title:""}),a.keepCentered){var g;google.maps.event.addDomListener(s,"idle",function(){g=s.getCenter()}),google.maps.event.addDomListener(window,"resize",function(){s.setCenter(g)})}this.showMarkers(a.markerPositions,s,a),this.showDirections(a.directions,s,a)},showMarkers:function(e,o,a){if(e&&e.length){var i=new google.maps.Geocoder;e.forEach(function(e){var n=function(){i.geocode({address:e.place},function(i,t){if(t==google.maps.GeocoderStatus.OK){var s=new google.maps.Marker({position:i[0].geometry.location,map:o,draggable:a.markersDraggable,icon:a.markerIcon,title:""});if(e.hasOwnProperty("info")&&e.info){var r={content:e.info};e.hasOwnProperty("info_max_width")&&e.info_max_width&&(r.maxWidth=e.info_max_width);var p=a.markerInfoDisplay;r.disableAutoPan="always"==p;var l=new google.maps.InfoWindow(r);"always"==p?(l.open(o,s),s.addListener("click",function(){l.open(o,s)})):s.addListener(p,function(){l.open(o,s)})}}else t==google.maps.GeocoderStatus.OVER_QUERY_LIMIT&&setTimeout(n,1e3*Math.random(),e)})};setTimeout(n,1e3*Math.random(),e)})}},showDirections:function(e,o){if(e){e.waypoints&&e.waypoints.length&&e.waypoints.map(function(e){e.stopover=Boolean(e.stopover)});var a=new google.maps.DirectionsRenderer;a.setMap(o);var i=new google.maps.DirectionsService;i.route({origin:e.origin,destination:e.destination,travelMode:e.travelMode.toUpperCase(),avoidHighways:e.avoidHighways,avoidTolls:e.avoidTolls,waypoints:e.waypoints,optimizeWaypoints:e.optimizeWaypoints},function(e,o){o==google.maps.DirectionsStatus.OK&&a.setDirections(e)})}},loadMaps:function(){e(".sow-google-map-canvas").each(function(o,a){var i=e(a),n=i.data("options"),t=n.address;if(!t){var s=n.markerPositions;s&&s.length&&(t=s[0].place)}var r,p={address:t};if(t&&t.indexOf(",")>-1){var l=t.split(",");l&&2==l.length&&(r=new google.maps.LatLng(l[0],l[1]),isNaN(r.lat())||isNaN(r.lng())||(p={location:{lat:r.lat(),lng:r.lng()}}))}if(p.hasOwnProperty("location"))this.showMap(a,p.location,n);else if(p.hasOwnProperty("address")){var g=new google.maps.Geocoder;g.geocode(p,function(e,o){o==google.maps.GeocoderStatus.OK?this.showMap(a,e[0].geometry.location,n):o==google.maps.GeocoderStatus.ZERO_RESULTS&&i.append("<div><p><strong>There were no results for the place you entered. Please try another.</strong></p></div>")}.bind(this))}}.bind(this))}}};jQuery(function(e){if(window.google&&window.google.maps)new SiteOriginGoogleMap(e).loadMaps();else{var o=e(".sow-google-map-canvas").data("
|
1 |
+
function soGoogleMapInitialize(){new SiteOriginGoogleMap(window.jQuery).loadMaps()}var SiteOriginGoogleMap=function(e){return{showMap:function(e,o,a){var i=Number(a.zoom);i||(i=14);var n="user_map_style",t={zoom:i,scrollwheel:a.scrollZoom,draggable:a.draggable,disableDefaultUI:a.disableUi,center:o,mapTypeControlOptions:{mapTypeIds:[google.maps.MapTypeId.ROADMAP,n]}},s=new google.maps.Map(e,t),r={name:a.mapName},p=a.mapStyles;if(p){var l=new google.maps.StyledMapType(p,r);s.mapTypes.set(n,l),s.setMapTypeId(n)}if(a.markerAtCenter&&new google.maps.Marker({position:o,map:s,draggable:a.markersDraggable,icon:a.markerIcon,title:""}),a.keepCentered){var g;google.maps.event.addDomListener(s,"idle",function(){g=s.getCenter()}),google.maps.event.addDomListener(window,"resize",function(){s.setCenter(g)})}this.showMarkers(a.markerPositions,s,a),this.showDirections(a.directions,s,a)},showMarkers:function(e,o,a){if(e&&e.length){var i=new google.maps.Geocoder;e.forEach(function(e){var n=function(){i.geocode({address:e.place},function(i,t){if(t==google.maps.GeocoderStatus.OK){var s=new google.maps.Marker({position:i[0].geometry.location,map:o,draggable:a.markersDraggable,icon:a.markerIcon,title:""});if(e.hasOwnProperty("info")&&e.info){var r={content:e.info};e.hasOwnProperty("info_max_width")&&e.info_max_width&&(r.maxWidth=e.info_max_width);var p=a.markerInfoDisplay;r.disableAutoPan="always"==p;var l=new google.maps.InfoWindow(r);"always"==p?(l.open(o,s),s.addListener("click",function(){l.open(o,s)})):s.addListener(p,function(){l.open(o,s)})}}else t==google.maps.GeocoderStatus.OVER_QUERY_LIMIT&&setTimeout(n,1e3*Math.random(),e)})};setTimeout(n,1e3*Math.random(),e)})}},showDirections:function(e,o){if(e){e.waypoints&&e.waypoints.length&&e.waypoints.map(function(e){e.stopover=Boolean(e.stopover)});var a=new google.maps.DirectionsRenderer;a.setMap(o);var i=new google.maps.DirectionsService;i.route({origin:e.origin,destination:e.destination,travelMode:e.travelMode.toUpperCase(),avoidHighways:e.avoidHighways,avoidTolls:e.avoidTolls,waypoints:e.waypoints,optimizeWaypoints:e.optimizeWaypoints},function(e,o){o==google.maps.DirectionsStatus.OK&&a.setDirections(e)})}},loadMaps:function(){e(".sow-google-map-canvas").each(function(o,a){var i=e(a),n=i.data("options"),t=n.address;if(!t){var s=n.markerPositions;s&&s.length&&(t=s[0].place)}var r,p={address:t};if(t&&t.indexOf(",")>-1){var l=t.split(",");l&&2==l.length&&(r=new google.maps.LatLng(l[0],l[1]),isNaN(r.lat())||isNaN(r.lng())||(p={location:{lat:r.lat(),lng:r.lng()}}))}if(p.hasOwnProperty("location"))this.showMap(a,p.location,n);else if(p.hasOwnProperty("address")){var g=new google.maps.Geocoder;g.geocode(p,function(e,o){o==google.maps.GeocoderStatus.OK?this.showMap(a,e[0].geometry.location,n):o==google.maps.GeocoderStatus.ZERO_RESULTS&&i.append("<div><p><strong>There were no results for the place you entered. Please try another.</strong></p></div>")}.bind(this))}}.bind(this))}}};jQuery(function(e){if(window.google&&window.google.maps)new SiteOriginGoogleMap(e).loadMaps();else{var o=e(".sow-google-map-canvas").data("options").apiKey,a="https://maps.googleapis.com/maps/api/js?v=3.exp&callback=soGoogleMapInitialize";o&&(a+="&key="+o);var i=e('<script type="text/javascript" src="'+a+'">');e("body").append(i)}});
|
widgets/headline/headline.php
CHANGED
@@ -164,10 +164,6 @@ class SiteOrigin_Widget_Headline_Widget extends SiteOrigin_Widget {
|
|
164 |
);
|
165 |
}
|
166 |
|
167 |
-
function get_style_name( $instance ) {
|
168 |
-
return 'sow-headline';
|
169 |
-
}
|
170 |
-
|
171 |
function get_less_variables( $instance ) {
|
172 |
$less_vars = array();
|
173 |
|
@@ -191,7 +187,7 @@ class SiteOrigin_Widget_Headline_Widget extends SiteOrigin_Widget {
|
|
191 |
}
|
192 |
}
|
193 |
|
194 |
-
if ( ! empty( $instance['sub_headline'] ) ) {
|
195 |
$sub_headline_styles = $instance['sub_headline'];
|
196 |
if ( ! empty( $sub_headline_styles['align'] ) ) {
|
197 |
$less_vars['sub_headline_align'] = $sub_headline_styles['align'];
|
@@ -248,17 +244,6 @@ class SiteOrigin_Widget_Headline_Widget extends SiteOrigin_Widget {
|
|
248 |
);
|
249 |
}
|
250 |
|
251 |
-
/**
|
252 |
-
* Get the template for the headline widget
|
253 |
-
*
|
254 |
-
* @param $instance
|
255 |
-
*
|
256 |
-
* @return mixed|string
|
257 |
-
*/
|
258 |
-
function get_template_name( $instance ) {
|
259 |
-
return 'headline';
|
260 |
-
}
|
261 |
-
|
262 |
/**
|
263 |
* Get the template variables for the headline
|
264 |
*
|
164 |
);
|
165 |
}
|
166 |
|
|
|
|
|
|
|
|
|
167 |
function get_less_variables( $instance ) {
|
168 |
$less_vars = array();
|
169 |
|
187 |
}
|
188 |
}
|
189 |
|
190 |
+
if ( ! empty( $instance['sub_headline'] ) && ! empty ( $instance['sub_headline']['text'] ) ) {
|
191 |
$sub_headline_styles = $instance['sub_headline'];
|
192 |
if ( ! empty( $sub_headline_styles['align'] ) ) {
|
193 |
$less_vars['sub_headline_align'] = $sub_headline_styles['align'];
|
244 |
);
|
245 |
}
|
246 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
/**
|
248 |
* Get the template variables for the headline
|
249 |
*
|
widgets/headline/styles/{sow-headline.less → default.less}
RENAMED
File without changes
|
widgets/headline/tpl/{headline.php → default.php}
RENAMED
File without changes
|
widgets/hero/hero.php
CHANGED
@@ -88,6 +88,15 @@ class SiteOrigin_Widget_Hero_Widget extends SiteOrigin_Widget_Base_Slider {
|
|
88 |
'fallback' => true,
|
89 |
),
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
'opacity' => array(
|
92 |
'label' => __( 'Background image opacity', 'so-widgets-bundle' ),
|
93 |
'type' => 'slider',
|
@@ -230,8 +239,10 @@ class SiteOrigin_Widget_Hero_Widget extends SiteOrigin_Widget_Base_Slider {
|
|
230 |
|
231 |
return array(
|
232 |
'color' => !empty( $frame['background']['color'] ) ? $frame['background']['color'] : false,
|
233 |
-
'image' => !empty( $background_image ) ? $background_image[0] : false,
|
234 |
-
'image-
|
|
|
|
|
235 |
'url' => !empty( $frame['background']['url'] ) ? $frame['background']['url'] : false,
|
236 |
'new_window' => !empty( $frame['background']['new_window'] ),
|
237 |
'videos' => $frame['background']['videos'],
|
@@ -292,7 +303,7 @@ class SiteOrigin_Widget_Hero_Widget extends SiteOrigin_Widget_Base_Slider {
|
|
292 |
$less['nav_size'] = $instance['controls']['nav_size'];
|
293 |
|
294 |
// Hero specific design
|
295 |
-
//Measurement field type options
|
296 |
$meas_options = array();
|
297 |
$meas_options['slide_padding'] = $instance['design']['padding'];
|
298 |
$meas_options['slide_padding_extra_top'] = $instance['design']['extra_top_padding'];
|
88 |
'fallback' => true,
|
89 |
),
|
90 |
|
91 |
+
'image_type' => array(
|
92 |
+
'type' => 'select',
|
93 |
+
'label' => __('Background image type', 'so-widgets-bundle'),
|
94 |
+
'options' => array(
|
95 |
+
'cover' => __('Cover', 'so-widgets-bundle'),
|
96 |
+
),
|
97 |
+
'default' => 'cover',
|
98 |
+
),
|
99 |
+
|
100 |
'opacity' => array(
|
101 |
'label' => __( 'Background image opacity', 'so-widgets-bundle' ),
|
102 |
'type' => 'slider',
|
239 |
|
240 |
return array(
|
241 |
'color' => !empty( $frame['background']['color'] ) ? $frame['background']['color'] : false,
|
242 |
+
'image' => !empty( $background_image[0] ) ? $background_image[0] : false,
|
243 |
+
'image-width' => !empty( $background_image[1] ) ? $background_image[1] : 0,
|
244 |
+
'image-height' => !empty( $background_image[2] ) ? $background_image[2] : 0,
|
245 |
+
'image-sizing' => $frame['background']['image_type'],
|
246 |
'url' => !empty( $frame['background']['url'] ) ? $frame['background']['url'] : false,
|
247 |
'new_window' => !empty( $frame['background']['new_window'] ),
|
248 |
'videos' => $frame['background']['videos'],
|
303 |
$less['nav_size'] = $instance['controls']['nav_size'];
|
304 |
|
305 |
// Hero specific design
|
306 |
+
// Measurement field type options
|
307 |
$meas_options = array();
|
308 |
$meas_options['slide_padding'] = $instance['design']['padding'];
|
309 |
$meas_options['slide_padding_extra_top'] = $instance['design']['extra_top_padding'];
|
widgets/icon/icon.php
CHANGED
@@ -64,10 +64,6 @@ class SiteOrigin_Widget_Icon_Widget extends SiteOrigin_Widget {
|
|
64 |
);
|
65 |
}
|
66 |
|
67 |
-
function get_style_name( $instance ) {
|
68 |
-
return 'sow-icon';
|
69 |
-
}
|
70 |
-
|
71 |
function get_less_variables( $instance ) {
|
72 |
return array(
|
73 |
'color' => $instance['color'],
|
@@ -77,18 +73,6 @@ class SiteOrigin_Widget_Icon_Widget extends SiteOrigin_Widget {
|
|
77 |
);
|
78 |
}
|
79 |
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Get the template for the headline widget
|
83 |
-
*
|
84 |
-
* @param $instance
|
85 |
-
*
|
86 |
-
* @return mixed|string
|
87 |
-
*/
|
88 |
-
function get_template_name( $instance ) {
|
89 |
-
return 'icon';
|
90 |
-
}
|
91 |
-
|
92 |
/**
|
93 |
* Get the template variables for the headline
|
94 |
*
|
64 |
);
|
65 |
}
|
66 |
|
|
|
|
|
|
|
|
|
67 |
function get_less_variables( $instance ) {
|
68 |
return array(
|
69 |
'color' => $instance['color'],
|
73 |
);
|
74 |
}
|
75 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
76 |
/**
|
77 |
* Get the template variables for the headline
|
78 |
*
|
widgets/icon/styles/{sow-icon.less → default.less}
RENAMED
File without changes
|
widgets/icon/tpl/{icon.php → default.php}
RENAMED
File without changes
|
widgets/image-grid/image-grid.php
CHANGED
@@ -43,12 +43,6 @@ class SiteOrigin_Widgets_ImageGrid_Widget extends SiteOrigin_Widget {
|
|
43 |
}
|
44 |
|
45 |
function initialize_form(){
|
46 |
-
$intermediate = get_intermediate_image_sizes();
|
47 |
-
$sizes = array();
|
48 |
-
foreach( $intermediate as $name ) {
|
49 |
-
$sizes[$name] = ucwords(preg_replace('/[-_]/', ' ', $name));
|
50 |
-
}
|
51 |
-
$sizes = array_merge( array( 'full' => __('Full', 'so-widgets-bundle') ), $sizes );
|
52 |
|
53 |
return array(
|
54 |
|
@@ -83,8 +77,7 @@ class SiteOrigin_Widgets_ImageGrid_Widget extends SiteOrigin_Widget {
|
|
83 |
'fields' => array(
|
84 |
'attachment_size' => array(
|
85 |
'label' => __('Image size', 'so-widgets-bundle'),
|
86 |
-
'type' => '
|
87 |
-
'options' => $sizes,
|
88 |
'default' => 'full',
|
89 |
),
|
90 |
|
43 |
}
|
44 |
|
45 |
function initialize_form(){
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
|
47 |
return array(
|
48 |
|
77 |
'fields' => array(
|
78 |
'attachment_size' => array(
|
79 |
'label' => __('Image size', 'so-widgets-bundle'),
|
80 |
+
'type' => 'image-size',
|
|
|
81 |
'default' => 'full',
|
82 |
),
|
83 |
|
widgets/image/image.php
CHANGED
@@ -23,20 +23,7 @@ class SiteOrigin_Widget_Image_Widget extends SiteOrigin_Widget {
|
|
23 |
);
|
24 |
}
|
25 |
|
26 |
-
function initialize_form(){
|
27 |
-
|
28 |
-
global $_wp_additional_image_sizes;
|
29 |
-
$sizes = array(
|
30 |
-
'full' => __('Full', 'so-widgets-bundle'),
|
31 |
-
'large' => __('Large', 'so-widgets-bundle'),
|
32 |
-
'medium' => __('Medium', 'so-widgets-bundle'),
|
33 |
-
'thumb' => __('Thumbnail', 'so-widgets-bundle'),
|
34 |
-
);
|
35 |
-
if( !empty($_wp_additional_image_sizes) ) {
|
36 |
-
foreach($_wp_additional_image_sizes as $i => $s) {
|
37 |
-
$sizes[$i] = $i;
|
38 |
-
}
|
39 |
-
}
|
40 |
|
41 |
return array(
|
42 |
'image' => array(
|
@@ -47,9 +34,8 @@ class SiteOrigin_Widget_Image_Widget extends SiteOrigin_Widget {
|
|
47 |
),
|
48 |
|
49 |
'size' => array(
|
50 |
-
'type' => '
|
51 |
'label' => __('Image size', 'so-widgets-bundle'),
|
52 |
-
'options' => $sizes,
|
53 |
),
|
54 |
|
55 |
'align' => array(
|
@@ -115,10 +101,6 @@ class SiteOrigin_Widget_Image_Widget extends SiteOrigin_Widget {
|
|
115 |
return substr( md5( serialize( $this->get_less_variables( $instance ) ) ), 0, 12 );
|
116 |
}
|
117 |
|
118 |
-
function get_template_name($instance) {
|
119 |
-
return 'base';
|
120 |
-
}
|
121 |
-
|
122 |
public function get_template_variables( $instance, $args ) {
|
123 |
return array(
|
124 |
'title' => $instance['title'],
|
@@ -132,10 +114,6 @@ class SiteOrigin_Widget_Image_Widget extends SiteOrigin_Widget {
|
|
132 |
);
|
133 |
}
|
134 |
|
135 |
-
function get_style_name($instance) {
|
136 |
-
return 'sow-image';
|
137 |
-
}
|
138 |
-
|
139 |
function get_less_variables($instance){
|
140 |
return array(
|
141 |
'image_alignment' => $instance['align'],
|
23 |
);
|
24 |
}
|
25 |
|
26 |
+
function initialize_form() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
|
28 |
return array(
|
29 |
'image' => array(
|
34 |
),
|
35 |
|
36 |
'size' => array(
|
37 |
+
'type' => 'image-size',
|
38 |
'label' => __('Image size', 'so-widgets-bundle'),
|
|
|
39 |
),
|
40 |
|
41 |
'align' => array(
|
101 |
return substr( md5( serialize( $this->get_less_variables( $instance ) ) ), 0, 12 );
|
102 |
}
|
103 |
|
|
|
|
|
|
|
|
|
104 |
public function get_template_variables( $instance, $args ) {
|
105 |
return array(
|
106 |
'title' => $instance['title'],
|
114 |
);
|
115 |
}
|
116 |
|
|
|
|
|
|
|
|
|
117 |
function get_less_variables($instance){
|
118 |
return array(
|
119 |
'image_alignment' => $instance['align'],
|
widgets/image/styles/{sow-image.less → default.less}
RENAMED
File without changes
|
widgets/image/tpl/{base.php → default.php}
RENAMED
@@ -12,9 +12,7 @@
|
|
12 |
?>
|
13 |
|
14 |
<?php if( $title_position == 'above' ) : ?>
|
15 |
-
<?php echo $args['before_title']; ?>
|
16 |
-
<h2> <?php echo $title ?> </h2>
|
17 |
-
<?php echo $args['after_title']; ?>
|
18 |
<?php endif; ?>
|
19 |
|
20 |
<?php
|
@@ -33,9 +31,10 @@ if( !empty($src) ) {
|
|
33 |
if(!empty($src[1])) $attr['width'] = $src[1];
|
34 |
if(!empty($src[2])) $attr['height'] = $src[2];
|
35 |
if (function_exists('wp_get_attachment_image_srcset')) {
|
36 |
-
$attr['srcset'] = wp_get_attachment_image_srcset($image, $size);
|
37 |
}
|
38 |
}
|
|
|
39 |
|
40 |
$classes = array('so-widget-image');
|
41 |
|
@@ -50,7 +49,5 @@ if(!empty($alt)) $attr['alt'] = $alt;
|
|
50 |
</div>
|
51 |
|
52 |
<?php if( $title_position == 'below' ) : ?>
|
53 |
-
<?php echo $args['before_title']; ?>
|
54 |
-
<h2> <?php echo $title ?> </h2>
|
55 |
-
<?php echo $args['after_title']; ?>
|
56 |
<?php endif; ?>
|
12 |
?>
|
13 |
|
14 |
<?php if( $title_position == 'above' ) : ?>
|
15 |
+
<?php echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
|
|
|
|
|
16 |
<?php endif; ?>
|
17 |
|
18 |
<?php
|
31 |
if(!empty($src[1])) $attr['width'] = $src[1];
|
32 |
if(!empty($src[2])) $attr['height'] = $src[2];
|
33 |
if (function_exists('wp_get_attachment_image_srcset')) {
|
34 |
+
$attr['srcset'] = wp_get_attachment_image_srcset( $image, $size );
|
35 |
}
|
36 |
}
|
37 |
+
$attr = apply_filters( 'siteorigin_widgets_image_attr', $attr, $instance, $this );
|
38 |
|
39 |
$classes = array('so-widget-image');
|
40 |
|
49 |
</div>
|
50 |
|
51 |
<?php if( $title_position == 'below' ) : ?>
|
52 |
+
<?php echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
|
|
|
|
|
53 |
<?php endif; ?>
|
widgets/layout-slider/assets/banner.svg
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="utf-8"?>
|
2 |
+
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
3 |
+
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
4 |
+
viewBox="55 277 240 240" style="enable-background:new 55 277 240 240;" xml:space="preserve">
|
5 |
+
<style type="text/css">
|
6 |
+
.st0{fill:#1880B6;}
|
7 |
+
.st1{fill:#8ED9EF;}
|
8 |
+
.st2{fill:#324249;}
|
9 |
+
.st3{fill:#F2F0DA;}
|
10 |
+
</style>
|
11 |
+
<rect id="Image_Slider_1_" x="55" y="277" class="st0" width="240" height="240"/>
|
12 |
+
<g>
|
13 |
+
<g>
|
14 |
+
<path class="st1" d="M219,349h-88c-2.2,0-4,1.8-4,4v72.7l22.4-22.4c3.1-3.1,8.2-3.1,11.3,0l10.3,10.3l22.3-30.3
|
15 |
+
c3.1-3.1,8.2-3.1,11.3,0l18.4,18.4V353C223,350.8,221.2,349,219,349z"/>
|
16 |
+
<path class="st1" d="M115,361v72c0,2.2,1.8,4,4,4h4v-80h-4C116.8,357,115,358.8,115,361z"/>
|
17 |
+
<path class="st1" d="M231,357h-4v80h4c2.2,0,4-1.8,4-4v-72C235,358.8,233.2,357,231,357z"/>
|
18 |
+
</g>
|
19 |
+
<g>
|
20 |
+
<path class="st2" d="M231,353h-4v0c0-4.4-3.6-8-8-8h-88c-4.4,0-8,3.6-8,8h-4c-4.4,0-8,3.6-8,8v72c0,4.4,3.6,8,8,8h4
|
21 |
+
c0,4.4,3.6,8,8,8h88c4.4,0,8-3.6,8-8v0h4c4.4,0,8-3.6,8-8v-72C239,356.6,235.4,353,231,353z M123,437h-4c-2.2,0-4-1.8-4-4v-72
|
22 |
+
c0-2.2,1.8-4,4-4h4V437z M223,441c0,2.2-1.8,4-4,4h-88c-2.2,0-4-1.8-4-4v-9.6l25.2-25.2c1.6-1.6,4.1-1.6,5.7,0
|
23 |
+
c0,0,8.4,8.4,10.3,10.3c1.9,1.9,3.8,1.9,5.7,0c1.9-1.9,22.3-30.3,22.3-30.3c1.6-1.6,4.1-1.6,5.7,0l21.2,21.2V441z M223,401.7
|
24 |
+
l-18.4-18.4c-3.1-3.1-8.2-3.1-11.3,0L171,413.7l-10.3-10.3c-3.1-3.1-8.2-3.1-11.3,0L127,425.7V353c0-2.2,1.8-4,4-4h88
|
25 |
+
c2.2,0,4,1.8,4,4V401.7z M235,433c0,2.2-1.8,4-4,4h-4v-80h4c2.2,0,4,1.8,4,4V433z"/>
|
26 |
+
<path class="st2" d="M169,373h-6.2c-0.3-1.3-0.8-2.5-1.5-3.5l4.4-4.4c0.8-0.8,0.8-2,0-2.8c-0.8-0.8-2-0.8-2.8,0l-4.4,4.4
|
27 |
+
c-1.1-0.7-2.2-1.2-3.5-1.5V359c0-1.1-0.9-2-2-2c-1.1,0-2,0.9-2,2v6.2c-1.3,0.3-2.5,0.8-3.5,1.5l-4.4-4.4c-0.8-0.8-2-0.8-2.8,0
|
28 |
+
c-0.8,0.8-0.8,2.1,0,2.8l4.4,4.4c-0.7,1-1.2,2.2-1.5,3.5H137c-1.1,0-2,0.9-2,2c0,1.1,0.9,2,2,2h6.2c0.3,1.3,0.8,2.5,1.5,3.5
|
29 |
+
l-4.4,4.4c-0.8,0.8-0.8,2,0,2.8c0.8,0.8,2.1,0.8,2.8,0l4.4-4.4c1.1,0.7,2.2,1.2,3.5,1.5v6.2c0,1.1,0.9,2,2,2c1.1,0,2-0.9,2-2v-6.2
|
30 |
+
c1.3-0.3,2.5-0.8,3.5-1.5l4.4,4.4c0.8,0.8,2,0.8,2.8,0c0.8-0.8,0.8-2.1,0-2.8l-4.4-4.4c0.7-1,1.2-2.2,1.5-3.5h6.2c1.1,0,2-0.9,2-2
|
31 |
+
C171,373.9,170.1,373,169,373z M153,381c-3.3,0-6-2.7-6-6l0,0c0,0,0,0,0,0c0-3.3,2.7-6,6-6s6,2.7,6,6C159,378.3,156.3,381,153,381
|
32 |
+
z"/>
|
33 |
+
</g>
|
34 |
+
<g>
|
35 |
+
<path class="st3" d="M201.8,386.1c-1.6-1.6-4.1-1.6-5.7,0c0,0-20.4,28.4-22.3,30.3c-1.9,1.9-3.8,1.9-5.7,0
|
36 |
+
c-1.9-1.9-10.3-10.3-10.3-10.3c-1.6-1.6-4.1-1.6-5.7,0L127,431.4v9.6c0,2.2,1.8,4,4,4h88c2.2,0,4-1.8,4-4v-33.7L201.8,386.1z"/>
|
37 |
+
<path class="st3" d="M153,381c3.3,0,6-2.7,6-6c0-3.3-2.7-6-6-6c-3.3,0-6,2.7-6,6C147,378.3,149.7,381,153,381z"/>
|
38 |
+
</g>
|
39 |
+
</g>
|
40 |
+
</svg>
|
widgets/layout-slider/layout-slider.php
ADDED
@@ -0,0 +1,300 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Widget Name: Layout Slider
|
4 |
+
Description: A slider that allows you to create responsive columnized content for each slide.
|
5 |
+
Author: SiteOrigin
|
6 |
+
Author URI: https://siteorigin.com
|
7 |
+
*/
|
8 |
+
|
9 |
+
if( !class_exists( 'SiteOrigin_Widget_Base_Slider' ) ) include_once plugin_dir_path(SOW_BUNDLE_BASE_FILE) . '/base/inc/widgets/base-slider.class.php';
|
10 |
+
|
11 |
+
class SiteOrigin_Widget_LayoutSlider_Widget extends SiteOrigin_Widget_Base_Slider {
|
12 |
+
|
13 |
+
protected $buttons = array();
|
14 |
+
|
15 |
+
function __construct() {
|
16 |
+
parent::__construct(
|
17 |
+
'sow-layout-slider',
|
18 |
+
__('SiteOrigin Layout Slider', 'so-widgets-bundle'),
|
19 |
+
array(
|
20 |
+
'description' => __('A slider that allows you to create responsive columnized content for each slide.', 'so-widgets-bundle'),
|
21 |
+
'help' => 'https://siteorigin.com/widgets-bundle/layout-slider-widget/',
|
22 |
+
'panels_title' => false,
|
23 |
+
),
|
24 |
+
array( ),
|
25 |
+
false,
|
26 |
+
plugin_dir_path(__FILE__)
|
27 |
+
);
|
28 |
+
}
|
29 |
+
|
30 |
+
function initialize_form(){
|
31 |
+
return array(
|
32 |
+
'frames' => array(
|
33 |
+
'type' => 'repeater',
|
34 |
+
'label' => __('Slider frames', 'so-widgets-bundle'),
|
35 |
+
'item_name' => __('Frame', 'so-widgets-bundle'),
|
36 |
+
'item_label' => array(
|
37 |
+
'selector' => "[id*='frames-title']",
|
38 |
+
'update_event' => 'change',
|
39 |
+
'value_method' => 'val'
|
40 |
+
),
|
41 |
+
|
42 |
+
'fields' => array(
|
43 |
+
|
44 |
+
'content' => array(
|
45 |
+
'type' => 'builder',
|
46 |
+
'builder_type' => 'layout_slider_builder',
|
47 |
+
'label' => __( 'Content', 'so-widgets-bundle' ),
|
48 |
+
),
|
49 |
+
|
50 |
+
'background' => array(
|
51 |
+
'type' => 'section',
|
52 |
+
'label' => __('Background', 'so-widgets-bundle'),
|
53 |
+
'fields' => array(
|
54 |
+
'image' => array(
|
55 |
+
'type' => 'media',
|
56 |
+
'label' => __( 'Background image', 'so-widgets-bundle' ),
|
57 |
+
'library' => 'image',
|
58 |
+
'fallback' => true,
|
59 |
+
),
|
60 |
+
|
61 |
+
'image_type' => array(
|
62 |
+
'type' => 'select',
|
63 |
+
'label' => __('Background image type', 'so-widgets-bundle'),
|
64 |
+
'options' => array(
|
65 |
+
'cover' => __('Cover', 'so-widgets-bundle'),
|
66 |
+
),
|
67 |
+
'default' => 'cover',
|
68 |
+
),
|
69 |
+
|
70 |
+
'opacity' => array(
|
71 |
+
'label' => __( 'Background image opacity', 'so-widgets-bundle' ),
|
72 |
+
'type' => 'slider',
|
73 |
+
'min' => 0,
|
74 |
+
'max' => 100,
|
75 |
+
'default' => 100,
|
76 |
+
),
|
77 |
+
|
78 |
+
'color' => array(
|
79 |
+
'type' => 'color',
|
80 |
+
'label' => __( 'Background color', 'so-widgets-bundle' ),
|
81 |
+
'default' => '#333333',
|
82 |
+
),
|
83 |
+
|
84 |
+
'url' => array(
|
85 |
+
'type' => 'link',
|
86 |
+
'label' => __( 'Destination URL', 'so-widgets-bundle' ),
|
87 |
+
),
|
88 |
+
|
89 |
+
'new_window' => array(
|
90 |
+
'type' => 'checkbox',
|
91 |
+
'label' => __( 'Open URL in a new window', 'so-widgets-bundle' ),
|
92 |
+
),
|
93 |
+
|
94 |
+
'videos' => array(
|
95 |
+
'type' => 'repeater',
|
96 |
+
'item_name' => __('Video', 'so-widgets-bundle'),
|
97 |
+
'label' => __('Background videos', 'so-widgets-bundle'),
|
98 |
+
'item_label' => array(
|
99 |
+
'selector' => "[id*='frames-background_videos-url']",
|
100 |
+
'update_event' => 'change',
|
101 |
+
'value_method' => 'val'
|
102 |
+
),
|
103 |
+
'fields' => $this->video_form_fields(),
|
104 |
+
),
|
105 |
+
)
|
106 |
+
),
|
107 |
+
),
|
108 |
+
),
|
109 |
+
|
110 |
+
'controls' => array(
|
111 |
+
'type' => 'section',
|
112 |
+
'label' => __('Slider Controls', 'so-widgets-bundle'),
|
113 |
+
'fields' => $this->control_form_fields()
|
114 |
+
),
|
115 |
+
|
116 |
+
'design' => array(
|
117 |
+
'type' => 'section',
|
118 |
+
'label' => __('Design and Layout', 'so-widgets-bundle'),
|
119 |
+
'fields' => array(
|
120 |
+
|
121 |
+
'height' => array(
|
122 |
+
'type' => 'measurement',
|
123 |
+
'label' => __( 'Height', 'so-widgets-bundle' ),
|
124 |
+
'default' => 'default',
|
125 |
+
),
|
126 |
+
|
127 |
+
'padding' => array(
|
128 |
+
'type' => 'measurement',
|
129 |
+
'label' => __('Top and bottom padding', 'so-widgets-bundle'),
|
130 |
+
'default' => '50px',
|
131 |
+
),
|
132 |
+
|
133 |
+
'extra_top_padding' => array(
|
134 |
+
'type' => 'measurement',
|
135 |
+
'label' => __('Extra top padding', 'so-widgets-bundle'),
|
136 |
+
'description' => __('Additional padding added to the top of the slider', 'so-widgets-bundle'),
|
137 |
+
'default' => '0px',
|
138 |
+
),
|
139 |
+
|
140 |
+
'padding_sides' => array(
|
141 |
+
'type' => 'measurement',
|
142 |
+
'label' => __('Side padding', 'so-widgets-bundle'),
|
143 |
+
'default' => '20px',
|
144 |
+
),
|
145 |
+
|
146 |
+
'width' => array(
|
147 |
+
'type' => 'measurement',
|
148 |
+
'label' => __('Maximum container width', 'so-widgets-bundle'),
|
149 |
+
'default' => '1280px',
|
150 |
+
),
|
151 |
+
|
152 |
+
'heading_color' => array(
|
153 |
+
'type' => 'color',
|
154 |
+
'label' => __('Heading color', 'so-widgets-bundle'),
|
155 |
+
'default' => '#FFFFFF',
|
156 |
+
),
|
157 |
+
|
158 |
+
'heading_size' => array(
|
159 |
+
'type' => 'measurement',
|
160 |
+
'label' => __('Heading size', 'so-widgets-bundle'),
|
161 |
+
'default' => '38px',
|
162 |
+
),
|
163 |
+
|
164 |
+
'heading_shadow' => array(
|
165 |
+
'type' => 'slider',
|
166 |
+
'label' => __('Heading shadow intensity', 'so-widgets-bundle'),
|
167 |
+
'max' => 100,
|
168 |
+
'min' => 0,
|
169 |
+
'default' => 50,
|
170 |
+
),
|
171 |
+
|
172 |
+
'text_size' => array(
|
173 |
+
'type' => 'measurement',
|
174 |
+
'label' => __('Text size', 'so-widgets-bundle'),
|
175 |
+
'default' => '16px',
|
176 |
+
),
|
177 |
+
|
178 |
+
'text_color' => array(
|
179 |
+
'type' => 'color',
|
180 |
+
'label' => __('Text color', 'so-widgets-bundle'),
|
181 |
+
'default' => '#F6F6F6',
|
182 |
+
),
|
183 |
+
|
184 |
+
)
|
185 |
+
),
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
/**
|
190 |
+
* Get everything necessary for the background image.
|
191 |
+
*
|
192 |
+
* @param $i
|
193 |
+
* @param $frame
|
194 |
+
*
|
195 |
+
* @return array
|
196 |
+
*/
|
197 |
+
function get_frame_background( $i, $frame ){
|
198 |
+
$background_image = siteorigin_widgets_get_attachment_image_src(
|
199 |
+
$frame['background']['image'],
|
200 |
+
'full',
|
201 |
+
!empty( $frame['background']['image_fallback'] ) ? $frame['background']['image_fallback'] : ''
|
202 |
+
);
|
203 |
+
|
204 |
+
return array(
|
205 |
+
'color' => !empty( $frame['background']['color'] ) ? $frame['background']['color'] : false,
|
206 |
+
'image' => !empty( $background_image[0] ) ? $background_image[0] : false,
|
207 |
+
'image-width' => !empty( $background_image[1] ) ? $background_image[1] : 0,
|
208 |
+
'image-height' => !empty( $background_image[2] ) ? $background_image[2] : 0,
|
209 |
+
'image-sizing' => $frame['background']['image_type'],
|
210 |
+
'url' => !empty( $frame['background']['url'] ) ? $frame['background']['url'] : false,
|
211 |
+
'new_window' => !empty( $frame['background']['new_window'] ),
|
212 |
+
'videos' => $frame['background']['videos'],
|
213 |
+
'video-sizing' => 'background',
|
214 |
+
'opacity' => intval($frame['background']['opacity'])/100,
|
215 |
+
);
|
216 |
+
}
|
217 |
+
|
218 |
+
/**
|
219 |
+
* Render the actual content of the frame
|
220 |
+
*
|
221 |
+
* @param $i
|
222 |
+
* @param $frame
|
223 |
+
*/
|
224 |
+
function render_frame_contents($i, $frame) {
|
225 |
+
?>
|
226 |
+
<div class="sow-slider-image-container">
|
227 |
+
<div class="sow-slider-image-wrapper">
|
228 |
+
<?php echo $this->process_content( $frame['content'], $frame ); ?>
|
229 |
+
</div>
|
230 |
+
</div>
|
231 |
+
<?php
|
232 |
+
}
|
233 |
+
|
234 |
+
/**
|
235 |
+
* Process the content.
|
236 |
+
*
|
237 |
+
* @param $content
|
238 |
+
* @param $frame
|
239 |
+
*
|
240 |
+
* @return string
|
241 |
+
*/
|
242 |
+
function process_content( $content, $frame ) {
|
243 |
+
if( function_exists( 'siteorigin_panels_render' ) ) {
|
244 |
+
$content_builder_id = substr( md5( json_encode( $content ) ), 0, 8 );
|
245 |
+
echo siteorigin_panels_render( 'w'.$content_builder_id, true, $content );
|
246 |
+
}
|
247 |
+
else {
|
248 |
+
echo __( 'This widget requires Page Builder.', 'so-widgets-bundle' );
|
249 |
+
}
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* The less variables to control the design of the slider
|
254 |
+
*
|
255 |
+
* @param $instance
|
256 |
+
*
|
257 |
+
* @return array
|
258 |
+
*/
|
259 |
+
function get_less_variables($instance) {
|
260 |
+
$less = array();
|
261 |
+
|
262 |
+
// Slider navigation controls
|
263 |
+
$less['nav_color_hex'] = $instance['controls']['nav_color_hex'];
|
264 |
+
$less['nav_size'] = $instance['controls']['nav_size'];
|
265 |
+
|
266 |
+
// Hero specific design
|
267 |
+
//Measurement field type options
|
268 |
+
$meas_options = array();
|
269 |
+
$meas_options['slide_padding'] = $instance['design']['padding'];
|
270 |
+
$meas_options['slide_padding_extra_top'] = $instance['design']['extra_top_padding'];
|
271 |
+
$meas_options['slide_padding_sides'] = $instance['design']['padding_sides'];
|
272 |
+
$meas_options['slide_width'] = $instance['design']['width'];
|
273 |
+
$meas_options['slide_height'] = $instance['design']['height'];
|
274 |
+
|
275 |
+
$meas_options['heading_size'] = $instance['design']['heading_size'];
|
276 |
+
$meas_options['text_size'] = $instance['design']['text_size'];
|
277 |
+
|
278 |
+
foreach ( $meas_options as $key => $val ) {
|
279 |
+
$less[ $key ] = $this->add_default_measurement_unit( $val );
|
280 |
+
}
|
281 |
+
|
282 |
+
$less['heading_shadow'] = intval( $instance['design']['heading_shadow'] );
|
283 |
+
|
284 |
+
$less['heading_color'] = $instance['design']['heading_color'];
|
285 |
+
$less['text_color'] = $instance['design']['text_color'];
|
286 |
+
|
287 |
+
return $less;
|
288 |
+
}
|
289 |
+
|
290 |
+
function add_default_measurement_unit($val) {
|
291 |
+
if (!empty($val)) {
|
292 |
+
if (!preg_match('/\d+([a-zA-Z%]+)/', $val)) {
|
293 |
+
$val .= 'px';
|
294 |
+
}
|
295 |
+
}
|
296 |
+
return $val;
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
siteorigin_widget_register('sow-layout-slider', __FILE__, 'SiteOrigin_Widget_LayoutSlider_Widget');
|
widgets/layout-slider/styles/default.less
ADDED
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@import "../../../base/less/mixins";
|
2 |
+
|
3 |
+
@nav_color_hex: #FFFFFF;
|
4 |
+
@nav_size: 25;
|
5 |
+
|
6 |
+
@slide_padding: 50px;
|
7 |
+
@slide_padding_extra_top: 0px;
|
8 |
+
@slide_padding_sides: 10px;
|
9 |
+
@slide_width: 1280px;
|
10 |
+
@slide_height: default;
|
11 |
+
@heading_size: 38px;
|
12 |
+
@text_size: 16px;
|
13 |
+
@text_color: #F6F6F6;
|
14 |
+
@heading_shadow: 50;
|
15 |
+
|
16 |
+
@heading_color: #FFFFFF;
|
17 |
+
|
18 |
+
.sow-slider-base {
|
19 |
+
|
20 |
+
ul.sow-slider-images {
|
21 |
+
|
22 |
+
.sow-slider-image-wrapper {
|
23 |
+
padding: @slide_padding+@slide_padding_extra_top @slide_padding_sides @slide_padding @slide_padding_sides;
|
24 |
+
|
25 |
+
max-width: @slide_width;
|
26 |
+
height: @slide_height;
|
27 |
+
|
28 |
+
h1,h2,h3,h4,h5,h6{
|
29 |
+
line-height: 1.375em;
|
30 |
+
color: @heading_color;
|
31 |
+
text-shadow: 0 2px 2px rgba( 0, 0, 0, @heading_shadow/100 );
|
32 |
+
margin: 0.1em 0;
|
33 |
+
}
|
34 |
+
|
35 |
+
p{
|
36 |
+
color: @text_color;
|
37 |
+
text-shadow: 0 1px 2px rgba(0,0,0,0.25);
|
38 |
+
margin: 1em 0;
|
39 |
+
font-size: @text_size;
|
40 |
+
}
|
41 |
+
}
|
42 |
+
}
|
43 |
+
|
44 |
+
.sow-slider-pagination {
|
45 |
+
li a {
|
46 |
+
background: @nav_color_hex;
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
.sow-slide-nav {
|
51 |
+
|
52 |
+
font-size: ~"@{nav_size}px";
|
53 |
+
|
54 |
+
a {
|
55 |
+
color: @nav_color_hex;
|
56 |
+
}
|
57 |
+
}
|
58 |
+
|
59 |
+
}
|
widgets/layout-slider/tpl/default.php
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$this->render_template($instance['controls'], $instance['frames']);
|
widgets/post-carousel/js/carousel.js
CHANGED
@@ -73,57 +73,63 @@ jQuery( function($){
|
|
73 |
var prevTime = 0;
|
74 |
var posInterval;
|
75 |
var negativeDirection = isRTL ? 'right' : 'left';
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
127 |
var setNewPosition = function(newPosition) {
|
128 |
if(newPosition < 50 && newPosition > -( itemWidth * numItems )) {
|
129 |
$itemsContainer.css('transition-duration', "0s");
|
@@ -146,4 +152,4 @@ jQuery( function($){
|
|
146 |
}
|
147 |
)
|
148 |
} );
|
149 |
-
} );
|
73 |
var prevTime = 0;
|
74 |
var posInterval;
|
75 |
var negativeDirection = isRTL ? 'right' : 'left';
|
76 |
+
|
77 |
+
// Verify "swipe" method exists prior to invoking it.
|
78 |
+
if( 'function' === typeof $$.swipe ) {
|
79 |
+
$$.swipe( {
|
80 |
+
excludedElements: "",
|
81 |
+
triggerOnTouchEnd: true,
|
82 |
+
threshold: 75,
|
83 |
+
swipeStatus: function (event, phase, direction, distance, duration, fingerCount, fingerData) {
|
84 |
+
if ( phase == "start" ) {
|
85 |
+
startPosition = -( itemWidth * position);
|
86 |
+
prevTime = new Date().getTime();
|
87 |
+
clearInterval(posInterval);
|
88 |
+
}
|
89 |
+
else if ( phase == "move" ) {
|
90 |
+
if( direction == negativeDirection ) distance *= -1;
|
91 |
+
setNewPosition(startPosition + distance);
|
92 |
+
var newTime = new Date().getTime();
|
93 |
+
var timeDelta = (newTime - prevTime) / 1000;
|
94 |
+
velocity = (distance - prevDistance) / timeDelta;
|
95 |
+
prevTime = newTime;
|
96 |
+
prevDistance = distance;
|
97 |
+
}
|
98 |
+
else if ( phase == "end" ) {
|
99 |
+
validSwipe = true;
|
100 |
+
if( direction == negativeDirection ) distance *= -1;
|
101 |
+
if(Math.abs(velocity) > 400) {
|
102 |
+
velocity *= 0.1;
|
103 |
+
var startTime = new Date().getTime();
|
104 |
+
var cumulativeDistance = 0;
|
105 |
+
posInterval = setInterval(function () {
|
106 |
+
var time = (new Date().getTime() - startTime) / 1000;
|
107 |
+
cumulativeDistance += velocity * time;
|
108 |
+
var newPos = startPosition + distance + cumulativeDistance;
|
109 |
+
var decel = 30;
|
110 |
+
var end = (Math.abs(velocity) - decel) < 0;
|
111 |
+
if(direction == negativeDirection) {
|
112 |
+
velocity += decel;
|
113 |
+
} else {
|
114 |
+
velocity -= decel;
|
115 |
+
}
|
116 |
+
if(end || !setNewPosition(newPos)) {
|
117 |
+
clearInterval(posInterval);
|
118 |
+
setFinalPosition();
|
119 |
+
}
|
120 |
+
}, 20);
|
121 |
+
} else {
|
122 |
+
setFinalPosition();
|
123 |
+
}
|
124 |
+
}
|
125 |
+
else if( phase == "cancel") {
|
126 |
+
updatePosition();
|
127 |
+
}
|
128 |
+
}
|
129 |
+
} );
|
130 |
+
}
|
131 |
+
|
132 |
+
|
133 |
var setNewPosition = function(newPosition) {
|
134 |
if(newPosition < 50 && newPosition > -( itemWidth * numItems )) {
|
135 |
$itemsContainer.css('transition-duration', "0s");
|
152 |
}
|
153 |
)
|
154 |
} );
|
155 |
+
} );
|
widgets/post-carousel/js/carousel.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(e){e(".sow-carousel-wrapper").each(function(){var
|
1 |
+
jQuery(function(e){e(".sow-carousel-wrapper").each(function(){var t=e(this),a=t.closest(".sow-carousel-container"),n=t.closest(".sow-carousel-container").parent(),s=t.find(".sow-carousel-items"),o=t.find(".sow-carousel-item"),i=o.eq(0),r=0,c=1,l=!1,u=o.length,f=t.data("found-posts"),d=u==f,w=i.width()+parseInt(i.css("margin-right")),p=a.hasClass("js-rtl"),g=p?"margin-right":"margin-left",h=function(){0>r&&(r=0),r>=t.find(".sow-carousel-item").length-1&&(r=t.find(".sow-carousel-item").length-1,l||d||(l=!0,c++,s.append('<li class="sow-carousel-item sow-carousel-loading"></li>'),e.get(t.data("ajax-url"),{query:t.data("query"),action:"sow_carousel_load",paged:c},function(a,n){var o=e(a.html);o.appendTo(s).hide().fadeIn(),t.find(".sow-carousel-loading").remove(),u=t.find(".sow-carousel-item").length,d=u==f,l=!1}))),s.css("transition-duration","0.45s"),s.css(g,-(w*r)+"px")};n.on("click","a.sow-carousel-previous",function(e){e.preventDefault(),r-=p?-1:1,h()}),n.on("click","a.sow-carousel-next",function(e){e.preventDefault(),r+=p?-1:1,h()});var m,v=!1,D=0,I=0,T=0,x=0,y=p?"right":"left";"function"==typeof t.swipe&&t.swipe({excludedElements:"",triggerOnTouchEnd:!0,threshold:75,swipeStatus:function(e,t,a,n,s,o,i){if("start"==t)I=-(w*r),x=(new Date).getTime(),clearInterval(m);else if("move"==t){a==y&&(n*=-1),M(I+n);var c=(new Date).getTime(),l=(c-x)/1e3;T=(n-D)/l,x=c,D=n}else if("end"==t)if(v=!0,a==y&&(n*=-1),Math.abs(T)>400){T*=.1;var u=(new Date).getTime(),f=0;m=setInterval(function(){var e=((new Date).getTime()-u)/1e3;f+=T*e;var t=I+n+f,s=30,o=Math.abs(T)-s<0;a==y?T+=s:T-=s,(o||!M(t))&&(clearInterval(m),b())},20)}else b();else"cancel"==t&&h()}});var M=function(e){return 50>e&&e>-(w*u)?(s.css("transition-duration","0s"),s.css(g,e+"px"),!0):!1},b=function(){var e=parseInt(s.css(g));r=Math.abs(Math.round(e/w)),h()};t.on("click",".sow-carousel-item a",function(e){v&&(e.preventDefault(),v=!1)})})});
|
widgets/post-carousel/tpl/base.php
CHANGED
@@ -23,7 +23,7 @@ $posts = new WP_Query( $query );
|
|
23 |
data-ajax-url="<?php echo sow_esc_url( wp_nonce_url( admin_url('admin-ajax.php'), 'widgets_action', '_widgets_nonce' ) ) ?>"
|
24 |
>
|
25 |
<ul class="sow-carousel-items">
|
26 |
-
<?php include 'carousel-post-loop.php' ?>
|
27 |
</ul>
|
28 |
</div>
|
29 |
</div>
|
23 |
data-ajax-url="<?php echo sow_esc_url( wp_nonce_url( admin_url('admin-ajax.php'), 'widgets_action', '_widgets_nonce' ) ) ?>"
|
24 |
>
|
25 |
<ul class="sow-carousel-items">
|
26 |
+
<?php include plugin_dir_path( __FILE__ ) . 'carousel-post-loop.php' ?>
|
27 |
</ul>
|
28 |
</div>
|
29 |
</div>
|
widgets/simple-masonry/simple-masonry.php
CHANGED
@@ -186,14 +186,6 @@ class SiteOrigin_Widget_Simple_Masonry_Widget extends SiteOrigin_Widget {
|
|
186 |
);
|
187 |
}
|
188 |
|
189 |
-
function get_template_name($instance) {
|
190 |
-
return 'simple-masonry';
|
191 |
-
}
|
192 |
-
|
193 |
-
function get_style_name($instance) {
|
194 |
-
return 'simple-masonry';
|
195 |
-
}
|
196 |
-
|
197 |
public function get_template_variables( $instance, $args ) {
|
198 |
return array(
|
199 |
'items' => $instance['items'],
|
186 |
);
|
187 |
}
|
188 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
public function get_template_variables( $instance, $args ) {
|
190 |
return array(
|
191 |
'items' => $instance['items'],
|
widgets/simple-masonry/styles/{simple-masonry.less → default.less}
RENAMED
File without changes
|
widgets/simple-masonry/tpl/{simple-masonry.php → default.php}
RENAMED
File without changes
|
widgets/slider/slider.php
CHANGED
@@ -109,8 +109,10 @@ class SiteOrigin_Widget_Slider_Widget extends SiteOrigin_Widget_Base_Slider {
|
|
109 |
return array(
|
110 |
'color' => !empty( $frame['background_color'] ) ? $frame['background_color'] : false,
|
111 |
'image' => !empty( $background_image ) ? $background_image[0] : false,
|
112 |
-
'
|
|
|
113 |
'image-sizing' => $frame['background_image_type'],
|
|
|
114 |
'videos' => $frame['background_videos'],
|
115 |
'video-sizing' => empty($frame['foreground_image']) ? 'full' : 'background',
|
116 |
'url' => ! empty( $frame['url'] ) ? $frame['url'] : false,
|
109 |
return array(
|
110 |
'color' => !empty( $frame['background_color'] ) ? $frame['background_color'] : false,
|
111 |
'image' => !empty( $background_image ) ? $background_image[0] : false,
|
112 |
+
'image-width' => !empty( $background_image[1] ) ? $background_image[1] : 0,
|
113 |
+
'image-height' => !empty( $background_image[2] ) ? $background_image[2] : 0,
|
114 |
'image-sizing' => $frame['background_image_type'],
|
115 |
+
'opacity' => 1,
|
116 |
'videos' => $frame['background_videos'],
|
117 |
'video-sizing' => empty($frame['foreground_image']) ? 'full' : 'background',
|
118 |
'url' => ! empty( $frame['url'] ) ? $frame['url'] : false,
|
widgets/social-media-buttons/social-media-buttons.php
CHANGED
@@ -170,10 +170,6 @@ class SiteOrigin_Widget_SocialMediaButtons_Widget extends SiteOrigin_Widget {
|
|
170 |
wp_enqueue_script( 'sow-social-media-buttons', plugin_dir_url(__FILE__) . 'js/social-media-buttons-admin.js', array( 'jquery' ), SOW_BUNDLE_VERSION );
|
171 |
}
|
172 |
|
173 |
-
function get_template_name( $instance ) {
|
174 |
-
return 'social-media-buttons';
|
175 |
-
}
|
176 |
-
|
177 |
function get_style_name( $instance ) {
|
178 |
if ( empty( $instance['design']['theme'] ) ) {
|
179 |
return 'atom';
|
170 |
wp_enqueue_script( 'sow-social-media-buttons', plugin_dir_url(__FILE__) . 'js/social-media-buttons-admin.js', array( 'jquery' ), SOW_BUNDLE_VERSION );
|
171 |
}
|
172 |
|
|
|
|
|
|
|
|
|
173 |
function get_style_name( $instance ) {
|
174 |
if ( empty( $instance['design']['theme'] ) ) {
|
175 |
return 'atom';
|
widgets/social-media-buttons/tpl/{social-media-buttons.php → default.php}
RENAMED
File without changes
|
widgets/taxonomy/styles/default.less
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
@color: #b0b0b0;
|
2 |
+
@has_color: false;
|
3 |
+
@hover_color: #cdcdcd;
|
4 |
+
@has_hover_color: false;
|
5 |
+
|
6 |
+
a {
|
7 |
+
&.so-taxonomy-link {
|
8 |
+
.color() when (@has_color = true) {
|
9 |
+
color: @color;
|
10 |
+
}
|
11 |
+
.color();
|
12 |
+
|
13 |
+
.hover() when (@has_hover_color = true) {
|
14 |
+
&:hover {
|
15 |
+
color: @hover_color;
|
16 |
+
}
|
17 |
+
}
|
18 |
+
.hover();
|
19 |
+
}
|
20 |
+
|
21 |
+
&.so-taxonomy-button {
|
22 |
+
margin-top: 1em;
|
23 |
+
color: #fff;
|
24 |
+
background: @color;
|
25 |
+
display: inline-block;
|
26 |
+
margin-right: 0.5em;
|
27 |
+
margin-bottom: 0.5em;
|
28 |
+
text-decoration: none;
|
29 |
+
line-height: 1em;
|
30 |
+
font-size: 0.9em;
|
31 |
+
padding: 0.65em 1em;
|
32 |
+
|
33 |
+
&:hover {
|
34 |
+
background: @hover_color;
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
|
39 |
+
label {
|
40 |
+
display: inline-block;
|
41 |
+
margin-right: 0.5em;
|
42 |
+
}
|
widgets/taxonomy/taxonomy.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/*
|
4 |
+
Widget Name: Taxonomy
|
5 |
+
Description: Displays the selected taxonomy for the current post.
|
6 |
+
Author: SiteOrigin
|
7 |
+
Author URI: https://siteorigin.com
|
8 |
+
*/
|
9 |
+
|
10 |
+
class SiteOrigin_Widget_Taxonomy_Widget extends SiteOrigin_Widget {
|
11 |
+
|
12 |
+
function __construct() {
|
13 |
+
|
14 |
+
parent::__construct(
|
15 |
+
'sow-taxonomy',
|
16 |
+
__( 'SiteOrigin Taxonomy', 'so-widgets-bundle' ),
|
17 |
+
array(
|
18 |
+
'description' => __( 'A taxonomy widget.', 'so-widgets-bundle' )
|
19 |
+
),
|
20 |
+
array(),
|
21 |
+
false,
|
22 |
+
plugin_dir_path( __FILE__ )
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
function initialize_form() {
|
27 |
+
// Gets taxonomy objects and extracts the 'label' field from each one.
|
28 |
+
$taxonomies = wp_list_pluck( get_taxonomies( array(), 'objects' ), 'label' );
|
29 |
+
|
30 |
+
return array(
|
31 |
+
'title' => array(
|
32 |
+
'type' => 'text',
|
33 |
+
'label' => __( 'Title', 'so-widgets-bundle' ),
|
34 |
+
),
|
35 |
+
'taxonomy' => array(
|
36 |
+
'type' => 'select',
|
37 |
+
'label' => __( 'Taxonomies', 'so-widgets-bundle' ),
|
38 |
+
'options' => $taxonomies,
|
39 |
+
),
|
40 |
+
'label' => array(
|
41 |
+
'type' => 'text',
|
42 |
+
'label' => __( 'Label', 'so-widgets-bundle' ),
|
43 |
+
),
|
44 |
+
'display_format' => array(
|
45 |
+
'type' => 'select',
|
46 |
+
'label' => __( 'Display as', 'so-widgets-bundle' ),
|
47 |
+
'options' => array(
|
48 |
+
'link' => __( 'Links', 'so-widgets-bundle' ),
|
49 |
+
'button' => __( 'Buttons', 'so-widgets-bundle' ),
|
50 |
+
),
|
51 |
+
),
|
52 |
+
'color' => array(
|
53 |
+
'type' => 'color',
|
54 |
+
'label' => __( 'Color', 'so-widgets-bundle' ),
|
55 |
+
),
|
56 |
+
'hover_color' => array(
|
57 |
+
'type' => 'color',
|
58 |
+
'label' => __( 'Hover color', 'so-widgets-bundle' ),
|
59 |
+
),
|
60 |
+
);
|
61 |
+
}
|
62 |
+
|
63 |
+
function get_less_variables( $instance ) {
|
64 |
+
return array(
|
65 |
+
'color' => $instance['color'],
|
66 |
+
'has_color' => empty($instance['color']) ? 'false' : 'true',
|
67 |
+
'hover_color' => $instance['hover_color'],
|
68 |
+
'has_hover_color' => empty($instance['hover_color']) ? 'false' : 'true',
|
69 |
+
);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get the template variables for the taxonomy
|
74 |
+
*
|
75 |
+
* @param $instance
|
76 |
+
* @param $args
|
77 |
+
*
|
78 |
+
* @return array
|
79 |
+
*/
|
80 |
+
function get_template_variables( $instance, $args ) {
|
81 |
+
if ( empty( $instance ) ) {
|
82 |
+
return array();
|
83 |
+
}
|
84 |
+
|
85 |
+
return array(
|
86 |
+
'title' => $instance['title'],
|
87 |
+
'taxonomy_name' => $instance['taxonomy'],
|
88 |
+
'label' => $instance['label'],
|
89 |
+
'display_format' => $instance['display_format'],
|
90 |
+
);
|
91 |
+
}
|
92 |
+
}
|
93 |
+
|
94 |
+
siteorigin_widget_register( 'sow-taxonomy', __FILE__, 'SiteOrigin_Widget_Taxonomy_Widget' );
|
widgets/taxonomy/tpl/default.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @var $title
|
4 |
+
* @var $post
|
5 |
+
* @var $taxonomy_name
|
6 |
+
* @var $label
|
7 |
+
* @var $display_format
|
8 |
+
*/
|
9 |
+
?>
|
10 |
+
|
11 |
+
|
12 |
+
<?php if( !empty( $title ) ) echo $args['before_title'] . esc_html( $title ) . $args['after_title']; ?>
|
13 |
+
|
14 |
+
<div class="sow-taxonomy">
|
15 |
+
|
16 |
+
<?php if( !empty( $label ) ) : ?>
|
17 |
+
<label class="sow-taxonomy-label"><?php echo esc_html( $label ) ?></label>
|
18 |
+
<?php endif; ?>
|
19 |
+
|
20 |
+
<?php foreach ( get_the_terms( $post->ID, $taxonomy_name ) as $term ) : ?>
|
21 |
+
<a class="so-taxonomy-<?php echo esc_attr( $display_format )?>" href="<?php echo get_term_link( $term, $taxonomy_name ) ?>" rel="tag"><?php echo esc_html( $term->name ) ?></a>
|
22 |
+
<?php endforeach; ?>
|
23 |
+
|
24 |
+
</div>
|
widgets/video/tpl/default.php
CHANGED
@@ -1,23 +1,47 @@
|
|
1 |
<?php
|
2 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
$video_args = array(
|
5 |
-
'id'
|
6 |
-
'class'
|
7 |
'preload' => 'auto',
|
8 |
-
'style'
|
9 |
);
|
10 |
-
if( $autoplay )
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
?>
|
14 |
|
15 |
<div class="sow-video-wrapper">
|
16 |
<?php if ( $is_skinnable_video_host ) : ?>
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
<?php else : ?>
|
21 |
-
|
22 |
<?php endif; ?>
|
23 |
</div>
|
1 |
<?php
|
2 |
+
/**
|
3 |
+
* @var $player_id
|
4 |
+
* @var $autoplay
|
5 |
+
* @var $skin_class
|
6 |
+
* @var $is_skinnable_video_host
|
7 |
+
* @var $sources
|
8 |
+
* @var $src
|
9 |
+
* @var $video_type
|
10 |
+
*/
|
11 |
+
|
12 |
+
if ( ! empty( $instance['title'] ) ) {
|
13 |
+
echo $args['before_title'] . esc_html( $instance['title'] ) . $args['after_title'];
|
14 |
+
}
|
15 |
|
16 |
$video_args = array(
|
17 |
+
'id' => $player_id,
|
18 |
+
'class' => 'sow-video-widget',
|
19 |
'preload' => 'auto',
|
20 |
+
'style' => 'width:100%;height:100%;',
|
21 |
);
|
22 |
+
if ( $autoplay ) {
|
23 |
+
$video_args['autoplay'] = 1;
|
24 |
+
}
|
25 |
+
if ( ! empty( $poster ) ) {
|
26 |
+
$video_args['poster'] = esc_url( $poster );
|
27 |
+
}
|
28 |
+
if ( $skin_class != 'default' ) {
|
29 |
+
$video_args['class'] = 'mejs-' . $skin_class;
|
30 |
+
}
|
31 |
?>
|
32 |
|
33 |
<div class="sow-video-wrapper">
|
34 |
<?php if ( $is_skinnable_video_host ) : ?>
|
35 |
+
<video
|
36 |
+
<?php foreach ( $video_args as $k => $v ) : ?>
|
37 |
+
<?php echo $k . '="' . $v . '" '; ?>
|
38 |
+
<?php endforeach; ?>
|
39 |
+
>
|
40 |
+
<?php foreach ( $sources as $source ) : ?>
|
41 |
+
<source type="<?php echo esc_attr( $source['video_type'] ) ?>" src="<?php echo esc_url( $source['src'] ) ?>"/>
|
42 |
+
<?php endforeach; ?>
|
43 |
+
</video>
|
44 |
<?php else : ?>
|
45 |
+
<?php echo $this->get_video_oembed( $src, $autoplay ); ?>
|
46 |
<?php endif; ?>
|
47 |
</div>
|
widgets/video/video.php
CHANGED
@@ -1,4 +1,5 @@
|
|
1 |
<?php
|
|
|
2 |
/*
|
3 |
Widget Name: Video Player
|
4 |
Description: Play all your self or externally hosted videos in a customizable video player.
|
@@ -24,83 +25,88 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
24 |
);
|
25 |
}
|
26 |
|
27 |
-
function initialize_form(){
|
28 |
return array(
|
29 |
-
'title'
|
30 |
-
'type'
|
31 |
'label' => __( 'Title', 'so-widgets-bundle' )
|
32 |
),
|
33 |
'host_type' => array(
|
34 |
-
'type'
|
35 |
-
'label'
|
36 |
-
'default'
|
37 |
-
'options'
|
38 |
-
'self'
|
39 |
'external' => __( 'Externally hosted', 'so-widgets-bundle' ),
|
40 |
),
|
41 |
|
42 |
// This field should be a video type state emitter
|
43 |
'state_emitter' => array(
|
44 |
'callback' => 'select',
|
45 |
-
'args'
|
46 |
)
|
47 |
),
|
48 |
|
49 |
'video' => array(
|
50 |
-
'type'
|
51 |
-
'label'
|
52 |
'fields' => array(
|
53 |
-
'
|
54 |
-
'type'
|
55 |
-
'
|
56 |
-
'
|
57 |
-
|
58 |
-
|
59 |
-
|
|
|
|
|
|
|
|
|
|
|
60 |
'state_handler' => array(
|
61 |
-
'video_type[self]'
|
62 |
-
'video_type[external]' => array('hide'),
|
63 |
-
)
|
64 |
),
|
65 |
-
'self_poster'
|
66 |
-
'type'
|
67 |
-
'label'
|
68 |
-
'default'
|
69 |
-
'library'
|
70 |
'state_handler' => array(
|
71 |
-
'video_type[self]'
|
72 |
-
'video_type[external]' => array('hide'),
|
73 |
-
)
|
74 |
),
|
75 |
'external_video' => array(
|
76 |
-
'type'
|
77 |
-
'sanitize'
|
78 |
-
'label'
|
79 |
'state_handler' => array(
|
80 |
-
'video_type[external]' => array('show'),
|
81 |
-
'video_type[self]'
|
82 |
-
)
|
83 |
),
|
84 |
-
)
|
85 |
),
|
86 |
|
87 |
'playback' => array(
|
88 |
-
'type'
|
89 |
-
'label'
|
90 |
'fields' => array(
|
91 |
'autoplay' => array(
|
92 |
-
'type'
|
93 |
'default' => false,
|
94 |
-
'label'
|
95 |
),
|
96 |
-
'oembed'
|
97 |
-
'type'
|
98 |
-
'default'
|
99 |
-
'label'
|
100 |
-
'description'
|
101 |
'state_handler' => array(
|
102 |
-
'video_type[external]' => array('show'),
|
103 |
-
'video_type[self]'
|
104 |
)
|
105 |
)
|
106 |
),
|
@@ -110,8 +116,8 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
110 |
|
111 |
function enqueue_frontend_scripts( $instance ) {
|
112 |
$video_host = $instance['host_type'];
|
113 |
-
if( $video_host == 'external' ) {
|
114 |
-
$video_host = !empty( $instance['video']['external_video'] ) ? $this->get_host_from_url( $instance['video']['external_video'] ) : '';
|
115 |
}
|
116 |
if ( $this->is_skinnable_video_host( $video_host ) ) {
|
117 |
if ( $video_host == 'vimeo' && ! wp_script_is( 'froogaloop' ) ) {
|
@@ -120,7 +126,7 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
120 |
if ( ! wp_style_is( 'sow-html-player-responsive' ) ) {
|
121 |
wp_enqueue_style(
|
122 |
'html-player-responsive',
|
123 |
-
plugin_dir_url(__FILE__) . 'css/html-player-responsive.css',
|
124 |
array(),
|
125 |
SOW_BUNDLE_VERSION
|
126 |
);
|
@@ -131,7 +137,7 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
131 |
if ( ! wp_script_is( 'so-video-widget' ) ) {
|
132 |
wp_enqueue_script(
|
133 |
'so-video-widget',
|
134 |
-
plugin_dir_url(__FILE__) . 'js/so-video-widget' . SOW_BUNDLE_JS_SUFFIX . '.js',
|
135 |
array( 'jquery', 'mediaelement' ),
|
136 |
SOW_BUNDLE_VERSION
|
137 |
);
|
@@ -147,44 +153,51 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
147 |
function get_template_variables( $instance, $args ) {
|
148 |
static $player_id = 1;
|
149 |
|
150 |
-
$
|
151 |
-
$
|
|
|
|
|
|
|
152 |
if ( $video_host == 'self' ) {
|
153 |
|
154 |
-
|
155 |
-
|
156 |
-
$
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
}
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
}
|
166 |
-
|
167 |
-
$poster = !empty( $instance['video']['self_poster'] ) ? wp_get_attachment_url( $instance['video']['self_poster'] ) : '';
|
168 |
-
}
|
169 |
-
else {
|
170 |
-
$video_host = $this->get_host_from_url( $instance['video']['external_video'] );
|
171 |
-
$video_type = 'video/' . $video_host;
|
172 |
-
$src = !empty( $instance['video']['external_video'] ) ? $instance['video']['external_video'] : '';
|
173 |
}
|
174 |
|
175 |
$return = array(
|
176 |
-
'player_id'
|
177 |
-
'host_type'
|
178 |
-
'src'
|
179 |
-
'
|
|
|
180 |
'is_skinnable_video_host' => $this->is_skinnable_video_host( $video_host ),
|
181 |
-
'poster'
|
182 |
-
'autoplay'
|
183 |
-
'skin_class'
|
184 |
);
|
185 |
|
186 |
// Force oEmbed for this video
|
187 |
-
if( $instance['host_type'] == 'external' && $instance['playback']['oembed'] ) {
|
188 |
$return['is_skinnable_video_host'] = false;
|
189 |
}
|
190 |
|
@@ -199,31 +212,37 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
199 |
/**
|
200 |
* Gets a video source embed
|
201 |
*/
|
202 |
-
function get_video_oembed( $src, $autoplay = false ){
|
203 |
-
if( empty($src) )
|
|
|
|
|
204 |
|
205 |
global $content_width;
|
206 |
|
207 |
-
$video_width = !empty($content_width) ? $content_width : 640;
|
208 |
|
209 |
$hash = md5( serialize( array(
|
210 |
-
'src'
|
211 |
-
'width'
|
212 |
'autoplay' => $autoplay,
|
213 |
) ) );
|
214 |
|
215 |
-
$html = get_transient('sow-vid-embed[' . $hash . ']');
|
216 |
-
if( empty($html) ) {
|
217 |
$html = wp_oembed_get( $src, array( 'width' => $video_width ) );
|
218 |
|
219 |
-
if( $autoplay) {
|
220 |
-
$html = preg_replace_callback( '/src=["\'](http[^"\']*)["\']/', array(
|
|
|
|
|
|
|
221 |
}
|
222 |
|
223 |
-
if( !empty($html) ) {
|
224 |
-
set_transient( 'sow-vid-embed[' . $hash . ']', $html, 30*86400 );
|
225 |
}
|
226 |
}
|
|
|
227 |
return $html;
|
228 |
}
|
229 |
|
@@ -234,8 +253,8 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
234 |
*
|
235 |
* @return mixed
|
236 |
*/
|
237 |
-
function autoplay_callback($match){
|
238 |
-
return str_replace($match[1], add_query_arg('autoplay', 1, $match[1]), $match[0]);
|
239 |
}
|
240 |
|
241 |
/**
|
@@ -247,6 +266,7 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
247 |
*/
|
248 |
private function get_host_from_url( $video_url ) {
|
249 |
preg_match( '/https?:\/\/(www.)?([A-Za-z0-9\-]+)\./', $video_url, $matches );
|
|
|
250 |
return ( ! empty( $matches ) && count( $matches ) > 2 ) ? $matches[2] : '';
|
251 |
}
|
252 |
|
@@ -259,7 +279,37 @@ class SiteOrigin_Widget_Video_Widget extends SiteOrigin_Widget {
|
|
259 |
*/
|
260 |
private function is_skinnable_video_host( $video_host ) {
|
261 |
global $wp_version;
|
262 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
263 |
}
|
264 |
}
|
|
|
265 |
siteorigin_widget_register( 'video', __FILE__, 'SiteOrigin_Widget_Video_Widget' );
|
1 |
<?php
|
2 |
+
|
3 |
/*
|
4 |
Widget Name: Video Player
|
5 |
Description: Play all your self or externally hosted videos in a customizable video player.
|
25 |
);
|
26 |
}
|
27 |
|
28 |
+
function initialize_form() {
|
29 |
return array(
|
30 |
+
'title' => array(
|
31 |
+
'type' => 'text',
|
32 |
'label' => __( 'Title', 'so-widgets-bundle' )
|
33 |
),
|
34 |
'host_type' => array(
|
35 |
+
'type' => 'radio',
|
36 |
+
'label' => __( 'Video location', 'so-widgets-bundle' ),
|
37 |
+
'default' => 'self',
|
38 |
+
'options' => array(
|
39 |
+
'self' => __( 'Self hosted', 'so-widgets-bundle' ),
|
40 |
'external' => __( 'Externally hosted', 'so-widgets-bundle' ),
|
41 |
),
|
42 |
|
43 |
// This field should be a video type state emitter
|
44 |
'state_emitter' => array(
|
45 |
'callback' => 'select',
|
46 |
+
'args' => array( 'video_type' )
|
47 |
)
|
48 |
),
|
49 |
|
50 |
'video' => array(
|
51 |
+
'type' => 'section',
|
52 |
+
'label' => __( 'Video File', 'so-widgets-bundle' ),
|
53 |
'fields' => array(
|
54 |
+
'self_sources' => array(
|
55 |
+
'type' => 'repeater',
|
56 |
+
'label' => __( 'Sources', 'so-widgets-bundle' ),
|
57 |
+
'fields' => array(
|
58 |
+
'self_video' => array(
|
59 |
+
'type' => 'media',
|
60 |
+
'fallback' => true,
|
61 |
+
'label' => __( 'Select video', 'so-widgets-bundle' ),
|
62 |
+
'default' => '',
|
63 |
+
'library' => 'video',
|
64 |
+
),
|
65 |
+
),
|
66 |
'state_handler' => array(
|
67 |
+
'video_type[self]' => array( 'show' ),
|
68 |
+
'video_type[external]' => array( 'hide' ),
|
69 |
+
),
|
70 |
),
|
71 |
+
'self_poster' => array(
|
72 |
+
'type' => 'media',
|
73 |
+
'label' => __( 'Select cover image', 'so-widgets-bundle' ),
|
74 |
+
'default' => '',
|
75 |
+
'library' => 'image',
|
76 |
'state_handler' => array(
|
77 |
+
'video_type[self]' => array( 'show' ),
|
78 |
+
'video_type[external]' => array( 'hide' ),
|
79 |
+
),
|
80 |
),
|
81 |
'external_video' => array(
|
82 |
+
'type' => 'text',
|
83 |
+
'sanitize' => 'url',
|
84 |
+
'label' => __( 'Video URL', 'so-widgets-bundle' ),
|
85 |
'state_handler' => array(
|
86 |
+
'video_type[external]' => array( 'show' ),
|
87 |
+
'video_type[self]' => array( 'hide' ),
|
88 |
+
),
|
89 |
),
|
90 |
+
),
|
91 |
),
|
92 |
|
93 |
'playback' => array(
|
94 |
+
'type' => 'section',
|
95 |
+
'label' => __( 'Video Playback', 'so-widgets-bundle' ),
|
96 |
'fields' => array(
|
97 |
'autoplay' => array(
|
98 |
+
'type' => 'checkbox',
|
99 |
'default' => false,
|
100 |
+
'label' => __( 'Autoplay', 'so-widgets-bundle' )
|
101 |
),
|
102 |
+
'oembed' => array(
|
103 |
+
'type' => 'checkbox',
|
104 |
+
'default' => true,
|
105 |
+
'label' => __( 'Use oEmbed', 'so-widgets-bundle' ),
|
106 |
+
'description' => __( 'Always use the embedded video rather than the MediaElement player.', 'so-widgets-bundle' ),
|
107 |
'state_handler' => array(
|
108 |
+
'video_type[external]' => array( 'show' ),
|
109 |
+
'video_type[self]' => array( 'hide' ),
|
110 |
)
|
111 |
)
|
112 |
),
|
116 |
|
117 |
function enqueue_frontend_scripts( $instance ) {
|
118 |
$video_host = $instance['host_type'];
|
119 |
+
if ( $video_host == 'external' ) {
|
120 |
+
$video_host = ! empty( $instance['video']['external_video'] ) ? $this->get_host_from_url( $instance['video']['external_video'] ) : '';
|
121 |
}
|
122 |
if ( $this->is_skinnable_video_host( $video_host ) ) {
|
123 |
if ( $video_host == 'vimeo' && ! wp_script_is( 'froogaloop' ) ) {
|
126 |
if ( ! wp_style_is( 'sow-html-player-responsive' ) ) {
|
127 |
wp_enqueue_style(
|
128 |
'html-player-responsive',
|
129 |
+
plugin_dir_url( __FILE__ ) . 'css/html-player-responsive.css',
|
130 |
array(),
|
131 |
SOW_BUNDLE_VERSION
|
132 |
);
|
137 |
if ( ! wp_script_is( 'so-video-widget' ) ) {
|
138 |
wp_enqueue_script(
|
139 |
'so-video-widget',
|
140 |
+
plugin_dir_url( __FILE__ ) . 'js/so-video-widget' . SOW_BUNDLE_JS_SUFFIX . '.js',
|
141 |
array( 'jquery', 'mediaelement' ),
|
142 |
SOW_BUNDLE_VERSION
|
143 |
);
|
153 |
function get_template_variables( $instance, $args ) {
|
154 |
static $player_id = 1;
|
155 |
|
156 |
+
$self_sources = array();
|
157 |
+
$external_src = '';
|
158 |
+
$external_video_type = '';
|
159 |
+
$poster = '';
|
160 |
+
$video_host = $instance['host_type'];
|
161 |
if ( $video_host == 'self' ) {
|
162 |
|
163 |
+
foreach ( $instance['video']['self_sources'] as $source ) {
|
164 |
+
$src = '';
|
165 |
+
$video_type = '';
|
166 |
+
if ( ! empty( $source['self_video'] ) ) {
|
167 |
+
// Handle an attachment video
|
168 |
+
$src = wp_get_attachment_url( $source['self_video'] );
|
169 |
+
$video_type = get_post_mime_type( $source['self_video'] );
|
170 |
+
} else if ( ! empty( $source['self_video_fallback'] ) ) {
|
171 |
+
// Handle an external URL video
|
172 |
+
$src = $source['self_video_fallback'];
|
173 |
+
$vid_info = wp_check_filetype( basename( $source['self_video_fallback'] ) );
|
174 |
+
$video_type = $vid_info['type'];
|
175 |
+
}
|
176 |
+
if ( ! empty( $src ) ) {
|
177 |
+
$self_sources[] = array( 'src' => $src, 'video_type' => $video_type );
|
178 |
+
}
|
179 |
}
|
180 |
+
$poster = ! empty( $instance['video']['self_poster'] ) ? wp_get_attachment_url( $instance['video']['self_poster'] ) : '';
|
181 |
+
} else {
|
182 |
+
$video_host = $this->get_host_from_url( $instance['video']['external_video'] );
|
183 |
+
$external_video_type = 'video/' . $video_host;
|
184 |
+
$external_src = ! empty( $instance['video']['external_video'] ) ? $instance['video']['external_video'] : '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
185 |
}
|
186 |
|
187 |
$return = array(
|
188 |
+
'player_id' => 'sow-player-' . ( $player_id ++ ),
|
189 |
+
'host_type' => $instance['host_type'],
|
190 |
+
'src' => $external_src,
|
191 |
+
'sources' => $self_sources,
|
192 |
+
'video_type' => $external_video_type,
|
193 |
'is_skinnable_video_host' => $this->is_skinnable_video_host( $video_host ),
|
194 |
+
'poster' => $poster,
|
195 |
+
'autoplay' => ! empty( $instance['playback']['autoplay'] ),
|
196 |
+
'skin_class' => 'default'
|
197 |
);
|
198 |
|
199 |
// Force oEmbed for this video
|
200 |
+
if ( $instance['host_type'] == 'external' && $instance['playback']['oembed'] ) {
|
201 |
$return['is_skinnable_video_host'] = false;
|
202 |
}
|
203 |
|
212 |
/**
|
213 |
* Gets a video source embed
|
214 |
*/
|
215 |
+
function get_video_oembed( $src, $autoplay = false ) {
|
216 |
+
if ( empty( $src ) ) {
|
217 |
+
return '';
|
218 |
+
}
|
219 |
|
220 |
global $content_width;
|
221 |
|
222 |
+
$video_width = ! empty( $content_width ) ? $content_width : 640;
|
223 |
|
224 |
$hash = md5( serialize( array(
|
225 |
+
'src' => $src,
|
226 |
+
'width' => $video_width,
|
227 |
'autoplay' => $autoplay,
|
228 |
) ) );
|
229 |
|
230 |
+
$html = get_transient( 'sow-vid-embed[' . $hash . ']' );
|
231 |
+
if ( empty( $html ) ) {
|
232 |
$html = wp_oembed_get( $src, array( 'width' => $video_width ) );
|
233 |
|
234 |
+
if ( $autoplay ) {
|
235 |
+
$html = preg_replace_callback( '/src=["\'](http[^"\']*)["\']/', array(
|
236 |
+
$this,
|
237 |
+
'autoplay_callback'
|
238 |
+
), $html );
|
239 |
}
|
240 |
|
241 |
+
if ( ! empty( $html ) ) {
|
242 |
+
set_transient( 'sow-vid-embed[' . $hash . ']', $html, 30 * 86400 );
|
243 |
}
|
244 |
}
|
245 |
+
|
246 |
return $html;
|
247 |
}
|
248 |
|
253 |
*
|
254 |
* @return mixed
|
255 |
*/
|
256 |
+
function autoplay_callback( $match ) {
|
257 |
+
return str_replace( $match[1], add_query_arg( 'autoplay', 1, $match[1] ), $match[0] );
|
258 |
}
|
259 |
|
260 |
/**
|
266 |
*/
|
267 |
private function get_host_from_url( $video_url ) {
|
268 |
preg_match( '/https?:\/\/(www.)?([A-Za-z0-9\-]+)\./', $video_url, $matches );
|
269 |
+
|
270 |
return ( ! empty( $matches ) && count( $matches ) > 2 ) ? $matches[2] : '';
|
271 |
}
|
272 |
|
279 |
*/
|
280 |
private function is_skinnable_video_host( $video_host ) {
|
281 |
global $wp_version;
|
282 |
+
|
283 |
+
return $video_host == 'self' || ( ( $video_host == 'youtube' || $video_host == 'vimeo' ) && $wp_version >= 4.2 );
|
284 |
+
}
|
285 |
+
|
286 |
+
/**
|
287 |
+
*
|
288 |
+
* Update older versions of widget to use multiple sources.
|
289 |
+
*
|
290 |
+
* @param $instance
|
291 |
+
*
|
292 |
+
* @return mixed
|
293 |
+
*/
|
294 |
+
function modify_instance( $instance ) {
|
295 |
+
$video_src = array();
|
296 |
+
if ( isset( $instance['video']['self_video'] ) && ! empty( $instance['video']['self_video'] ) ) {
|
297 |
+
$video_src['self_video'] = $instance['video']['self_video'];
|
298 |
+
unset( $instance['video']['self_video'] );
|
299 |
+
}
|
300 |
+
if ( isset( $instance['video']['self_video_fallback'] ) && ! empty( $instance['video']['self_video_fallback'] ) ) {
|
301 |
+
$video_src['self_video_fallback'] = $instance['video']['self_video_fallback'];
|
302 |
+
unset( $instance['video']['self_video_fallback'] );
|
303 |
+
}
|
304 |
+
if ( ! empty( $video_src ) ) {
|
305 |
+
if ( ! isset( $instance['video']['self_sources'] ) ) {
|
306 |
+
$instance['video']['self_sources'] = array();
|
307 |
+
}
|
308 |
+
$instance['video']['self_sources'][] = $video_src;
|
309 |
+
}
|
310 |
+
|
311 |
+
return $instance;
|
312 |
}
|
313 |
}
|
314 |
+
|
315 |
siteorigin_widget_register( 'video', __FILE__, 'SiteOrigin_Widget_Video_Widget' );
|