WordPress Page Builder – Beaver Builder - Version 2.0.3.2

Version Description

Download this release

Release Info

Developer pross
Plugin Icon 128x128 WordPress Page Builder – Beaver Builder
Version 2.0.3.2
Comparing to
See all releases

Code changes from version 1.11 to 2.0.3.2

Files changed (150) hide show
  1. changelog.txt +221 -1
  2. classes/class-fl-builder-admin-settings.php +1 -0
  3. classes/class-fl-builder-ajax-layout.php +57 -11
  4. classes/class-fl-builder-ajax.php +17 -11
  5. classes/class-fl-builder-auto-suggest.php +17 -0
  6. classes/class-fl-builder-fonts.php +6 -8
  7. classes/class-fl-builder-icons.php +7 -5
  8. classes/class-fl-builder-loader.php +6 -2
  9. classes/class-fl-builder-loop.php +66 -23
  10. classes/class-fl-builder-model.php +859 -242
  11. classes/class-fl-builder-module.php +82 -1
  12. classes/class-fl-builder-revisions.php +139 -0
  13. classes/class-fl-builder-service-activecampaign.php +6 -2
  14. classes/class-fl-builder-services.php +10 -0
  15. classes/class-fl-builder-ui-content-panel.php +312 -0
  16. classes/class-fl-builder-ui-settings-forms.php +737 -0
  17. classes/class-fl-builder-user-settings.php +93 -0
  18. classes/class-fl-builder-utils.php +12 -0
  19. classes/class-fl-builder-wpcli-command.php +1 -0
  20. classes/class-fl-builder.php +605 -424
  21. css/fl-builder-layout.css +9 -0
  22. css/fl-builder-ui-skin-dark.css +392 -0
  23. css/fl-builder.css +3020 -409
  24. css/fl-builder.min.css +1 -1
  25. css/fl-color-picker.css +97 -46
  26. css/fl-icon-selector.css +38 -9
  27. css/fl-lightbox.css +136 -48
  28. css/jquery.nanoscroller.css +4 -5
  29. css/jquery.tiptip.css +7 -26
  30. fl-builder.php +1 -1
  31. img/svg/button.svg +1 -0
  32. img/svg/chart-bar.svg +1 -0
  33. img/svg/clock.svg +1 -0
  34. img/svg/editor-code.svg +1 -0
  35. img/svg/editor-table.svg +1 -0
  36. img/svg/format-audio.svg +1 -0
  37. img/svg/format-gallery.svg +1 -0
  38. img/svg/format-image.svg +1 -0
  39. img/svg/format-quote.svg +1 -0
  40. img/svg/format-video.svg +1 -0
  41. img/svg/insert.svg +1 -0
  42. img/svg/layout.svg +1 -0
  43. img/svg/location.svg +1 -0
  44. img/svg/megaphone.svg +1 -0
  45. img/svg/minus.svg +1 -0
  46. img/svg/plus-alt.svg +1 -0
  47. img/svg/schedule.svg +1 -0
  48. img/svg/select-arrow-down-alt2-light.svg +1 -0
  49. img/svg/select-arrow-down-alt2.svg +1 -0
  50. img/svg/share-alt2.svg +1 -0
  51. img/svg/slides.svg +1 -0
  52. img/svg/star-filled.svg +1 -0
  53. img/svg/text.svg +1 -0
  54. img/svg/wordpress-alt.svg +1 -0
  55. includes/admin-settings-welcome.php +10 -8
  56. includes/column-settings.php +14 -128
  57. includes/compatibility.php +11 -0
  58. includes/field-button.php +0 -1
  59. includes/field-code.php +0 -57
  60. includes/field-color.php +0 -8
  61. includes/field-editor.php +0 -70
  62. includes/field-font.php +0 -9
  63. includes/field-form.php +0 -38
  64. includes/field-icon.php +0 -12
  65. includes/field-layout.php +0 -9
  66. includes/field-link.php +0 -9
  67. includes/field-multiple-audios.php +0 -27
  68. includes/field-multiple-photos.php +0 -26
  69. includes/field-ordering.php +0 -26
  70. includes/field-photo-sizes.php +0 -12
  71. includes/field-photo.php +0 -22
  72. includes/field-post-type.php +0 -5
  73. includes/field-select.php +0 -152
  74. includes/field-suggest.php +0 -12
  75. includes/field-text.php +0 -76
  76. includes/field-textarea.php +0 -3
  77. includes/field-time.php +0 -28
  78. includes/field-timezone.php +0 -6
  79. includes/field-unit.php +0 -6
  80. includes/field-video.php +0 -22
  81. includes/global-settings.php +6 -0
  82. includes/icon-selector.php +1 -1
  83. includes/jquery.php +2 -2
  84. includes/loop-settings-matching.php +5 -2
  85. includes/module-settings.php +4 -49
  86. includes/row-css.php +18 -0
  87. includes/row-js.php +1 -0
  88. includes/row-settings.php +23 -158
  89. includes/service-settings.php +0 -46
  90. includes/settings.php +0 -84
  91. includes/template-selector.php +0 -67
  92. includes/ui-bar-title-area.php +20 -0
  93. includes/ui-bar.php +26 -0
  94. includes/{ui-fields.php → ui-extras.php} +2 -4
  95. includes/ui-field-button.php +5 -0
  96. includes/ui-field-code.php +22 -0
  97. includes/ui-field-color.php +14 -0
  98. includes/ui-field-dimension.php +59 -0
  99. includes/ui-field-editor.php +20 -0
  100. includes/ui-field-font.php +9 -0
  101. includes/ui-field-form.php +53 -0
  102. includes/ui-field-icon.php +11 -0
  103. includes/ui-field-layout.php +9 -0
  104. includes/ui-field-link.php +11 -0
  105. includes/ui-field-multiple-audios.php +38 -0
  106. includes/ui-field-multiple-photos.php +32 -0
  107. includes/ui-field-ordering.php +33 -0
  108. includes/ui-field-photo-sizes.php +9 -0
  109. includes/ui-field-photo.php +53 -0
  110. includes/ui-field-post-type.php +5 -0
  111. includes/ui-field-select.php +153 -0
  112. includes/ui-field-suggest.php +11 -0
  113. includes/ui-field-text.php +9 -0
  114. includes/ui-field-textarea.php +6 -0
  115. includes/ui-field-time.php +28 -0
  116. includes/ui-field-timezone.php +9 -0
  117. includes/ui-field-unit.php +6 -0
  118. includes/ui-field-video.php +41 -0
  119. includes/ui-field.php +83 -0
  120. includes/ui-js-config.php +65 -0
  121. includes/ui-js-templates.php +733 -4
  122. includes/{field.php → ui-legacy-custom-field.php} +11 -9
  123. includes/ui-legacy-field.php +37 -0
  124. includes/ui-legacy-settings.php +24 -0
  125. includes/{loop-settings.php → ui-loop-settings.php} +6 -2
  126. includes/ui-panel-module-templates.php +0 -20
  127. includes/ui-panel-row-templates.php +0 -20
  128. includes/ui-panel.php +0 -72
  129. includes/ui-service-settings.php +49 -0
  130. includes/ui-settings-config.php +4 -0
  131. includes/ui-settings-form-row.php +40 -0
  132. includes/ui-settings-form.php +116 -0
  133. includes/updater-config.php +1 -1
  134. includes/updater/classes/class-fl-updater.php +1 -1
  135. js/fl-builder-ajax-layout.js +89 -74
  136. js/fl-builder-layout.js +1 -2
  137. js/fl-builder-preview.js +397 -318
  138. js/fl-builder-responsive-editing.js +78 -75
  139. js/fl-builder-revisions.js +243 -0
  140. js/fl-builder-save-manager.js +246 -0
  141. js/fl-builder-search.js +422 -0
  142. js/fl-builder-services.js +65 -65
  143. js/fl-builder-simulate-media-query.js +103 -104
  144. js/fl-builder-tour.js +31 -62
  145. js/fl-builder-ui-main-menu.js +418 -0
  146. js/fl-builder-ui-panel-content-library.js +1008 -0
  147. js/fl-builder-ui-pinned.js +702 -0
  148. js/fl-builder-ui-settings-forms.js +864 -0
  149. js/fl-builder-ui.js +1185 -0
  150. js/fl-builder.js +1140 -738
changelog.txt CHANGED
@@ -1,3 +1,223 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <h4>1.11 11/28/17</h4>
2
  <p><strong>This will be the final 1.x release before 2.x is made available to all customers via remote update.</strong></p>
3
  <p><strong>Enhancements</strong></p>
@@ -2122,5 +2342,5 @@
2122
  <h4>0.8.2</h4>
2123
  <p>Responsive module margins now only reset if negative or greater than the default.</p>
2124
 
2125
- <h4>0.8.1</h4>
2126
  <p>Initial beta release.</p>
1
+ <h4>2.0.3.2 - 12/20/2017</h4>
2
+ <p><strong>Hotfix</strong></p>
3
+ <ul>
4
+ <li>Removed the next/prev settings tab shortcuts as they interfere with text editing.</li>
5
+ <li>Fixed module settings reverting to defaults when duplicating a module that isn't saved yet.</li>
6
+ <li>Fixed contact form errors when global or using the reCAPTCHA.</li>
7
+ </ul>
8
+
9
+ <h4>2.0.3.1 - 12/13/2017</h4>
10
+ <p><strong>Hotfix</strong></p>
11
+ <ul>
12
+ <li>Fixed a bug in multisite where subsite settings were being loaded from main site.</li>
13
+ <li>Fixed an issue with content slider only showing two slides.</li>
14
+ <li>Fixed javascript error shown when trying to edit a saved module.</li>
15
+ </ul>
16
+
17
+ <h4>2.0.3 - 12/11/2017</h4>
18
+ <p><strong>Enhancements</strong></p>
19
+ <ul>
20
+ <li>Enable Rest API support for builder template post type.</li>
21
+ <li>Pass <code>$settings</code> in available args in <code>fl_builder_loop_query_args</code> filter.</li>
22
+ <li>Insert Layout Shortcode will now render non BB content which was a fallback in 1.x.</li>
23
+ <li>New filter <code>fl_builder_photo_sizes_select</code>.</li>
24
+ </ul>
25
+ <p><strong>Bug Fixes</strong></p>
26
+ <ul>
27
+ <li>Fixed various UI scrollbar issues on Windows.</li>
28
+ <li>Fixed group name HTML entities issue.</li>
29
+ <li>Fixed duplicate audio issue in content slider when video is set to autoplay.</li>
30
+ <li>Fixed a multisite icon issue, network settings were being ignored on primary site.</li>
31
+ <li>Fixed issue with WordPress widgets being available in Builder UI when disabled in admin settings.</li>
32
+ <li>Fixed Active Campaign re-subscribe issue in Subscribe Module.</li>
33
+ <li>Fixed issue in form field settings <code>preview_text</code> now works with <code>select</code> field type.</li>
34
+ <li>Fixed PHP 7.2 warning thrown in <code>get_settings_form_fields</code></li>
35
+ <li>Fixed form fields issue: Duplicate item button missing until you add a second item.</li>
36
+ <li>Updated bxslider library, fixes 40px margin issue with content slider.</li>
37
+ <li>Remove Core WP Gallery Widget from list of available widgets in the builder.</li>
38
+ <li>Disabled swipe on row background videos.</li>
39
+ <li>Fixed GeneratePress Premium plugin Blog option overrules the Post modules excerpt setting.</li>
40
+ </ul>
41
+
42
+ <h4>2.0.2.2 - 12/06/2017</h4>
43
+ <p>Beaver Builder 2.0 is now available for remote update!</p>
44
+
45
+ <h4>2.0.2.1 - 11/27/2017</h4>
46
+ <p><strong>Bug Fixes</strong></p>
47
+ <ul>
48
+ <li>Fixed responsive editing mode not working correctly.</li>
49
+ <li>Fixed white labeling not working correctly on the updates page.</li>
50
+ </ul>
51
+
52
+ <h4>2.0.2 - 11/16/2017</h4>
53
+ <p><strong>Enhancements</strong></p>
54
+ <ul>
55
+ <li>Added <code>fl_builder_cache_cleared</code> action.</li>
56
+ </ul>
57
+ <p><strong>Bug Fixes</strong></p>
58
+ <ul>
59
+ <li>Fixed settings config not loading when query strings are removed from script URLs.</li>
60
+ <li>Fixed widgets not showing when site language is not in English.</li>
61
+ <li>Fixed error when using namespaced widgets.</li>
62
+ <li>Fixed JS errors in IE.</li>
63
+ <li>Fixed keyboard shortcut formatting in IE.</li>
64
+ <li>Fixed capitalization issues with translations.</li>
65
+ <li>Fixed character encoding issues with strtolower.</li>
66
+ </ul>
67
+
68
+ <h4>2.0.1.1 - 11/07/2017</h4>
69
+ <p><strong>Bug Fixes</strong></p>
70
+ <ul>
71
+ <li>Hotfix for a change in 2.0.1 that broke loading of the settings for the Subscribe Form module.</li>
72
+ </ul>
73
+
74
+ <h4>2.0.1 - 11/06/2017</h4>
75
+ <p><strong>Bug Fixes</strong></p>
76
+ <ul>
77
+ <li>Fixed errors caused by settings config not completely loading on certain server setups.</li>
78
+ <li>Fixed PHP warnings when attachment meta doesn't have a width or height set.</li>
79
+ </ul>
80
+
81
+ <h4>2.0 - 11/01/2017</h4>
82
+ <p><strong>Beaver Builder 2.0 is here!</strong></p>
83
+ <p>Please note that 2.0 is currently only available from your My Account page or via remote update if you already have 2.0 installed. We'll be releasing remote updates for older versions of Beaver Builder within the next few weeks.</p>
84
+
85
+ <h4>2.0-beta.3 - 10/31/2017</h4>
86
+ <p><strong>Enhancements</strong></p>
87
+ <ul>
88
+ <li>Updated the help video for 2.0.</li>
89
+ <li>Added fl_row_resize_settings filter.</li>
90
+ </ul>
91
+ <p><strong>Bug Fixes</strong></p>
92
+ <ul>
93
+ <li>Fixed various UI styling issues.</li>
94
+ <li>Fixed editing global rows not working properly.</li>
95
+ <li>Fixed template override settings not working on multisite.</li>
96
+ <li>Fixed repeater fields in nested forms not working.</li>
97
+ <li>Fixed stylesheets in the body tag not being parsed for responsive preview.</li>
98
+ <li>Fixed content panel showing during preview or unpinning during preview when not expected.</li>
99
+ <li>Fixed anchor links in the layout causing the builder to launch again after publish.</li>
100
+ </ul>
101
+
102
+ <h4>2.0-beta.2 - 10/12/2017</h4>
103
+ <p><strong>Enhancements</strong></p>
104
+ <ul>
105
+ <li>Publish button now says 'Submit for Review' if a user doesn't have permission to publish.</li>
106
+ <li>Pinned settings are now responsive for smaller devices.</li>
107
+ <li>Moved WordPress widgets into their own group.</li>
108
+ <li>Moved Themer modules into their own group (coming in Themer 1.0.3).</li>
109
+ </ul>
110
+ <p><strong>Bug Fixes</strong></p>
111
+ <ul>
112
+ <li>Fixed row actions being covered by modules when the row has no padding.</li>
113
+ <li>Fixed values in text inputs not being escaped which breaks the markup.</li>
114
+ <li>Fixed settings being dragged or resized so you can't access the drag handle anymore.</li>
115
+ <li>Fixed browser zoom triggering the action overflow menu when it shouldn't.</li>
116
+ <li>Fixed multiple issues with saving new templates.</li>
117
+ <li>Fixed styling issues with dark mode.</li>
118
+ <li>Fixed module aliases not showing in the content panel.</li>
119
+ <li>Fixed widgets not showing in the content panel.</li>
120
+ </ul>
121
+
122
+ <h4>2.0-beta.1 - 10/04/2017</h4>
123
+ <p><strong>Enhancements</strong></p>
124
+ <ul>
125
+ <li>Added keyboard shortcut UI to the builder menu.</li>
126
+ <li>Reworked keyboard shortcut system to support displaying shortcuts with labels and modifier key symbols.</li>
127
+ </ul>
128
+ <p><strong>Bug Fixes</strong></p>
129
+ <ul>
130
+ <li>Fixed various styling issues.</li>
131
+ <li>Fixed photo and video fields that aren't in node settings not showing saved data when opened again after the page is refreshed.</li>
132
+ <li>Fixed error when saving a template with no category set.</li>
133
+ <li>Fixed saved values for medium and responsive in dimension fields not showing when going back to edit a node.</li>
134
+ <li>Fixed module templates not showing in the content panel.</li>
135
+ <li>Fixed issue with module hover in the content panel being covered by siblings.</li>
136
+ <li>Fixed a major issue with secondary loops triggering the builder's content filter when they shouldn't. This caused a number of issues including an infinite loop in Themer and the incorrect posts being displayed on standard builder pages.</li>
137
+ <li>Fixed FLBuilder::render_query so it doesn't have to override $wp_query which was causing incorrect connection data for Themer layouts.</li>
138
+ </ul>
139
+
140
+ <h4>2.0-alpha.7 - 09/21/2017</h4>
141
+ <p><strong>Enhancements</strong></p>
142
+ <ul>
143
+ <li>Added the ability to match posts in the loop settings by related taxonomy terms.</li>
144
+ </ul>
145
+ <p><strong>Bug Fixes</strong></p>
146
+ <ul>
147
+ <li>Fixed page scrolling breaking when opening the main menu.</li>
148
+ <li>Fixed field connections not rendering in nested settings forms.</li>
149
+ </ul>
150
+
151
+ <h4>2.0-alpha.6.1 - 09/19/2017</h4>
152
+ <p><strong>Bug Fixes</strong></p>
153
+ <ul>
154
+ <li>Fixed a bug with the option labels in select option groups not showing.</li>
155
+ </ul>
156
+
157
+ <h4>2.0-alpha.6 - 09/19/2017</h4>
158
+ <p><strong>Bug Fixes</strong></p>
159
+ <ul>
160
+ <li>Fixed a bug breaking the Pods integration.</li>
161
+ <li>Fixed an issue causing the builder UI to break on SiteGround servers.</li>
162
+ </ul>
163
+
164
+ <h4>2.0-alpha.5 - 09/06/2017</h4>
165
+ <p><strong>Enhancements</strong></p>
166
+ <ul>
167
+ <li>Settings panel tabs no longer become a drop-down menu when slim. Tabs that cannot fit into the available space are pushed into a menu.</li>
168
+ <li>You can now move between settings tabs with the keyboard shortcuts "CMD + Left Arrow" or "CMD + Right Arrow" (CTRL on Windows).</li>
169
+ <li>You can now reset row or column widths from the module overlay.</li>
170
+ <li>"CMD + i" (CTRL on Windows) shortcut will take you directly to module search.</li>
171
+ <li>Module search is now case-insensitive.</li>
172
+ <li>Duplicated items that appear off screen will now scroll into view.</li>
173
+ </ul>
174
+ <p><strong>Bug Fixes</strong></p>
175
+ <ul>
176
+ <li>Fixed scrolling not working when hovering over the content panel and then back into the layout.</li>
177
+ <li>Hovering over the content panel should no longer cause screen jitter in Windows browsers.</li>
178
+ <li>Icon selector search/filter has been restored.</li>
179
+ <li>J, K, L, and ; keys now show content panel tabs even when the panel has been collapsed.</li>
180
+ <li>Dropping a row template into the layout immediately loads fonts.</li>
181
+ <li>Overriding core templates now works again when applying a template.<li>
182
+ <li>Fixed ACE editor resize causing incorrect cursor position.</li>
183
+ <li>Fixed multiple issues with pinning in Safari and Firefox.</li>
184
+ </ul>
185
+
186
+ <h4>2.0-alpha.4 - 08/29/2017</h4>
187
+ <ul>
188
+ <li>A new slimmer version of the settings panels now opens when clicking to edit content.</li>
189
+ <li>Settings panels can now be resized to any size that you desire.</li>
190
+ <li>We'll remember the size and position you set for the settings panels even after reloading the page.</li>
191
+ <li>The content panel and settings can now be pinned together on either the left or right side of the screen. You can resize the pinned sidebar when you need a little more room.</li>
192
+ <li>You can now work with the toolbar or in the layout even when settings are open.</li>
193
+ <li>If settings are open and you take action anywhere else in the builder, we'll save and close them for you. This means you can edit one module and click to edit another without ever needing to click save in between.</li>
194
+ <li>Module search has been moved into the modules tab for more intuitive access.</li>
195
+ </ul>
196
+
197
+ <h4>2.0-alpha.3 - 08/07/2017</h4>
198
+ <ul>
199
+ <li>Settings forms now load instantly! We've completely rewritten the settings forms in JavaScript so they don’t need to be loaded from the server anymore. The only time something needs to load is if you’re using a third party add-on that introduces legacy PHP fields. We’ll have docs on the new JavaScript settings APIs when 2.0 is released and hope that all major add-on authors will convert their fields to JavaScript so everything loads instantly! :)</li>
200
+ <li>Added an initial set of core row templates.</li>
201
+ <li>Various bug fixes and style tweaks.</li>
202
+ </ul>
203
+
204
+ <h4>2.0-alpha.2 - 07/24/2017</h4>
205
+ <ul>
206
+ <li>Added the ability to duplicate columns.</li>
207
+ <li>Increased contrast to light and dark UI modes.</li>
208
+ <li>Added module icons.</li>
209
+ <li>Restyled content group selector.</li>
210
+ <li>Reworked how group labels are displayed in search results.</li>
211
+ <li>Style hardening for GeneratePress theme.</li>
212
+ <li>Publishing out of the builder now moves the history state and updates the url. Re-entering will move back.</li>
213
+ </ul>
214
+
215
+ <h4>1.11.1 11/29/17</h4>
216
+ <p><strong>Hot Fix</strong></p>
217
+ <ul>
218
+ <li>Fixed issue with ScrollTo links.</li>
219
+ </ul>
220
+
221
  <h4>1.11 11/28/17</h4>
222
  <p><strong>This will be the final 1.x release before 2.x is made available to all customers via remote update.</strong></p>
223
  <p><strong>Enhancements</strong></p>
2342
  <h4>0.8.2</h4>
2343
  <p>Responsive module margins now only reset if negative or greater than the default.</p>
2344
 
2345
+ <h4>0.8.1</h4>
2346
  <p>Initial beta release.</p>
classes/class-fl-builder-admin-settings.php CHANGED
@@ -559,6 +559,7 @@ final class FLBuilderAdminSettings {
559
  FLCustomizer::clear_all_css_cache();
560
  }
561
  }
 
562
  }
563
  }
564
 
559
  FLCustomizer::clear_all_css_cache();
560
  }
561
  }
562
+ do_action( 'fl_builder_cache_cleared' );
563
  }
564
  }
565
 
classes/class-fl-builder-ajax-layout.php CHANGED
@@ -87,7 +87,10 @@ final class FLBuilderAJAXLayout {
87
  }
88
 
89
  // Return the response.
90
- return self::render( $row->node );
 
 
 
91
  } // End if().
92
  else {
93
 
@@ -118,10 +121,12 @@ final class FLBuilderAJAXLayout {
118
  *
119
  * @since 1.7
120
  * @param string $node_id The ID of a row to copy.
 
 
121
  * @return array
122
  */
123
- static public function copy_row( $node_id ) {
124
- $row = FLBuilderModel::copy_row( $node_id );
125
 
126
  return self::render( $row->node );
127
  }
@@ -175,6 +180,21 @@ final class FLBuilderAJAXLayout {
175
  return self::render( $group->node );
176
  }
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  /**
179
  * Renders the layout data for a new module.
180
  *
@@ -203,9 +223,6 @@ final class FLBuilderAJAXLayout {
203
  $module = FLBuilderModel::add_default_module( $parent_id, $type, $position, $defaults );
204
  }
205
 
206
- // Render the new module's settings.
207
- $settings = FLBuilder::render_module_settings( $module->node, $module->settings->type, $module->parent, false );
208
-
209
  // Maybe render the module's parent for a partial refresh?
210
  if ( $module->partial_refresh ) {
211
 
@@ -230,8 +247,13 @@ final class FLBuilderAJAXLayout {
230
 
231
  // Return the response.
232
  return array(
233
- 'layout' => self::render( $render_id ),
234
- 'settings' => $settings['settings'],
 
 
 
 
 
235
  );
236
  }
237
 
@@ -240,10 +262,11 @@ final class FLBuilderAJAXLayout {
240
  *
241
  * @since 1.7
242
  * @param string $node_id The ID of a module to copy.
 
243
  * @return array
244
  */
245
- static public function copy_module( $node_id ) {
246
- $module = FLBuilderModel::copy_module( $node_id );
247
 
248
  return self::render( $module->node );
249
  }
@@ -531,7 +554,30 @@ final class FLBuilderAJAXLayout {
531
  global $wp_scripts;
532
  global $wp_styles;
533
 
534
- $scripts_styles = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
 
536
  // Start the output buffer.
537
  ob_start();
87
  }
88
 
89
  // Return the response.
90
+ return array(
91
+ 'layout' => self::render( $row->node ),
92
+ 'config' => FLBuilderUISettingsForms::get_node_js_config(),
93
+ );
94
  } // End if().
95
  else {
96
 
121
  *
122
  * @since 1.7
123
  * @param string $node_id The ID of a row to copy.
124
+ * @param object $settings These settings will be used for the copy if present.
125
+ * @param string $settings_id The ID of the node who's settings were passed.
126
  * @return array
127
  */
128
+ static public function copy_row( $node_id, $settings = null, $settings_id = null ) {
129
+ $row = FLBuilderModel::copy_row( $node_id, $settings, $settings_id );
130
 
131
  return self::render( $row->node );
132
  }
180
  return self::render( $group->node );
181
  }
182
 
183
+ /**
184
+ * Renders the layout data for a copied column.
185
+ *
186
+ * @since 2.0
187
+ * @param string $node_id The ID of a column to copy.
188
+ * @param object $settings These settings will be used for the copy if present.
189
+ * @param string $settings_id The ID of the node who's settings were passed.
190
+ * @return array
191
+ */
192
+ static public function copy_col( $node_id, $settings = null, $settings_id = null ) {
193
+ $col = FLBuilderModel::copy_col( $node_id, $settings, $settings_id );
194
+
195
+ return self::render( $col->node );
196
+ }
197
+
198
  /**
199
  * Renders the layout data for a new module.
200
  *
223
  $module = FLBuilderModel::add_default_module( $parent_id, $type, $position, $defaults );
224
  }
225
 
 
 
 
226
  // Maybe render the module's parent for a partial refresh?
227
  if ( $module->partial_refresh ) {
228
 
247
 
248
  // Return the response.
249
  return array(
250
+ 'type' => $module->settings->type,
251
+ 'nodeId' => $module->node,
252
+ 'parentId' => $module->parent,
253
+ 'global' => FLBuilderModel::is_node_global( $module ),
254
+ 'layout' => self::render( $render_id ),
255
+ 'settings' => null === $template_id ? null : $module->settings,
256
+ 'legacy' => FLBuilderUISettingsForms::pre_render_legacy_module_settings( $module->settings->type, $module->settings ),
257
  );
258
  }
259
 
262
  *
263
  * @since 1.7
264
  * @param string $node_id The ID of a module to copy.
265
+ * @param object $settings These settings will be used for the copy if present.
266
  * @return array
267
  */
268
+ static public function copy_module( $node_id, $settings = null ) {
269
+ $module = FLBuilderModel::copy_module( $node_id, $settings );
270
 
271
  return self::render( $module->node );
272
  }
554
  global $wp_scripts;
555
  global $wp_styles;
556
 
557
+ $partial_refresh_data = self::get_partial_refresh_data();
558
+ $modules = array();
559
+ $scripts_styles = '';
560
+
561
+ // Enqueue module font styles.
562
+ if ( ! $partial_refresh_data['is_partial_refresh'] ) {
563
+ $modules = FLBuilderModel::get_all_modules();
564
+ } elseif ( 'module' !== $partial_refresh_data['node']->type ) {
565
+ $nodes = FLBuilderModel::get_nested_nodes( $partial_refresh_data['node'] );
566
+ foreach ( $nodes as $node ) {
567
+ if ( 'module' === $node->type && isset( FLBuilderModel::$modules[ $node->settings->type ] ) ) {
568
+ $node->form = FLBuilderModel::$modules[ $node->settings->type ]->form;
569
+ $modules[] = $node;
570
+ }
571
+ }
572
+ } else {
573
+ $modules = array( $partial_refresh_data['node'] );
574
+ }
575
+
576
+ foreach ( $modules as $module ) {
577
+ FLBuilderFonts::add_fonts_for_module( $module );
578
+ }
579
+
580
+ FLBuilderFonts::enqueue_styles();
581
 
582
  // Start the output buffer.
583
  ob_start();
classes/class-fl-builder-ajax.php CHANGED
@@ -80,15 +80,6 @@ final class FLBuilderAJAX {
80
  * @return void
81
  */
82
  static private function add_actions() {
83
- // FLBuilder
84
- self::add_action( 'render_settings_form', 'FLBuilder::render_settings_form', array( 'type', 'settings' ) );
85
- self::add_action( 'render_row_settings', 'FLBuilder::render_row_settings', array( 'node_id' ) );
86
- self::add_action( 'render_column_settings', 'FLBuilder::render_column_settings', array( 'node_id' ) );
87
- self::add_action( 'render_module_settings', 'FLBuilder::render_module_settings', array( 'node_id', 'type', 'parent_id' ) );
88
- self::add_action( 'render_layout_settings', 'FLBuilder::render_layout_settings' );
89
- self::add_action( 'render_global_settings', 'FLBuilder::render_global_settings' );
90
- self::add_action( 'render_template_selector', 'FLBuilder::render_template_selector' );
91
- self::add_action( 'render_icon_selector', 'FLBuilder::render_icon_selector' );
92
 
93
  // FLBuilderModel
94
  self::add_action( 'delete_node', 'FLBuilderModel::delete_node', array( 'node_id' ) );
@@ -99,6 +90,7 @@ final class FLBuilderAJAX {
99
  self::add_action( 'move_col', 'FLBuilderModel::move_col', array( 'node_id', 'new_parent', 'position', 'resize' ) );
100
  self::add_action( 'resize_cols', 'FLBuilderModel::resize_cols', array( 'col_id', 'col_width', 'sibling_id', 'sibling_width' ) );
101
  self::add_action( 'reset_col_widths', 'FLBuilderModel::reset_col_widths', array( 'group_id' ) );
 
102
  self::add_action( 'save_settings', 'FLBuilderModel::save_settings', array( 'node_id', 'settings' ) );
103
  self::add_action( 'save_layout_settings', 'FLBuilderModel::save_layout_settings', array( 'settings' ) );
104
  self::add_action( 'save_global_settings', 'FLBuilderModel::save_global_settings', array( 'settings' ) );
@@ -111,15 +103,28 @@ final class FLBuilderAJAX {
111
  self::add_action( 'save_draft', 'FLBuilderModel::save_draft' );
112
  self::add_action( 'clear_draft_layout', 'FLBuilderModel::clear_draft_layout' );
113
  self::add_action( 'disable_builder', 'FLBuilderModel::disable' );
 
114
 
115
  // FLBuilderAJAXLayout
116
  self::add_action( 'render_layout', 'FLBuilderAJAXLayout::render' );
 
117
  self::add_action( 'render_new_row', 'FLBuilderAJAXLayout::render_new_row', array( 'cols', 'position', 'template_id', 'template_type' ) );
118
- self::add_action( 'copy_row', 'FLBuilderAJAXLayout::copy_row', array( 'node_id' ) );
119
  self::add_action( 'render_new_column_group', 'FLBuilderAJAXLayout::render_new_column_group', array( 'node_id', 'cols', 'position' ) );
120
  self::add_action( 'render_new_columns', 'FLBuilderAJAXLayout::render_new_columns', array( 'node_id', 'insert', 'type', 'nested' ) );
 
121
  self::add_action( 'render_new_module', 'FLBuilderAJAXLayout::render_new_module', array( 'parent_id', 'position', 'type', 'alias', 'template_id', 'template_type' ) );
122
- self::add_action( 'copy_module', 'FLBuilderAJAXLayout::copy_module', array( 'node_id' ) );
 
 
 
 
 
 
 
 
 
 
123
 
124
  // FLBuilderServices
125
  self::add_action( 'render_service_settings', 'FLBuilderServices::render_settings' );
@@ -130,6 +135,7 @@ final class FLBuilderAJAX {
130
 
131
  // FLBuilderAutoSuggest
132
  self::add_action( 'fl_builder_autosuggest', 'FLBuilderAutoSuggest::init' );
 
133
  }
134
 
135
  /**
80
  * @return void
81
  */
82
  static private function add_actions() {
 
 
 
 
 
 
 
 
 
83
 
84
  // FLBuilderModel
85
  self::add_action( 'delete_node', 'FLBuilderModel::delete_node', array( 'node_id' ) );
90
  self::add_action( 'move_col', 'FLBuilderModel::move_col', array( 'node_id', 'new_parent', 'position', 'resize' ) );
91
  self::add_action( 'resize_cols', 'FLBuilderModel::resize_cols', array( 'col_id', 'col_width', 'sibling_id', 'sibling_width' ) );
92
  self::add_action( 'reset_col_widths', 'FLBuilderModel::reset_col_widths', array( 'group_id' ) );
93
+ self::add_action( 'resize_row_content', 'FLBuilderModel::resize_row_content', array( 'node', 'width' ) );
94
  self::add_action( 'save_settings', 'FLBuilderModel::save_settings', array( 'node_id', 'settings' ) );
95
  self::add_action( 'save_layout_settings', 'FLBuilderModel::save_layout_settings', array( 'settings' ) );
96
  self::add_action( 'save_global_settings', 'FLBuilderModel::save_global_settings', array( 'settings' ) );
103
  self::add_action( 'save_draft', 'FLBuilderModel::save_draft' );
104
  self::add_action( 'clear_draft_layout', 'FLBuilderModel::clear_draft_layout' );
105
  self::add_action( 'disable_builder', 'FLBuilderModel::disable' );
106
+ self::add_action( 'clear_cache', 'FLBuilderModel::delete_all_asset_cache' );
107
 
108
  // FLBuilderAJAXLayout
109
  self::add_action( 'render_layout', 'FLBuilderAJAXLayout::render' );
110
+ self::add_action( 'render_node', 'FLBuilderAJAXLayout::render', array( 'node_id' ) );
111
  self::add_action( 'render_new_row', 'FLBuilderAJAXLayout::render_new_row', array( 'cols', 'position', 'template_id', 'template_type' ) );
112
+ self::add_action( 'copy_row', 'FLBuilderAJAXLayout::copy_row', array( 'node_id', 'settings', 'settings_id' ) );
113
  self::add_action( 'render_new_column_group', 'FLBuilderAJAXLayout::render_new_column_group', array( 'node_id', 'cols', 'position' ) );
114
  self::add_action( 'render_new_columns', 'FLBuilderAJAXLayout::render_new_columns', array( 'node_id', 'insert', 'type', 'nested' ) );
115
+ self::add_action( 'copy_col', 'FLBuilderAJAXLayout::copy_col', array( 'node_id', 'settings', 'settings_id' ) );
116
  self::add_action( 'render_new_module', 'FLBuilderAJAXLayout::render_new_module', array( 'parent_id', 'position', 'type', 'alias', 'template_id', 'template_type' ) );
117
+ self::add_action( 'copy_module', 'FLBuilderAJAXLayout::copy_module', array( 'node_id', 'settings' ) );
118
+
119
+ // FLBuilderUISettingsForms
120
+ self::add_action( 'render_legacy_settings', 'FLBuilderUISettingsForms::render_legacy_settings', array( 'data', 'form', 'group', 'lightbox' ) );
121
+ self::add_action( 'render_settings_form', 'FLBuilderUISettingsForms::render_settings_form', array( 'type', 'settings' ) );
122
+ self::add_action( 'render_icon_selector', 'FLBuilderUISettingsForms::render_icon_selector' );
123
+
124
+ // FLBuilderRevisions
125
+ self::add_action( 'render_revision_preview', 'FLBuilderRevisions::render_preview', array( 'revision_id' ) );
126
+ self::add_action( 'restore_revision', 'FLBuilderRevisions::restore', array( 'revision_id' ) );
127
+ self::add_action( 'refresh_revision_items', 'FLBuilderRevisions::get_config', array( 'post_id' ) );
128
 
129
  // FLBuilderServices
130
  self::add_action( 'render_service_settings', 'FLBuilderServices::render_settings' );
135
 
136
  // FLBuilderAutoSuggest
137
  self::add_action( 'fl_builder_autosuggest', 'FLBuilderAutoSuggest::init' );
138
+ self::add_action( 'get_autosuggest_values', 'FLBuilderAutoSuggest::get_values', array( 'fields' ) );
139
  }
140
 
141
  /**
classes/class-fl-builder-auto-suggest.php CHANGED
@@ -78,6 +78,23 @@ final class FLBuilderAutoSuggest {
78
  return isset( $data ) ? str_replace( "'", '&#39;', json_encode( $data ) ) : '';
79
  }
80
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
  /**
82
  * Returns the SQL escaped like value for auto suggest queries.
83
  *
78
  return isset( $data ) ? str_replace( "'", '&#39;', json_encode( $data ) ) : '';
79
  }
80
 
81
+ /**
82
+ * Returns the values for all suggest fields in a settings form.
83
+ *
84
+ * @since 2.0
85
+ * @param array $fields
86
+ * @return array
87
+ */
88
+ static public function get_values( $fields ) {
89
+ $values = array();
90
+
91
+ foreach ( $fields as $field ) {
92
+ $values[ $field['name'] ] = self::get_value( $field['action'], $field['value'], $field['data'] );
93
+ }
94
+
95
+ return $values;
96
+ }
97
+
98
  /**
99
  * Returns the SQL escaped like value for auto suggest queries.
100
  *
classes/class-fl-builder-fonts.php CHANGED
@@ -47,17 +47,17 @@ final class FLBuilderFonts {
47
  $system_fonts = apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system );
48
  $google_fonts = apply_filters( 'fl_builder_font_families_google', FLBuilderFontFamilies::google() );
49
 
50
- echo '<option value="Default" ' . selected( 'Default', $font ) . '>' . __( 'Default', 'fl-builder' ) . '</option>';
51
  echo '<optgroup label="System">';
52
 
53
  foreach ( $system_fonts as $name => $variants ) {
54
- echo '<option value="' . $name . '" ' . selected( $name, $font ) . '>' . $name . '</option>';
55
  }
56
 
57
  echo '<optgroup label="Google">';
58
 
59
  foreach ( $google_fonts as $name => $variants ) {
60
- echo '<option value="' . $name . '" ' . selected( $name, $font ) . '>' . $name . '</option>';
61
  }
62
  }
63
 
@@ -71,19 +71,18 @@ final class FLBuilderFonts {
71
  */
72
  static public function display_select_weight( $font, $weight ) {
73
  if ( 'Default' == $font ) {
74
- echo '<option value="default">' . __( 'Default', 'fl-builder' ) . '</option>';
75
  } else {
76
  $system_fonts = apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system );
77
  $google_fonts = apply_filters( 'fl_builder_font_families_google', FLBuilderFontFamilies::google() );
78
 
79
  if ( array_key_exists( $font, $system_fonts ) ) {
80
  foreach ( $system_fonts[ $font ]['weights'] as $variant ) {
81
- echo '<option value="' . $variant . '" ' . selected( $variant, $weight ) . '>' . FLBuilderFonts::get_weight_string( $variant ) . '</option>';
82
  }
83
  } else {
84
  foreach ( $google_fonts[ $font ] as $variant ) {
85
-
86
- echo '<option value="' . $variant . '" ' . selected( $variant, $weight ) . '>' . FLBuilderFonts::get_weight_string( $variant ) . '</option>';
87
  }
88
  }
89
  }
@@ -459,5 +458,4 @@ final class FLBuilderFontFamilies {
459
  ),
460
  ),
461
  );
462
-
463
  }
47
  $system_fonts = apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system );
48
  $google_fonts = apply_filters( 'fl_builder_font_families_google', FLBuilderFontFamilies::google() );
49
 
50
+ echo '<option value="Default" ' . selected( 'Default', $font, false ) . '>' . __( 'Default', 'fl-builder' ) . '</option>';
51
  echo '<optgroup label="System">';
52
 
53
  foreach ( $system_fonts as $name => $variants ) {
54
+ echo '<option value="' . $name . '" ' . selected( $name, $font, false ) . '>' . $name . '</option>';
55
  }
56
 
57
  echo '<optgroup label="Google">';
58
 
59
  foreach ( $google_fonts as $name => $variants ) {
60
+ echo '<option value="' . $name . '" ' . selected( $name, $font, false ) . '>' . $name . '</option>';
61
  }
62
  }
63
 
71
  */
72
  static public function display_select_weight( $font, $weight ) {
73
  if ( 'Default' == $font ) {
74
+ echo '<option value="default" selected="selected">' . __( 'Default', 'fl-builder' ) . '</option>';
75
  } else {
76
  $system_fonts = apply_filters( 'fl_builder_font_families_system', FLBuilderFontFamilies::$system );
77
  $google_fonts = apply_filters( 'fl_builder_font_families_google', FLBuilderFontFamilies::google() );
78
 
79
  if ( array_key_exists( $font, $system_fonts ) ) {
80
  foreach ( $system_fonts[ $font ]['weights'] as $variant ) {
81
+ echo '<option value="' . $variant . '" ' . selected( $variant, $weight, false ) . '>' . FLBuilderFonts::get_weight_string( $variant ) . '</option>';
82
  }
83
  } else {
84
  foreach ( $google_fonts[ $font ] as $variant ) {
85
+ echo '<option value="' . $variant . '" ' . selected( $variant, $weight, false ) . '>' . FLBuilderFonts::get_weight_string( $variant ) . '</option>';
 
86
  }
87
  }
88
  }
458
  ),
459
  ),
460
  );
 
461
  }
classes/class-fl-builder-icons.php CHANGED
@@ -24,19 +24,21 @@ final class FLBuilderIcons {
24
  * @return array An array of data for each icon set.
25
  */
26
  static public function get_sets() {
 
27
  // Return the sets if already registered.
28
  if ( self::$sets ) {
29
  return self::$sets;
30
  }
31
-
32
  // Check to see if we should pull sets from the main site.
33
  if ( is_multisite() ) {
34
 
35
- $blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
36
  $enabled_icons = get_option( '_fl_builder_enabled_icons' );
37
 
38
- if ( empty( $enabled_icons ) ) {
39
- switch_to_blog( $blog_id );
 
40
  }
41
  }
42
 
@@ -45,7 +47,7 @@ final class FLBuilderIcons {
45
  self::register_core_sets();
46
 
47
  // Revert to the current site if we pulled from the main site.
48
- if ( is_multisite() && empty( $enabled_icons ) ) {
49
  restore_current_blog();
50
  }
51
 
24
  * @return array An array of data for each icon set.
25
  */
26
  static public function get_sets() {
27
+ $switched = false;
28
  // Return the sets if already registered.
29
  if ( self::$sets ) {
30
  return self::$sets;
31
  }
32
+ global $blog_id;
33
  // Check to see if we should pull sets from the main site.
34
  if ( is_multisite() ) {
35
 
36
+ $id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
37
  $enabled_icons = get_option( '_fl_builder_enabled_icons' );
38
 
39
+ if ( ( $id != $blog_id ) || empty( $enabled_icons ) ) {
40
+ switch_to_blog( $id );
41
+ $switched = true;
42
  }
43
  }
44
 
47
  self::register_core_sets();
48
 
49
  // Revert to the current site if we pulled from the main site.
50
+ if ( is_multisite() && $switched ) {
51
  restore_current_blog();
52
  }
53
 
classes/class-fl-builder-loader.php CHANGED
@@ -43,7 +43,7 @@ if ( ! class_exists( 'FLBuilderLoader' ) ) {
43
  * @return void
44
  */
45
  static private function define_constants() {
46
- define( 'FL_BUILDER_VERSION', '1.11' );
47
  define( 'FL_BUILDER_FILE', trailingslashit( dirname( dirname( __FILE__ ) ) ) . 'fl-builder.php' );
48
  define( 'FL_BUILDER_DIR', plugin_dir_path( FL_BUILDER_FILE ) );
49
  define( 'FL_BUILDER_URL', plugins_url( '/', FL_BUILDER_FILE ) );
@@ -82,11 +82,15 @@ if ( ! class_exists( 'FLBuilderLoader' ) ) {
82
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-model.php';
83
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-module.php';
84
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-photo.php';
 
85
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-services.php';
86
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-shortcodes.php';
87
- require_once FL_BUILDER_DIR . 'classes/class-fl-builder-update.php';
88
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-timezones.php';
 
 
 
89
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-user-access.php';
 
90
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-utils.php';
91
 
92
  /* WP CLI Commands */
43
  * @return void
44
  */
45
  static private function define_constants() {
46
+ define( 'FL_BUILDER_VERSION', '2.0.3.2' );
47
  define( 'FL_BUILDER_FILE', trailingslashit( dirname( dirname( __FILE__ ) ) ) . 'fl-builder.php' );
48
  define( 'FL_BUILDER_DIR', plugin_dir_path( FL_BUILDER_FILE ) );
49
  define( 'FL_BUILDER_URL', plugins_url( '/', FL_BUILDER_FILE ) );
82
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-model.php';
83
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-module.php';
84
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-photo.php';
85
+ require_once FL_BUILDER_DIR . 'classes/class-fl-builder-revisions.php';
86
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-services.php';
87
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-shortcodes.php';
 
88
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-timezones.php';
89
+ require_once FL_BUILDER_DIR . 'classes/class-fl-builder-ui-content-panel.php';
90
+ require_once FL_BUILDER_DIR . 'classes/class-fl-builder-ui-settings-forms.php';
91
+ require_once FL_BUILDER_DIR . 'classes/class-fl-builder-update.php';
92
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-user-access.php';
93
+ require_once FL_BUILDER_DIR . 'classes/class-fl-builder-user-settings.php';
94
  require_once FL_BUILDER_DIR . 'classes/class-fl-builder-utils.php';
95
 
96
  /* WP CLI Commands */
classes/class-fl-builder-loop.php CHANGED
@@ -85,6 +85,7 @@ final class FLBuilderLoop {
85
  */
86
  static public function query( $settings ) {
87
  $settings = apply_filters( 'fl_builder_loop_before_query_settings', $settings );
 
88
  do_action( 'fl_builder_loop_before_query', $settings );
89
 
90
  // Count how many times this method has been called
@@ -164,19 +165,20 @@ final class FLBuilderLoop {
164
 
165
  // Build the query args.
166
  $args = apply_filters( 'fl_builder_loop_query_args', array(
167
- 'paged' => $paged,
168
- 'posts_per_page' => $posts_per_page,
169
- 'post_type' => $post_type,
170
- 'orderby' => $order_by,
171
- 'order' => $order,
172
- 'tax_query' => array(
173
  'relation' => 'AND',
174
  ),
175
- 'ignore_sticky_posts' => true,
176
- 'offset' => $paged_offset,
177
- 'fl_original_offset' => $offset,
178
- 'fl_builder_loop' => true,
179
- 'fields' => $fields,
 
180
  ) );
181
 
182
  // Order by meta value arg.
@@ -207,33 +209,72 @@ final class FLBuilderLoop {
207
  foreach ( $taxonomies as $tax_slug => $tax ) {
208
 
209
  $tax_value = '';
 
210
  $operator = 'IN';
211
 
212
- // Set to NOT IN if matching is present and set to 0.
213
- if ( isset( $settings->{'tax_' . $post_type . '_' . $tax_slug . '_matching'} ) ) {
214
- if ( ! $settings->{'tax_' . $post_type . '_' . $tax_slug . '_matching'} ) {
215
- $operator = 'NOT IN';
216
- }
217
- }
218
-
219
- // New settings slug.
220
  if ( isset( $settings->{'tax_' . $post_type . '_' . $tax_slug} ) ) {
 
221
  $tax_value = $settings->{'tax_' . $post_type . '_' . $tax_slug};
222
- } // End if().
223
- elseif ( isset( $settings->{'tax_' . $tax_slug} ) ) {
224
  $tax_value = $settings->{'tax_' . $tax_slug};
225
  }
226
 
 
227
  if ( ! empty( $tax_value ) ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
228
 
229
  $args['tax_query'][] = array(
230
  'taxonomy' => $tax_slug,
231
  'field' => 'id',
232
- 'terms' => explode( ',', $tax_value ),
233
  'operator' => $operator,
234
  );
235
  }
236
- }
237
 
238
  // Post in/not in query.
239
  if ( isset( $settings->{'posts_' . $post_type} ) ) {
@@ -960,6 +1001,8 @@ final class FLBuilderLoop {
960
  return;
961
  }
962
 
 
 
963
  if ( ! isset( $settings->{ $name . '_matching' } ) ) {
964
  $settings->{ $name . '_matching' } = '1';
965
  }
85
  */
86
  static public function query( $settings ) {
87
  $settings = apply_filters( 'fl_builder_loop_before_query_settings', $settings );
88
+
89
  do_action( 'fl_builder_loop_before_query', $settings );
90
 
91
  // Count how many times this method has been called
165
 
166
  // Build the query args.
167
  $args = apply_filters( 'fl_builder_loop_query_args', array(
168
+ 'paged' => $paged,
169
+ 'posts_per_page' => $posts_per_page,
170
+ 'post_type' => $post_type,
171
+ 'orderby' => $order_by,
172
+ 'order' => $order,
173
+ 'tax_query' => array(
174
  'relation' => 'AND',
175
  ),
176
+ 'ignore_sticky_posts' => true,
177
+ 'offset' => $paged_offset,
178
+ 'fl_original_offset' => $offset,
179
+ 'fl_builder_loop' => true,
180
+ 'fields' => $fields,
181
+ 'settings' => $settings,
182
  ) );
183
 
184
  // Order by meta value arg.
209
  foreach ( $taxonomies as $tax_slug => $tax ) {
210
 
211
  $tax_value = '';
212
+ $term_ids = array();
213
  $operator = 'IN';
214
 
215
+ // Get the value of the suggest field.
 
 
 
 
 
 
 
216
  if ( isset( $settings->{'tax_' . $post_type . '_' . $tax_slug} ) ) {
217
+ // New style slug.
218
  $tax_value = $settings->{'tax_' . $post_type . '_' . $tax_slug};
219
+ } elseif ( isset( $settings->{'tax_' . $tax_slug} ) ) {
220
+ // Old style slug for backwards compat.
221
  $tax_value = $settings->{'tax_' . $tax_slug};
222
  }
223
 
224
+ // Get the term IDs array.
225
  if ( ! empty( $tax_value ) ) {
226
+ $term_ids = explode( ',', $tax_value );
227
+ }
228
+
229
+ // Handle matching settings.
230
+ if ( isset( $settings->{'tax_' . $post_type . '_' . $tax_slug . '_matching'} ) ) {
231
+
232
+ $tax_matching = $settings->{'tax_' . $post_type . '_' . $tax_slug . '_matching'};
233
+
234
+ if ( ! $tax_matching ) {
235
+ // Do not match these terms.
236
+ $operator = 'NOT IN';
237
+ } elseif ( 'related' === $tax_matching ) {
238
+ // Match posts by related terms from the global post.
239
+ global $post;
240
+ $terms = wp_get_post_terms( $post->ID, $tax_slug );
241
+ $related = array();
242
+
243
+ foreach ( $terms as $term ) {
244
+ if ( ! in_array( $term->term_id, $term_ids ) ) {
245
+ $related[] = $term->term_id;
246
+ }
247
+ }
248
+
249
+ if ( empty( $related ) ) {
250
+ // If no related terms, match all except those in the suggest field.
251
+ $operator = 'NOT IN';
252
+ } else {
253
+
254
+ // Don't include posts with terms selected in the suggest field.
255
+ $args['tax_query'][] = array(
256
+ 'taxonomy' => $tax_slug,
257
+ 'field' => 'id',
258
+ 'terms' => $term_ids,
259
+ 'operator' => 'NOT IN',
260
+ );
261
+
262
+ // Set the term IDs to the related terms.
263
+ $term_ids = $related;
264
+ }
265
+ }
266
+ }// End if().
267
+
268
+ if ( ! empty( $term_ids ) ) {
269
 
270
  $args['tax_query'][] = array(
271
  'taxonomy' => $tax_slug,
272
  'field' => 'id',
273
+ 'terms' => $term_ids,
274
  'operator' => $operator,
275
  );
276
  }
277
+ }// End foreach().
278
 
279
  // Post in/not in query.
280
  if ( isset( $settings->{'posts_' . $post_type} ) ) {
1001
  return;
1002
  }
1003
 
1004
+ $label = FLBuilderUtils::strtolower( $field['label'] );
1005
+
1006
  if ( ! isset( $settings->{ $name . '_matching' } ) ) {
1007
  $settings->{ $name . '_matching' } = '1';
1008
  }
classes/class-fl-builder-model.php CHANGED
@@ -188,6 +188,7 @@ final class FLBuilderModel {
188
 
189
  /* Filters */
190
  add_filter( 'heartbeat_received', __CLASS__ . '::lock_post', 10, 2 );
 
191
 
192
  /* Core Templates */
193
  self::register_core_templates();
@@ -263,7 +264,7 @@ final class FLBuilderModel {
263
  $_POST['fl_builder_data']['node_settings'] = FLBuilderUtils::modsec_fix_decode( $_POST['fl_builder_data']['node_settings'] );
264
  }
265
 
266
- $data = FLBuilderUtils::json_decode_deep( wp_unslash( $_POST['fl_builder_data'] ) );
267
 
268
  foreach ( $data as $key => $val ) {
269
  self::$post_data[ $key ] = $val;
@@ -354,30 +355,39 @@ final class FLBuilderModel {
354
  * is being displayed or worked on.
355
  *
356
  * @since 1.0
 
357
  * @return int|bool The post id or false.
358
  */
359
- static public function get_post_id() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
  global $wp_the_query;
361
  global $post;
362
 
363
- $post_data = self::get_post_data();
364
-
365
- // Get a post ID from the internal $post_id array if not empty.
366
- if ( ! empty( self::$post_id ) ) {
367
- return self::$post_id[0];
368
- } // End if().
369
- elseif ( isset( $post_data['post_id'] ) ) {
370
- return $post_data['post_id'];
371
- } // Get a post ID from the main query.
372
- elseif ( in_the_loop() && is_main_query() && isset( $wp_the_query->post ) ) {
373
  return $wp_the_query->post->ID;
374
- } // Get a post ID in a query outside of the main loop.
375
- elseif ( isset( $post ) ) {
376
  return $post->ID;
377
- } // No post ID found.
378
- else {
379
- return false;
380
  }
 
 
 
381
  }
382
 
383
  /**
@@ -456,17 +466,20 @@ final class FLBuilderModel {
456
  * for the current post.
457
  *
458
  * @since 1.0
 
459
  * @return bool
460
  */
461
- static public function is_builder_enabled() {
462
- $post_id = self::get_post_id();
 
 
 
463
 
464
  if ( ! is_admin() && post_password_required( $post_id ) ) {
465
  return false;
466
- } elseif ( self::is_builder_active() ) {
467
  return true;
468
  } else {
469
-
470
  $post_types = self::get_post_types();
471
  $post = get_post( $post_id );
472
 
@@ -496,6 +509,8 @@ final class FLBuilderModel {
496
  return self::$active;
497
  } elseif ( ! is_admin() && is_singular() && $query_id != $post_id ) {
498
  self::$active = false;
 
 
499
  } elseif ( self::is_post_editable() && ! is_admin() && ! post_password_required() ) {
500
  $post_data = self::get_post_data();
501
  self::$active = isset( $_GET['fl_builder'] ) || isset( $post_data['fl_builder'] );
@@ -580,11 +595,10 @@ final class FLBuilderModel {
580
  $cols = self::get_nodes( 'column' );
581
  $col = array_shift( $cols );
582
  $settings = self::get_module_defaults( 'rich-text' );
583
- $settings->text = wpautop( $post->post_content );
584
 
585
  self::add_module( 'rich-text', $settings, $col->node );
586
- } // End if().
587
- elseif ( empty( $draft ) ) {
588
  self::update_layout_data( $published, 'draft', $post->ID );
589
  self::update_layout_settings( self::get_layout_settings( 'published' ), 'draft', $post->ID );
590
  }
@@ -922,8 +936,7 @@ final class FLBuilderModel {
922
  // Return all nodes?
923
  if ( ! $type ) {
924
  $nodes = $data;
925
- } // End if().
926
- else {
927
 
928
  foreach ( $data as $node_id => $node ) {
929
 
@@ -1083,15 +1096,18 @@ final class FLBuilderModel {
1083
  * @return array
1084
  */
1085
  static public function get_child_nodes( $parent_id, $status = null ) {
1086
- $parent = is_object( $parent_id ) ? $parent_id : self::get_node( $parent_id );
1087
- $template_post_id = self::is_node_global( $parent );
1088
- $status = $template_post_id && ! self::is_post_node_template() ? 'published' : $status;
1089
- $data = self::get_layout_data( $status, $template_post_id );
1090
- $nodes = array();
1091
 
1092
- foreach ( $data as $node_id => $node ) {
1093
- if ( $node->parent == $parent->node || ( $template_post_id && $parent->template_node_id == $node->parent ) ) {
1094
- $nodes[ $node_id ] = $node;
 
 
 
1095
  }
1096
  }
1097
 
@@ -1251,14 +1267,18 @@ final class FLBuilderModel {
1251
  * @return object
1252
  */
1253
  static public function process_node_settings( $node, $new_settings ) {
 
1254
  if ( 'row' == $node->type ) {
1255
  $new_settings = self::process_row_settings( $node, $new_settings );
 
1256
  }
1257
  if ( 'column' == $node->type ) {
1258
  $new_settings = self::process_col_settings( $node, $new_settings );
 
1259
  }
1260
  if ( 'module' == $node->type ) {
1261
  $new_settings = self::process_module_settings( $node, $new_settings );
 
1262
  }
1263
 
1264
  return $new_settings;
@@ -1534,9 +1554,11 @@ final class FLBuilderModel {
1534
  *
1535
  * @since 1.0
1536
  * @param string $node_id Node ID of the row to copy.
 
 
1537
  * @return void
1538
  */
1539
- static public function copy_row( $node_id = null ) {
1540
  $layout_data = self::get_layout_data();
1541
  $row = self::get_node( $node_id );
1542
  $new_row_id = self::generate_node_id();
@@ -1593,6 +1615,15 @@ final class FLBuilderModel {
1593
  }
1594
  }// End foreach().
1595
 
 
 
 
 
 
 
 
 
 
1596
  // Generate new child ids.
1597
  $new_nodes = self::generate_new_node_ids( $new_nodes );
1598
 
@@ -1718,7 +1749,7 @@ final class FLBuilderModel {
1718
  }
1719
 
1720
  // Cache background slideshow data.
1721
- if ( 'slideshow' == $new_settings->bg_type && 'wordpress' == $new_settings->ss_source ) {
1722
 
1723
  // Make sure we have a photo data object.
1724
  if ( ! isset( $row->settings->ss_photo_data ) ) {
@@ -1761,8 +1792,7 @@ final class FLBuilderModel {
1761
 
1762
  $data['webm'] = $row->settings->bg_video_webm_data;
1763
  }
1764
- } // End if().
1765
- elseif ( 'slideshow' == $row->settings->bg_type && isset( $row->settings->ss_photo_data ) ) {
1766
  $data = $row->settings->ss_photo_data;
1767
  }
1768
 
@@ -1794,6 +1824,22 @@ final class FLBuilderModel {
1794
  return $ss->get_source();
1795
  }
1796
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1797
  /**
1798
  * Adds a column group to a row in the current layout.
1799
  *
@@ -1842,8 +1888,7 @@ final class FLBuilderModel {
1842
  $data[ $col_node_id ]->template_node_id = $col_node_id;
1843
  }
1844
  }
1845
- } // End if().
1846
- else {
1847
 
1848
  $old_group = $data[ $cols ]->parent;
1849
  $siblings = self::get_nodes( 'column', $old_group );
@@ -1867,7 +1912,7 @@ final class FLBuilderModel {
1867
  $data[ $sibling->node ]->position = $sibling_pos;
1868
  $sibling_pos++;
1869
  }
1870
- }
1871
 
1872
  // Update the layout data.
1873
  self::update_layout_data( $data );
@@ -1982,8 +2027,7 @@ final class FLBuilderModel {
1982
  // Delete the group if empty.
1983
  if ( count( $cols ) === 0 ) {
1984
  self::delete_node( $group->node );
1985
- } // End if().
1986
- else {
1987
 
1988
  // Get the layout data.
1989
  $data = self::get_layout_data();
@@ -2297,6 +2341,98 @@ final class FLBuilderModel {
2297
  return $parent;
2298
  }
2299
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2300
  /**
2301
  * Returns the default settings for column nodes.
2302
  *
@@ -2318,7 +2454,7 @@ final class FLBuilderModel {
2318
  $dir = dir( $path );
2319
  $module_path = '';
2320
 
2321
- while ( false !== ($entry = $dir->read()) ) { // @codingStandardsIgnoreLine
2322
 
2323
  if ( ! is_dir( $path . $entry ) || '.' == $entry || '..' == $entry ) {
2324
  continue;
@@ -2333,14 +2469,14 @@ final class FLBuilderModel {
2333
  // Check for the module class in a child theme.
2334
  if ( is_child_theme() && file_exists( $child_path ) ) {
2335
  require_once $child_path;
2336
- } // End if().
2337
- elseif ( file_exists( $theme_path ) ) {
2338
  require_once $theme_path;
2339
- } // Check for the module class in the builder directory.
2340
- elseif ( file_exists( $builder_path ) ) {
2341
  require_once $builder_path;
2342
  }
2343
  }
 
 
2344
  }
2345
 
2346
  /**
@@ -2396,8 +2532,10 @@ final class FLBuilderModel {
2396
  $instance->name = isset( $config['name'] ) ? $config['name'] : $slug;
2397
  $instance->description = isset( $config['description'] ) ? $config['description'] : '';
2398
  $instance->category = isset( $config['category'] ) ? $config['category'] : null;
 
2399
  $instance->settings = isset( $config['settings'] ) ? $config['settings'] : array();
2400
  $instance->enabled = isset( $config['enabled'] ) ? $config['enabled'] : true;
 
2401
 
2402
  self::$module_aliases[ $alias ] = $instance;
2403
  }
@@ -2452,32 +2590,86 @@ final class FLBuilderModel {
2452
  }
2453
 
2454
  /**
2455
- * Returns an array of categorized modules.
2456
  *
2457
- * @since 1.0
2458
- * @param bool $show_disabled Whether to include disabled modules in the result.
2459
  * @return array
2460
  */
2461
- static public function get_categorized_modules( $show_disabled = false ) {
2462
- $enabled_modules = self::get_enabled_modules();
2463
- $widgets = null;
2464
- $categories = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2465
 
2466
  // Add any predefined custom categories.
2467
  foreach ( apply_filters( 'fl_builder_module_categories', array() ) as $custom_category ) {
2468
  $categories[ $custom_category ] = array();
2469
  }
2470
 
2471
- // Get the core category keys.
2472
- $basic_key = __( 'Basic Modules', 'fl-builder' );
2473
- $advanced_key = __( 'Advanced Modules', 'fl-builder' );
2474
- $other_key = __( 'Other Modules', 'fl-builder' );
2475
- $widgets_key = __( 'WordPress Widgets', 'fl-builder' );
2476
-
2477
  // Build the default category arrays.
2478
- $categories[ $basic_key ] = array();
2479
- $categories[ $advanced_key ] = array();
2480
- $categories[ $other_key ] = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2481
 
2482
  // Build the categories array.
2483
  foreach ( self::$modules as $module ) {
@@ -2532,33 +2724,96 @@ final class FLBuilderModel {
2532
  }
2533
 
2534
  /**
2535
- * Returns the slug for a module category.
2536
  *
2537
- * @since 1.0
2538
- * @param string $name The category name.
2539
- * @return string
2540
  */
2541
- static public function get_module_category_slug( $name ) {
2542
- // Get the core category keys.
2543
- $basic_key = __( 'Basic Modules', 'fl-builder' );
2544
- $advanced_key = __( 'Advanced Modules', 'fl-builder' );
2545
- $other_key = __( 'Other Modules', 'fl-builder' );
2546
- $widgets_key = __( 'WordPress Widgets', 'fl-builder' );
2547
 
2548
- if ( $name == $basic_key ) {
2549
- return 'basic';
2550
- }
2551
- if ( $name == $advanced_key ) {
2552
- return 'advanced';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2553
  }
2554
- if ( $name == $other_key ) {
2555
- return 'other';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2556
  }
2557
- if ( $name == $widgets_key ) {
2558
- return 'widgets';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2559
  }
2560
 
2561
- return sanitize_html_class( $name );
2562
  }
2563
 
2564
  /**
@@ -2581,6 +2836,7 @@ final class FLBuilderModel {
2581
  $instance->settings = $module->settings;
2582
  $instance->type = 'module';
2583
  $instance->form = self::$modules[ $module->settings->type ]->form;
 
2584
 
2585
  if ( isset( $module->template_id ) ) {
2586
  $instance->template_id = $module->template_id;
@@ -2621,6 +2877,7 @@ final class FLBuilderModel {
2621
  $instances[ $i ]->position = $module->position;
2622
  $instances[ $i ]->settings = $module->settings;
2623
  $instances[ $i ]->type = 'module';
 
2624
  $instances[ $i ]->form = self::$modules[ $module->settings->type ]->form;
2625
 
2626
  if ( isset( $module->template_id ) ) {
@@ -2672,16 +2929,16 @@ final class FLBuilderModel {
2672
  $settings = $instance->update( $settings );
2673
 
2674
  // Save the module.
2675
- $data[ $module_node_id ] = new StdClass();
2676
- $data[ $module_node_id ]->node = $module_node_id;
2677
- $data[ $module_node_id ]->type = 'module';
2678
- $data[ $module_node_id ]->parent = $parent_id;
2679
  $data[ $module_node_id ]->position = self::next_node_position( 'module', $parent_id );
2680
  $data[ $module_node_id ]->settings = $settings;
2681
 
2682
  // Add node template data.
2683
  if ( self::is_node_global( $parent ) ) {
2684
- $data[ $module_node_id ]->template_id = $parent->template_id;
2685
  $data[ $module_node_id ]->template_node_id = $module_node_id;
2686
  }
2687
 
@@ -2709,22 +2966,22 @@ final class FLBuilderModel {
2709
  static public function add_module_parent( $parent_id = null, $position = null ) {
2710
  $parent = ! $parent_id ? null : self::get_node( $parent_id );
2711
 
2712
- // Add a new row if we don't have a parent.
2713
  if ( ! $parent ) {
 
2714
  $row = self::add_row( '1-col', $position );
2715
  $col_groups = self::get_nodes( 'column-group', $row->node );
2716
  $col_group = array_shift( $col_groups );
2717
  $cols = self::get_nodes( 'column', $col_group->node );
2718
  $parent = array_shift( $cols );
2719
  $parent_id = $parent->node;
2720
- } // End if().
2721
- elseif ( 'row' == $parent->type ) {
2722
  $col_group = self::add_col_group( $parent->node, '1-col', $position );
2723
  $cols = self::get_nodes( 'column', $col_group->node );
2724
  $parent = array_shift( $cols );
2725
  $parent_id = $parent->node;
2726
- } // Add a new column if the parent is a column group.
2727
- elseif ( 'column-group' == $parent->type ) {
2728
  $parent = self::add_col( $parent->node, $position );
2729
  $parent_id = $parent->node;
2730
  }
@@ -2786,7 +3043,7 @@ final class FLBuilderModel {
2786
  * @return array $defaults Default settings for the module.
2787
  */
2788
  static public function add_default_module( $parent_id = null, $type = null, $position = null, $defaults = null ) {
2789
- $parent = 0 == $parent_id ? null : self::get_node( $parent_id );
2790
  $settings = self::get_module_defaults( $type );
2791
  $module_node_id = self::generate_node_id();
2792
 
@@ -2810,11 +3067,11 @@ final class FLBuilderModel {
2810
  $settings = $instance->update( $settings );
2811
 
2812
  // Save the module.
2813
- $data = self::get_layout_data();
2814
- $data[ $module_node_id ] = new StdClass();
2815
- $data[ $module_node_id ]->node = $module_node_id;
2816
- $data[ $module_node_id ]->type = 'module';
2817
- $data[ $module_node_id ]->parent = $parent_id;
2818
  $data[ $module_node_id ]->position = self::next_node_position( 'module', $parent_id );
2819
  $data[ $module_node_id ]->settings = $settings;
2820
 
@@ -2841,11 +3098,16 @@ final class FLBuilderModel {
2841
  *
2842
  * @since 1.0
2843
  * @param string $node_id Node ID of the module to copy.
 
2844
  * @return object The new module object.
2845
  */
2846
- static public function copy_module( $node_id = null ) {
2847
  $module = self::get_module( $node_id );
2848
 
 
 
 
 
2849
  return self::add_module( $module->settings->type, $module->settings, $module->parent, $module->position + 1 );
2850
  }
2851
 
@@ -2893,18 +3155,31 @@ final class FLBuilderModel {
2893
  }
2894
 
2895
  /**
2896
- * Returns the default settings for a module.
 
2897
  *
2898
  * @since 1.0
2899
  * @param string $type The type of module.
2900
- * @return object
2901
  */
2902
- static public function get_module_defaults( $type ) {
2903
- $defaults = new StdClass();
2904
 
2905
- if ( isset( self::$modules[ $type ]->form ) ) {
2906
- $defaults = self::get_settings_form_defaults( $type );
2907
- $defaults->type = $type;
 
 
 
 
 
 
 
 
 
 
 
 
 
2908
  }
2909
 
2910
  return $defaults;
@@ -2938,6 +3213,7 @@ final class FLBuilderModel {
2938
  'WP_Widget_Media_Audio',
2939
  'WP_Widget_Media_Image',
2940
  'WP_Widget_Media_Video',
 
2941
  'WP_Widget_Text',
2942
  'WP_Widget_Custom_HTML',
2943
  ) );
@@ -2946,7 +3222,9 @@ final class FLBuilderModel {
2946
  if ( in_array( $class, $exclude ) ) {
2947
  continue;
2948
  }
2949
- $widget->class = get_class( $widget );
 
 
2950
  $widgets[ $widget->name ] = $widget;
2951
  }
2952
 
@@ -2975,6 +3253,64 @@ final class FLBuilderModel {
2975
  return $sidebars;
2976
  }
2977
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2978
  /**
2979
  * Loads the files for all core builder settings.
2980
  *
@@ -2999,6 +3335,16 @@ final class FLBuilderModel {
2999
  */
3000
  static public function register_settings_form( $id, $form ) {
3001
  self::$settings_forms[ $id ] = apply_filters( 'fl_builder_register_settings_form', $form, $id );
 
 
 
 
 
 
 
 
 
 
3002
  }
3003
 
3004
  /**
@@ -3016,13 +3362,24 @@ final class FLBuilderModel {
3016
  * Returns an array of fields in a settings form.
3017
  *
3018
  * @since 1.0
3019
- * @param array $form The form data array.
 
3020
  * @return array
3021
  */
3022
- static public function get_settings_form_fields( $form ) {
3023
  $fields = array();
3024
 
3025
- foreach ( $form as $tab ) {
 
 
 
 
 
 
 
 
 
 
3026
  if ( isset( $tab['sections'] ) ) {
3027
  foreach ( $tab['sections'] as $section ) {
3028
  if ( isset( $section['fields'] ) ) {
@@ -3057,18 +3414,28 @@ final class FLBuilderModel {
3057
  if ( isset( self::$settings_forms[ $type ] ) ) {
3058
  $form_type = $type;
3059
  $tabs = self::$settings_forms[ $type ]['tabs'];
3060
- } // End if().
3061
- elseif ( isset( self::$modules[ $type ] ) ) {
3062
  $form_type = $type . '-module';
3063
  $tabs = self::$modules[ $type ]->form;
3064
- } // The form can't be found.
3065
- else {
3066
  return $defaults;
3067
  }
3068
 
3069
  // Get the fields.
3070
  $fields = self::get_settings_form_fields( $tabs );
3071
 
 
 
 
 
 
 
 
 
 
 
 
 
3072
  // Loop through the fields and get the defaults.
3073
  foreach ( $fields as $name => $field ) {
3074
 
@@ -3192,8 +3559,35 @@ final class FLBuilderModel {
3192
  self::delete_node_template_asset_cache( $template_post_id );
3193
  }
3194
 
3195
- // Return the new layout.
3196
- return FLBuilderAJAXLayout::render();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3197
  }
3198
 
3199
  /**
@@ -3464,15 +3858,14 @@ final class FLBuilderModel {
3464
  $status = ! $status ? self::get_node_status() : $status;
3465
 
3466
  // Get published data?
3467
- if ( 'published' == $status ) {
3468
  if ( isset( self::$published_layout_data[ $post_id ] ) ) {
3469
  $data = self::$published_layout_data[ $post_id ];
3470
  } else {
3471
  $data = get_metadata( 'post', $post_id, '_fl_builder_data', true );
3472
  self::$published_layout_data[ $post_id ] = self::clean_layout_data( $data );
3473
  }
3474
- } // End if().
3475
- elseif ( 'draft' == $status ) {
3476
  if ( isset( self::$draft_layout_data[ $post_id ] ) ) {
3477
  $data = self::$draft_layout_data[ $post_id ];
3478
  } else {
@@ -3594,6 +3987,24 @@ final class FLBuilderModel {
3594
  return $cleaned;
3595
  }
3596
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3597
  /**
3598
  * Get the builder settings for a layout.
3599
  *
@@ -3903,22 +4314,51 @@ final class FLBuilderModel {
3903
  // Set the template type.
3904
  wp_set_post_terms( $post_id, 'layout', 'fl-builder-template-type' );
3905
 
 
 
 
 
 
 
 
3906
  // Get the layout data and settings to copy.
3907
- $data = self::get_layout_data();
3908
- $settings = self::get_layout_settings();
3909
 
3910
  // Generate new node ids.
3911
  $data = self::generate_new_node_ids( $data );
3912
 
3913
  // Save the template layout data and settings.
3914
  self::update_layout_data( $data, 'published', $post_id );
3915
- self::update_layout_settings( $settings, 'published', $post_id );
3916
 
3917
  // Enable the builder for this template.
3918
  update_post_meta( $post_id, '_fl_builder_enabled', true );
3919
 
3920
  // Allow extensions to hook into saving a user template.
3921
  do_action( 'fl_builder_after_save_user_template', $post_id );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3922
  }
3923
 
3924
  /**
@@ -3957,41 +4397,54 @@ final class FLBuilderModel {
3957
  foreach ( $posts as $post ) {
3958
 
3959
  if ( has_post_thumbnail( $post->ID ) ) {
3960
- $image_data = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'medium' );
3961
  $image = $image_data[0];
3962
  } else {
3963
  $image = FL_BUILDER_URL . 'img/templates/blank.jpg';
3964
  }
3965
 
3966
  $templates[] = array(
3967
- 'id' => $post->ID,
 
3968
  'name' => $post->post_title,
3969
  'image' => $image,
 
3970
  'type' => 'user',
 
 
 
 
3971
  );
3972
  }
3973
 
3974
  // Loop through templates and build the categorized array.
3975
- foreach ( $templates as $template ) {
3976
 
3977
- $cats = wp_get_post_terms( $template['id'], 'fl-builder-template-category' );
3978
 
3979
  if ( 0 === count( $cats ) || is_wp_error( $cats ) ) {
 
 
 
3980
  $categorized['uncategorized']['templates'][] = $template;
3981
  } else {
3982
 
3983
  foreach ( $cats as $cat ) {
 
 
3984
 
 
3985
  if ( ! isset( $categorized[ $cat->slug ] ) ) {
3986
  $categorized[ $cat->slug ] = array(
3987
  'name' => $cat->name,
3988
  'templates' => array(),
3989
  );
3990
  }
3991
-
3992
  $categorized[ $cat->slug ]['templates'][] = $template;
3993
  }
3994
  }
 
 
3995
  }
3996
 
3997
  // Unset the uncategorized cat if no templates.
@@ -4055,7 +4508,7 @@ final class FLBuilderModel {
4055
  * @since 1.1.3
4056
  * @param int|object $template The post ID of the template to apply or a template data object.
4057
  * @param bool $append Whether to append the new template or replacing the existing layout.
4058
- * @return void
4059
  */
4060
  static public function apply_user_template( $template = null, $append = false ) {
4061
  if ( $template ) {
@@ -4108,11 +4561,15 @@ final class FLBuilderModel {
4108
  // Delete old asset cache.
4109
  self::delete_asset_cache();
4110
 
4111
- return array(
4112
- 'layout_css' => $settings->css,
4113
- );
4114
  }// End if().
4115
  }// End if().
 
 
 
 
 
 
 
4116
  }
4117
 
4118
  /**
@@ -4218,8 +4675,7 @@ final class FLBuilderModel {
4218
  // For logged out users
4219
  if ( 'logged_out' == $node->settings->visibility_display && ! is_user_logged_in() ) {
4220
  $is_visible = true;
4221
- } // End if().
4222
- elseif ( 'logged_in' == $node->settings->visibility_display && is_user_logged_in() ) {
4223
  $is_visible = true;
4224
 
4225
  // User capability setting
@@ -4230,7 +4686,7 @@ final class FLBuilderModel {
4230
  $is_visible = false;
4231
  }
4232
  }
4233
- } // Never
4234
  elseif ( 0 == $node->settings->visibility_display ) {
4235
  $is_visible = false;
4236
  } else {
@@ -4442,8 +4898,7 @@ final class FLBuilderModel {
4442
  unset( $nodes[ $node_id ]->template_root_node );
4443
  }
4444
  }
4445
- } // End if().
4446
- else {
4447
 
4448
  foreach ( $nodes as $node_id => $node ) {
4449
 
@@ -4492,6 +4947,8 @@ final class FLBuilderModel {
4492
  'name' => $settings['name'],
4493
  'type' => $root_node->type,
4494
  'layout' => $settings['global'] ? FLBuilderAJAXLayout::render( $root_node->node, $template_node_id ) : null,
 
 
4495
  );
4496
  }
4497
 
@@ -4633,7 +5090,7 @@ final class FLBuilderModel {
4633
  // Remove template info from the layout data.
4634
  foreach ( $layout_data as $node_id => $node ) {
4635
  unset( $layout_data[ $node_id ]->template_id );
4636
- unset( $layout_data[ $node_id ]->template_post_id );
4637
  unset( $layout_data[ $node_id ]->template_root_node );
4638
  }
4639
 
@@ -4727,8 +5184,8 @@ final class FLBuilderModel {
4727
  * @return void
4728
  */
4729
  static public function apply_node_template( $template_id = null, $parent_id = null, $position = 0, $template = null ) {
4730
- $parent = 0 == $parent_id ? null : self::get_node( $parent_id );
4731
- $template_post_id = self::get_node_template_post_id( $template_id );
4732
 
4733
  // Allow extensions to hook into applying a node template.
4734
  $override = apply_filters( 'fl_builder_override_apply_node_template', false, array(
@@ -4750,8 +5207,7 @@ final class FLBuilderModel {
4750
  $template_settings = $template->settings;
4751
  $type = $template->type;
4752
  $global = $template->global;
4753
- } // End if().
4754
- else {
4755
  $template_data = self::get_layout_data( 'published', $template_post_id );
4756
  $template_settings = self::get_layout_settings( 'published', $template_post_id );
4757
  $type = self::get_user_template_type( $template_post_id );
@@ -4764,10 +5220,23 @@ final class FLBuilderModel {
4764
  // Get the root node from the template data.
4765
  $root_node = self::get_node_template_root( $type, $template_data );
4766
 
4767
- // Add a new parent for module node templates if needed.
4768
- if ( 'module' == $root_node->type && ( ! $parent || 'row' == $parent->type || 'column-group' == $parent->type ) ) {
4769
- $parent_id = self::add_module_parent( $parent_id, $position );
4770
- $position = null;
 
 
 
 
 
 
 
 
 
 
 
 
 
4771
  }
4772
 
4773
  // Update the root node's parent.
@@ -4780,13 +5249,12 @@ final class FLBuilderModel {
4780
  // Only merge the root node for global templates.
4781
  if ( $global ) {
4782
  $layout_data[ $root_node->node ] = $template_data[ $root_node->node ];
4783
- } // End if().
4784
- else {
4785
 
4786
  // Merge template data.
4787
  foreach ( $template_data as $node_id => $node ) {
4788
  unset( $template_data[ $node_id ]->template_id );
4789
- unset( $template_data[ $node_id ]->template_post_id );
4790
  unset( $template_data[ $node_id ]->template_root_node );
4791
  }
4792
 
@@ -4820,13 +5288,37 @@ final class FLBuilderModel {
4820
  * Registers a template data file with the builder.
4821
  *
4822
  * @since 1.8
4823
- * @param sting $path The directory path to the template data file.
 
4824
  * @return void
4825
  */
4826
- static public function register_templates( $path = false ) {
4827
- if ( $path && file_exists( $path ) ) {
4828
- self::$templates[] = $path;
 
4829
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4830
  }
4831
 
4832
  /**
@@ -4837,6 +5329,7 @@ final class FLBuilderModel {
4837
  */
4838
  static private function register_core_templates() {
4839
  $templates = glob( FL_BUILDER_DIR . 'data/*' );
 
4840
 
4841
  // glob() will return false on error so cast as an array() just in case.
4842
  foreach ( (array) $templates as $template ) {
@@ -4845,8 +5338,10 @@ final class FLBuilderModel {
4845
  continue;
4846
  }
4847
 
4848
- self::register_templates( $template );
4849
  }
 
 
4850
  }
4851
 
4852
  /**
@@ -4870,11 +5365,11 @@ final class FLBuilderModel {
4870