Page Builder by SiteOrigin - Version 2.5.1

Version Description

  • 14 April 2017 =
  • Added null function for Sydney theme compatibility.
  • Added method for including additional external layout directories.
  • Added fix for old Vantage PB layout compatibility.
  • Fixed Firefox layout issues.
  • Fixed positioning of edit row dropdown.
  • Fixed warning coming from legacy widgets.
  • Added legacy layout rendering for old browsers.
  • Switched to using calc for cell sizing.
Download this release

Release Info

Developer gpriday
Plugin Icon 128x128 Page Builder by SiteOrigin
Version 2.5.1
Comparing to
See all releases

Code changes from version 2.5.0 to 2.5.1

css/admin.css CHANGED
@@ -282,10 +282,12 @@
282
  cursor: move;
283
  }
284
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper .so-dropdown-links-wrapper {
285
- display: none;
 
 
286
  z-index: 101;
287
  right: -10px;
288
- top: 22px;
289
  width: 125px;
290
  }
291
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper .so-dropdown-links-wrapper ul li a.so-row-delete {
@@ -318,7 +320,9 @@
318
  right: 2px;
319
  }
320
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper:hover .so-dropdown-links-wrapper {
321
- display: block;
 
 
322
  }
323
  .siteorigin-panels-builder .so-rows-container .ui-sortable-placeholder {
324
  visibility: visible !important;
@@ -384,11 +388,11 @@
384
  background: #e4eff4;
385
  padding: 7px 7px 0px 7px;
386
  height: 100%;
387
- min-height: 70px;
388
- -webkit-transition: background 0.25s ease-in-out;
389
- -moz-transition: background 0.25s ease-in-out;
390
- -o-transition: background 0.25s ease-in-out;
391
- transition: background 0.25s ease-in-out;
392
  }
393
  @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
394
  .siteorigin-panels-builder .so-rows-container .so-row-container .so-cells .cell.cell-selected .cell-wrapper {
@@ -549,10 +553,10 @@
549
  cursor: col-resize;
550
  background: #f6fafb;
551
  height: 100%;
552
- -webkit-transition: background 0.25s ease-in-out;
553
- -moz-transition: background 0.25s ease-in-out;
554
- -o-transition: background 0.25s ease-in-out;
555
- transition: background 0.25s ease-in-out;
556
  }
557
  .siteorigin-panels-builder .so-rows-container .so-row-container .so-cells .cell:first-child .resize-handle {
558
  display: none;
@@ -870,10 +874,10 @@
870
  display: block;
871
  top: 0;
872
  right: 0;
873
- -webkit-transition: all 0.2s ease;
874
- -moz-transition: all 0.2s ease;
875
- -o-transition: all 0.2s ease;
876
- transition: all 0.2s ease;
877
  background: #fafafa;
878
  border-left: 1px solid #d8d8d8;
879
  border-bottom: 1px solid #d8d8d8;
@@ -1313,10 +1317,10 @@
1313
  cursor: col-resize;
1314
  background: #e5f4fb;
1315
  height: 360px;
1316
- -webkit-transition: background 0.15s ease-in-out;
1317
- -moz-transition: background 0.15s ease-in-out;
1318
- -o-transition: background 0.15s ease-in-out;
1319
- transition: background 0.15s ease-in-out;
1320
  }
1321
  .so-panels-dialog.so-panels-dialog-row-edit .so-content .row-preview .preview-cell .resize-handle:hover,
1322
  .so-panels-dialog.so-panels-dialog-row-edit .so-content .row-preview .preview-cell .resize-handle.ui-draggable-dragging {
@@ -1399,10 +1403,10 @@
1399
  padding: 50px 30px;
1400
  border: 4px dashed #E0E0E0;
1401
  text-align: center;
1402
- -webkit-transition: all 0.25s ease;
1403
- -moz-transition: all 0.25s ease;
1404
- -o-transition: all 0.25s ease;
1405
- transition: all 0.25s ease;
1406
  }
1407
  .so-panels-dialog.so-panels-dialog-prebuilt-layouts .so-content .import-upload-ui .drag-upload-area.file-dragover {
1408
  background-color: #f2f9fc;
@@ -1844,10 +1848,10 @@
1844
  width: 20px;
1845
  height: 20px;
1846
  overflow: hidden;
1847
- -webkit-transition: all 0.25s ease;
1848
- -moz-transition: all 0.25s ease;
1849
- -o-transition: all 0.25s ease;
1850
- transition: all 0.25s ease;
1851
  }
1852
  .so-panels-live-editor .live-editor-collapse .collapse-icon:before {
1853
  display: block;
@@ -2291,7 +2295,7 @@
2291
  float: right;
2292
  line-height: 16px;
2293
  }
2294
- .so-dropdown-wrapper .so-dropdown-links-wrapper ul .so-pointer {
2295
  width: 12px;
2296
  height: 6px;
2297
  position: absolute;
282
  cursor: move;
283
  }
284
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper .so-dropdown-links-wrapper {
285
+ visibility: hidden;
286
+ opacity: 0;
287
+ transition: 0s visibility linear 0.075s, opacity 0.075s linear;
288
  z-index: 101;
289
  right: -10px;
290
+ top: 100%;
291
  width: 125px;
292
  }
293
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper .so-dropdown-links-wrapper ul li a.so-row-delete {
320
  right: 2px;
321
  }
322
  .siteorigin-panels-builder .so-rows-container .so-row-toolbar .so-dropdown-wrapper:hover .so-dropdown-links-wrapper {
323
+ visibility: visible;
324
+ opacity: 1;
325
+ transition-delay: 0s;
326
  }
327
  .siteorigin-panels-builder .so-rows-container .ui-sortable-placeholder {
328
  visibility: visible !important;
388
  background: #e4eff4;
389
  padding: 7px 7px 0px 7px;
390
  height: 100%;
391
+ min-height: 63px;
392
+ -webkit-transition: background 0.25s ease-in-out 0s;
393
+ -moz-transition: background 0.25s ease-in-out 0s;
394
+ -o-transition: background 0.25s ease-in-out 0s;
395
+ transition: background 0.25s ease-in-out 0s;
396
  }
397
  @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
398
  .siteorigin-panels-builder .so-rows-container .so-row-container .so-cells .cell.cell-selected .cell-wrapper {
553
  cursor: col-resize;
554
  background: #f6fafb;
555
  height: 100%;
556
+ -webkit-transition: background 0.25s ease-in-out 0s;
557
+ -moz-transition: background 0.25s ease-in-out 0s;
558
+ -o-transition: background 0.25s ease-in-out 0s;
559
+ transition: background 0.25s ease-in-out 0s;
560
  }
561
  .siteorigin-panels-builder .so-rows-container .so-row-container .so-cells .cell:first-child .resize-handle {
562
  display: none;
874
  display: block;
875
  top: 0;
876
  right: 0;
877
+ -webkit-transition: all 0.2s ease 0s;
878
+ -moz-transition: all 0.2s ease 0s;
879
+ -o-transition: all 0.2s ease 0s;
880
+ transition: all 0.2s ease 0s;
881
  background: #fafafa;
882
  border-left: 1px solid #d8d8d8;
883
  border-bottom: 1px solid #d8d8d8;
1317
  cursor: col-resize;
1318
  background: #e5f4fb;
1319
  height: 360px;
1320
+ -webkit-transition: background 0.15s ease-in-out 0s;
1321
+ -moz-transition: background 0.15s ease-in-out 0s;
1322
+ -o-transition: background 0.15s ease-in-out 0s;
1323
+ transition: background 0.15s ease-in-out 0s;
1324
  }
1325
  .so-panels-dialog.so-panels-dialog-row-edit .so-content .row-preview .preview-cell .resize-handle:hover,
1326
  .so-panels-dialog.so-panels-dialog-row-edit .so-content .row-preview .preview-cell .resize-handle.ui-draggable-dragging {
1403
  padding: 50px 30px;
1404
  border: 4px dashed #E0E0E0;
1405
  text-align: center;
1406
+ -webkit-transition: all 0.25s ease 0s;
1407
+ -moz-transition: all 0.25s ease 0s;
1408
+ -o-transition: all 0.25s ease 0s;
1409
+ transition: all 0.25s ease 0s;
1410
  }
1411
  .so-panels-dialog.so-panels-dialog-prebuilt-layouts .so-content .import-upload-ui .drag-upload-area.file-dragover {
1412
  background-color: #f2f9fc;
1848
  width: 20px;
1849
  height: 20px;
1850
  overflow: hidden;
1851
+ -webkit-transition: all 0.25s ease 0s;
1852
+ -moz-transition: all 0.25s ease 0s;
1853
+ -o-transition: all 0.25s ease 0s;
1854
+ transition: all 0.25s ease 0s;
1855
  }
1856
  .so-panels-live-editor .live-editor-collapse .collapse-icon:before {
1857
  display: block;
2295
  float: right;
2296
  line-height: 16px;
2297
  }
2298
+ .so-dropdown-wrapper .so-dropdown-links-wrapper .so-pointer {
2299
  width: 12px;
2300
  height: 6px;
2301
  position: absolute;
css/front-legacy.css ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .panel-grid {
2
+ zoom: 1;
3
+ }
4
+ .panel-grid:before {
5
+ content: '';
6
+ display: block;
7
+ }
8
+ .panel-grid:after {
9
+ content: '';
10
+ display: table;
11
+ clear: both;
12
+ }
13
+ .panel-grid-cell {
14
+ -ms-box-sizing: border-box;
15
+ -moz-box-sizing: border-box;
16
+ -webkit-box-sizing: border-box;
17
+ box-sizing: border-box;
18
+ min-height: 1em;
19
+ float: left;
20
+ }
21
+ .panel-grid-cell .so-panel {
22
+ zoom: 1;
23
+ }
24
+ .panel-grid-cell .so-panel:before {
25
+ content: '';
26
+ display: block;
27
+ }
28
+ .panel-grid-cell .so-panel:after {
29
+ content: '';
30
+ display: table;
31
+ clear: both;
32
+ }
33
+ .panel-grid-cell .panel-last-child {
34
+ margin-bottom: 0;
35
+ }
36
+ .panel-grid-cell .widget-title {
37
+ margin-top: 0;
38
+ }
39
+ .panel-row-style {
40
+ zoom: 1;
41
+ }
42
+ .panel-row-style:before {
43
+ content: '';
44
+ display: block;
45
+ }
46
+ .panel-row-style:after {
47
+ content: '';
48
+ display: table;
49
+ clear: both;
50
+ }
css/front.css CHANGED
@@ -5,6 +5,9 @@
5
  -ms-flex-wrap: wrap;
6
  -webkit-flex-wrap: wrap;
7
  flex-wrap: nowrap;
 
 
 
8
  }
9
  .panel-grid-cell {
10
  -ms-box-sizing: border-box;
@@ -33,24 +36,12 @@
33
  .panel-grid-cell .widget-title {
34
  margin-top: 0;
35
  }
36
- .panel-row-style {
37
- zoom: 1;
38
- }
39
- .panel-row-style:before {
40
- content: '';
41
- display: block;
42
- }
43
- .panel-row-style:after {
44
- content: '';
45
- display: table;
46
- clear: both;
47
- }
48
- .siteorigin-panels-stretch {
49
- margin-right: -1000px;
50
- margin-left: -1000px;
51
- padding-right: 1000px;
52
- padding-left: 1000px;
53
- }
54
  body.siteorigin-panels-before-js {
55
  overflow-x: hidden;
56
  }
 
 
 
 
 
 
5
  -ms-flex-wrap: wrap;
6
  -webkit-flex-wrap: wrap;
7
  flex-wrap: nowrap;
8
+ -ms-justify-content: space-between;
9
+ -webkit-justify-content: space-between;
10
+ justify-content: space-between;
11
  }
12
  .panel-grid-cell {
13
  -ms-box-sizing: border-box;
36
  .panel-grid-cell .widget-title {
37
  margin-top: 0;
38
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  body.siteorigin-panels-before-js {
40
  overflow-x: hidden;
41
  }
42
+ body.siteorigin-panels-before-js .siteorigin-panels-stretch {
43
+ margin-right: -1000px !important;
44
+ margin-left: -1000px !important;
45
+ padding-right: 1000px !important;
46
+ padding-left: 1000px !important;
47
+ }
inc/admin-layouts.php ADDED
@@ -0,0 +1,313 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class SiteOrigin_Panels_Admin
5
+ *
6
+ * Handles all the admin and database interactions.
7
+ */
8
+ class SiteOrigin_Panels_Admin_Layouts {
9
+
10
+ const LAYOUT_URL = 'http://layouts.siteorigin.com/';
11
+
12
+ function __construct() {
13
+ // Filter all the available external layout directories.
14
+ add_filter( 'siteorigin_panels_external_layout_directories', array( $this, 'filter_directories' ), 8 );
15
+
16
+ add_action( 'wp_ajax_so_panels_layouts_query', array( $this, 'action_get_prebuilt_layouts' ) );
17
+ add_action( 'wp_ajax_so_panels_get_layout', array( $this, 'action_get_prebuilt_layout' ) );
18
+ add_action( 'wp_ajax_so_panels_import_layout', array( $this, 'action_import_layout' ) );
19
+ add_action( 'wp_ajax_so_panels_export_layout', array( $this, 'action_export_layout' ) );
20
+ add_action( 'wp_ajax_so_panels_directory_enable', array( $this, 'action_directory_enable' ) );
21
+ }
22
+
23
+ /**
24
+ * @return SiteOrigin_Panels_Admin_Layouts
25
+ */
26
+ public static function single() {
27
+ static $single;
28
+ return empty( $single ) ? $single = new self() : $single;
29
+ }
30
+
31
+ /**
32
+ * Add the main SiteOrigin layout directory
33
+ */
34
+ public function filter_directories( $directories ){
35
+ if ( apply_filters( 'siteorigin_panels_layouts_directory_enabled', true ) ) {
36
+ $directories['siteorigin'] = array(
37
+ // The title of the layouts directory in the sidebar.
38
+ 'title' => __( 'Layouts Directory', 'siteorigin-panels' ),
39
+ // The URL of the directory.
40
+ 'url' => self::LAYOUT_URL,
41
+ // Any additional arguments to pass to the layouts server
42
+ 'args' => array()
43
+ );
44
+ }
45
+
46
+ return $directories;
47
+ }
48
+
49
+ /**
50
+ * Get all the layout directories.
51
+ *
52
+ * @return array
53
+ */
54
+ public function get_directories(){
55
+ $directories = apply_filters( 'siteorigin_panels_external_layout_directories', array() );
56
+ if( empty( $directories ) || ! is_array( $directories ) ) {
57
+ $directories = array();
58
+ }
59
+
60
+ return $directories;
61
+ }
62
+
63
+ /**
64
+ * Gets all the prebuilt layouts
65
+ */
66
+ function action_get_prebuilt_layouts() {
67
+ if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
68
+ wp_die();
69
+ }
70
+
71
+ // Get any layouts that the current user could edit.
72
+ header( 'content-type: application/json' );
73
+
74
+ $type = ! empty( $_REQUEST['type'] ) ? $_REQUEST['type'] : 'directory-siteorigin';
75
+ $search = ! empty( $_REQUEST['search'] ) ? trim( strtolower( $_REQUEST['search'] ) ) : '';
76
+ $page_num = ! empty( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1;
77
+
78
+ $return = array(
79
+ 'title' => '',
80
+ 'items' => array()
81
+ );
82
+ if ( $type == 'prebuilt' ) {
83
+ $return['title'] = __( 'Theme Defined Layouts', 'siteorigin-panels' );
84
+
85
+ // This is for theme bundled prebuilt directories
86
+ $layouts = apply_filters( 'siteorigin_panels_prebuilt_layouts', array() );
87
+
88
+ foreach ( $layouts as $id => $vals ) {
89
+ if ( ! empty( $search ) && strpos( strtolower( $vals['name'] ), $search ) === false ) {
90
+ continue;
91
+ }
92
+
93
+ $return['items'][] = array(
94
+ 'title' => $vals['name'],
95
+ 'id' => $id,
96
+ 'type' => 'prebuilt',
97
+ 'description' => isset( $vals['description'] ) ? $vals['description'] : '',
98
+ 'screenshot' => ! empty( $vals['screenshot'] ) ? $vals['screenshot'] : ''
99
+ );
100
+ }
101
+
102
+ $return['max_num_pages'] = 1;
103
+ } elseif ( substr( $type, 0, 10 ) == 'directory-' ) {
104
+ $return['title'] = __( 'Layouts Directory', 'siteorigin-panels' );
105
+
106
+ // This is a query of the prebuilt layout directory
107
+ $query = array();
108
+ if ( ! empty( $search ) ) {
109
+ $query['search'] = $search;
110
+ }
111
+ $query['page'] = $page_num;
112
+
113
+ $directory_id = str_replace( 'directory-', '', $type );
114
+ $directories = $this->get_directories();
115
+ $directory = ! empty( $directories[ $directory_id ] ) ? $directories[ $directory_id ] : false;
116
+
117
+ if( empty( $directory ) ) {
118
+ return false;
119
+ }
120
+
121
+ $url = add_query_arg( $query, $directory[ 'url' ] . 'wp-admin/admin-ajax.php?action=query_layouts' );
122
+ if( ! empty( $directory[ 'args' ] ) && is_array( $directory[ 'args' ] ) ) {
123
+ $url = add_query_arg( $directory[ 'args' ], $url );
124
+ }
125
+
126
+ $url = apply_filters( 'siteorigin_panels_layouts_directory_url', $url );
127
+ $response = wp_remote_get( $url );
128
+
129
+ if ( is_array( $response ) && $response['response']['code'] == 200 ) {
130
+ $results = json_decode( $response['body'], true );
131
+ if ( ! empty( $results ) && ! empty( $results['items'] ) ) {
132
+ foreach ( $results['items'] as $item ) {
133
+ $item['id'] = $item['slug'];
134
+ $item['type'] = $type;
135
+
136
+ if( empty( $item['screenshot'] ) && ! empty( $item['preview'] ) ) {
137
+ $screenshot_url = add_query_arg( 'screenshot_preview', 1, $item['preview'] );
138
+ $item['screenshot'] = 'http://s.wordpress.com/mshots/v1/' . urlencode( $screenshot_url ) . '?w=700';
139
+ }
140
+
141
+ $return['items'][] = $item;
142
+ }
143
+ }
144
+
145
+ $return['max_num_pages'] = $results['max_num_pages'];
146
+ }
147
+ } elseif ( strpos( $type, 'clone_' ) !== false ) {
148
+ // Check that the user can view the given page types
149
+ $post_type = get_post_type_object( str_replace( 'clone_', '', $type ) );
150
+ if( empty( $post_type ) ) {
151
+ return;
152
+ }
153
+
154
+ $return['title'] = sprintf( __( 'Clone %s', 'siteorigin-panels' ), esc_html( $post_type->labels->singular_name ) );
155
+
156
+ global $wpdb;
157
+ $user_can_read_private = ( $post_type == 'post' && current_user_can( 'read_private_posts' ) || ( $post_type == 'page' && current_user_can( 'read_private_pages' ) ) );
158
+ $include_private = $user_can_read_private ? "OR posts.post_status = 'private' " : "";
159
+
160
+ // Select only the posts with the given post type that also have panels_data
161
+ $results = $wpdb->get_results( "
162
+ SELECT SQL_CALC_FOUND_ROWS DISTINCT ID, post_title, meta.meta_value
163
+ FROM {$wpdb->posts} AS posts
164
+ JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
165
+ WHERE
166
+ posts.post_type = '" . esc_sql( $post_type->name ) . "'
167
+ AND meta.meta_key = 'panels_data'
168
+ " . ( ! empty( $search ) ? 'AND posts.post_title LIKE "%' . esc_sql( $search ) . '%"' : '' ) . "
169
+ AND ( posts.post_status = 'publish' OR posts.post_status = 'draft' " . $include_private . ")
170
+ ORDER BY post_date DESC
171
+ LIMIT 16 OFFSET " . intval( ( $page_num - 1 ) * 16 ) );
172
+ $total_posts = $wpdb->get_var( "SELECT FOUND_ROWS();" );
173
+
174
+ foreach ( $results as $result ) {
175
+ $thumbnail = get_the_post_thumbnail_url( $result->ID, array( 400, 300 ) );
176
+ $return['items'][] = array(
177
+ 'id' => $result->ID,
178
+ 'title' => $result->post_title,
179
+ 'type' => $type,
180
+ 'screenshot' => ! empty( $thumbnail ) ? $thumbnail : ''
181
+ );
182
+ }
183
+
184
+ $return['max_num_pages'] = ceil( $total_posts / 16 );
185
+
186
+ } else {
187
+ // An invalid type. Display an error message.
188
+ }
189
+
190
+ // Add the search part to the title
191
+ if ( ! empty( $search ) ) {
192
+ $return['title'] .= __( ' - Results For:', 'siteorigin-panels' ) . ' <em>' . esc_html( $search ) . '</em>';
193
+ }
194
+
195
+ echo json_encode( $return );
196
+
197
+ wp_die();
198
+ }
199
+
200
+ /**
201
+ * Ajax handler to get an individual prebuilt layout
202
+ */
203
+ function action_get_prebuilt_layout() {
204
+ if ( empty( $_REQUEST['type'] ) ) {
205
+ wp_die();
206
+ }
207
+ if ( empty( $_REQUEST['lid'] ) ) {
208
+ wp_die();
209
+ }
210
+ if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
211
+ wp_die();
212
+ }
213
+
214
+ header( 'content-type: application/json' );
215
+ $panels_data = array();
216
+
217
+ if ( $_REQUEST['type'] == 'prebuilt' ) {
218
+ $layouts = apply_filters( 'siteorigin_panels_prebuilt_layouts', array() );
219
+ $lid = ! empty( $_REQUEST['lid'] ) ? $_REQUEST['lid'] : false;
220
+
221
+ if ( empty( $lid ) || empty( $layouts[ $lid ] ) ) {
222
+ // Display an error message
223
+ wp_die();
224
+ }
225
+
226
+ $layout = $layouts[ $_REQUEST['lid'] ];
227
+
228
+ // Fix the format of this layout
229
+ if( !empty( $layout[ 'filename' ] ) ) {
230
+ $filename = $layout[ 'filename' ];
231
+ // Only accept filenames that end with .json
232
+ if( substr( $filename, -5, 5 ) === '.json' && file_exists( $filename ) ) {
233
+ $panels_data = json_decode( file_get_contents( $filename ), true );
234
+ $layout[ 'widgets' ] = ! empty( $panels_data[ 'widgets' ] ) ? $panels_data[ 'widgets' ] : array();
235
+ $layout[ 'grids' ] = ! empty( $panels_data[ 'grids' ] ) ? $panels_data[ 'grids' ] : array();
236
+ $layout[ 'grid_cells' ] = ! empty( $panels_data[ 'grid_cells' ] ) ? $panels_data[ 'grid_cells' ] : array();
237
+ }
238
+ }
239
+
240
+ // A theme or plugin could use this to change the data in the layout
241
+ $panels_data = apply_filters( 'siteorigin_panels_prebuilt_layout', $layout, $lid );
242
+
243
+ // Remove all the layout specific attributes
244
+ if ( isset( $panels_data['name'] ) ) unset( $panels_data['name'] );
245
+ if ( isset( $panels_data['screenshot'] ) ) unset( $panels_data['screenshot'] );
246
+ if ( isset( $panels_data['filename'] ) ) unset( $panels_data['filename'] );
247
+
248
+ } elseif ( substr( $_REQUEST['type'], 0, 10 ) == 'directory-' ) {
249
+ $directory_id = str_replace( 'directory-', '', $_REQUEST['type'] );
250
+ $directories = $this->get_directories();
251
+ $directory = ! empty( $directories[ $directory_id ] ) ? $directories[ $directory_id ] : false;
252
+
253
+ if( ! empty( $directory ) ) {
254
+ $url = $directory[ 'url' ] . 'layout/' . urlencode( $_REQUEST[ 'lid' ] ) . '/?action=download';
255
+ if( ! empty( $directory[ 'args' ] ) && is_array( $directory[ 'args' ] ) ) {
256
+ $url = add_query_arg( $directory[ 'args' ], $url );
257
+ }
258
+
259
+ $response = wp_remote_get( $url );
260
+ if ( $response['response']['code'] == 200 ) {
261
+ // For now, we'll just pretend to load this
262
+ $panels_data = json_decode( $response['body'], true );
263
+ } else {
264
+ // Display some sort of error message
265
+ }
266
+ }
267
+
268
+ } elseif ( current_user_can( 'edit_post', $_REQUEST['lid'] ) ) {
269
+ $panels_data = get_post_meta( $_REQUEST['lid'], 'panels_data', true );
270
+ }
271
+
272
+ $panels_data = apply_filters( 'siteorigin_panels_data', $panels_data );
273
+
274
+ $panels_data['widgets'] = SiteOrigin_Panels_Admin::single()->process_raw_widgets( $panels_data['widgets'], array(), true, true );
275
+
276
+ echo json_encode( $panels_data );
277
+ wp_die();
278
+ }
279
+
280
+ /**
281
+ * Ajax handler to import a layout
282
+ */
283
+ function action_import_layout() {
284
+ if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
285
+ wp_die();
286
+ }
287
+
288
+ if ( ! empty( $_FILES['panels_import_data']['tmp_name'] ) ) {
289
+ header( 'content-type:application/json' );
290
+ $json = file_get_contents( $_FILES['panels_import_data']['tmp_name'] );
291
+ @unlink( $_FILES['panels_import_data']['tmp_name'] );
292
+ echo $json;
293
+ }
294
+ wp_die();
295
+ }
296
+
297
+ /**
298
+ * Export a given layout as a JSON file.
299
+ */
300
+ function action_export_layout() {
301
+ if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
302
+ wp_die();
303
+ }
304
+
305
+ header( 'content-type: application/json' );
306
+ header( 'Content-Disposition: attachment; filename=layout-' . date( 'dmY' ) . '.json' );
307
+
308
+ $export_data = wp_unslash( $_POST['panels_export_data'] );
309
+ echo $export_data;
310
+
311
+ wp_die();
312
+ }
313
+ }
inc/admin.php CHANGED
@@ -7,8 +7,6 @@
7
  */
8
  class SiteOrigin_Panels_Admin {
9
 
10
- const LAYOUT_URL = 'http://layouts.siteorigin.com/';
11
-
12
  /**
13
  * @var bool Store that we're in the save post action, to prevent infinite loops
14
  */
@@ -55,16 +53,12 @@ class SiteOrigin_Panels_Admin {
55
  // Register all the admin actions
56
  add_action( 'wp_ajax_so_panels_builder_content', array( $this, 'action_builder_content' ) );
57
  add_action( 'wp_ajax_so_panels_widget_form', array( $this, 'action_widget_form' ) );
58
- add_action( 'wp_ajax_so_panels_layouts_query', array( $this, 'action_get_prebuilt_layouts' ) );
59
- add_action( 'wp_ajax_so_panels_get_layout', array( $this, 'action_get_prebuilt_layout' ) );
60
- add_action( 'wp_ajax_so_panels_import_layout', array( $this, 'action_import_layout' ) );
61
- add_action( 'wp_ajax_so_panels_export_layout', array( $this, 'action_export_layout' ) );
62
  add_action( 'wp_ajax_so_panels_live_editor_preview', array( $this, 'action_live_editor_preview' ) );
63
- add_action('wp_ajax_so_panels_directory_enable', array( $this, 'action_directory_enable' ) );
64
-
65
  // Initialize the additional admin classes.
66
  SiteOrigin_Panels_Admin_Widget_Dialog::single();
67
  SiteOrigin_Panels_Admin_Widgets_Bundle::single();
 
68
 
69
  $this->in_save_post = false;
70
  }
@@ -191,8 +185,8 @@ class SiteOrigin_Panels_Admin {
191
  // Store a version of the HTML in post_content
192
  SiteOrigin_Panels_Post_Content_Filters::add_filters();
193
  $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] = true;
194
- $post_content = SiteOrigin_Panels_Renderer::single()->render( $post_id, false, $panels_data );
195
- $post_css = SiteOrigin_Panels_Renderer::single()->generate_css( $post_id, $panels_data );
196
  SiteOrigin_Panels_Post_Content_Filters::remove_filters();
197
  unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] );
198
 
@@ -904,7 +898,7 @@ class SiteOrigin_Panels_Admin {
904
  // Create a version of the builder data for post content
905
  SiteOrigin_Panels_Post_Content_Filters::add_filters();
906
  $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] = true;
907
- echo SiteOrigin_Panels_Renderer::single()->render( intval( $_POST['post_id'] ), false, $panels_data );
908
  SiteOrigin_Panels_Post_Content_Filters::remove_filters();
909
  unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] );
910
 
@@ -935,254 +929,30 @@ class SiteOrigin_Panels_Admin {
935
  }
936
 
937
  /**
938
- * Gets all the prebuilt layouts
939
- */
940
- function action_get_prebuilt_layouts() {
941
- if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
942
- wp_die();
943
- }
944
-
945
- // Get any layouts that the current user could edit.
946
- header( 'content-type: application/json' );
947
-
948
- $type = ! empty( $_REQUEST['type'] ) ? $_REQUEST['type'] : 'directory';
949
- $search = ! empty( $_REQUEST['search'] ) ? trim( strtolower( $_REQUEST['search'] ) ) : '';
950
- $page = ! empty( $_REQUEST['page'] ) ? intval( $_REQUEST['page'] ) : 1;
951
-
952
- $return = array(
953
- 'title' => '',
954
- 'items' => array()
955
- );
956
- if ( $type == 'prebuilt' ) {
957
- $return['title'] = __( 'Theme Defined Layouts', 'siteorigin-panels' );
958
-
959
- // This is for theme bundled prebuilt directories
960
- $layouts = apply_filters( 'siteorigin_panels_prebuilt_layouts', array() );
961
-
962
- foreach ( $layouts as $id => $vals ) {
963
- if ( ! empty( $search ) && strpos( strtolower( $vals['name'] ), $search ) === false ) {
964
- continue;
965
- }
966
-
967
- $return['items'][] = array(
968
- 'title' => $vals['name'],
969
- 'id' => $id,
970
- 'type' => 'prebuilt',
971
- 'description' => isset( $vals['description'] ) ? $vals['description'] : '',
972
- 'screenshot' => ! empty( $vals['screenshot'] ) ? $vals['screenshot'] : ''
973
- );
974
- }
975
-
976
- $return['max_num_pages'] = 1;
977
- } elseif ( $type == 'directory' ) {
978
- $return['title'] = __( 'Layouts Directory', 'siteorigin-panels' );
979
-
980
- // This is a query of the prebuilt layout directory
981
- $query = array();
982
- if ( ! empty( $search ) ) {
983
- $query['search'] = $search;
984
- }
985
- $query['page'] = $page;
986
-
987
- $url = add_query_arg( $query, self::LAYOUT_URL . 'wp-admin/admin-ajax.php?action=query_layouts' );
988
- $url = apply_filters( 'siteorigin_panels_layouts_directory_url', $url );
989
- $response = wp_remote_get( $url );
990
-
991
- if ( is_array( $response ) && $response['response']['code'] == 200 ) {
992
- $results = json_decode( $response['body'], true );
993
- if ( ! empty( $results ) && ! empty( $results['items'] ) ) {
994
- foreach ( $results['items'] as $item ) {
995
- $screenshot_url = add_query_arg( 'screenshot_preview', 1, $item['preview'] );
996
- $item['id'] = $item['slug'];
997
- $item['screenshot'] = 'http://s.wordpress.com/mshots/v1/' . urlencode( $screenshot_url ) . '?w=400';
998
- $item['type'] = 'directory';
999
- $return['items'][] = $item;
1000
- }
1001
- }
1002
-
1003
- $return['max_num_pages'] = $results['max_num_pages'];
1004
- }
1005
- } elseif ( strpos( $type, 'clone_' ) !== false ) {
1006
- // Check that the user can view the given page types
1007
- $post_type = get_post_type_object( str_replace( 'clone_', '', $type ) );
1008
- if( empty( $post_type ) ) {
1009
- return;
1010
- }
1011
-
1012
- $return['title'] = sprintf( __( 'Clone %s', 'siteorigin-panels' ), esc_html( $post_type->labels->singular_name ) );
1013
-
1014
- global $wpdb;
1015
- $user_can_read_private = ( $post_type == 'post' && current_user_can( 'read_private_posts' ) || ( $post_type == 'page' && current_user_can( 'read_private_pages' ) ) );
1016
- $include_private = $user_can_read_private ? "OR posts.post_status = 'private' " : "";
1017
-
1018
- // Select only the posts with the given post type that also have panels_data
1019
- $results = $wpdb->get_results( "
1020
- SELECT SQL_CALC_FOUND_ROWS DISTINCT ID, post_title, meta.meta_value
1021
- FROM {$wpdb->posts} AS posts
1022
- JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
1023
- WHERE
1024
- posts.post_type = '" . esc_sql( $post_type->name ) . "'
1025
- AND meta.meta_key = 'panels_data'
1026
- " . ( ! empty( $search ) ? 'AND posts.post_title LIKE "%' . esc_sql( $search ) . '%"' : '' ) . "
1027
- AND ( posts.post_status = 'publish' OR posts.post_status = 'draft' " . $include_private . ")
1028
- ORDER BY post_date DESC
1029
- LIMIT 16 OFFSET " . intval( ( $page - 1 ) * 16 ) );
1030
- $total_posts = $wpdb->get_var( "SELECT FOUND_ROWS();" );
1031
-
1032
- foreach ( $results as $result ) {
1033
- $thumbnail = get_the_post_thumbnail_url( $result->ID, array( 400, 300 ) );
1034
- $return['items'][] = array(
1035
- 'id' => $result->ID,
1036
- 'title' => $result->post_title,
1037
- 'type' => $type,
1038
- 'screenshot' => ! empty( $thumbnail ) ? $thumbnail : ''
1039
- );
1040
- }
1041
-
1042
- $return['max_num_pages'] = ceil( $total_posts / 16 );
1043
-
1044
- } else {
1045
- // An invalid type. Display an error message.
1046
- }
1047
-
1048
- // Add the search part to the title
1049
- if ( ! empty( $search ) ) {
1050
- $return['title'] .= __( ' - Results For:', 'siteorigin-panels' ) . ' <em>' . esc_html( $search ) . '</em>';
1051
- }
1052
-
1053
- echo json_encode( $return );
1054
-
1055
- wp_die();
1056
- }
1057
-
1058
- /**
1059
- * Ajax handler to get an individual prebuilt layout
1060
  */
1061
- function action_get_prebuilt_layout() {
1062
- if ( empty( $_REQUEST['type'] ) ) {
1063
- wp_die();
1064
- }
1065
- if ( empty( $_REQUEST['lid'] ) ) {
1066
- wp_die();
1067
- }
1068
- if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
1069
  wp_die();
1070
  }
1071
 
1072
- header( 'content-type: application/json' );
1073
- $panels_data = array();
1074
-
1075
- if ( $_REQUEST['type'] == 'prebuilt' ) {
1076
- $layouts = apply_filters( 'siteorigin_panels_prebuilt_layouts', array() );
1077
- $lid = ! empty( $_REQUEST['lid'] ) ? $_REQUEST['lid'] : false;
1078
-
1079
- if ( empty( $lid ) || empty( $layouts[ $lid ] ) ) {
1080
- // Display an error message
1081
- wp_die();
1082
- }
1083
-
1084
- $layout = $layouts[ $_REQUEST['lid'] ];
1085
-
1086
- // Fix the format of this layout
1087
- if( !empty( $layout[ 'filename' ] ) ) {
1088
- $filename = $layout[ 'filename' ];
1089
- // Only accept filenames that end with .json
1090
- if( substr( $filename, -5, 5 ) === '.json' && file_exists( $filename ) ) {
1091
- $panels_data = json_decode( file_get_contents( $filename ), true );
1092
- $layout[ 'widgets' ] = ! empty( $panels_data[ 'widgets' ] ) ? $panels_data[ 'widgets' ] : array();
1093
- $layout[ 'grids' ] = ! empty( $panels_data[ 'grids' ] ) ? $panels_data[ 'grids' ] : array();
1094
- $layout[ 'grid_cells' ] = ! empty( $panels_data[ 'grid_cells' ] ) ? $panels_data[ 'grid_cells' ] : array();
1095
- }
1096
- }
1097
-
1098
- // A theme or plugin could use this to change the data in the layout
1099
- $panels_data = apply_filters( 'siteorigin_panels_prebuilt_layout', $layout, $lid );
1100
-
1101
- // Remove all the layout specific attributes
1102
- if ( isset( $panels_data['name'] ) ) unset( $panels_data['name'] );
1103
- if ( isset( $panels_data['screenshot'] ) ) unset( $panels_data['screenshot'] );
1104
- if ( isset( $panels_data['filename'] ) ) unset( $panels_data['filename'] );
1105
-
1106
- } elseif ( $_REQUEST['type'] == 'directory' ) {
1107
- $response = wp_remote_get(
1108
- self::LAYOUT_URL . 'layout/' . urlencode( $_REQUEST['lid'] ) . '/?action=download'
1109
- );
1110
-
1111
- if ( $response['response']['code'] == 200 ) {
1112
- // For now, we'll just pretend to load this
1113
- $panels_data = json_decode( $response['body'], true );
1114
- } else {
1115
- // Display some sort of error message
1116
- }
1117
- } elseif ( current_user_can( 'edit_post', $_REQUEST['lid'] ) ) {
1118
- $panels_data = get_post_meta( $_REQUEST['lid'], 'panels_data', true );
1119
- }
1120
-
1121
- $panels_data = apply_filters( 'siteorigin_panels_data', $panels_data );
1122
-
1123
- $panels_data['widgets'] = $this->process_raw_widgets( $panels_data['widgets'], array(), true, true );
1124
-
1125
- echo json_encode( $panels_data );
1126
- wp_die();
1127
- }
1128
-
1129
- /**
1130
- * Ajax handler to import a layout
1131
- */
1132
- function action_import_layout() {
1133
- if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
1134
- wp_die();
1135
- }
1136
 
1137
- if ( ! empty( $_FILES['panels_import_data']['tmp_name'] ) ) {
1138
- header( 'content-type:application/json' );
1139
- $json = file_get_contents( $_FILES['panels_import_data']['tmp_name'] );
1140
- @unlink( $_FILES['panels_import_data']['tmp_name'] );
1141
- echo $json;
1142
- }
1143
- wp_die();
1144
  }
1145
-
1146
  /**
1147
- * Export a given layout as a JSON file.
1148
  */
1149
- function action_export_layout() {
1150
  if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
1151
  wp_die();
1152
  }
1153
-
1154
- header( 'content-type: application/json' );
1155
- header( 'Content-Disposition: attachment; filename=layout-' . date( 'dmY' ) . '.json' );
1156
-
1157
- $export_data = wp_unslash( $_POST['panels_export_data'] );
1158
- echo $export_data;
1159
-
1160
  wp_die();
1161
  }
1162
 
1163
- /**
1164
- * Preview in the live editor when there is no public view of the item
1165
- */
1166
- function action_live_editor_preview() {
1167
- if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'live-editor-preview' ) ) {
1168
- wp_die();
1169
- }
1170
-
1171
- include plugin_dir_path( __FILE__ ) . '../tpl/live-editor-preview.php';
1172
-
1173
- exit();
1174
- }
1175
-
1176
- /**
1177
- * Enable the directory.
1178
- */
1179
- function action_directory_enable(){
1180
- if( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce($_REQUEST['_panelsnonce'], 'panels_action') ) wp_die();
1181
- $user = get_current_user_id();
1182
- update_user_meta( $user, 'so_panels_directory_enabled', true );
1183
- wp_die();
1184
- }
1185
-
1186
  /**
1187
  * Add a column that indicates if a column is powered by Page Builder
1188
  *
@@ -1200,9 +970,9 @@ class SiteOrigin_Panels_Admin {
1200
  );
1201
  }
1202
  else {
1203
- $columns = array_slice($columns, 0, $index, true) +
1204
- array( 'panels' => __( 'Page Builder', 'siteorigin-panels' ) ) +
1205
- array_slice( $columns, $index, count( $columns ) - 1, true) ;
1206
  }
1207
 
1208
  return $columns;
@@ -1246,6 +1016,10 @@ class SiteOrigin_Panels_Admin {
1246
  return is_string( $value ) ? addcslashes( $value, '\\' ) : $value;
1247
  }
1248
 
 
 
 
 
1249
  /**
1250
  * Add all the courses to the learning dialog
1251
  *
@@ -1254,23 +1028,23 @@ class SiteOrigin_Panels_Admin {
1254
  * @return mixed
1255
  */
1256
  public function filter_learn_lessons( $lessons ) {
1257
- $lessons[ 'page-builder-tips' ] = array(
1258
- 'title' => __( '12 Page Builder Tips', 'siteorigin-panels' ),
1259
- 'video' => '212380146',
1260
- 'poster' => plugin_dir_url( __FILE__ ) . '../posters/page-builder-tips.svg',
1261
- 'description' => __( "Sign up to our newsletter and we'll send you this free Page Builder video course.", 'siteorigin-panels' ) . ' ' .
1262
- __( "12 tips that'll help you get the most out of Page Builder.", 'siteorigin-panels' ) . ' ' .
1263
- __( "Watch the video to find out more, then sign up below to get started.", 'siteorigin-panels' ),
1264
  'form_description' => __( "We'll email you a confirmation. You can unsubscribe at any time.", 'siteorigin-panels' ),
1265
  );
1266
-
1267
- $lessons[ 'page-builder-animations' ] = array(
1268
- 'title' => __( 'Free Page Builder Addons', 'siteorigin-panels' ),
1269
- 'video' => '212380210',
1270
- 'poster' => plugin_dir_url( __FILE__ ) . '../posters/addons.svg',
1271
- 'description' => __( "The free animations addon allows you to add beautiful animations to Page Builder elements.", 'siteorigin-panels' ) . ' ' .
1272
- __( "Sign up to our newsletter and we'll send you the addon as a free gift.", 'siteorigin-panels' ) . ' ' .
1273
- __( "Plus, we'll send you even more powerful addons, for as long as you're subscribed.", 'siteorigin-panels' ),
1274
  'form_description' => __( "We'll email you a confirmation. You can unsubscribe at any time.", 'siteorigin-panels' ),
1275
  );
1276
 
7
  */
8
  class SiteOrigin_Panels_Admin {
9
 
 
 
10
  /**
11
  * @var bool Store that we're in the save post action, to prevent infinite loops
12
  */
53
  // Register all the admin actions
54
  add_action( 'wp_ajax_so_panels_builder_content', array( $this, 'action_builder_content' ) );
55
  add_action( 'wp_ajax_so_panels_widget_form', array( $this, 'action_widget_form' ) );
 
 
 
 
56
  add_action( 'wp_ajax_so_panels_live_editor_preview', array( $this, 'action_live_editor_preview' ) );
57
+
 
58
  // Initialize the additional admin classes.
59
  SiteOrigin_Panels_Admin_Widget_Dialog::single();
60
  SiteOrigin_Panels_Admin_Widgets_Bundle::single();
61
+ SiteOrigin_Panels_Admin_Layouts::single();
62
 
63
  $this->in_save_post = false;
64
  }
185
  // Store a version of the HTML in post_content
186
  SiteOrigin_Panels_Post_Content_Filters::add_filters();
187
  $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] = true;
188
+ $post_content = SiteOrigin_Panels::renderer()->render( $post_id, false, $panels_data );
189
+ $post_css = SiteOrigin_Panels::renderer()->generate_css( $post_id, $panels_data );
190
  SiteOrigin_Panels_Post_Content_Filters::remove_filters();
191
  unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] );
192
 
898
  // Create a version of the builder data for post content
899
  SiteOrigin_Panels_Post_Content_Filters::add_filters();
900
  $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] = true;
901
+ echo SiteOrigin_Panels::renderer()->render( intval( $_POST['post_id'] ), false, $panels_data );
902
  SiteOrigin_Panels_Post_Content_Filters::remove_filters();
903
  unset( $GLOBALS[ 'SITEORIGIN_PANELS_POST_CONTENT_RENDER' ] );
904
 
929
  }
930
 
931
  /**
932
+ * Preview in the live editor when there is no public view of the item
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
933
  */
934
+ function action_live_editor_preview() {
935
+ if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'live-editor-preview' ) ) {
 
 
 
 
 
 
936
  wp_die();
937
  }
938
 
939
+ include plugin_dir_path( __FILE__ ) . '../tpl/live-editor-preview.php';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
940
 
941
+ exit();
 
 
 
 
 
 
942
  }
943
+
944
  /**
945
+ * Enable the directory.
946
  */
947
+ function action_directory_enable() {
948
  if ( empty( $_REQUEST['_panelsnonce'] ) || ! wp_verify_nonce( $_REQUEST['_panelsnonce'], 'panels_action' ) ) {
949
  wp_die();
950
  }
951
+ $user = get_current_user_id();
952
+ update_user_meta( $user, 'so_panels_directory_enabled', true );
 
 
 
 
 
953
  wp_die();
954
  }
955
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
956
  /**
957
  * Add a column that indicates if a column is powered by Page Builder
958
  *
970
  );
971
  }
972
  else {
973
+ $columns = array_slice( $columns, 0, $index, true ) +
974
+ array( 'panels' => __( 'Page Builder', 'siteorigin-panels' ) ) +
975
+ array_slice( $columns, $index, count( $columns ) - 1, true );
976
  }
977
 
978
  return $columns;
1016
  return is_string( $value ) ? addcslashes( $value, '\\' ) : $value;
1017
  }
1018
 
1019
+ public function get_layout_directories(){
1020
+
1021
+ }
1022
+
1023
  /**
1024
  * Add all the courses to the learning dialog
1025
  *
1028
  * @return mixed
1029
  */
1030
  public function filter_learn_lessons( $lessons ) {
1031
+ $lessons['page-builder-tips'] = array(
1032
+ 'title' => __( '12 Page Builder Tips', 'siteorigin-panels' ),
1033
+ 'video' => '212380146',
1034
+ 'poster' => plugin_dir_url( __FILE__ ) . '../posters/page-builder-tips.svg',
1035
+ 'description' => __( "Sign up to our newsletter and we'll send you this free Page Builder video course.", 'siteorigin-panels' ) . ' ' .
1036
+ __( "12 tips that'll help you get the most out of Page Builder.", 'siteorigin-panels' ) . ' ' .
1037
+ __( "Watch the video to find out more, then sign up below to get started.", 'siteorigin-panels' ),
1038
  'form_description' => __( "We'll email you a confirmation. You can unsubscribe at any time.", 'siteorigin-panels' ),
1039
  );
1040
+
1041
+ $lessons['page-builder-animations'] = array(
1042
+ 'title' => __( 'Free Page Builder Addons', 'siteorigin-panels' ),
1043
+ 'video' => '212380210',
1044
+ 'poster' => plugin_dir_url( __FILE__ ) . '../posters/addons.svg',
1045
+ 'description' => __( "The free animations addon allows you to add beautiful animations to Page Builder elements.", 'siteorigin-panels' ) . ' ' .
1046
+ __( "Sign up to our newsletter and we'll send you the addon as a free gift.", 'siteorigin-panels' ) . ' ' .
1047
+ __( "Plus, we'll send you even more powerful addons, for as long as you're subscribed.", 'siteorigin-panels' ),
1048
  'form_description' => __( "We'll email you a confirmation. You can unsubscribe at any time.", 'siteorigin-panels' ),
1049
  );
1050
 
inc/cache-renderer.php CHANGED
@@ -129,13 +129,13 @@ class SiteOrigin_Panels_Cache_Renderer {
129
 
130
  if( empty( $this->cache[ 'html' ][ $post_id ] ) ) {
131
  // Generate the HTML for the post
132
- $panels_html = SiteOrigin_Panels_Renderer::single()->render( $post_id, false );
133
  $this->add( 'html', $panels_html, $post_id );
134
  }
135
 
136
  if( empty( $this->cache[ 'css' ][ $post_id ] ) ) {
137
  // Create a single line version of the CSS
138
- $panels_css = SiteOrigin_Panels_Renderer::single()->generate_css( $post_id );
139
  $this->add( 'css', $panels_css, $post_id );
140
  }
141
 
129
 
130
  if( empty( $this->cache[ 'html' ][ $post_id ] ) ) {
131
  // Generate the HTML for the post
132
+ $panels_html = SiteOrigin_Panels::renderer()->render( $post_id, false );
133
  $this->add( 'html', $panels_html, $post_id );
134
  }
135
 
136
  if( empty( $this->cache[ 'css' ][ $post_id ] ) ) {
137
  // Create a single line version of the CSS
138
+ $panels_css = SiteOrigin_Panels::renderer()->generate_css( $post_id );
139
  $this->add( 'css', $panels_css, $post_id );
140
  }
141
 
inc/css-builder.php CHANGED
@@ -24,16 +24,15 @@ class SiteOrigin_Panels_Css_Builder {
24
  public function add_css( $selector, $attributes, $resolution = 1920 ) {
25
  $attribute_string = array();
26
  foreach ( $attributes as $k => $v ) {
27
- if ( ! strlen( (string) $v ) ) {
28
- continue;
29
- }
30
-
31
  if( is_array( $v ) ) {
32
  for( $i = 0; $i < count( $v ); $i++ ) {
 
33
  $attribute_string[] = esc_html( $k ) . ':' . esc_html( $v[ $i ] );
34
  }
35
  }
36
  else {
 
37
  $attribute_string[] = esc_html( $k ) . ':' . esc_html( $v );
38
  }
39
  }
24
  public function add_css( $selector, $attributes, $resolution = 1920 ) {
25
  $attribute_string = array();
26
  foreach ( $attributes as $k => $v ) {
27
+
 
 
 
28
  if( is_array( $v ) ) {
29
  for( $i = 0; $i < count( $v ); $i++ ) {
30
+ if ( ! strlen( (string) $v[ $i ] ) ) continue;
31
  $attribute_string[] = esc_html( $k ) . ':' . esc_html( $v[ $i ] );
32
  }
33
  }
34
  else {
35
+ if ( ! strlen( (string) $v ) ) continue;
36
  $attribute_string[] = esc_html( $k ) . ':' . esc_html( $v );
37
  }
38
  }
inc/functions.php CHANGED
@@ -38,7 +38,7 @@ function siteorigin_panels_get_home_page_data() {
38
  * @return string The HTML content.
39
  */
40
  function siteorigin_panels_render( $post_id = false, $enqueue_css = true, $panels_data = false ) {
41
- return SiteOrigin_Panels_Renderer::single()->render( $post_id, $enqueue_css, $panels_data );
42
  }
43
 
44
  /**
@@ -55,7 +55,7 @@ function siteorigin_panels_process_raw_widgets( $widgets, $old_widgets = false,
55
  }
56
 
57
  function siteorigin_panels_the_widget( $widget_info, $instance, $grid, $cell, $panel, $is_first, $is_last, $post_id = false, $style_wrapper = '' ) {
58
- SiteOrigin_Panels_Renderer::single()->the_widget( $widget_info, $instance, $grid, $cell, $panel, $is_first, $is_last, $post_id, $style_wrapper );
59
  }
60
 
61
  /**
@@ -72,3 +72,12 @@ function siteorigin_panels_setting( $key = '' ) {
72
  function siteorigin_panels_plugin_activation_install_url( $plugin, $plugin_name, $source = false ) {
73
  return SiteOrigin_Panels_Admin_Widgets_Bundle::install_url( $plugin, $plugin_name, $source );
74
  }
 
 
 
 
 
 
 
 
 
38
  * @return string The HTML content.
39
  */
40
  function siteorigin_panels_render( $post_id = false, $enqueue_css = true, $panels_data = false ) {
41
+ return SiteOrigin_Panels::renderer()->render( $post_id, $enqueue_css, $panels_data );
42
  }
43
 
44
  /**
55
  }
56
 
57
  function siteorigin_panels_the_widget( $widget_info, $instance, $grid, $cell, $panel, $is_first, $is_last, $post_id = false, $style_wrapper = '' ) {
58
+ SiteOrigin_Panels::renderer()->the_widget( $widget_info, $instance, $grid, $cell, $panel, $is_first, $is_last, $post_id, $style_wrapper );
59
  }
60
 
61
  /**
72
  function siteorigin_panels_plugin_activation_install_url( $plugin, $plugin_name, $source = false ) {
73
  return SiteOrigin_Panels_Admin_Widgets_Bundle::install_url( $plugin, $plugin_name, $source );
74
  }
75
+
76
+ /**
77
+ * A null function for compatibility with aTheme themes.
78
+ *
79
+ * @return bool
80
+ */
81
+ function siteorigin_panels_activate(){
82
+ return false;
83
+ }
inc/renderer-legacy.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class SiteOrigin_Panels_Renderer_Legacy extends SiteOrigin_Panels_Renderer {
4
+
5
+ public static function single() {
6
+ static $single;
7
+ return empty( $single ) ? $single = new self() : $single;
8
+ }
9
+
10
+ /**
11
+ * Generate the CSS for the page layout.
12
+ *
13
+ * @param $post_id
14
+ * @param $panels_data
15
+ * @param $layout_data
16
+ *
17
+ * @return string
18
+ */
19
+ public function generate_css( $post_id, $panels_data = false, $layout_data = false) {
20
+ // Exit if we don't have panels data
21
+ if ( empty( $panels_data ) ) {
22
+ $panels_data = get_post_meta( $post_id, 'panels_data', true );
23
+ if( empty( $panels_data ) ) {
24
+ return '';
25
+ }
26
+ }
27
+ if ( empty( $layout_data ) ) {
28
+ $layout_data = $this->get_panels_layout_data( $panels_data );
29
+ $layout_data = apply_filters( 'siteorigin_panels_layout_data', $layout_data, $post_id );
30
+ }
31
+
32
+ // Get some of the default settings
33
+ $settings = siteorigin_panels_setting();
34
+ $panels_tablet_width = $settings['tablet-width'];
35
+ $panels_mobile_width = $settings['mobile-width'];
36
+ $panels_margin_bottom = $settings['margin-bottom'];
37
+ $panels_margin_bottom_last_row = $settings['margin-bottom-last-row'];
38
+
39
+ $css = new SiteOrigin_Panels_Css_Builder();
40
+
41
+ $ci = 0;
42
+ foreach ( $layout_data as $ri => $row ) {
43
+ if( empty( $row['cells'] ) ) continue;
44
+
45
+ // Let other themes and plugins change the gutter.
46
+ $gutter = apply_filters( 'siteorigin_panels_css_row_gutter', $settings['margin-sides'] . 'px', $row, $ri, $panels_data );
47
+ preg_match( '/([0-9\.,]+)(.*)/', $gutter, $gutter_parts );
48
+
49
+ $cell_count = count( $row['cells'] );
50
+
51
+ // Add the cell sizing
52
+ foreach( $row['cells'] as $ci => $cell ) {
53
+ $weight = apply_filters( 'siteorigin_panels_css_cell_weight', $cell['weight'], $row, $ri, $cell, $ci - 1, $panels_data, $post_id );
54
+
55
+ // Add the width and ensure we have correct formatting for CSS.
56
+ $css->add_cell_css( $post_id, $ri, $ci, '', array(
57
+ 'width' => round( $weight * 100, 4 ) . '%',
58
+ ) );
59
+ }
60
+
61
+ $css->add_cell_css( $post_id, $ri, false, '', array(
62
+
63
+ ) );
64
+
65
+ if(
66
+ $ri != count( $layout_data ) - 1 ||
67
+ ! empty( $row[ 'style' ][ 'bottom_margin' ] ) ||
68
+ ! empty( $panels_margin_bottom_last_row )
69
+ ) {
70
+ // Filter the bottom margin for this row with the arguments
71
+ $css->add_row_css( $post_id, $ri, '', array(
72
+ 'margin-bottom' => apply_filters( 'siteorigin_panels_css_row_margin_bottom', $panels_margin_bottom . 'px', $row, $ri, $panels_data, $post_id )
73
+ ) );
74
+ }
75
+
76
+ $margin_half = ( floatval( $gutter_parts[1] ) / 2 ) . $gutter_parts[2];
77
+ $css->add_row_css($post_id, $ri, '', array(
78
+ 'margin-left' => '-' . $margin_half,
79
+ 'margin-right' => '-' . $margin_half,
80
+ ) );
81
+ $css->add_cell_css($post_id, $ri, false, '', array(
82
+ 'padding-left' => $margin_half,
83
+ 'padding-right' => $margin_half,
84
+ ) );
85
+ }
86
+
87
+ // Add the bottom margins
88
+ $css->add_widget_css( $post_id, false, false, false, '', array(
89
+ 'margin-bottom' => apply_filters( 'siteorigin_panels_css_cell_margin_bottom', $panels_margin_bottom . 'px', false, false, $panels_data, $post_id )
90
+ ) );
91
+ $css->add_widget_css( $post_id, false, false, false, ':last-child', array(
92
+ 'margin-bottom' => apply_filters( 'siteorigin_panels_css_cell_last_margin_bottom', '0px', false, false, $panels_data, $post_id )
93
+ ) );
94
+
95
+ if ( $settings['responsive'] ) {
96
+
97
+ $css->add_cell_css($post_id, false, false, '', array(
98
+ 'float' => 'none',
99
+ 'width' => 'auto'
100
+ ), $panels_mobile_width);
101
+
102
+ $css->add_row_css($post_id, false, '', array(
103
+ 'margin-left' => 0,
104
+ 'margin-right' => 0,
105
+ ), $panels_mobile_width);
106
+
107
+ $css->add_cell_css( $post_id, false, false, '', array(
108
+ 'padding' => 0,
109
+ ), $panels_mobile_width );
110
+
111
+ // Hide empty cells on mobile
112
+ $css->add_row_css( $post_id, false, ' .panel-grid-cell-empty', array(
113
+ 'display' => 'none',
114
+ ), $panels_mobile_width );
115
+
116
+ // Hide empty cells on mobile
117
+ $css->add_row_css( $post_id, false, ' .panel-grid-cell-mobile-last', array(
118
+ 'margin-bottom' => '0px',
119
+ ), $panels_mobile_width );
120
+
121
+ foreach ( $layout_data as $ri => $row ) {
122
+ $css->add_cell_css( $post_id, $ri, false, '', array(
123
+ 'margin-bottom' => $panels_margin_bottom . 'px',
124
+ ), $panels_mobile_width );
125
+
126
+ $css->add_cell_css( $post_id, $ri, false, ':last-child', array(
127
+ 'margin-bottom' => '0px',
128
+ ), $panels_mobile_width );
129
+ }
130
+ }
131
+
132
+ foreach ( $panels_data['widgets'] as $widget_id => $widget ) {
133
+ if ( ! empty( $widget['panels_info']['style']['link_color'] ) ) {
134
+ $css->add_widget_css( $post_id, $widget['panels_info']['grid'], $widget['panels_info']['cell'], $widget['panels_info']['cell_index'], ' a', array(
135
+ 'color' => $widget['panels_info']['style']['link_color']
136
+ ) );
137
+ }
138
+ }
139
+
140
+ // Let other plugins and components filter the CSS object.
141
+ $css = apply_filters( 'siteorigin_panels_css_object', $css, $panels_data, $post_id, $layout_data );
142
+
143
+ return $css->get_css();
144
+ }
145
+
146
+ public function front_css_url(){
147
+ return plugin_dir_url( __FILE__ ) . '../css/front' . ( siteorigin_panels_setting( 'legacy-layout' ) ? '-legacy' : '' ) . '.css';
148
+ }
149
+ }
inc/renderer.php CHANGED
@@ -11,7 +11,6 @@ class SiteOrigin_Panels_Renderer {
11
 
12
  public static function single() {
13
  static $single;
14
-
15
  return empty( $single ) ? $single = new self() : $single;
16
  }
17
 
@@ -83,10 +82,10 @@ class SiteOrigin_Panels_Renderer {
83
 
84
  // Add the width and ensure we have correct formatting for CSS.
85
  $css->add_cell_css( $post_id, $ri, $ci, '', array(
86
- '-ms-flex' => $weight,
87
- '-webkit-flex' => $weight,
88
- 'flex' => $weight,
89
- 'width' => 0, // Workaround for flex child elements growing with their content.
90
  ) );
91
  }
92
 
@@ -182,14 +181,6 @@ class SiteOrigin_Panels_Renderer {
182
  }
183
  }
184
 
185
- if ( ! empty( $gutter_parts[1] ) ) {
186
- $css->add_cell_css( $post_id, $ri, false, '', array(
187
- 'margin-right' => floatval( $gutter_parts[1] ) . $gutter_parts[2],
188
- ) );
189
- $css->add_cell_css( $post_id, $ri, false, ':last-child', array(
190
- 'margin-right' => 0,
191
- ) );
192
- }
193
  }
194
 
195
  // Add the bottom margins
@@ -216,14 +207,6 @@ class SiteOrigin_Panels_Renderer {
216
  ), $panels_mobile_width );
217
  }
218
 
219
- foreach ( $panels_data['widgets'] as $widget_id => $widget ) {
220
- if ( ! empty( $widget['panels_info']['style']['link_color'] ) ) {
221
- $css->add_widget_css( $post_id, $widget['panels_info']['grid'], $widget['panels_info']['cell'], $widget['panels_info']['cell_index'], ' a', array(
222
- 'color' => $widget['panels_info']['style']['link_color']
223
- ) );
224
- }
225
- }
226
-
227
  // Let other plugins and components filter the CSS object.
228
  $css = apply_filters( 'siteorigin_panels_css_object', $css, $panels_data, $post_id, $layout_data );
229
 
@@ -450,7 +433,7 @@ class SiteOrigin_Panels_Renderer {
450
 
451
  $before_widget = '<div ';
452
  foreach( $attributes as $k => $v ) {
453
- $before_widget .= esc_attr( $k ) . '="' . esc_attr( $v ) . '"';
454
  }
455
  $before_widget .= '>';
456
 
@@ -722,6 +705,8 @@ class SiteOrigin_Panels_Renderer {
722
  echo apply_filters( 'siteorigin_panels_before_cell', '', $cell, $cell_attributes );
723
 
724
  $this->render_element( 'div', $cell_attributes );
 
 
725
 
726
  if ( empty( $cell['style']['class'] ) && ! empty( $grid['style']['cell_class'] ) ) {
727
  $cell['style']['class'] = $grid['style']['cell_class'];
@@ -779,4 +764,8 @@ class SiteOrigin_Panels_Renderer {
779
  );
780
 
781
  }
 
 
 
 
782
  }
11
 
12
  public static function single() {
13
  static $single;
 
14
  return empty( $single ) ? $single = new self() : $single;
15
  }
16
 
82
 
83
  // Add the width and ensure we have correct formatting for CSS.
84
  $css->add_cell_css( $post_id, $ri, $ci, '', array(
85
+ 'width' => array(
86
+ round( $weight * 100, 4 ) . '%',
87
+ 'calc(' . round( $weight * 100, 4 ) . '% - ( ' . ( 1 - $weight ) . ' * ' . $gutter . ' ) )',
88
+ )
89
  ) );
90
  }
91
 
181
  }
182
  }
183
 
 
 
 
 
 
 
 
 
184
  }
185
 
186
  // Add the bottom margins
207
  ), $panels_mobile_width );
208
  }
209
 
 
 
 
 
 
 
 
 
210
  // Let other plugins and components filter the CSS object.
211
  $css = apply_filters( 'siteorigin_panels_css_object', $css, $panels_data, $post_id, $layout_data );
212
 
433
 
434
  $before_widget = '<div ';
435
  foreach( $attributes as $k => $v ) {
436
+ $before_widget .= esc_attr( $k ) . '="' . esc_attr( $v ) . '" ';
437
  }
438
  $before_widget .= '>';
439
 
705
  echo apply_filters( 'siteorigin_panels_before_cell', '', $cell, $cell_attributes );
706
 
707
  $this->render_element( 'div', $cell_attributes );
708
+
709
+ $grid = $panels_data['grids'][$ri];
710
 
711
  if ( empty( $cell['style']['class'] ) && ! empty( $grid['style']['cell_class'] ) ) {
712
  $cell['style']['class'] = $grid['style']['cell_class'];
764
  );
765
 
766
  }
767
+
768
+ public function front_css_url(){
769
+ return plugin_dir_url( __FILE__ ) . '../css/front.css';
770
+ }
771
  }
inc/settings.php CHANGED
@@ -131,6 +131,7 @@ class SiteOrigin_Panels_Settings {
131
  // The layout fields
132
  $defaults['responsive'] = true;
133
  $defaults['tablet-layout'] = false;
 
134
  $defaults['tablet-width'] = 1024;
135
  $defaults['mobile-width'] = 780;
136
  $defaults['margin-bottom'] = 30;
@@ -333,6 +334,17 @@ class SiteOrigin_Panels_Settings {
333
  'label' => __( 'Use Tablet Layout', 'siteorigin-panels' ),
334
  'description' => __( 'Collapses columns differently on tablet devices.', 'siteorigin-panels' ),
335
  );
 
 
 
 
 
 
 
 
 
 
 
336
 
337
  $fields['layout']['fields']['tablet-width'] = array(
338
  'type' => 'number',
@@ -398,7 +410,7 @@ class SiteOrigin_Panels_Settings {
398
  $fields['content']['fields']['cache-content'] = array(
399
  'type' => 'checkbox',
400
  'label' => __( 'Content Cache', 'siteorigin-panels' ),
401
- 'description' => __( "Cache CSS and HTML generated by Page Builder." , 'siteorigin-panels' ),
402
  );
403
 
404
  return $fields;
@@ -509,7 +521,7 @@ class SiteOrigin_Panels_Settings {
509
  }
510
 
511
  foreach ( $section['fields'] as $field_id => $field ) {
512
-
513
  switch ( $field['type'] ) {
514
  case 'text' :
515
  $values[ $field_id ] = ! empty( $post[ $field_id ] ) ? sanitize_text_field( $post[ $field_id ] ) : '';
@@ -562,12 +574,17 @@ class SiteOrigin_Panels_Settings {
562
 
563
  break;
564
  }
565
-
566
  }
567
  }
568
 
569
  // Don't let mobile width go below 320
570
  $values[ 'mobile-width' ] = max( $values[ 'mobile-width' ], 320 );
 
 
 
 
 
 
571
 
572
  // Save the values to the database
573
  update_option( 'siteorigin_panels_settings', $values );
131
  // The layout fields
132
  $defaults['responsive'] = true;
133
  $defaults['tablet-layout'] = false;
134
+ $defaults['legacy-layout'] = 'auto';
135
  $defaults['tablet-width'] = 1024;
136
  $defaults['mobile-width'] = 780;
137
  $defaults['margin-bottom'] = 30;
334
  'label' => __( 'Use Tablet Layout', 'siteorigin-panels' ),
335
  'description' => __( 'Collapses columns differently on tablet devices.', 'siteorigin-panels' ),
336
  );
337
+
338
+ $fields['layout']['fields']['legacy-layout'] = array(
339
+ 'type' => 'select',
340
+ 'options' => array(
341
+ 'auto' => __( 'Detect older browsers', 'siteorigin-panels' ),
342
+ 'never' => __( 'Never', 'siteorigin-panels' ),
343
+ 'always' => __( 'Always', 'siteorigin-panels' ),
344
+ ),
345
+ 'label' => __( 'Use Legacy Layout Engine', 'siteorigin-panels' ),
346
+ 'description' => __( 'The CSS and HTML uses floats instead of flexbox for compatibility with very old browsers.', 'siteorigin-panels' ),
347
+ );
348
 
349
  $fields['layout']['fields']['tablet-width'] = array(
350
  'type' => 'number',
410
  $fields['content']['fields']['cache-content'] = array(
411
  'type' => 'checkbox',
412
  'label' => __( 'Content Cache', 'siteorigin-panels' ),
413
+ 'description' => __( "Cache CSS and HTML generated by Page Builder. Can't be using auto detect for legacy layout engine." , 'siteorigin-panels' ),
414
  );
415
 
416
  return $fields;
521
  }
522
 
523
  foreach ( $section['fields'] as $field_id => $field ) {
524
+ // Sanitize the fields
525
  switch ( $field['type'] ) {
526
  case 'text' :
527
  $values[ $field_id ] = ! empty( $post[ $field_id ] ) ? sanitize_text_field( $post[ $field_id ] ) : '';
574
 
575
  break;
576
  }
 
577
  }
578
  }
579
 
580
  // Don't let mobile width go below 320
581
  $values[ 'mobile-width' ] = max( $values[ 'mobile-width' ], 320 );
582
+
583
+ // Don't enable cache when legacy layout is auto
584
+ if( $values[ 'legacy-layout' ] == 'auto' ) {
585
+ $values['copy-styles'] = false;
586
+ $values['cache-content'] = false;
587
+ }
588
 
589
  // Save the values to the database
590
  update_option( 'siteorigin_panels_settings', $values );
inc/styles-admin.php CHANGED
@@ -214,7 +214,7 @@ class SiteOrigin_Panels_Styles_Admin {
214
  case 'image' :
215
  $image = false;
216
  if ( ! empty( $current ) ) {
217
- $image = wp_get_attachment_image_src( $current, 'thumbnail' );
218
  }
219
 
220
  ?>
@@ -365,7 +365,7 @@ class SiteOrigin_Panels_Styles_Admin {
365
  }
366
  break;
367
  case 'image' :
368
- $return[ $k ] = ! empty( $styles[ $k ] ) ? intval( $styles[ $k ] ) : false;
369
  break;
370
  case 'url' :
371
  $return[ $k ] = esc_url_raw( $styles[ $k ] );
214
  case 'image' :
215
  $image = false;
216
  if ( ! empty( $current ) ) {
217
+ $image = SiteOrigin_Panels_Styles::get_attachment_image_src( $current, 'thumbnail' );
218
  }
219
 
220
  ?>
365
  }
366
  break;
367
  case 'image' :
368
+ $return[ $k ] = ! empty( $styles[ $k ] ) ? sanitize_text_field( $styles[ $k ] ) : false;
369
  break;
370
  case 'url' :
371
  $return[ $k ] = esc_url_raw( $styles[ $k ] );
inc/styles.php CHANGED
@@ -18,6 +18,7 @@ class SiteOrigin_Panels_Styles {
18
  // Style wrapper attributes
19
  add_filter( 'siteorigin_panels_row_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
20
  add_filter( 'siteorigin_panels_row_style_attributes', array( $this, 'row_style_attributes' ), 10, 2 );
 
21
  add_filter( 'siteorigin_panels_cell_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
22
  add_filter( 'siteorigin_panels_widget_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
23
 
@@ -338,7 +339,7 @@ class SiteOrigin_Panels_Styles {
338
 
339
  if ( ! empty( $style['background_display'] ) && ! empty( $style['background_image_attachment'] ) ) {
340
 
341
- $url = wp_get_attachment_image_src( $style['background_image_attachment'], 'full' );
342
 
343
  if (
344
  ! empty( $url ) &&
@@ -372,6 +373,14 @@ class SiteOrigin_Panels_Styles {
372
  return $attributes;
373
  }
374
 
 
 
 
 
 
 
 
 
375
  /**
376
  * Get the CSS styles that apply to all rows, cells and widgets
377
  *
@@ -388,7 +397,7 @@ class SiteOrigin_Panels_Styles {
388
 
389
  if ( ! empty( $style['background_display'] ) && ! empty( $style['background_image_attachment'] ) ) {
390
 
391
- $url = wp_get_attachment_image_src( $style['background_image_attachment'], 'full' );
392
 
393
  if ( ! empty( $url ) ) {
394
  $css[ 'background-image' ] = 'url(' . $url[0] . ')';
@@ -599,6 +608,12 @@ class SiteOrigin_Panels_Styles {
599
  $mobile_width
600
  );
601
  }
 
 
 
 
 
 
602
  }
603
  }
604
  }
@@ -621,5 +636,18 @@ class SiteOrigin_Panels_Styles {
621
 
622
  return $gutter;
623
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
624
 
625
  }
18
  // Style wrapper attributes
19
  add_filter( 'siteorigin_panels_row_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
20
  add_filter( 'siteorigin_panels_row_style_attributes', array( $this, 'row_style_attributes' ), 10, 2 );
21
+ add_filter( 'siteorigin_panels_row_style_attributes', array( $this, 'vantage_row_style_attributes' ), 11, 2 );
22
  add_filter( 'siteorigin_panels_cell_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
23
  add_filter( 'siteorigin_panels_widget_style_attributes', array( $this, 'general_style_attributes' ), 10, 2 );
24
 
339
 
340
  if ( ! empty( $style['background_display'] ) && ! empty( $style['background_image_attachment'] ) ) {
341
 
342
+ $url = self::get_attachment_image_src( $style['background_image_attachment'], 'full' );
343
 
344
  if (
345
  ! empty( $url ) &&
373
  return $attributes;
374
  }
375
 
376
+ static function vantage_row_style_attributes( $attributes, $style ) {
377
+ if ( isset( $style['class'] ) && $style['class'] == 'wide-grey' && ! empty( $attributes['style'] ) ) {
378
+ $attributes['style'] = preg_replace( '/padding-left: 1000px; padding-right: 1000px;/', '', $attributes['style'] );
379
+ }
380
+
381
+ return $attributes;
382
+ }
383
+
384
  /**
385
  * Get the CSS styles that apply to all rows, cells and widgets
386
  *
397
 
398
  if ( ! empty( $style['background_display'] ) && ! empty( $style['background_image_attachment'] ) ) {
399
 
400
+ $url = self::get_attachment_image_src( $style['background_image_attachment'], 'full' );
401
 
402
  if ( ! empty( $url ) ) {
403
  $css[ 'background-image' ] = 'url(' . $url[0] . ')';
608
  $mobile_width
609
  );
610
  }
611
+
612
+ if ( ! empty( $widget['panels_info']['style']['link_color'] ) ) {
613
+ $css->add_widget_css( $post_id, $ri, $ci, $wi, ' a', array(
614
+ 'color' => $widget['panels_info']['style']['link_color']
615
+ ) );
616
+ }
617
  }
618
  }
619
  }
636
 
637
  return $gutter;
638
  }
639
+
640
+ public static function get_attachment_image_src( $image, $size = 'full' ){
641
+ if( empty( $image ) ) {
642
+ return false;
643
+ }
644
+ else if( is_numeric( $image ) ) {
645
+ return wp_get_attachment_image_src( $image, $size );
646
+ }
647
+ else if( is_string( $image ) ) {
648
+ preg_match( '/(.*?)\#([0-9]+)x([0-9]+)$/', $image, $matches );
649
+ return ! empty( $matches ) ? $matches : false;
650
+ }
651
+ }
652
 
653
  }
js/siteorigin-panels-25.js CHANGED
@@ -566,10 +566,10 @@ module.exports = panels.view.dialog.extend( {
566
  page = 1;
567
  }
568
  if ( type === undefined ) {
569
- type = 'directory';
570
  }
571
 
572
- if ( type === 'directory' && ! panelsOptions.directory_enabled ) {
573
  // Display the button to enable the prebuilt layout
574
  c.removeClass( 'so-panels-loading' ).html( $( '#siteorigin-panels-directory-enable' ).html() );
575
  c.find( '.so-panels-enable-directory' ).click( function ( e ) {
@@ -586,7 +586,7 @@ module.exports = panels.view.dialog.extend( {
586
  // Enable the layout directory
587
  panelsOptions.directory_enabled = true;
588
  c.addClass( 'so-panels-loading' );
589
- thisView.displayLayoutDirectory( search, page );
590
  } );
591
  return;
592
  }
@@ -633,9 +633,7 @@ module.exports = panels.view.dialog.extend( {
633
  // Handle nice preloading of the screenshots
634
  c.find( '.so-screenshot' ).each( function () {
635
  var $$ = $( this ), $a = $$.find( '.so-screenshot-wrapper' );
636
- $a.css( 'height', (
637
- $a.width() / 4 * 3
638
- ) + 'px' ).addClass( 'so-loading' );
639
 
640
  if ( $$.data( 'src' ) !== '' ) {
641
  // Set the initial height
@@ -6183,6 +6181,7 @@ module.exports = Backbone.View.extend( {
6183
 
6184
  // Reset everything to have an automatic height
6185
  this.$( '.so-cells .cell-wrapper' ).css( 'min-height', 0 );
 
6186
 
6187
  // We'll tie the values to the row view, to prevent issue with values going to different rows
6188
  var height = 0;
@@ -6200,6 +6199,7 @@ module.exports = Backbone.View.extend( {
6200
 
6201
  // Resize all the grids and cell wrappers
6202
  this.$( '.so-cells .cell-wrapper' ).css( 'min-height', Math.max( height, 63 ) );
 
6203
  },
6204
 
6205
  /**
566
  page = 1;
567
  }
568
  if ( type === undefined ) {
569
+ type = 'directory-siteorigin';
570
  }
571
 
572
+ if ( type.match('^directory-') && ! panelsOptions.directory_enabled ) {
573
  // Display the button to enable the prebuilt layout
574
  c.removeClass( 'so-panels-loading' ).html( $( '#siteorigin-panels-directory-enable' ).html() );
575
  c.find( '.so-panels-enable-directory' ).click( function ( e ) {
586
  // Enable the layout directory
587
  panelsOptions.directory_enabled = true;
588
  c.addClass( 'so-panels-loading' );
589
+ thisView.displayLayoutDirectory( search, page, type );
590
  } );
591
  return;
592
  }
633
  // Handle nice preloading of the screenshots
634
  c.find( '.so-screenshot' ).each( function () {
635
  var $$ = $( this ), $a = $$.find( '.so-screenshot-wrapper' );
636
+ $a.css( 'height', ( $a.width() / 4 * 3 ) + 'px' ).addClass( 'so-loading' );
 
 
637
 
638
  if ( $$.data( 'src' ) !== '' ) {
639
  // Set the initial height
6181
 
6182
  // Reset everything to have an automatic height
6183
  this.$( '.so-cells .cell-wrapper' ).css( 'min-height', 0 );
6184
+ this.$( '.so-cells .resize-handle' ).css( 'height', 0 );
6185
 
6186
  // We'll tie the values to the row view, to prevent issue with values going to different rows
6187
  var height = 0;
6199
 
6200
  // Resize all the grids and cell wrappers
6201
  this.$( '.so-cells .cell-wrapper' ).css( 'min-height', Math.max( height, 63 ) );
6202
+ this.$( '.so-cells .resize-handle' ).css( 'height', this.$( '.so-cells .cell-wrapper' ).outerHeight() );
6203
  },
6204
 
6205
  /**
js/siteorigin-panels-25.min.js CHANGED
@@ -1,4 +1,4 @@
1
- !function e(t,i,s){function l(n,a){if(!i[n]){if(!t[n]){var r="function"==typeof require&&require;if(!a&&r)return r(n,!0);if(o)return o(n,!0);var d=new Error("Cannot find module '"+n+"'");throw d.code="MODULE_NOT_FOUND",d}var c=i[n]={exports:{}};t[n][0].call(c.exports,function(e){var i=t[n][1][e];return l(i||e)},c,c.exports,e,t,i,s)}return i[n].exports}for(var o="function"==typeof require&&require,n=0;n<s.length;n++)l(s[n]);return l}({1:[function(e,t,i){var s=window.panels;t.exports=Backbone.Collection.extend({model:s.model.cell,initialize:function(){},totalWeight:function(){var e=0;return this.each(function(t){e+=t.get("weight")}),e}})},{}],2:[function(e,t,i){var s=window.panels;t.exports=Backbone.Collection.extend({model:s.model.historyEntry,builder:null,maxSize:12,initialize:function(){this.on("add",this.onAddEntry,this)},addEntry:function(e,t){_.isEmpty(t)&&(t=this.builder.getPanelsData());var i=new s.model.historyEntry({text:e,data:JSON.stringify(t),time:parseInt((new Date).getTime()/1e3),collection:this});this.add(i)},onAddEntry:function(e){if(this.models.length>1){var t=this.at(this.models.length-2);(e.get("text")===t.get("text")&&e.get("time")-t.get("time")<15||e.get("data")===t.get("data"))&&(this.remove(e),t.set("count",t.get("count")+1))}for(;this.models.length>this.maxSize;)this.shift()}})},{}],3:[function(e,t,i){var s=window.panels;t.exports=Backbone.Collection.extend({model:s.model.row,empty:function(){for(var e;;){if(!(e=this.collection.first()))break;e.destroy()}}})},{}],4:[function(e,t,i){var s=window.panels;t.exports=Backbone.Collection.extend({model:s.model.widget,initialize:function(){}})},{}],5:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({dialogClass:"so-panels-dialog-add-builder",render:function(){this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-builder").html(),{})),this.$(".so-content .siteorigin-panels-builder").append(this.builder.$el)},initializeDialog:function(){var e=this;this.once("open_dialog_complete",function(){e.builder.initSortable()}),this.on("open_dialog_complete",function(){e.builder.trigger("builder_resize")})}})},{}],6:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({historyEntryTemplate:_.template(s.helpers.utils.processTemplate(l("#siteorigin-panels-dialog-history-entry").html())),entries:{},currentEntry:null,revertEntry:null,selectedEntry:null,previewScrollTop:null,dialogClass:"so-panels-dialog-history",dialogIcon:"history",events:{"click .so-close":"closeDialog","click .so-restore":"restoreSelectedEntry"},initializeDialog:function(){this.entries=new s.collection.historyEntries,this.on("open_dialog",this.setCurrentEntry,this),this.on("open_dialog",this.renderHistoryEntries,this)},render:function(){var e=this;this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-history").html(),{})),this.$("iframe.siteorigin-panels-history-iframe").load(function(){var t=l(this);t.show(),t.contents().scrollTop(e.previewScrollTop)})},setRevertEntry:function(e){this.revertEntry=new s.model.historyEntry({data:JSON.stringify(e.getPanelsData()),time:parseInt((new Date).getTime()/1e3)})},setCurrentEntry:function(){this.currentEntry=new s.model.historyEntry({data:JSON.stringify(this.builder.model.getPanelsData()),time:parseInt((new Date).getTime()/1e3)}),this.selectedEntry=this.currentEntry,this.previewEntry(this.currentEntry),this.$(".so-buttons .so-restore").addClass("disabled")},renderHistoryEntries:function(){var e=this,t=this.$(".history-entries").empty();this.currentEntry.get("data")===this.revertEntry.get("data")&&_.isEmpty(this.entries.models)||l(this.historyEntryTemplate({title:panelsOptions.loc.history.revert,count:1})).data("historyEntry",this.revertEntry).prependTo(t),this.entries.each(function(i){var s=e.historyEntryTemplate({title:panelsOptions.loc.history[i.get("text")],count:i.get("count")});l(s).data("historyEntry",i).prependTo(t)}),l(this.historyEntryTemplate({title:panelsOptions.loc.history.current,count:1})).data("historyEntry",this.currentEntry).addClass("so-selected").prependTo(t),t.find(".history-entry").click(function(){var i=jQuery(this);t.find(".history-entry").not(i).removeClass("so-selected"),i.addClass("so-selected");var s=i.data("historyEntry");e.selectedEntry=s,e.selectedEntry.cid!==e.currentEntry.cid?e.$(".so-buttons .so-restore").removeClass("disabled"):e.$(".so-buttons .so-restore").addClass("disabled"),e.previewEntry(s)}),this.updateEntryTimes()},previewEntry:function(e){var t=this.$("iframe.siteorigin-panels-history-iframe");t.hide(),this.previewScrollTop=t.contents().scrollTop(),this.$('form.history-form input[name="live_editor_panels_data"]').val(e.get("data")),this.$('form.history-form input[name="live_editor_post_ID"]').val(this.builder.config.postId),this.$("form.history-form").submit()},restoreSelectedEntry:function(){return!this.$(".so-buttons .so-restore").hasClass("disabled")&&(this.currentEntry.get("data")===this.selectedEntry.get("data")?(this.closeDialog(),!1):("restore"!==this.selectedEntry.get("text")&&this.builder.addHistoryEntry("restore",this.builder.model.getPanelsData()),this.builder.model.loadPanelsData(JSON.parse(this.selectedEntry.get("data"))),this.closeDialog(),!1))},updateEntryTimes:function(){var e=this;this.$(".history-entries .history-entry").each(function(){var t=jQuery(this),i=t.find(".timesince"),s=t.data("historyEntry");i.html(e.timeSince(s.get("time")))})},timeSince:function(e){var t,i=parseInt((new Date).getTime()/1e3)-e,s=[];return i>3600&&(t=Math.floor(i/3600),1===t?s.push(panelsOptions.loc.time.hour.replace("%d",t)):s.push(panelsOptions.loc.time.hours.replace("%d",t)),i-=3600*t),i>60&&(t=Math.floor(i/60),1===t?s.push(panelsOptions.loc.time.minute.replace("%d",t)):s.push(panelsOptions.loc.time.minutes.replace("%d",t)),i-=60*t),i>0&&(1===i?s.push(panelsOptions.loc.time.second.replace("%d",i)):s.push(panelsOptions.loc.time.seconds.replace("%d",i))),_.isEmpty(s)?panelsOptions.loc.time.now:panelsOptions.loc.time.ago.replace("%s",s.slice(0,2).join(", "))}})},{}],7:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({directoryTemplate:_.template(s.helpers.utils.processTemplate(l("#siteorigin-panels-directory-items").html())),builder:null,dialogClass:"so-panels-dialog-prebuilt-layouts",dialogIcon:"layouts",layoutCache:{},currentTab:!1,directoryPage:1,events:{"click .so-close":"closeDialog","click .so-sidebar-tabs li a":"tabClickHandler","click .so-content .layout":"layoutClickHandler","keyup .so-sidebar-search":"searchHandler","click .so-screenshot, .so-title":"directoryItemClickHandler"},initializeDialog:function(){var e=this;this.on("open_dialog",function(){e.$(".so-sidebar-tabs li a").first().click(),e.$(".so-status").removeClass("so-panels-loading")}),this.on("button_click",this.toolbarButtonClick,this)},render:function(){this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-prebuilt").html(),{})),this.initToolbar()},tabClickHandler:function(e){e.preventDefault(),this.selectedLayoutItem=null,this.uploadedLayout=null,this.updateButtonState(!1),this.$(".so-sidebar-tabs li").removeClass("tab-active");var t=l(e.target),i=t.attr("href").split("#")[1];t.parent().addClass("tab-active");var s=this;this.$(".so-content").empty(),s.currentTab=i,"import"==i?this.displayImportExport():this.displayLayoutDirectory("",1,i),s.$(".so-sidebar-search").val("")},displayImportExport:function(){var e=this.$(".so-content").empty().removeClass("so-panels-loading");e.html(l("#siteorigin-panels-dialog-prebuilt-importexport").html());var t=this,i=t.$(".import-upload-ui").hide();new plupload.Uploader({runtimes:"html5,silverlight,flash,html4",browse_button:i.find(".file-browse-button").get(0),container:i.get(0),drop_element:i.find(".drag-upload-area").get(0),file_data_name:"panels_import_data",multiple_queues:!1,max_file_size:panelsOptions.plupload.max_file_size,url:panelsOptions.plupload.url,flash_swf_url:panelsOptions.plupload.flash_swf_url,silverlight_xap_url:panelsOptions.plupload.silverlight_xap_url,filters:[{title:panelsOptions.plupload.filter_title,extensions:"json"}],multipart_params:{action:"so_panels_import_layout"},init:{PostInit:function(e){e.features.dragdrop&&i.addClass("has-drag-drop"),i.show().find(".progress-precent").css("width","0%")},FilesAdded:function(e){i.find(".file-browse-button").blur(),i.find(".drag-upload-area").removeClass("file-dragover"),i.find(".progress-bar").fadeIn("fast"),t.$(".js-so-selected-file").text(panelsOptions.loc.prebuilt_loading),e.start()},UploadProgress:function(e,t){i.find(".progress-precent").css("width",t.percent+"%")},FileUploaded:function(e,s,l){var o=JSON.parse(l.response);_.isUndefined(o.widgets)?alert(panelsOptions.plupload.error_message):(t.uploadedLayout=o,i.find(".progress-bar").hide(),t.$(".js-so-selected-file").text(panelsOptions.loc.ready_to_insert.replace("%s",s.name)),t.updateButtonState(!0))},Error:function(){alert(panelsOptions.plupload.error_message)}}}).init(),i.find(".drag-upload-area").on("dragover",function(){l(this).addClass("file-dragover")}).on("dragleave",function(){l(this).removeClass("file-dragover")}),e.find(".so-export").submit(function(e){l(this).find('input[name="panels_export_data"]').val(JSON.stringify(t.builder.model.getPanelsData()))})},displayLayoutDirectory:function(e,t,i){var s=this,o=this.$(".so-content").empty().addClass("so-panels-loading");if(void 0===e&&(e=""),void 0===t&&(t=1),void 0===i&&(i="directory"),"directory"===i&&!panelsOptions.directory_enabled)return o.removeClass("so-panels-loading").html(l("#siteorigin-panels-directory-enable").html()),void o.find(".so-panels-enable-directory").click(function(i){i.preventDefault(),l.get(panelsOptions.ajaxurl,{action:"so_panels_directory_enable"},function(){}),panelsOptions.directory_enabled=!0,o.addClass("so-panels-loading"),s.displayLayoutDirectory(e,t)});l.get(panelsOptions.ajaxurl,{action:"so_panels_layouts_query",search:e,page:t,type:i},function(n){if(s.currentTab===i){o.removeClass("so-panels-loading").html(s.directoryTemplate(n));var a=o.find(".so-previous"),r=o.find(".so-next");t<=1?a.addClass("button-disabled"):a.click(function(i){i.preventDefault(),s.displayLayoutDirectory(e,t-1,s.currentTab)}),t===n.max_num_pages||0===n.max_num_pages?r.addClass("button-disabled"):r.click(function(i){i.preventDefault(),s.displayLayoutDirectory(e,t+1,s.currentTab)}),o.find(".so-screenshot").each(function(){var e=l(this),t=e.find(".so-screenshot-wrapper");if(t.css("height",t.width()/4*3+"px").addClass("so-loading"),""!==e.data("src"))var i=l("<img/>").attr("src",e.data("src")).load(function(){t.removeClass("so-loading").css("height","auto"),i.appendTo(t).hide().fadeIn("fast")});else l("<img/>").attr("src",panelsOptions.prebuiltDefaultScreenshot).appendTo(t).hide().fadeIn("fast")}),o.find(".so-directory-browse").html(n.title)}},"json")},directoryItemClickHandler:function(e){var t=this.$(e.target).closest(".so-directory-item");this.$(".so-directory-items").find(".selected").removeClass("selected"),t.addClass("selected"),this.selectedLayoutItem={lid:t.data("layout-id"),type:t.data("layout-type")},this.updateButtonState(!0)},toolbarButtonClick:function(e){if(!this.canAddLayout())return!1;var t=e.data("value");if(_.isUndefined(t))return!1;if(this.updateButtonState(!1),e.hasClass("so-needs-confirm")&&!e.hasClass("so-confirmed")){if(this.updateButtonState(!0),e.hasClass("so-confirming"))return;e.addClass("so-confirming");var i=e.html();return e.html('<span class="dashicons dashicons-yes"></span>'+e.data("confirm")),setTimeout(function(){e.removeClass("so-confirmed").html(i)},2500),setTimeout(function(){e.removeClass("so-confirming"),e.addClass("so-confirmed")},200),!1}this.addingLayout=!0,"import"===this.currentTab?this.addLayoutToBuilder(this.uploadedLayout,t):this.loadSelectedLayout().then(function(e){this.addLayoutToBuilder(e,t)}.bind(this))},canAddLayout:function(){return(this.selectedLayoutItem||this.uploadedLayout)&&!this.addingLayout},loadSelectedLayout:function(){this.setStatusMessage(panelsOptions.loc.prebuilt_loading,!0);var e=_.extend(this.selectedLayoutItem,{action:"so_panels_get_layout"}),t=new l.Deferred;return l.get(panelsOptions.ajaxurl,e,function(e){void 0!==e.error?(alert(e.error),t.reject(e)):(this.setStatusMessage("",!1),t.resolve(e))}.bind(this)),t.promise()},searchHandler:function(e){13===e.keyCode&&this.displayLayoutDirectory(l(e.currentTarget).val(),1,this.currentTab)},updateButtonState:function(e){e=e&&(this.selectedLayoutItem||this.uploadedLayout);var t=this.$(".so-import-layout");t.prop("disabled",!e),e?t.removeClass("disabled"):t.addClass("disabled")},addLayoutToBuilder:function(e,t){this.builder.addHistoryEntry("prebuilt_loaded"),this.builder.model.loadPanelsData(e,t),this.addingLayout=!1,this.closeDialog()}})},{}],8:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({cellPreviewTemplate:_.template(s.helpers.utils.processTemplate(l("#siteorigin-panels-dialog-row-cell-preview").html())),editableLabel:!0,events:{"click .so-close":"closeDialog","click .so-toolbar .so-save":"saveHandler","click .so-toolbar .so-insert":"insertHandler","click .so-toolbar .so-delete":"deleteHandler","click .so-toolbar .so-duplicate":"duplicateHandler","change .row-set-form > *":"setCellsFromForm","click .row-set-form button.set-row":"setCellsFromForm"},dialogIcon:"add-row",dialogClass:"so-panels-dialog-row-edit",styleType:"row",dialogType:"edit",row:{cells:null,style:{}},cellStylesCache:[],initializeDialog:function(){this.on("open_dialog",function(){_.isUndefined(this.model)||_.isEmpty(this.model.get("cells"))?this.setRowModel(null):this.setRowModel(this.model),this.regenerateRowPreview()},this),this.row={cells:new s.collection.cells([{weight:.5},{weight:.5}]),style:{}},this.dialogFormsLoaded=0;var e=this;this.on("form_loaded styles_loaded",function(){2===++this.dialogFormsLoaded&&e.updateModel({refreshArgs:{silent:!0}})}),this.on("close_dialog",this.closeHandler),this.on("edit_label",function(e){if(e!==panelsOptions.loc.row.add&&e!==panelsOptions.loc.row.edit||(e=""),this.model.set("label",e),_.isEmpty(e)){var t="create"===this.dialogType?panelsOptions.loc.row.add:panelsOptions.loc.row.edit;this.$(".so-title").text(t)}}.bind(this))},setRowDialogType:function(e){this.dialogType=e},render:function(){var e="create"===this.dialogType?panelsOptions.loc.row.add:panelsOptions.loc.row.edit;this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-row").html(),{title:e,dialogType:this.dialogType}));var t=this.$(".so-title");this.model.has("label")&&!_.isEmpty(this.model.get("label"))&&t.text(this.model.get("label")),this.$(".so-edit-title").val(t.text()),this.styles=new s.view.styles,this.styles.model=this.model,this.styles.render("row",this.builder.config.postId,{builderType:this.builder.config.builderType,dialog:this}),this.builder.supports("addRow")||this.$(".so-buttons .so-duplicate").remove(),this.builder.supports("deleteRow")||this.$(".so-buttons .so-delete").remove();var i=this.$(".so-sidebar.so-right-sidebar");return this.styles.attach(i),this.styles.on("styles_loaded",function(e){e?i.removeClass("so-panels-loading"):(i.closest(".so-panels-dialog").removeClass("so-panels-dialog-has-right-sidebar"),i.remove())},this),i.addClass("so-panels-loading"),_.isUndefined(this.model)||this.$("input.so-row-field").val(this.model.get("cells").length),this.$("input.so-row-field").keyup(function(){l(this).trigger("change")}),this},setRowModel:function(e){return this.model=e,_.isEmpty(this.model)?this:(this.row={cells:this.model.get("cells").clone(),style:{}},this.$("input.so-row-field").val(this.model.get("cells").length),this.clearCellStylesCache(),this)},regenerateRowPreview:function(){var e=this,t=this.$(".row-preview"),i=this.getSelectedCellIndex();t.empty();var s;this.row.cells.each(function(o,n){var a=l(this.cellPreviewTemplate({weight:o.get("weight")}));t.append(a),n==i&&a.find(".preview-cell-in").addClass("cell-selected");var r,d=a.prev();d.length&&(r=l('<div class="resize-handle"></div>'),r.appendTo(a).dblclick(function(){var t=e.row.cells.at(n-1),i=o.get("weight")+t.get("weight");o.set("weight",i/2),t.set("weight",i/2),e.scaleRowWidths()}),r.draggable({axis:"x",containment:t,start:function(e,t){var i=a.clone().appendTo(t.helper).css({position:"absolute",top:"0",width:a.outerWidth(),left:6,height:a.outerHeight()});i.find(".resize-handle").remove();var s=d.clone().appendTo(t.helper).css({position:"absolute",top:"0",width:d.outerWidth(),right:6,height:d.outerHeight()});s.find(".resize-handle").remove(),l(this).data({newCellClone:i,prevCellClone:s}),a.find("> .preview-cell-in").css("visibility","hidden"),d.find("> .preview-cell-in").css("visibility","hidden")},drag:function(i,s){var o=e.row.cells.at(n).get("weight"),a=e.row.cells.at(n-1).get("weight"),r=o-(s.position.left+6)/t.width(),d=a+(s.position.left+6)/t.width();s.helper.offset().left,t.offset().left;l(this).data("newCellClone").css("width",t.width()*r).find(".preview-cell-weight").html(Math.round(1e3*r)/10),l(this).data("prevCellClone").css("width",t.width()*d).find(".preview-cell-weight").html(Math.round(1e3*d)/10)},stop:function(i,s){l(this).data("newCellClone").remove(),l(this).data("prevCellClone").remove(),a.find(".preview-cell-in").css("visibility","visible"),d.find(".preview-cell-in").css("visibility","visible");var o=s.position.left+6,r=o/t.width(),c=e.row.cells.at(n),h=e.row.cells.at(n-1);c.get("weight")-r>.02&&h.get("weight")+r>.02&&(c.set("weight",c.get("weight")-r),h.set("weight",h.get("weight")+r)),e.scaleRowWidths(),s.helper.css("left",-6)}})),a.click(function(e){if(l(e.target).is(".preview-cell")||l(e.target).is(".preview-cell-in")){var t=l(e.target);t.closest(".row-preview").find(".preview-cell .preview-cell-in").removeClass("cell-selected"),t.addClass("cell-selected"),this.openSelectedCellStyles()}}.bind(this)),a.find(".preview-cell-weight").click(function(i){e.$(".resize-handle").css("pointer-event","none").draggable("disable"),t.find(".preview-cell-weight").each(function(){var i=jQuery(this).hide();l('<input type="text" class="preview-cell-weight-input no-user-interacted" />').val(parseFloat(i.html())).insertAfter(i).focus(function(){clearTimeout(s)}).keyup(function(e){9!==e.keyCode&&l(this).removeClass("no-user-interacted"),13===e.keyCode&&(e.preventDefault(),l(this).blur())}).keydown(function(e){if(9===e.keyCode){e.preventDefault();var i=t.find(".preview-cell-weight-input"),s=i.index(l(this));s===i.length-1?i.eq(0).focus().select():i.eq(s+1).focus().select()}}).blur(function(){t.find(".preview-cell-weight-input").each(function(t,i){isNaN(parseFloat(l(i).val()))&&l(i).val(Math.floor(1e3*e.row.cells.at(t).get("weight"))/10)}),s=setTimeout(function(){if(0===t.find(".preview-cell-weight-input").length)return!1;var i=[],s=[],o=0,n=0;if(t.find(".preview-cell-weight-input").each(function(t,a){var r=parseFloat(l(a).val());r=isNaN(r)?1/e.row.cells.length:Math.round(10*r)/1e3;var d=!l(a).hasClass("no-user-interacted");i.push(r),s.push(d),d?o+=r:n+=r}),o>0&&n>0&&1-o>0)for(var a=0;a<i.length;a++)s[a]||(i[a]=i[a]/n*(1-o));var r=_.reduce(i,function(e,t){return e+t});i=i.map(function(e){return e/r}),Math.min.apply(Math,i)>.01&&e.row.cells.each(function(e,t){e.set("weight",i[t])}),t.find(".preview-cell").each(function(t,i){var s=e.row.cells.at(t).get("weight");l(i).animate({width:Math.round(1e3*s)/10+"%"},250),l(i).find(".preview-cell-weight-input").val(Math.round(1e3*s)/10)}),t.find(".preview-cell").css("overflow","visible"),setTimeout(function(){e.regenerateRowPreview()},260)},100)}).click(function(){l(this).select()})}),l(this).siblings(".preview-cell-weight-input").select()})},this),this.openSelectedCellStyles(),this.trigger("form_loaded",this)},getSelectedCellIndex:function(){var e=-1;return this.$(".preview-cell .preview-cell-in").each(function(t,i){l(i).is(".cell-selected")&&(e=t)}),e},openSelectedCellStyles:function(){if(!_.isUndefined(this.cellStyles)){if(this.cellStyles.stylesLoaded){var e={};try{e=this.getFormValues(".so-sidebar .so-visual-styles.so-cell-styles").style}catch(e){console.log("Error retrieving cell styles - "+e.message)}this.cellStyles.model.set("style",e)}this.cellStyles.detach()}if(this.cellStyles=this.getSelectedCellStyles(),this.cellStyles){var t=this.$(".so-sidebar.so-right-sidebar");this.cellStyles.attach(t),this.cellStyles.stylesLoaded||(this.cellStyles.on("styles_loaded",function(){t.removeClass("so-panels-loading")},this),t.addClass("so-panels-loading"))}},getSelectedCellStyles:function(){var e=this.getSelectedCellIndex();if(e>-1){var t=this.cellStylesCache[e];t||(t=new s.view.styles,t.model=this.row.cells.at(e),t.render("cell",this.builder.config.postId,{builderType:this.builder.config.builderType,dialog:this,index:e}),this.cellStylesCache[e]=t)}return t},clearCellStylesCache:function(){this.cellStylesCache.forEach(function(e){e.remove()}),this.cellStylesCache=[]},scaleRowWidths:function(){var e=this;this.$(".row-preview .preview-cell").each(function(t,i){var s=e.row.cells.at(t);l(i).css("width",100*s.get("weight")+"%").find(".preview-cell-weight").html(Math.round(1e3*s.get("weight"))/10)})},setCellsFromForm:function(){try{var e={cells:parseInt(this.$('.row-set-form input[name="cells"]').val()),ratio:parseFloat(this.$('.row-set-form select[name="ratio"]').val()),direction:this.$('.row-set-form select[name="ratio_direction"]').val()};_.isNaN(e.cells)&&(e.cells=1),isNaN(e.ratio)&&(e.ratio=1),e.cells<1?(e.cells=1,this.$('.row-set-form input[name="cells"]').val(e.cells)):e.cells>12&&(e.cells=12,this.$('.row-set-form input[name="cells"]').val(e.cells)),this.$('.row-set-form input[name="ratio"]').val(e.ratio);for(var t=[],i=this.row.cells.length!==e.cells,o=1,n=0;n<e.cells;n++)t.push(o),o*=e.ratio;var a=_.reduce(t,function(e,t){return e+t});if(t=_.map(t,function(e){return e/a}),t=_.filter(t,function(e){return e>.01}),"left"===e.direction&&(t=t.reverse()),this.row.cells=new s.collection.cells(this.row.cells.first(t.length)),_.each(t,function(e,t){var i=this.row.cells.at(t);i?i.set("weight",e):(i=new s.model.cell({weight:e,row:this.model}),this.row.cells.add(i))}.bind(this)),i)this.regenerateRowPreview();else{var r=this;this.$(".preview-cell").each(function(e,t){var i=r.row.cells.at(e).get("weight");l(t).animate({width:Math.round(1e3*i)/10+"%"},250),l(t).find(".preview-cell-weight").html(Math.round(1e3*i)/10)}),this.$(".preview-cell").css("overflow","visible"),setTimeout(function(){r.regenerateRowPreview()},260)}}catch(e){console.log("Error setting cells - "+e.message)}this.$(".row-set-form .so-button-row-set").removeClass("button-primary")},tabClickHandler:function(e){"#row-layout"===e.attr("href")?this.$(".so-panels-dialog").addClass("so-panels-dialog-has-right-sidebar"):this.$(".so-panels-dialog").removeClass("so-panels-dialog-has-right-sidebar")},updateModel:function(e){if(e=_.extend({refresh:!0,refreshArgs:null},e),_.isEmpty(this.model)||this.model.setCells(this.row.cells),!_.isUndefined(this.styles)&&this.styles.stylesLoaded){var t={};try{t=this.getFormValues(".so-sidebar .so-visual-styles.so-row-styles").style}catch(e){console.log("Error retrieving row styles - "+e.message)}this.model.set("style",t)}if(!_.isUndefined(this.cellStyles)&&this.cellStyles.stylesLoaded){var t={};try{t=this.getFormValues(".so-sidebar .so-visual-styles.so-cell-styles").style}catch(e){console.log("Error retrieving cell styles - "+e.message)}this.cellStyles.model.set("style",t)}e.refresh&&this.builder.model.refreshPanelsData(e.refreshArgs)},insertHandler:function(){this.builder.addHistoryEntry("row_added"),this.updateModel();var e=this.builder.getActiveCell({createCell:!1}),t={};return null!==e&&(t.at=this.builder.model.get("rows").indexOf(e.row)+1),this.model.collection=this.builder.model.get("rows"),this.builder.model.get("rows").add(this.model,t),this.closeDialog(),this.builder.model.refreshPanelsData(),!1},saveHandler:function(){return this.builder.addHistoryEntry("row_edited"),this.updateModel(),this.closeDialog(),this.builder.model.refreshPanelsData(),!1},deleteHandler:function(){return this.model.trigger("visual_destroy"),this.closeDialog({silent:!0}),!1},duplicateHandler:function(){this.builder.addHistoryEntry("row_duplicated");var e=this.model.clone(this.builder.model);return this.builder.model.get("rows").add(e,{at:this.builder.model.get("rows").indexOf(this.model)+1}),this.closeDialog({silent:!0}),!1},closeHandler:function(){this.clearCellStylesCache(),_.isUndefined(this.cellStyles)||(this.cellStyles=void 0)}})},{}],9:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({builder:null,sidebarWidgetTemplate:_.template(s.helpers.utils.processTemplate(l("#siteorigin-panels-dialog-widget-sidebar-widget").html())),dialogClass:"so-panels-dialog-edit-widget",dialogIcon:"add-widget",widgetView:!1,savingWidget:!1,editableLabel:!0,events:{"click .so-close":"saveHandler","click .so-nav.so-previous":"navToPrevious","click .so-nav.so-next":"navToNext","click .so-toolbar .so-delete":"deleteHandler","click .so-toolbar .so-duplicate":"duplicateHandler"},initializeDialog:function(){var e=this;this.model.on("change:values",this.handleChangeValues,this),this.model.on("destroy",this.remove,this),this.dialogFormsLoaded=0,this.on("form_loaded styles_loaded",function(){2===++this.dialogFormsLoaded&&e.updateModel({refreshArgs:{silent:!0}})}),this.on("edit_label",function(e){e===panelsOptions.widgets[this.model.get("class")].title&&(e=""),this.model.set("label",e),_.isEmpty(e)&&this.$(".so-title").text(this.model.getWidgetField("title"))}.bind(this))},render:function(){this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-widget").html(),{})),this.loadForm();var e=this.model.getWidgetField("title");this.$(".so-title .widget-name").html(e),this.$(".so-edit-title").val(e),this.builder.supports("addWidget")||this.$(".so-buttons .so-duplicate").remove(),this.builder.supports("deleteWidget")||this.$(".so-buttons .so-delete").remove(),this.styles=new s.view.styles,this.styles.model=this.model,this.styles.render("widget",this.builder.config.postId,{builderType:this.builder.config.builderType,dialog:this});var t=this.$(".so-sidebar.so-right-sidebar");this.styles.attach(t),this.styles.on("styles_loaded",function(e){e?t.removeClass("so-panels-loading"):(t.closest(".so-panels-dialog").removeClass("so-panels-dialog-has-right-sidebar"),t.remove())},this),t.addClass("so-panels-loading")},getPrevDialog:function(){var e=this.builder.$(".so-cells .cell .so-widget");if(e.length<=1)return!1;var t=e.index(this.widgetView.$el);if(0===t)return!1;do{if(widgetView=e.eq(--t).data("view"),!_.isUndefined(widgetView)&&!widgetView.model.get("read_only"))return widgetView.getEditDialog()}while(!_.isUndefined(widgetView)&&t>0);return!1},getNextDialog:function(){var e=this.builder.$(".so-cells .cell .so-widget");if(e.length<=1)return!1;var t,i=e.index(this.widgetView.$el);if(i===e.length-1)return!1;do{if(t=e.eq(++i).data("view"),!_.isUndefined(t)&&!t.model.get("read_only"))return t.getEditDialog()}while(!_.isUndefined(t));return!1},loadForm:function(){if(this.$("> *").length){var e=this;this.$(".so-content").addClass("so-panels-loading");var t={action:"so_panels_widget_form",widget:this.model.get("class"),instance:JSON.stringify(this.model.get("values")),raw:this.model.get("raw")};l.post(panelsOptions.ajaxurl,t,function(t){var i=t.replace(/{\$id}/g,e.model.cid);e.$(".so-content").removeClass("so-panels-loading").html(i),e.trigger("form_loaded",e),e.$(".panel-dialog").trigger("panelsopen"),e.on("close_dialog",e.updateModel,e)},"html")}},updateModel:function(e){if(e=_.extend({refresh:!0,refreshArgs:null},e),this.savingWidget=!0,!this.model.get("missing")){var t=this.getFormValues();_.isUndefined(t.widgets)?t={}:(t=t.widgets,t=t[Object.keys(t)[0]]),this.model.setValues(t),this.model.set("raw",!0)}if(this.styles.stylesLoaded){var i={};try{i=this.getFormValues(".so-sidebar .so-visual-styles").style}catch(e){}this.model.set("style",i)}this.savingWidget=!1,e.refresh&&this.builder.model.refreshPanelsData(e.refreshArgs)},handleChangeValues:function(){this.savingWidget||this.loadForm()},saveHandler:function(){this.builder.addHistoryEntry("widget_edited"),this.closeDialog()},deleteHandler:function(){return this.model.trigger("visual_destroy"),this.closeDialog({silent:!0}),this.builder.model.refreshPanelsData(),!1},duplicateHandler:function(){return this.model.trigger("user_duplicate"),this.closeDialog({silent:!0}),this.builder.model.refreshPanelsData(),!1}})},{}],10:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=s.view.dialog.extend({builder:null,widgetTemplate:_.template(s.helpers.utils.processTemplate(l("#siteorigin-panels-dialog-widgets-widget").html())),filter:{},dialogClass:"so-panels-dialog-add-widget",dialogIcon:"add-widget",events:{"click .so-close":"closeDialog","click .widget-type":"widgetClickHandler","keyup .so-sidebar-search":"searchHandler"},initializeDialog:function(){this.on("open_dialog",function(){this.filter.search="",this.filterWidgets(this.filter)},this),this.on("open_dialog_complete",function(){this.$(".so-sidebar-search").val("").focus(),this.balanceWidgetHeights()}),this.on("tab_click",this.tabClickHandler,this)},render:function(){this.renderDialog(this.parseDialogContent(l("#siteorigin-panels-dialog-widgets").html(),{})),_.each(panelsOptions.widgets,function(e){var t=l(this.widgetTemplate({title:e.title,description:e.description}));_.isUndefined(e.icon)&&(e.icon="dashicons dashicons-admin-generic"),l('<span class="widget-icon" />').addClass(e.icon).prependTo(t.find(".widget-type-wrapper")),t.data("class",e.class).appendTo(this.$(".widget-type-list"))},this);var e=this.$(".so-sidebar-tabs");_.each(panelsOptions.widget_dialog_tabs,function(t){l(this.dialogTabTemplate({title:t.title})).data({message:t.message,filter:t.filter}).appendTo(e)},this),this.initTabs();var t=this;l(window).resize(function(){t.balanceWidgetHeights()})},tabClickHandler:function(e){this.filter=e.parent().data("filter"),this.filter.search=this.$(".so-sidebar-search").val();var t=e.parent().data("message");return _.isEmpty(t)&&(t=""),this.$(".so-toolbar .so-status").html(t),this.filterWidgets(this.filter),!1},searchHandler:function(e){if(13===e.which){var t=this.$(".widget-type-list .widget-type:visible");1===t.length&&t.click()}else this.filter.search=l(e.target).val().trim(),this.filterWidgets(this.filter)},filterWidgets:function(e){_.isUndefined(e)&&(e={}),_.isUndefined(e.groups)&&(e.groups=""),this.$(".widget-type-list .widget-type").each(function(){var t,i=l(this),s=i.data("class"),o=_.isUndefined(panelsOptions.widgets[s])?null:panelsOptions.widgets[s];t=!!_.isEmpty(e.groups)||null!==o&&!_.isEmpty(_.intersection(e.groups,panelsOptions.widgets[s].groups)),t&&(_.isUndefined(e.search)||""===e.search||-1===o.title.toLowerCase().indexOf(e.search.toLowerCase())&&(t=!1)),t?i.show():i.hide()}),this.balanceWidgetHeights()},widgetClickHandler:function(e){this.builder.addHistoryEntry("widget_added");var t=l(e.currentTarget),i=new s.model.widget({class:t.data("class")});i.cell=this.builder.getActiveCell(),i.cell.get("widgets").add(i),this.closeDialog(),this.builder.model.refreshPanelsData()},balanceWidgetHeights:function(e){var t=[[]],i=null,s=Math.round(this.$(".widget-type").parent().width()/this.$(".widget-type").width());this.$(".widget-type").css("clear","none").filter(":visible").each(function(e,t){e%s==0&&0!==e&&l(t).css("clear","both")}),this.$(".widget-type-wrapper").css("height","auto").filter(":visible").each(function(e,s){var o=l(s);null!==i&&i.position().top!==o.position().top&&(t[t.length]=[]),i=o,t[t.length-1].push(o)}),_.each(t,function(e,t){var i=_.max(e.map(function(e){return e.height()}));_.each(e,function(e){e.height(i)})})}})},{}],11:[function(e,t,i){t.exports={canCopyPaste:function(){return"undefined"!=typeof Storage&&panelsOptions.user},setModel:function(e){if(!this.canCopyPaste())return!1;var t=panels.helpers.serialize.serialize(e)
2
  ;return e instanceof panels.model.row?t.thingType="row-model":e instanceof panels.model.widget&&(t.thingType="widget-model"),localStorage["panels_clipboard_"+panelsOptions.user]=JSON.stringify(t),!0},isModel:function(e){if(!this.canCopyPaste())return!1;var t=localStorage["panels_clipboard_"+panelsOptions.user];return void 0!==t&&(t=JSON.parse(t),t.thingType&&t.thingType===e)},getModel:function(e){if(!this.canCopyPaste())return null;var t=localStorage["panels_clipboard_"+panelsOptions.user];return void 0!==t&&(t=JSON.parse(t),t.thingType&&t.thingType===e)?panels.helpers.serialize.unserialize(t,t.thingType,null):null}}},{}],12:[function(e,t,i){t.exports={lock:function(){if("hidden"!==jQuery("body").css("overflow")){var e=[self.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,self.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop];jQuery("body").data({"scroll-position":e}).css("overflow","hidden"),_.isUndefined(e)||window.scrollTo(e[0],e[1])}},unlock:function(){if("hidden"===jQuery("body").css("overflow")&&!jQuery(".so-panels-dialog-wrapper").is(":visible")&&!jQuery(".so-panels-live-editor").is(":visible")){jQuery("body").css("overflow","visible");var e=jQuery("body").data("scroll-position");_.isUndefined(e)||window.scrollTo(e[0],e[1])}}}},{}],13:[function(e,t,i){t.exports={serialize:function(e){var t;if(e instanceof Backbone.Model){var i={};for(var s in e.attributes)if(e.attributes.hasOwnProperty(s)){if("builder"===s||"collection"===s)continue;t=e.attributes[s],t instanceof Backbone.Model||t instanceof Backbone.Collection?i[s]=this.serialize(t):i[s]=t}return i}if(e instanceof Backbone.Collection){for(var l=[],o=0;o<e.models.length;o++)t=e.models[o],t instanceof Backbone.Model||t instanceof Backbone.Collection?l.push(this.serialize(t)):l.push(t);return l}},unserialize:function(e,t,i){var s;switch(t){case"row-model":s=new panels.model.row,s.builder=i,s.set("style",e.style),s.setCells(this.unserialize(e.cells,"cell-collection",s));break;case"cell-model":s=new panels.model.cell,s.row=i,s.set("weight",e.weight),s.set("style",e.style),s.set("widgets",this.unserialize(e.widgets,"widget-collection",s));break;case"widget-model":s=new panels.model.widget,s.cell=i;for(var l in e)e.hasOwnProperty(l)&&s.set(l,e[l]);s.set("widget_id",panels.helpers.utils.generateUUID());break;case"cell-collection":s=new panels.collection.cells;for(var o=0;o<e.length;o++)s.push(this.unserialize(e[o],"cell-model",i));break;case"widget-collection":s=new panels.collection.widgets;for(var o=0;o<e.length;o++)s.push(this.unserialize(e[o],"widget-model",i));break;default:console.log("Unknown Thing - "+t)}return s}}},{}],14:[function(e,t,i){t.exports={generateUUID:function(){var e=(new Date).getTime();return window.performance&&"function"==typeof window.performance.now&&(e+=performance.now()),"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(t){var i=(e+16*Math.random())%16|0;return e=Math.floor(e/16),("x"==t?i:3&i|8).toString(16)})},processTemplate:function(e){return e=e.replace(/{{%/g,"<%"),e=e.replace(/%}}/g,"%>"),e=e.trim()},selectElementContents:function(e){var t=document.createRange();t.selectNodeContents(e);var i=window.getSelection();i.removeAllRanges(),i.addRange(t)}}},{}],15:[function(e,t,i){var s=window.panels,l=jQuery;t.exports=function(e){return this.each(function(){var t=jQuery(this),i=t.closest("form").find(".widget-id").val(),o=l.extend(!0,{},e);if(_.isUndefined(i)||!(i.indexOf("__i__")>-1)){var n=new s.model.builder,a=new s.view.builder({model:n,config:o}),r=t.closest(".so-panels-dialog-wrapper").data("view");_.isUndefined(r)||(r.on("close_dialog",function(){n.refreshPanelsData()}),r.on("open_dialog_complete",function(){a.trigger("builder_resize")}),r.model.on("destroy",function(){n.emptyRows().destroy()}),a.setDialogParents(panelsOptions.loc.layout_widget,r));var d=Boolean(t.closest(".widget-content").length);a.render().attach({container:t,dialog:d||"dialog"===t.data("mode"),type:t.data("type")}).setDataField(t.find("input.panels-data")),d||"dialog"===t.data("mode")?(a.setDialogParents(panelsOptions.loc.layout_widget,a.dialog),t.find(".siteorigin-panels-display-builder").click(function(e){e.preventDefault(),a.dialog.openDialog()})):t.find(".siteorigin-panels-display-builder").parent().remove(),l(document).trigger("panels_setup",a)}})}},{}],16:[function(e,t,i){var s={};window.panels=s,window.siteoriginPanels=s,s.helpers={},s.helpers.clipboard=e("./helpers/clipboard"),s.helpers.utils=e("./helpers/utils"),s.helpers.serialize=e("./helpers/serialize"),s.helpers.pageScroll=e("./helpers/page-scroll"),s.model={},s.model.widget=e("./model/widget"),s.model.cell=e("./model/cell"),s.model.row=e("./model/row"),s.model.builder=e("./model/builder"),s.model.historyEntry=e("./model/history-entry"),s.collection={},s.collection.widgets=e("./collection/widgets"),s.collection.cells=e("./collection/cells"),s.collection.rows=e("./collection/rows"),s.collection.historyEntries=e("./collection/history-entries"),s.view={},s.view.widget=e("./view/widget"),s.view.cell=e("./view/cell"),s.view.row=e("./view/row"),s.view.builder=e("./view/builder"),s.view.dialog=e("./view/dialog"),s.view.styles=e("./view/styles"),s.view.liveEditor=e("./view/live-editor"),s.dialog={},s.dialog.builder=e("./dialog/builder"),s.dialog.widgets=e("./dialog/widgets"),s.dialog.widget=e("./dialog/widget"),s.dialog.prebuilt=e("./dialog/prebuilt"),s.dialog.row=e("./dialog/row"),s.dialog.history=e("./dialog/history"),s.utils={},s.utils.menu=e("./utils/menu"),jQuery.fn.soPanelsSetupBuilderWidget=e("./jquery/setup-builder-widget"),jQuery(function(e){var t,i,s,l;if(e("#siteorigin-panels-metabox").length&&e("form#post").length)t=e("#siteorigin-panels-metabox"),i=e("#siteorigin-panels-metabox .siteorigin-panels-data-field"),s=e("form#post"),l={editorType:"tinyMCE",postId:e("#post_ID").val(),editorId:"#content",builderType:e("#siteorigin-panels-metabox").data("builder-type"),builderSupports:e("#siteorigin-panels-metabox").data("builder-supports"),loadOnAttach:panelsOptions.loadOnAttach&&1==e("#auto_draft").val(),loadLiveEditor:1==e("#siteorigin-panels-metabox").data("live-editor"),liveEditorPreview:t.data("preview-url")};else if(e(".siteorigin-panels-builder-form").length){var o=e(".siteorigin-panels-builder-form");t=o.find(".siteorigin-panels-builder-container"),i=o.find('input[name="panels_data"]'),s=o,l={editorType:"standalone",postId:o.data("post-id"),editorId:"#post_content",builderType:o.data("type"),builderSupports:o.data("builder-supports"),loadLiveEditor:!1,liveEditorPreview:o.data("preview-url")}}if(!_.isUndefined(t)){var n=window.siteoriginPanels,a=new n.model.builder,r=new n.view.builder({model:a,config:l});r.render().attach({container:t}).setDataField(i).attachToEditor(),s.submit(function(){a.refreshPanelsData()}),t.removeClass("so-panels-loading"),e(document).trigger("panels_setup",r,window.panels)}e(document).on("widget-added",function(t,i){e(i).find(".siteorigin-page-builder-widget").soPanelsSetupBuilderWidget()}),e("body").hasClass("wp-customizer")||e(function(){e(".siteorigin-page-builder-widget").soPanelsSetupBuilderWidget()})})},{"./collection/cells":1,"./collection/history-entries":2,"./collection/rows":3,"./collection/widgets":4,"./dialog/builder":5,"./dialog/history":6,"./dialog/prebuilt":7,"./dialog/row":8,"./dialog/widget":9,"./dialog/widgets":10,"./helpers/clipboard":11,"./helpers/page-scroll":12,"./helpers/serialize":13,"./helpers/utils":14,"./jquery/setup-builder-widget":15,"./model/builder":17,"./model/cell":18,"./model/history-entry":19,"./model/row":20,"./model/widget":21,"./utils/menu":22,"./view/builder":23,"./view/cell":24,"./view/dialog":25,"./view/live-editor":26,"./view/row":27,"./view/styles":28,"./view/widget":29}],17:[function(e,t,i){t.exports=Backbone.Model.extend({layoutPosition:{BEFORE:"before",AFTER:"after",REPLACE:"replace"},rows:{},defaults:{data:{widgets:[],grids:[],grid_cells:[]}},initialize:function(){this.set("rows",new panels.collection.rows)},addRow:function(e,t,i){i=_.extend({noAnimate:!1},i);var s=new panels.collection.cells(t);e=_.extend({collection:this.get("rows"),cells:s},e);var l=new panels.model.row(e);return l.builder=this,this.get("rows").add(l,i),l},loadPanelsData:function(e,t){try{t===this.layoutPosition.BEFORE?e=this.concatPanelsData(e,this.getPanelsData()):t===this.layoutPosition.AFTER&&(e=this.concatPanelsData(this.getPanelsData(),e)),this.emptyRows(),this.set("data",JSON.parse(JSON.stringify(e)),{silent:!0});var i=[];if(_.isUndefined(e.grid_cells))return void this.trigger("load_panels_data");for(var s,l=0;l<e.grid_cells.length;l++)s=parseInt(e.grid_cells[l].grid),_.isUndefined(i[s])&&(i[s]=[]),i[s].push(e.grid_cells[l]);var o=this;if(_.each(i,function(t,i){var s={};_.isUndefined(e.grids[i].style)||(s.style=e.grids[i].style),_.isUndefined(e.grids[i].color_label)||(s.color_label=e.grids[i].color_label),_.isUndefined(e.grids[i].label)||(s.label=e.grids[i].label),o.addRow(s,t,{noAnimate:!0})}),_.isUndefined(e.widgets))return;_.each(e.widgets,function(e){var t=null;_.isUndefined(e.panels_info)?(t=e.info,delete e.info):(t=e.panels_info,delete e.panels_info);var i=o.get("rows").at(parseInt(t.grid)),s=i.get("cells").at(parseInt(t.cell)),l=new panels.model.widget({class:t.class,values:e});_.isUndefined(t.style)||l.set("style",t.style),_.isUndefined(t.read_only)||l.set("read_only",t.read_only),_.isUndefined(t.widget_id)?l.set("widget_id",panels.helpers.utils.generateUUID()):l.set("widget_id",t.widget_id),_.isUndefined(t.label)||l.set("label",t.label),l.cell=s,s.get("widgets").add(l,{noAnimate:!0})}),this.trigger("load_panels_data")}catch(e){console.log("Error loading data: "+e.message)}},concatPanelsData:function(e,t){if(_.isUndefined(t)||_.isUndefined(t.grids)||_.isEmpty(t.grids)||_.isUndefined(t.grid_cells)||_.isEmpty(t.grid_cells))return e;if(_.isUndefined(e)||_.isUndefined(e.grids)||_.isEmpty(e.grids))return t;var i=e.grids.length,s=_.isUndefined(e.widgets)?0:e.widgets.length,l={grids:[],grid_cells:[],widgets:[]};l.grids=e.grids.concat(t.grids),_.isUndefined(e.grid_cells)||(l.grid_cells=e.grid_cells.slice()),_.isUndefined(e.widgets)||(l.widgets=e.widgets.slice());var o;for(o=0;o<t.grid_cells.length;o++){var n=t.grid_cells[o];n.grid=parseInt(n.grid)+i,l.grid_cells.push(n)}if(!_.isUndefined(t.widgets))for(o=0;o<t.widgets.length;o++){var a=t.widgets[o];a.panels_info.grid=parseInt(a.panels_info.grid)+i,a.panels_info.id=parseInt(a.panels_info.id)+s,l.widgets.push(a)}return l},getPanelsData:function(){var e={widgets:[],grids:[],grid_cells:[]},t=0;return this.get("rows").each(function(i,s){i.get("cells").each(function(i,l){i.get("widgets").each(function(i,o){var n={class:i.get("class"),raw:i.get("raw"),grid:s,cell:l,id:t++,widget_id:i.get("widget_id"),style:i.get("style"),label:i.get("label")};_.isEmpty(n.widget_id)&&(n.widget_id=panels.helpers.utils.generateUUID());var a=_.extend(_.clone(i.get("values")),{panels_info:n});e.widgets.push(a)}),e.grid_cells.push({grid:s,index:l,weight:i.get("weight"),style:i.get("style")})}),e.grids.push({cells:i.get("cells").length,style:i.get("style"),color_label:i.get("color_label"),label:i.get("label")})}),e},refreshPanelsData:function(e){e=_.extend({silent:!1},e);var t=this.get("data"),i=this.getPanelsData();this.set("data",i,{silent:!0}),e.silent||JSON.stringify(i)===JSON.stringify(t)||(this.trigger("change"),this.trigger("change:data"),this.trigger("refresh_panels_data",i,e))},emptyRows:function(){return _.invoke(this.get("rows").toArray(),"destroy"),this.get("rows").reset(),this},isValidLayoutPosition:function(e){return e===this.layoutPosition.BEFORE||e===this.layoutPosition.AFTER||e===this.layoutPosition.REPLACE},getPanelsDataFromHtml:function(e,t){var i=this,s=jQuery('<div id="wrapper">'+e+"</div>");if(s.find(".panel-layout .panel-grid").length){var l={grids:[],grid_cells:[],widgets:[]},o=new RegExp(panelsOptions.siteoriginWidgetRegex,"i"),n=function(){function e(e){return e&&"string"==typeof e&&(e=e.replace(/<script[^>]*>([\S\s]*?)<\/script>/gim,""),e=e.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gim,""),t.innerHTML=e,e=t.textContent,t.textContent=""),e}var t=document.createElement("div");return e}(),a=function(e){var t=e.find("div");if(!t.length)return e.html();var i;for(i=0;i<t.length-1&&jQuery.trim(t.eq(i).text())==jQuery.trim(t.eq(i+1).text());i++);var s=t.eq(i).find(".widget-title:header"),l="";return s.length&&(