WordPress Page Builder – Beaver Builder - Version 2.2.1.4

Version Description

Download this release

Release Info

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

Code changes from version 2.2.0.6 to 2.2.1.4

Files changed (77) hide show
  1. changelog.txt +82 -0
  2. classes/class-fl-builder-admin-posts.php +63 -15
  3. classes/class-fl-builder-admin-settings.php +65 -44
  4. classes/class-fl-builder-admin.php +20 -14
  5. classes/class-fl-builder-ajax-layout.php +111 -74
  6. classes/class-fl-builder-art.php +179 -175
  7. classes/class-fl-builder-auto-suggest.php +33 -34
  8. classes/class-fl-builder-color.php +24 -24
  9. classes/class-fl-builder-css.php +81 -76
  10. classes/class-fl-builder-debug.php +8 -2
  11. classes/class-fl-builder-export.php +5 -5
  12. classes/class-fl-builder-filesystem.php +3 -3
  13. classes/class-fl-builder-fonts.php +27 -2
  14. classes/class-fl-builder-icons.php +49 -42
  15. classes/class-fl-builder-import.php +1 -1
  16. classes/class-fl-builder-importer.php +8 -8
  17. classes/class-fl-builder-loader.php +5 -5
  18. classes/class-fl-builder-loop.php +94 -78
  19. classes/class-fl-builder-model.php +614 -564
  20. classes/class-fl-builder-module.php +21 -21
  21. classes/class-fl-builder-notifications.php +32 -18
  22. classes/class-fl-builder-privacy.php +9 -9
  23. classes/class-fl-builder-revisions.php +11 -11
  24. classes/class-fl-builder-service-activecampaign.php +62 -63
  25. classes/class-fl-builder-service-aweber.php +40 -41
  26. classes/class-fl-builder-service-campaign-monitor.php +32 -32
  27. classes/class-fl-builder-service-campayn.php +51 -52
  28. classes/class-fl-builder-service-constant-contact.php +48 -49
  29. classes/class-fl-builder-service-convertkit.php +24 -24
  30. classes/class-fl-builder-service-drip.php +47 -48
  31. classes/class-fl-builder-service-email-address.php +10 -10
  32. classes/class-fl-builder-service-enormail.php +22 -22
  33. classes/class-fl-builder-service-getresponse.php +36 -36
  34. classes/class-fl-builder-service-godaddy-email-marketing.php +35 -36
  35. classes/class-fl-builder-service-hatchbuck.php +36 -37
  36. classes/class-fl-builder-service-icontact-pro.php +77 -81
  37. classes/class-fl-builder-service-icontact.php +54 -56
  38. classes/class-fl-builder-service-infusionsoft.php +45 -46
  39. classes/class-fl-builder-service-madmimi.php +34 -35
  40. classes/class-fl-builder-service-mailchimp.php +37 -36
  41. classes/class-fl-builder-service-mailerlite.php +24 -24
  42. classes/class-fl-builder-service-mailpoet.php +21 -21
  43. classes/class-fl-builder-service-mailrelay.php +44 -45
  44. classes/class-fl-builder-service-mautic.php +56 -57
  45. classes/class-fl-builder-service-ontraport.php +35 -37
  46. classes/class-fl-builder-service-sendinblue.php +21 -21
  47. classes/class-fl-builder-service-sendy.php +33 -33
  48. classes/class-fl-builder-services.php +138 -138
  49. classes/class-fl-builder-settings-compat-helper.php +6 -6
  50. classes/class-fl-builder-settings-compat.php +1 -1
  51. classes/class-fl-builder-settings-presets.php +20 -10
  52. classes/class-fl-builder-shortcodes.php +5 -5
  53. classes/class-fl-builder-ui-content-panel.php +71 -71
  54. classes/class-fl-builder-ui-settings-forms.php +86 -83
  55. classes/class-fl-builder-update.php +14 -12
  56. classes/class-fl-builder-usage.php +138 -136
  57. classes/class-fl-builder-user-access.php +4 -4
  58. classes/class-fl-builder-user-settings.php +4 -4
  59. classes/class-fl-builder-utils.php +16 -16
  60. classes/class-fl-builder-wp-blocks-layout.php +19 -19
  61. classes/class-fl-builder-wp-blocks.php +16 -16
  62. classes/class-fl-builder-wpcli-command.php +8 -4
  63. classes/class-fl-builder-wpml.php +12 -8
  64. classes/class-fl-builder.php +483 -369
  65. css/fl-builder-layout-auto-spacing.css +0 -2
  66. css/fl-builder-layout.css +1 -1
  67. css/fl-builder-rtl.css +8 -0
  68. css/fl-builder.css +7 -4
  69. css/fl-builder.min.css +1 -1
  70. extensions/fl-builder-cache-helper/classes/class-fl-builder-cache-helper.php +10 -10
  71. extensions/fl-builder-cache-helper/plugins/defines.php +1 -1
  72. extensions/fl-builder-cache-helper/plugins/hummingbird.php +2 -2
  73. extensions/fl-builder-multisite/classes/class-fl-builder-multisite.php +9 -9
  74. fl-builder.php +1 -1
  75. fonts/fontawesome/css/all.min.css +1 -5
  76. fonts/fontawesome/webfonts/fa-brands-400.eot +0 -0
  77. fonts/fontawesome/webfonts/fa-brands-400.svg +8 -250
changelog.txt CHANGED
@@ -1,3 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <h4>2.2.0.6 - 01/24/2019</h4>
2
  <p><strong>Hot Fix</strong></p>
3
  <ul>
1
+ <h4>2.2.1.4 - 03/05/2019</h4>
2
+ <p><strong>Hot Fix</strong></p>
3
+ <ul>
4
+ <li>Fixed PHP notice in WPML global node filter.</li>
5
+ <li>Fixed fatal JS error with SumoMe plugin.</li>
6
+ <li>Fixed PHP notice if a deleted font is registered.</li>
7
+ <li>Run fl_builder_cache_cleared after plugin update.</li>
8
+ </ul>
9
+
10
+ <h4>2.2.1.3 - 02/27/2019</h4>
11
+ <p><strong>Hot Fix</strong></p>
12
+ <ul>
13
+ <li>Updated translations, introduced de_formal and finally fixed de_de.</li>
14
+ <li>Fixed the form filter for settings presets throwing an error when sections or fields aren't defined.</li>
15
+ <li>Fixed a recursion bug when rendering WPML translated global columns.</li>
16
+ <li>Fixed more issues with SiteGround plugin.</li>
17
+ </ul>
18
+
19
+ <h4>2.2.1.2 - 02/20/2019</h4>
20
+ <p><strong>Hot Fix</strong></p>
21
+ <ul>
22
+ <li>Fixed Prebuilt Rows on multisite.</li>
23
+ <li>Fixed Text Editor links and relative urls on images.</li>
24
+ <li>Fixed Content Slider button colors.</li>
25
+ </ul>
26
+
27
+ <h4>2.2.1.1 - 02/14/2019</h4>
28
+ <p><strong>Hot Fix</strong></p>
29
+ <ul>
30
+ <li>Fixed JS issue on module setting.</li>
31
+ <li>Fixed background overlay z-index issues.</li>
32
+ </ul>
33
+
34
+ <h4>2.2.1 - 02/13/2019</h4>
35
+ <p><strong>Enhancements</strong></p>
36
+ <ul>
37
+ <li>Allow admin post type list to be sorted by builder enabled.</li>
38
+ <li>Add support for vw units for font-size in the Typography settings for modules.</li>
39
+ <li>Show recently used fonts in font selector.</li>
40
+ <li>Filter <code>fl_get_fa5_url</code> added to change the actual URL enqueued for FA5.</li>
41
+ <li>Added new filter to Map Module <code>fl_builder_map_args</code>.</li>
42
+ <li>Updated jQuery.validate to 1.18 to allow for customizable error messages.</li>
43
+ <li>Updated Flyout Menu icon to use FA5.</li>
44
+ <li>Changed Template taxonomy label from Categories to Categories ( Beaver Builder ) to avoid confusion in CPT plugins.</li>
45
+ <li>Allow modules to only display certain parts of the typography settings.</li>
46
+ <li>Add optional limit for multiple setting types, when limit is reached user can not add/copy.</li>
47
+ <li>Pass Youtube Embed Parameters StartTime and EndTime to Youtube Player API.</li>
48
+ <li>Convert notifications to use native WP cron.</li>
49
+ <li>Updated inline action and filter docs for use on hooks.wpbeaverbuilder.com</li>
50
+ </ul>
51
+ <p><strong>Bug Fixes</strong></p>
52
+ <ul>
53
+ <li>Fixed relative urls issue when adding images to rich-text module.</li>
54
+ <li>Fixed an issue with IE11 in layout css.</li>
55
+ <li>Fixed submenu issue in IE11 caused by z-index.</li>
56
+ <li>Fixed subject field connections not working with insert.</li>
57
+ <li>Fixed custom svg icons and groups not working for module aliases.</li>
58
+ <li>Fixed select fields not displaying selected value if all values are numbers.</li>
59
+ <li>Fixed modules ordering and sorted alphabetically.</li>
60
+ <li>Fixed Number Counter issue with Firefox and decimal numbers.</li>
61
+ <li>Fixed PHP notice when no image is selected but lightbox is used in Photo Module.</li>
62
+ <li>Fixed mega-menu issue with hide-heading on mobile menu.</li>
63
+ <li>Fixed fatal error in MailPoet 3 integration.</li>
64
+ <li>Fixed HTML module RTL language layout issue.</li>
65
+ <li>Fixed below row style in menu module when animation is enabled.</li>
66
+ <li>Fixed content slider buttons CSS not being applied.</li>
67
+ <li>Fixed invalid css if text color happens to be empty.</li>
68
+ <li>Fixed heading color not working when editing saved heading module.</li>
69
+ <li>Fixed auto spacing issue on mobile for columns.</li>
70
+ <li>Fixed rich-text module dropdowns being transparent if white text is selected in theme.</li>
71
+ <li>Changed row overlay background pseudo selector to :before to prevent z-index issues.</li>
72
+ <li>Posts module - Feed layout - hide image width option when it doesn't apply.</li>
73
+ <li>Fixed unnecessary large queries being used for demo usage stats data.</li>
74
+ </ul>
75
+
76
+ <h4>2.2.0.7 - 02/06/2019</h4>
77
+ <p><strong>Hot Fix</strong></p>
78
+ <ul>
79
+ <li>Multisite saved rows templates issue fixed.</li>
80
+ <li>Font Awesome updated to 5.7.1</li>
81
+ </ul>
82
+
83
  <h4>2.2.0.6 - 01/24/2019</h4>
84
  <p><strong>Hot Fix</strong></p>
85
  <ul>
classes/class-fl-builder-admin-posts.php CHANGED
@@ -15,12 +15,13 @@ final class FLBuilderAdminPosts {
15
  */
16
  static public function init() {
17
  /* Actions */
18
- add_action( 'current_screen', __CLASS__ . '::init_rendering' );
19
 
20
  /* Filters */
21
- add_filter( 'redirect_post_location', __CLASS__ . '::redirect_post_location' );
22
- add_filter( 'page_row_actions', __CLASS__ . '::render_row_actions_link' );
23
- add_filter( 'post_row_actions', __CLASS__ . '::render_row_actions_link' );
 
24
  }
25
 
26
  /**
@@ -63,6 +64,22 @@ final class FLBuilderAdminPosts {
63
  return use_block_editor_for_post_type( $post_type );
64
  }
65
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66
  /**
67
  * Sets the body class, loads assets and renders the UI
68
  * if we are on a post type that supports the builder.
@@ -75,14 +92,45 @@ final class FLBuilderAdminPosts {
75
 
76
  if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
77
 
78
- $render_ui = apply_filters( 'fl_builder_render_admin_edit_ui', true );
79
- $post_type = self::get_post_type();
80
  $post_types = FLBuilderModel::get_post_types();
81
 
82
  if ( $render_ui && in_array( $post_type, $post_types ) ) {
83
- add_filter( 'admin_body_class', __CLASS__ . '::body_class', 99 );
84
- add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
85
- add_action( 'edit_form_after_title', __CLASS__ . '::render' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
86
  }
87
  }
88
  }
@@ -141,9 +189,9 @@ final class FLBuilderAdminPosts {
141
  static public function render() {
142
  global $post;
143
 
144
- $post_type_obj = get_post_type_object( $post->post_type );
145
  $post_type_name = strtolower( $post_type_obj->labels->singular_name );
146
- $enabled = FLBuilderModel::is_builder_enabled();
147
 
148
  include FL_BUILDER_DIR . 'includes/admin-posts.php';
149
  }
@@ -161,12 +209,12 @@ final class FLBuilderAdminPosts {
161
  if ( 'trash' != $post->post_status && current_user_can( 'edit_post', $post->ID ) && wp_check_post_lock( $post->ID ) === false ) {
162
 
163
  $is_post_editable = (bool) apply_filters( 'fl_builder_is_post_editable', true, $post );
164
- $user_access = FLBuilderUserAccess::current_user_can( 'builder_access' );
165
- $post_types = FLBuilderModel::get_post_types();
166
 
167
  if ( in_array( $post->post_type, $post_types ) && $is_post_editable && $user_access ) {
168
- $enabled = get_post_meta( $post->ID, '_fl_builder_enabled', true );
169
- $dot = ' <span style="color:' . ( $enabled ? '#6bc373' : '#d9d9d9' ) . '; font-size:18px;">&bull;</span>';
170
  $actions['fl-builder'] = '<a href="' . FLBuilderModel::get_edit_url() . '">' . FLBuilderModel::get_branding() . $dot . '</a>';
171
  }
172
  }
15
  */
16
  static public function init() {
17
  /* Actions */
18
+ add_action( 'current_screen', __CLASS__ . '::init_rendering' );
19
 
20
  /* Filters */
21
+ add_filter( 'redirect_post_location', __CLASS__ . '::redirect_post_location' );
22
+ add_filter( 'page_row_actions', __CLASS__ . '::render_row_actions_link' );
23
+ add_filter( 'post_row_actions', __CLASS__ . '::render_row_actions_link' );
24
+ add_action( 'pre_get_posts', __CLASS__ . '::sort_builder_enabled' );
25
  }
26
 
27
  /**
64
  return use_block_editor_for_post_type( $post_type );
65
  }
66
 
67
+ /**
68
+ * Allow sorting by builder enabled in pages list.
69
+ * @since 2.2.1
70
+ */
71
+ static public function sort_builder_enabled( $query ) {
72
+ global $pagenow;
73
+ if ( is_admin()
74
+ && 'edit.php' == $pagenow
75
+ && ! isset( $_GET['orderby'] )
76
+ && isset( $_GET['post_type'] )
77
+ && isset( $_GET['bbsort'] ) ) {
78
+ $query->set( 'meta_key', '_fl_builder_enabled' );
79
+ $query->set( 'meta_value', '1' );
80
+ }
81
+ }
82
+
83
  /**
84
  * Sets the body class, loads assets and renders the UI
85
  * if we are on a post type that supports the builder.
92
 
93
  if ( in_array( $pagenow, array( 'post.php', 'post-new.php' ) ) ) {
94
 
95
+ $render_ui = apply_filters( 'fl_builder_render_admin_edit_ui', true );
96
+ $post_type = self::get_post_type();
97
  $post_types = FLBuilderModel::get_post_types();
98
 
99
  if ( $render_ui && in_array( $post_type, $post_types ) ) {
100
+ add_filter( 'admin_body_class', __CLASS__ . '::body_class', 99 );
101
+ add_action( 'admin_enqueue_scripts', __CLASS__ . '::styles_scripts' );
102
+ add_action( 'edit_form_after_title', __CLASS__ . '::render' );
103
+ }
104
+ }
105
+
106
+ if ( 'edit.php' == $pagenow && true === apply_filters( 'fl_builder_admin_edit_sort_bb_enabled', true ) ) {
107
+ $post_types = FLBuilderModel::get_post_types();
108
+ $post_type = self::get_post_type();
109
+ if ( in_array( $post_type, $post_types ) ) {
110
+ wp_enqueue_script( 'fl-builder-admin-posts-list', FL_BUILDER_URL . 'js/fl-builder-admin-posts-list.js', array( 'jquery' ), FL_BUILDER_VERSION );
111
+ $args = array(
112
+ 'post_type' => $post_type,
113
+ 'posts_per_page' => -1,
114
+ 'meta_query' => array(
115
+ array(
116
+ 'key' => '_fl_builder_enabled',
117
+ 'compare' => '!=',
118
+ 'value' => '',
119
+ ),
120
+ ),
121
+ );
122
+ $result = new WP_Query( $args );
123
+ $count = is_array( $result->posts ) ? count( $result->posts ) : 0;
124
+ $clicked = isset( $_GET['bbsort'] ) ? true : false;
125
+ wp_localize_script( 'fl-builder-admin-posts-list',
126
+ 'fl_builder_enabled_count',
127
+ array(
128
+ 'count' => $count,
129
+ 'brand' => FLBuilderModel::get_branding(),
130
+ 'clicked' => $clicked,
131
+ 'type' => $post_type,
132
+ )
133
+ );
134
  }
135
  }
136
  }
189
  static public function render() {
190
  global $post;
191
 
192
+ $post_type_obj = get_post_type_object( $post->post_type );
193
  $post_type_name = strtolower( $post_type_obj->labels->singular_name );
194
+ $enabled = FLBuilderModel::is_builder_enabled();
195
 
196
  include FL_BUILDER_DIR . 'includes/admin-posts.php';
197
  }
209
  if ( 'trash' != $post->post_status && current_user_can( 'edit_post', $post->ID ) && wp_check_post_lock( $post->ID ) === false ) {
210
 
211
  $is_post_editable = (bool) apply_filters( 'fl_builder_is_post_editable', true, $post );
212
+ $user_access = FLBuilderUserAccess::current_user_can( 'builder_access' );
213
+ $post_types = FLBuilderModel::get_post_types();
214
 
215
  if ( in_array( $post->post_type, $post_types ) && $is_post_editable && $user_access ) {
216
+ $enabled = get_post_meta( $post->ID, '_fl_builder_enabled', true );
217
+ $dot = ' <span style="color:' . ( $enabled ? '#6bc373' : '#d9d9d9' ) . '; font-size:18px;">&bull;</span>';
218
  $actions['fl-builder'] = '<a href="' . FLBuilderModel::get_edit_url() . '">' . FLBuilderModel::get_branding() . $dot . '</a>';
219
  }
220
  }
classes/class-fl-builder-admin-settings.php CHANGED
@@ -153,52 +153,52 @@ final class FLBuilderAdminSettings {
153
  */
154
  static public function render_nav_items() {
155
  $item_data = apply_filters( 'fl_builder_admin_settings_nav_items', array(
156
- 'welcome' => array(
157
- 'title' => __( 'Welcome', 'fl-builder' ),
158
- 'show' => ! FLBuilderModel::is_white_labeled() && ( is_network_admin() || ! self::multisite_support() ),
159
- 'priority' => 50,
160
  ),
161
- 'license' => array(
162
- 'title' => __( 'License', 'fl-builder' ),
163
- 'show' => FL_BUILDER_LITE !== true && ( is_network_admin() || ! self::multisite_support() ),
164
- 'priority' => 100,
165
  ),
166
- 'upgrade' => array(
167
- 'title' => __( 'Upgrade', 'fl-builder' ),
168
- 'show' => FL_BUILDER_LITE === true,
169
- 'priority' => 200,
170
  ),
171
- 'modules' => array(
172
- 'title' => __( 'Modules', 'fl-builder' ),
173
- 'show' => true,
174
- 'priority' => 300,
175
  ),
176
- 'post-types' => array(
177
- 'title' => __( 'Post Types', 'fl-builder' ),
178
- 'show' => true,
179
- 'priority' => 400,
180
  ),
181
  'user-access' => array(
182
- 'title' => __( 'User Access', 'fl-builder' ),
183
- 'show' => true,
184
- 'priority' => 500,
185
  ),
186
- 'icons' => array(
187
- 'title' => __( 'Icons', 'fl-builder' ),
188
- 'show' => FL_BUILDER_LITE !== true,
189
- 'priority' => 600,
190
  ),
191
- 'tools' => array(
192
- 'title' => __( 'Tools', 'fl-builder' ),
193
- 'show' => true,
194
- 'priority' => 700,
195
  ),
196
  ) );
197
 
198
  $sorted_data = array();
199
 
200
  foreach ( $item_data as $key => $data ) {
201
- $data['key'] = $key;
202
  $sorted_data[ $data['priority'] ] = $data;
203
  }
204
 
@@ -248,7 +248,10 @@ final class FLBuilderAdminSettings {
248
  // Tools
249
  self::render_form( 'tools' );
250
 
251
- // Let extensions hook into form rendering.
 
 
 
252
  do_action( 'fl_builder_admin_settings_render_forms' );
253
  }
254
 
@@ -347,7 +350,10 @@ final class FLBuilderAdminSettings {
347
  self::debug();
348
  self::uninstall();
349
 
350
- // Let extensions hook into saving.
 
 
 
351
  do_action( 'fl_builder_admin_settings_save' );
352
  }
353
 
@@ -449,23 +455,30 @@ final class FLBuilderAdminSettings {
449
  fl_builder_filesystem()->rmdir( $sets[ $key ]['path'], true );
450
  FLBuilderIcons::remove_set( $key );
451
  }
452
-
 
 
 
453
  do_action( 'fl_builder_admin_settings_remove_icon_set', $key );
454
  }
455
 
456
  // Upload a new set?
457
  if ( ! empty( $_POST['fl-new-icon-set'] ) ) {
458
 
459
- $dir = FLBuilderModel::get_cache_dir( 'icons' );
460
- $id = (int) $_POST['fl-new-icon-set'];
461
- $path = apply_filters( 'fl_builder_icon_set_upload_path', get_attached_file( $id ) );
462
- $new_path = apply_filters( 'fl_builder_icon_set_new_path', $dir['path'] . 'icon-' . time() . '/' );
463
 
464
  fl_builder_filesystem()->get_filesystem();
465
 
 
 
 
 
466
  do_action( 'fl_builder_before_unzip_icon_set', $id, $path, $new_path );
467
 
468
- $unzipped = unzip_file( $path, $new_path );
469
 
470
  // unzip returned a WP_Error
471
  if ( is_wp_error( $unzipped ) ) {
@@ -484,9 +497,9 @@ final class FLBuilderAdminSettings {
484
 
485
  if ( 1 == count( $files ) ) {
486
 
487
- $values = array_values( $files );
488
  $subfolder_info = array_shift( $values );
489
- $subfolder = $new_path . $subfolder_info['name'] . '/';
490
 
491
  if ( fl_builder_filesystem()->file_exists( $subfolder ) && fl_builder_filesystem()->is_dir( $subfolder ) ) {
492
 
@@ -502,12 +515,16 @@ final class FLBuilderAdminSettings {
502
  }
503
  }
504
 
 
 
 
 
505
  do_action( 'fl_builder_after_unzip_icon_set', $new_path );
506
 
507
  $check_path = apply_filters( 'fl_builder_icon_set_check_path', $new_path );
508
 
509
  // Check for supported sets.
510
- $is_icomoon = fl_builder_filesystem()->file_exists( $check_path . 'selection.json' );
511
  $is_fontello = fl_builder_filesystem()->file_exists( $check_path . 'config.json' );
512
 
513
  // Show an error if we don't have a supported icon set.
@@ -529,7 +546,7 @@ final class FLBuilderAdminSettings {
529
 
530
  // Enable the new set.
531
  if ( is_array( $enabled_icons ) ) {
532
- $key = FLBuilderIcons::get_key_from_path( $check_path );
533
  $enabled_icons[] = $key;
534
  }
535
  }
@@ -586,6 +603,10 @@ final class FLBuilderAdminSettings {
586
  FLCustomizer::clear_all_css_cache();
587
  }
588
  }
 
 
 
 
589
  do_action( 'fl_builder_cache_cleared' );
590
  }
591
  }
153
  */
154
  static public function render_nav_items() {
155
  $item_data = apply_filters( 'fl_builder_admin_settings_nav_items', array(
156
+ 'welcome' => array(
157
+ 'title' => __( 'Welcome', 'fl-builder' ),
158
+ 'show' => ! FLBuilderModel::is_white_labeled() && ( is_network_admin() || ! self::multisite_support() ),
159
+ 'priority' => 50,
160
  ),
161
+ 'license' => array(
162
+ 'title' => __( 'License', 'fl-builder' ),
163
+ 'show' => FL_BUILDER_LITE !== true && ( is_network_admin() || ! self::multisite_support() ),
164
+ 'priority' => 100,
165
  ),
166
+ 'upgrade' => array(
167
+ 'title' => __( 'Upgrade', 'fl-builder' ),
168
+ 'show' => FL_BUILDER_LITE === true,
169
+ 'priority' => 200,
170
  ),
171
+ 'modules' => array(
172
+ 'title' => __( 'Modules', 'fl-builder' ),
173
+ 'show' => true,
174
+ 'priority' => 300,
175
  ),
176
+ 'post-types' => array(
177
+ 'title' => __( 'Post Types', 'fl-builder' ),
178
+ 'show' => true,
179
+ 'priority' => 400,
180
  ),
181
  'user-access' => array(
182
+ 'title' => __( 'User Access', 'fl-builder' ),
183
+ 'show' => true,
184
+ 'priority' => 500,
185
  ),
186
+ 'icons' => array(
187
+ 'title' => __( 'Icons', 'fl-builder' ),
188
+ 'show' => FL_BUILDER_LITE !== true,
189
+ 'priority' => 600,
190
  ),
191
+ 'tools' => array(
192
+ 'title' => __( 'Tools', 'fl-builder' ),
193
+ 'show' => true,
194
+ 'priority' => 700,
195
  ),
196
  ) );
197
 
198
  $sorted_data = array();
199
 
200
  foreach ( $item_data as $key => $data ) {
201
+ $data['key'] = $key;
202
  $sorted_data[ $data['priority'] ] = $data;
203
  }
204
 
248
  // Tools
249
  self::render_form( 'tools' );
250
 
251
+ /**
252
+ * Let extensions hook into form rendering.
253
+ * @see fl_builder_admin_settings_render_forms
254
+ */
255
  do_action( 'fl_builder_admin_settings_render_forms' );
256
  }
257
 
350
  self::debug();
351
  self::uninstall();
352
 
353
+ /**
354
+ * Let extensions hook into saving.
355
+ * @see fl_builder_admin_settings_save
356
+ */
357
  do_action( 'fl_builder_admin_settings_save' );
358
  }
359
 
455
  fl_builder_filesystem()->rmdir( $sets[ $key ]['path'], true );
456
  FLBuilderIcons::remove_set( $key );
457
  }
458
+ /**
459
+ * After set is deleted.
460
+ * @see fl_builder_admin_settings_remove_icon_set
461
+ */
462
  do_action( 'fl_builder_admin_settings_remove_icon_set', $key );
463
  }
464
 
465
  // Upload a new set?
466
  if ( ! empty( $_POST['fl-new-icon-set'] ) ) {
467
 
468
+ $dir = FLBuilderModel::get_cache_dir( 'icons' );
469
+ $id = (int) $_POST['fl-new-icon-set'];
470
+ $path = apply_filters( 'fl_builder_icon_set_upload_path', get_attached_file( $id ) );
471
+ $new_path = apply_filters( 'fl_builder_icon_set_new_path', $dir['path'] . 'icon-' . time() . '/' );
472
 
473
  fl_builder_filesystem()->get_filesystem();
474
 
475
+ /**
476
+ * Before set is unziped.
477
+ * @see fl_builder_before_unzip_icon_set
478
+ */
479
  do_action( 'fl_builder_before_unzip_icon_set', $id, $path, $new_path );
480
 
481
+ $unzipped = unzip_file( $path, $new_path );
482
 
483
  // unzip returned a WP_Error
484
  if ( is_wp_error( $unzipped ) ) {
497
 
498
  if ( 1 == count( $files ) ) {
499
 
500
+ $values = array_values( $files );
501
  $subfolder_info = array_shift( $values );
502
+ $subfolder = $new_path . $subfolder_info['name'] . '/';
503
 
504
  if ( fl_builder_filesystem()->file_exists( $subfolder ) && fl_builder_filesystem()->is_dir( $subfolder ) ) {
505
 
515
  }
516
  }
517
 
518
+ /**
519
+ * After set is unzipped.
520
+ * @see fl_builder_after_unzip_icon_set
521
+ */
522
  do_action( 'fl_builder_after_unzip_icon_set', $new_path );
523
 
524
  $check_path = apply_filters( 'fl_builder_icon_set_check_path', $new_path );
525
 
526
  // Check for supported sets.
527
+ $is_icomoon = fl_builder_filesystem()->file_exists( $check_path . 'selection.json' );
528
  $is_fontello = fl_builder_filesystem()->file_exists( $check_path . 'config.json' );
529
 
530
  // Show an error if we don't have a supported icon set.
546
 
547
  // Enable the new set.
548
  if ( is_array( $enabled_icons ) ) {
549
+ $key = FLBuilderIcons::get_key_from_path( $check_path );
550
  $enabled_icons[] = $key;
551
  }
552
  }
603
  FLCustomizer::clear_all_css_cache();
604
  }
605
  }
606
+ /**
607
+ * Fires after cache is cleared.
608
+ * @see fl_builder_cache_cleared
609
+ */
610
  do_action( 'fl_builder_cache_cleared' );
611
  }
612
  }
classes/class-fl-builder-admin.php CHANGED
@@ -17,14 +17,14 @@ final class FLBuilderAdmin {
17
  $basename = plugin_basename( FL_BUILDER_FILE );
18
 
19
  // Activation
20
- register_activation_hook( FL_BUILDER_FILE, __CLASS__ . '::activate' );
21
 
22
  // Actions
23
- add_action( 'admin_init', __CLASS__ . '::show_activate_notice' );
24
- add_action( 'admin_init', __CLASS__ . '::sanity_checks' );
25
 
26
  // Filters
27
- add_filter( 'plugin_action_links_' . $basename, __CLASS__ . '::render_plugin_action_links' );
28
  }
29
 
30
  /**
@@ -43,7 +43,10 @@ final class FLBuilderAdmin {
43
  self::show_activate_error( __( 'The <strong>Page Builder</strong> plugin requires WordPress version 3.5 or greater. Please update WordPress before activating the plugin.', 'fl-builder' ) );
44
  }
45
 
46
- // Allow extensions to hook activation.
 
 
 
47
  $activate = apply_filters( 'fl_builder_activate', true );
48
 
49
  // Should we continue with activation?
@@ -52,8 +55,8 @@ final class FLBuilderAdmin {
52
  // Check for multisite.
53
  if ( is_multisite() ) {
54
  $url = FLBuilderModel::get_upgrade_url( array(
55
- 'utm_medium' => 'bb-pro',
56
- 'utm_source' => 'plugins-admin-page',
57
  'utm_campaign' => 'no-multisite-support',
58
  ) );
59
  self::show_activate_error( sprintf( __( 'This version of the <strong>Page Builder</strong> plugin is not compatible with WordPress Multisite. <a%s>Please upgrade</a> to the Multisite version of this plugin.', 'fl-builder' ), ' href="' . $url . '" target="_blank"' ) );
@@ -65,7 +68,10 @@ final class FLBuilderAdmin {
65
  // Trigger the activation notice.
66
  self::trigger_activate_notice();
67
 
68
- // Allow add-ons to hook into activation.
 
 
 
69
  do_action( 'fl_builder_activated' );
70
 
71
  // Flush the rewrite rules.
@@ -216,18 +222,18 @@ final class FLBuilderAdmin {
216
  */
217
  static public function render_plugin_action_links( $actions ) {
218
  if ( FL_BUILDER_LITE === true ) {
219
- $url = FLBuilderModel::get_upgrade_url( array(
220
- 'utm_medium' => 'bb-lite',
221
- 'utm_source' => 'plugins-admin-page',
222
  'utm_campaign' => 'plugins-admin-upgrade',
223
  ) );
224
  $actions[] = '<a href="' . $url . '" style="color:#3db634;" target="_blank">' . _x( 'Upgrade', 'Plugin action link label.', 'fl-builder' ) . '</a>';
225
  }
226
 
227
  if ( ! FLBuilderModel::is_white_labeled() ) {
228
- $url = FLBuilderModel::get_store_url( 'change-logs', array(
229
- 'utm_medium' => 'bb-pro',
230
- 'utm_source' => 'plugins-admin-page',
231
  'utm_campaign' => 'plugins-admin-changelog',
232
  ) );
233
  $actions[] = '<a href="' . $url . '" target="_blank">' . _x( 'Change Log', 'Plugin action link label.', 'fl-builder' ) . '</a>';
17
  $basename = plugin_basename( FL_BUILDER_FILE );
18
 
19
  // Activation
20
+ register_activation_hook( FL_BUILDER_FILE, __CLASS__ . '::activate' );
21
 
22
  // Actions
23
+ add_action( 'admin_init', __CLASS__ . '::show_activate_notice' );
24
+ add_action( 'admin_init', __CLASS__ . '::sanity_checks' );
25
 
26
  // Filters
27
+ add_filter( 'plugin_action_links_' . $basename, __CLASS__ . '::render_plugin_action_links' );
28
  }
29
 
30
  /**
43
  self::show_activate_error( __( 'The <strong>Page Builder</strong> plugin requires WordPress version 3.5 or greater. Please update WordPress before activating the plugin.', 'fl-builder' ) );
44
  }
45
 
46
+ /**
47
+ * Allow extensions to hook activation.
48
+ * @see fl_builder_activate
49
+ */
50
  $activate = apply_filters( 'fl_builder_activate', true );
51
 
52
  // Should we continue with activation?
55
  // Check for multisite.
56
  if ( is_multisite() ) {
57
  $url = FLBuilderModel::get_upgrade_url( array(
58
+ 'utm_medium' => 'bb-pro',
59
+ 'utm_source' => 'plugins-admin-page',
60
  'utm_campaign' => 'no-multisite-support',
61
  ) );
62
  self::show_activate_error( sprintf( __( 'This version of the <strong>Page Builder</strong> plugin is not compatible with WordPress Multisite. <a%s>Please upgrade</a> to the Multisite version of this plugin.', 'fl-builder' ), ' href="' . $url . '" target="_blank"' ) );
68
  // Trigger the activation notice.
69
  self::trigger_activate_notice();
70
 
71
+ /**
72
+ * Allow add-ons to hook into activation.
73
+ * @see fl_builder_activated
74
+ */
75
  do_action( 'fl_builder_activated' );
76
 
77
  // Flush the rewrite rules.
222
  */
223
  static public function render_plugin_action_links( $actions ) {
224
  if ( FL_BUILDER_LITE === true ) {
225
+ $url = FLBuilderModel::get_upgrade_url( array(
226
+ 'utm_medium' => 'bb-lite',
227
+ 'utm_source' => 'plugins-admin-page',
228
  'utm_campaign' => 'plugins-admin-upgrade',
229
  ) );
230
  $actions[] = '<a href="' . $url . '" style="color:#3db634;" target="_blank">' . _x( 'Upgrade', 'Plugin action link label.', 'fl-builder' ) . '</a>';
231
  }
232
 
233
  if ( ! FLBuilderModel::is_white_labeled() ) {
234
+ $url = FLBuilderModel::get_store_url( 'change-logs', array(
235
+ 'utm_medium' => 'bb-pro',
236
+ 'utm_source' => 'plugins-admin-page',
237
  'utm_campaign' => 'plugins-admin-changelog',
238
  ) );
239
  $actions[] = '<a href="' . $url . '" target="_blank">' . _x( 'Change Log', 'Plugin action link label.', 'fl-builder' ) . '</a>';
classes/class-fl-builder-ajax-layout.php CHANGED
@@ -25,6 +25,10 @@ final class FLBuilderAJAXLayout {
25
  * @return array
26
  */
27
  static public function render( $node_id = null, $old_node_id = null ) {
 
 
 
 
28
  do_action( 'fl_builder_before_render_ajax_layout' );
29
 
30
  // Update the node ID in the post data?
@@ -50,18 +54,25 @@ final class FLBuilderAJAXLayout {
50
  // Render the assets.
51
  $assets = self::render_assets();
52
 
 
 
 
 
53
  do_action( 'fl_builder_after_render_ajax_layout' );
54
 
55
- // Return the response.
 
 
 
56
  return apply_filters( 'fl_builder_ajax_layout_response', array(
57
- 'partial' => $partial_refresh_data['is_partial_refresh'],
58
- 'nodeId' => $partial_refresh_data['node_id'],
59
- 'nodeType' => $partial_refresh_data['node_type'],
60
- 'oldNodeId' => $old_node_id,
61
- 'html' => $html,
62
- 'scriptsStyles' => $scripts_styles,
63
- 'css' => $assets['css'],
64
- 'js' => $assets['js'],
65
  ) );
66
  }
67
 
@@ -78,19 +89,27 @@ final class FLBuilderAJAXLayout {
78
  // Add the row.
79
  $row = FLBuilderModel::add_row( $cols, $position, $module );
80
 
81
- // Render the row.
 
 
 
82
  do_action( 'fl_builder_before_render_ajax_layout_html' );
83
  ob_start();
84
  FLBuilder::render_row( $row );
85
  $html = ob_get_clean();
 
 
 
 
 
86
  do_action( 'fl_builder_after_render_ajax_layout_html' );
87
 
88
  // Return the response.
89
  return array(
90
- 'partial' => true,
91
- 'nodeType' => $row->type,
92
- 'html' => $html,
93
- 'js' => 'FLBuilder._renderLayoutComplete();',
94
  );
95
  }
96
 
@@ -104,7 +123,9 @@ final class FLBuilderAJAXLayout {
104
  * @return array
105
  */
106
  static public function render_new_row_template( $position, $template_id, $template_type = 'user' ) {
107
- if ( 'core' == $template_type ) {
 
 
108
  $template = FLBuilderModel::get_template( $template_id, 'row' );
109
  $row = FLBuilderModel::apply_node_template( $template_id, null, $position, $template );
110
  } else {
@@ -146,19 +167,27 @@ final class FLBuilderAJAXLayout {
146
  // Add the group.
147
  $group = FLBuilderModel::add_col_group( $node_id, $cols, $position, $module );
148
 
149
- // Render the group.
 
 
 
150
  do_action( 'fl_builder_before_render_ajax_layout_html' );
151
  ob_start();
152
  FLBuilder::render_column_group( $group );
153
  $html = ob_get_clean();
 
 
 
 
 
154
  do_action( 'fl_builder_after_render_ajax_layout_html' );
155
 
156
  // Return the response.
157
  return array(
158
- 'partial' => true,
159
- 'nodeType' => $group->type,
160
- 'html' => $html,
161
- 'js' => 'FLBuilder._renderLayoutComplete();',
162
  );
163
  }
164
 
@@ -204,13 +233,13 @@ final class FLBuilderAJAXLayout {
204
 
205
  // Get the node to render.
206
  if ( ! $parent ) {
207
- $row = FLBuilderModel::get_col_parent( 'row', $column );
208
- $render_id = $row->node;
209
  } elseif ( 'row' == $parent->type ) {
210
- $group = FLBuilderModel::get_col_parent( 'column-group', $column );
211
- $render_id = $group->node;
212
  } elseif ( 'column-group' == $parent->type ) {
213
- $render_id = $parent->node;
214
  } else {
215
  $render_id = $column->node;
216
  }
@@ -272,13 +301,13 @@ final class FLBuilderAJAXLayout {
272
 
273
  // Get the node to render.
274
  if ( ! $parent ) {
275
- $row = FLBuilderModel::get_module_parent( 'row', $module );
276
- $render_id = $row->node;
277
  } elseif ( 'row' == $parent->type ) {
278
- $group = FLBuilderModel::get_module_parent( 'column-group', $module );
279
- $render_id = $group->node;
280
  } elseif ( 'column-group' == $parent->type ) {
281
- $render_id = $parent->node;
282
  } else {
283
  $render_id = $module->node;
284
  }
@@ -288,13 +317,13 @@ final class FLBuilderAJAXLayout {
288
 
289
  // Return the response.
290
  return array(
291
- 'type' => $module->settings->type,
292
- 'nodeId' => $module->node,
293
- 'parentId' => $module->parent,
294
- 'global' => FLBuilderModel::is_node_global( $module ),
295
- 'layout' => self::render( $render_id ),
296
- 'settings' => null === $template_id && ! $alias ? null : $module->settings,
297
- 'legacy' => FLBuilderUISettingsForms::pre_render_legacy_module_settings( $module->settings->type, $module->settings ),
298
  );
299
  }
300
 
@@ -323,39 +352,39 @@ final class FLBuilderAJAXLayout {
323
  // Get the data if it's not cached.
324
  if ( ! self::$partial_refresh_data ) {
325
 
326
- $post_data = FLBuilderModel::get_post_data();
327
  $partial_refresh = false;
328
- $node_type = null;
329
 
330
  // Check for partial refresh if we have a node ID.
331
  if ( isset( $post_data['node_id'] ) ) {
332
 
333
  // Get the node.
334
- $node_id = $post_data['node_id'];
335
- $node = FLBuilderModel::get_node( $post_data['node_id'] );
336
  $node_type = null;
337
 
338
  // Check a module for partial refresh.
339
  if ( $node && 'module' == $node->type ) {
340
- $node = FLBuilderModel::get_module( $node_id );
341
- $node_type = 'module';
342
- $partial_refresh = $node->partial_refresh;
343
  } elseif ( $node ) {
344
- $node_type = $node->type;
345
- $partial_refresh = self::node_modules_support_partial_refresh( $node );
346
  }
347
  } else {
348
- $node_id = null;
349
- $node = null;
350
- $node_type = null;
351
  }
352
 
353
  // Cache the partial refresh data.
354
  self::$partial_refresh_data = array(
355
  'is_partial_refresh' => $partial_refresh,
356
- 'node_id' => $node_id,
357
- 'node' => $node,
358
- 'node_type' => $node_type,
359
  );
360
  }
361
 
@@ -372,7 +401,7 @@ final class FLBuilderAJAXLayout {
372
  * @return bool
373
  */
374
  static private function node_modules_support_partial_refresh( $node ) {
375
- $nodes = FLBuilderModel::get_categorized_nodes();
376
 
377
  if ( 'row' == $node->type ) {
378
 
@@ -426,6 +455,10 @@ final class FLBuilderAJAXLayout {
426
  * @return string
427
  */
428
  static private function render_html() {
 
 
 
 
429
  do_action( 'fl_builder_before_render_ajax_layout_html' );
430
 
431
  // Get the partial refresh data.
@@ -441,19 +474,19 @@ final class FLBuilderAJAXLayout {
441
 
442
  case 'row':
443
  FLBuilder::render_row( $partial_refresh_data['node'] );
444
- break;
445
 
446
  case 'column-group':
447
  FLBuilder::render_column_group( $partial_refresh_data['node'] );
448
- break;
449
 
450
  case 'column':
451
  FLBuilder::render_column( $partial_refresh_data['node'] );
452
- break;
453
 
454
  case 'module':
455
  FLBuilder::render_module( $partial_refresh_data['node'] );
456
- break;
457
  }
458
  } else {
459
  FLBuilder::render_nodes();
@@ -474,7 +507,10 @@ final class FLBuilderAJAXLayout {
474
  echo do_shortcode( $html );
475
  $html = ob_get_clean();
476
  }
477
-
 
 
 
478
  do_action( 'fl_builder_after_render_ajax_layout_html' );
479
 
480
  // Return the rendered HTML.
@@ -489,12 +525,12 @@ final class FLBuilderAJAXLayout {
489
  * @return array
490
  */
491
  static private function render_assets() {
492
- $partial_refresh_data = self::get_partial_refresh_data();
493
- $asset_info = FLBuilderModel::get_asset_info();
494
- $asset_ver = FLBuilderModel::get_asset_version();
495
- $enqueuemethod = FLBuilderModel::get_asset_enqueue_method();
496
- $assets = array(
497
- 'js' => '',
498
  'css' => '',
499
  );
500
 
@@ -511,28 +547,29 @@ final class FLBuilderAJAXLayout {
511
  switch ( $partial_refresh_data['node']->type ) {
512
 
513
  case 'row':
514
- $assets['js'] = FLBuilder::render_row_js( $partial_refresh_data['node'] );
515
  $assets['js'] .= FLBuilder::render_row_modules_js( $partial_refresh_data['node'] );
516
- break;
517
 
518
  case 'column-group':
519
  $assets['js'] = FLBuilder::render_column_group_modules_js( $partial_refresh_data['node'] );
520
- break;
521
 
522
  case 'column':
523
  $assets['js'] = FLBuilder::render_column_modules_js( $partial_refresh_data['node'] );
524
- break;
525
 
526
  case 'module':
527
  $assets['js'] = FLBuilder::render_module_js( $partial_refresh_data['node'] );
528
- break;
529
  }
530
 
531
  $assets['js'] .= 'FLBuilder._renderLayoutComplete();';
532
 
533
  try {
534
  $min = FLJSMin::minify( $assets['js'] );
535
- } catch ( Exception $e ) {}
 
536
 
537
  if ( $min ) {
538
  $assets['js'] = $min;
@@ -608,9 +645,9 @@ final class FLBuilderAJAXLayout {
608
  global $wp_scripts;
609
  global $wp_styles;
610
 
611
- $partial_refresh_data = self::get_partial_refresh_data();
612
- $modules = array();
613
- $scripts_styles = '';
614
 
615
  // Enqueue module font styles.
616
  if ( ! $partial_refresh_data['is_partial_refresh'] ) {
@@ -620,7 +657,7 @@ final class FLBuilderAJAXLayout {
620
  foreach ( $nodes as $node ) {
621
  if ( 'module' === $node->type && isset( FLBuilderModel::$modules[ $node->settings->type ] ) ) {
622
  $node->form = FLBuilderModel::$modules[ $node->settings->type ]->form;
623
- $modules[] = $node;
624
  }
625
  }
626
  } else {
25
  * @return array
26
  */
27
  static public function render( $node_id = null, $old_node_id = null ) {
28
+ /**
29
+ * Before ajax layout rendered.
30
+ * @see fl_builder_before_render_ajax_layout
31
+ */
32
  do_action( 'fl_builder_before_render_ajax_layout' );
33
 
34
  // Update the node ID in the post data?
54
  // Render the assets.
55
  $assets = self::render_assets();
56
 
57
+ /**
58
+ * After ajax layout rendered.
59
+ * @see fl_builder_after_render_ajax_layout
60
+ */
61
  do_action( 'fl_builder_after_render_ajax_layout' );
62
 
63
+ /**
64
+ * Return filtered response.
65
+ * @see fl_builder_ajax_layout_response
66
+ */
67
  return apply_filters( 'fl_builder_ajax_layout_response', array(
68
+ 'partial' => $partial_refresh_data['is_partial_refresh'],
69
+ 'nodeId' => $partial_refresh_data['node_id'],
70
+ 'nodeType' => $partial_refresh_data['node_type'],
71
+ 'oldNodeId' => $old_node_id,
72
+ 'html' => $html,
73
+ 'scriptsStyles' => $scripts_styles,
74
+ 'css' => $assets['css'],
75
+ 'js' => $assets['js'],
76
  ) );
77
  }
78
 
89
  // Add the row.
90
  $row = FLBuilderModel::add_row( $cols, $position, $module );
91
 
92
+ /**
93
+ * Render the row.
94
+ * @see fl_builder_before_render_ajax_layout_html
95
+ */
96
  do_action( 'fl_builder_before_render_ajax_layout_html' );
97
  ob_start();
98
  FLBuilder::render_row( $row );
99
  $html = ob_get_clean();
100
+
101
+ /**
102
+ * After rendering row.
103
+ * @see fl_builder_after_render_ajax_layout_html
104
+ */
105
  do_action( 'fl_builder_after_render_ajax_layout_html' );
106
 
107
  // Return the response.
108
  return array(
109
+ 'partial' => true,
110
+ 'nodeType' => $row->type,
111
+ 'html' => $html,
112
+ 'js' => 'FLBuilder._renderLayoutComplete();',
113
  );
114
  }
115
 
123
  * @return array
124
  */
125
  static public function render_new_row_template( $position, $template_id, $template_type = 'user' ) {
126
+ if ( class_exists( 'FLBuilderTemplatesOverride' ) && FLBuilderTemplatesOverride::show_rows() && FLBuilderTemplatesOverride::get_source_site_id() ) {
127
+ $row = FLBuilderModel::apply_node_template( $template_id, null, $position );
128
+ } elseif ( 'core' == $template_type ) {
129
  $template = FLBuilderModel::get_template( $template_id, 'row' );
130
  $row = FLBuilderModel::apply_node_template( $template_id, null, $position, $template );
131
  } else {
167
  // Add the group.
168
  $group = FLBuilderModel::add_col_group( $node_id, $cols, $position, $module );
169
 
170
+ /**
171
+ * Render the group.
172
+ * @see fl_builder_before_render_ajax_layout_html
173
+ */
174
  do_action( 'fl_builder_before_render_ajax_layout_html' );
175
  ob_start();
176
  FLBuilder::render_column_group( $group );
177
  $html = ob_get_clean();
178
+
179
+ /**
180
+ * After rendering group.
181
+ * @see fl_builder_after_render_ajax_layout_html
182
+ */
183
  do_action( 'fl_builder_after_render_ajax_layout_html' );
184
 
185
  // Return the response.
186
  return array(
187
+ 'partial' => true,
188
+ 'nodeType' => $group->type,
189
+ 'html' => $html,
190
+ 'js' => 'FLBuilder._renderLayoutComplete();',
191
  );
192
  }
193
 
233
 
234
  // Get the node to render.
235
  if ( ! $parent ) {
236
+ $row = FLBuilderModel::get_col_parent( 'row', $column );
237
+ $render_id = $row->node;
238
  } elseif ( 'row' == $parent->type ) {
239
+ $group = FLBuilderModel::get_col_parent( 'column-group', $column );
240
+ $render_id = $group->node;
241
  } elseif ( 'column-group' == $parent->type ) {
242
+ $render_id = $parent->node;
243
  } else {
244
  $render_id = $column->node;
245
  }
301
 
302
  // Get the node to render.
303
  if ( ! $parent ) {
304
+ $row = FLBuilderModel::get_module_parent( 'row', $module );
305
+ $render_id = $row->node;
306
  } elseif ( 'row' == $parent->type ) {
307
+ $group = FLBuilderModel::get_module_parent( 'column-group', $module );
308
+ $render_id = $group->node;
309
  } elseif ( 'column-group' == $parent->type ) {
310
+ $render_id = $parent->node;
311
  } else {
312
  $render_id = $module->node;
313
  }
317
 
318
  // Return the response.
319
  return array(
320
+ 'type' => $module->settings->type,
321
+ 'nodeId' => $module->node,
322
+ 'parentId' => $module->parent,
323
+ 'global' => FLBuilderModel::is_node_global( $module ),
324
+ 'layout' => self::render( $render_id ),
325
+ 'settings' => null === $template_id && ! $alias ? null : $module->settings,
326
+ 'legacy' => FLBuilderUISettingsForms::pre_render_legacy_module_settings( $module->settings->type, $module->settings ),
327
  );
328
  }
329
 
352
  // Get the data if it's not cached.
353
  if ( ! self::$partial_refresh_data ) {
354
 
355
+ $post_data = FLBuilderModel::get_post_data();
356
  $partial_refresh = false;
357
+ $node_type = null;
358
 
359
  // Check for partial refresh if we have a node ID.
360
  if ( isset( $post_data['node_id'] ) ) {
361
 
362
  // Get the node.
363
+ $node_id = $post_data['node_id'];
364
+ $node = FLBuilderModel::get_node( $post_data['node_id'] );
365
  $node_type = null;
366
 
367
  // Check a module for partial refresh.
368
  if ( $node && 'module' == $node->type ) {
369
+ $node = FLBuilderModel::get_module( $node_id );
370
+ $node_type = 'module';
371
+ $partial_refresh = $node->partial_refresh;
372
  } elseif ( $node ) {
373
+ $node_type = $node->type;
374
+ $partial_refresh = self::node_modules_support_partial_refresh( $node );
375
  }
376
  } else {
377
+ $node_id = null;
378
+ $node = null;
379
+ $node_type = null;
380
  }
381
 
382
  // Cache the partial refresh data.
383
  self::$partial_refresh_data = array(
384
  'is_partial_refresh' => $partial_refresh,
385
+ 'node_id' => $node_id,
386
+ 'node' => $node,
387
+ 'node_type' => $node_type,
388
  );
389
  }
390
 
401
  * @return bool
402
  */
403
  static private function node_modules_support_partial_refresh( $node ) {
404
+ $nodes = FLBuilderModel::get_categorized_nodes();
405
 
406
  if ( 'row' == $node->type ) {
407
 
455
  * @return string
456
  */
457
  static private function render_html() {
458
+ /**
459
+ * Before html for layout or node is rendered.
460
+ * @see fl_builder_before_render_ajax_layout_html
461
+ */
462
  do_action( 'fl_builder_before_render_ajax_layout_html' );
463
 
464
  // Get the partial refresh data.
474
 
475
  case 'row':
476
  FLBuilder::render_row( $partial_refresh_data['node'] );
477
+ break;
478
 
479
  case 'column-group':
480
  FLBuilder::render_column_group( $partial_refresh_data['node'] );
481
+ break;
482
 
483
  case 'column':
484
  FLBuilder::render_column( $partial_refresh_data['node'] );
485
+ break;
486
 
487
  case 'module':
488
  FLBuilder::render_module( $partial_refresh_data['node'] );
489
+ break;
490
  }
491
  } else {
492
  FLBuilder::render_nodes();
507
  echo do_shortcode( $html );
508
  $html = ob_get_clean();
509
  }
510
+ /**
511
+ * After html for layout or node is rendered.
512
+ * @see fl_builder_after_render_ajax_layout_html
513
+ */
514
  do_action( 'fl_builder_after_render_ajax_layout_html' );
515
 
516
  // Return the rendered HTML.
525
  * @return array
526
  */
527
  static private function render_assets() {
528
+ $partial_refresh_data = self::get_partial_refresh_data();
529
+ $asset_info = FLBuilderModel::get_asset_info();
530
+ $asset_ver = FLBuilderModel::get_asset_version();
531
+ $enqueuemethod = FLBuilderModel::get_asset_enqueue_method();
532
+ $assets = array(
533
+ 'js' => '',
534
  'css' => '',
535
  );
536
 
547
  switch ( $partial_refresh_data['node']->type ) {
548
 
549
  case 'row':
550
+ $assets['js'] = FLBuilder::render_row_js( $partial_refresh_data['node'] );
551
  $assets['js'] .= FLBuilder::render_row_modules_js( $partial_refresh_data['node'] );
552
+ break;
553
 
554
  case 'column-group':
555
  $assets['js'] = FLBuilder::render_column_group_modules_js( $partial_refresh_data['node'] );
556
+ break;
557
 
558
  case 'column':
559
  $assets['js'] = FLBuilder::render_column_modules_js( $partial_refresh_data['node'] );
560
+ break;
561
 
562
  case 'module':
563
  $assets['js'] = FLBuilder::render_module_js( $partial_refresh_data['node'] );
564
+ break;
565
  }
566
 
567
  $assets['js'] .= 'FLBuilder._renderLayoutComplete();';
568
 
569
  try {
570
  $min = FLJSMin::minify( $assets['js'] );
571
+ } catch ( Exception $e ) {
572
+ }
573
 
574
  if ( $min ) {
575
  $assets['js'] = $min;
645
  global $wp_scripts;
646
  global $wp_styles;
647
 
648
+ $partial_refresh_data = self::get_partial_refresh_data();
649
+ $modules = array();
650
+ $scripts_styles = '';
651
 
652
  // Enqueue module font styles.
653
  if ( ! $partial_refresh_data['is_partial_refresh'] ) {
657
  foreach ( $nodes as $node ) {
658
  if ( 'module' === $node->type && isset( FLBuilderModel::$modules[ $node->settings->type ] ) ) {
659
  $node->form = FLBuilderModel::$modules[ $node->settings->type ]->form;
660
+ $modules[] = $node;
661
  }
662
  }
663
  } else {
classes/class-fl-builder-art.php CHANGED
@@ -41,73 +41,77 @@ class FLBuilderArt {
41
  $art_dir = FL_BUILDER_DIR . 'includes/shapes/';
42
 
43
  self::register_shape(array(
44
- 'label' => __( 'Slanted Edge', 'fl-builder' ),
45
- 'name' => 'edge-slant',
46
- 'width' => 422,
47
  'height' => 33.98,
48
  'render' => $art_dir . 'edge-slant.svg.php',
49
  ));
50
 
51
  self::register_shape(array(
52
- 'label' => __( 'Waves', 'fl-builder' ),
53
- 'name' => 'wavy',
54
- 'width' => 800,
55
  'height' => 102,
56
  'render' => $art_dir . 'wavy.svg.php',
57
  ));
58
 
59
  self::register_shape( array(
60
- 'label' => __( 'Midpoint', 'fl-builder' ),
61
- 'name' => 'midpoint',
62
- 'width' => 800,
63
  'height' => 50,
64
  'render' => $art_dir . 'midpoint.svg.php',
65
  ));
66
 
67
  self::register_shape( array(
68
- 'label' => __( 'Triangle', 'fl-builder' ),
69
- 'name' => 'triangle',
70
- 'width' => 50,
71
  'height' => 34,
72
  'render' => $art_dir . 'triangle.svg.php',
73
  ));
74
  self::register_shape( array(
75
- 'label' => __( 'Circle', 'fl-builder' ),
76
- 'name' => 'circle',
77
- 'width' => 100,
78
  'height' => 100,
79
  'render' => $art_dir . 'circle.svg.php',
80
  ));
81
  self::register_shape( array(
82
- 'label' => __( 'Concave', 'fl-builder' ),
83
- 'name' => 'concave',
84
- 'width' => 800,
85
  'height' => 50,
86
  'render' => $art_dir . 'concave.svg.php',
87
  ));
88
  self::register_shape( array(
89
- 'label' => __( 'Spots', 'fl-builder' ),
90
- 'name' => 'dot-cluster',
91
- 'width' => 800,
92
  'height' => 315,
93
  'render' => $art_dir . 'dot-cluster.svg.php',
94
  ));
95
  self::register_shape( array(
96
- 'label' => __( 'Topography', 'fl-builder' ),
97
- 'name' => 'topography',
98
- 'width' => 600,
99
  'height' => 600,
100
  'render' => $art_dir . 'topography.svg.php',
101
  ));
102
  self::register_shape( array(
103
- 'label' => __( 'Rectangle', 'fl-builder' ),
104
- 'name' => 'rect',
105
- 'width' => 800,
106
  'height' => 450,
107
  'render' => $art_dir . 'rect.svg.php',
108
  ));
109
 
110
- // Trigger registration process for external shapes
 
 
 
 
111
  do_action( 'fl_register_art' );
112
  }
113
 
@@ -119,33 +123,33 @@ class FLBuilderArt {
119
  */
120
  static public function register_shape( $args = array() ) {
121
  $defaults = array(
122
- 'label' => __( 'Untitled Shape', 'fl-builder' ),
123
- 'name' => 'untitled-shape',
124
- 'x' => 0,
125
- 'y' => 0,
126
- 'width' => 0,
127
- 'height' => 0,
128
  'preserve_aspect_ratio' => 'none',
129
- 'render' => '',
130
- 'preset_settings' => array(),
131
  );
132
 
133
  $args = wp_parse_args( $args, $defaults );
134
- $key = $args['name'];
135
 
136
  /**
137
  * Setup a preset to reference the shape's initial configuration later
138
  * This is so when you choose a shape, we can also setup other fields for the optimal inital appearance.
139
  */
140
  FLBuilderSettingsPresets::register( 'shape', array(
141
- 'name' => $args['name'],
142
- 'label' => $args['label'],
143
  'settings' => $args['preset_settings'],
144
- 'data' => array(
145
  'viewBox' => array(
146
- 'x' => $args['x'],
147
- 'y' => $args['y'],
148
- 'width' => $args['width'],
149
  'height' => $args['height'],
150
  ),
151
  ),
@@ -236,17 +240,17 @@ class FLBuilderArt {
236
 
237
  if ( ! empty( $settings->{'top_edge_shape'} ) ) {
238
  $layers['top'] = array(
239
- 'label' => __( 'Top Shape Layer', 'fl-builder' ),
240
- 'type' => 'shape',
241
- 'prefix' => 'top_edge_',
242
  'position' => 'top',
243
  );
244
  }
245
  if ( ! empty( $settings->{'bottom_edge_shape'} ) ) {
246
  $layers['bottom'] = array(
247
- 'label' => __( 'Bottom Shape Layer', 'fl-builder' ),
248
- 'type' => 'shape',
249
- 'prefix' => 'bottom_edge_',
250
  'position' => 'bottom',
251
  );
252
  }
@@ -294,23 +298,23 @@ class FLBuilderArt {
294
  */
295
  static public function render_node_shape_layer( $layer, $node ) {
296
 
297
- $settings = $node->settings;
298
- $id = $node->node;
299
- $position = $layer['position'];
300
- $prefix = $layer['prefix'];
301
  $shape_name = $settings->{ $prefix . 'shape' };
302
  $shape_args = self::get_art( $shape_name );
303
- $content = self::render_art( $shape_args, $settings );
304
 
305
- $x = $shape_args['x'];
306
- $y = $shape_args['y'];
307
- $width = $shape_args['width'];
308
- $height = $shape_args['height'];
309
- $view_box = "$x $y $width $height";
310
  $preserve_aspect_ratio = $shape_args['preserve_aspect_ratio'];
311
 
312
- $align = $settings->{ $prefix . 'align' };
313
- $ending = str_replace( ' ', '-', $align );
314
  $svg_class = 'fl-builder-layer-align-' . $ending;
315
  include FL_BUILDER_DIR . 'includes/shape-layer.php';
316
  }
@@ -323,8 +327,8 @@ class FLBuilderArt {
323
  */
324
  static public function get_shape_settings_sections() {
325
  $sections = array();
326
- $layers = array(
327
- 'top' => __( 'Top', 'fl-builder' ),
328
  'bottom' => __( 'Bottom', 'fl-builder' ),
329
  );
330
 
@@ -333,18 +337,18 @@ class FLBuilderArt {
333
 
334
  // Preset & Shape Section
335
  $sections[ $prefix . 'shape' ] = array(
336
- 'title' => sprintf( __( '%s Shape', 'fl-builder' ), $position_label ),
337
  'fields' => array(
338
  $prefix . 'shape' => array(
339
- 'type' => 'select',
340
- 'label' => __( 'Shape', 'fl-builder' ),
341
  'options' => 'shapes',
342
- 'hide' => array(
343
  '' => array(
344
  'sections' => array(
345
  $prefix . 'style',
346
  ),
347
- 'fields' => array(
348
  $prefix . 'size',
349
  $prefix . 'align',
350
  $prefix . 'z_pos',
@@ -352,21 +356,21 @@ class FLBuilderArt {
352
  ),
353
  ),
354
  'preview' => array(
355
- 'type' => 'callback',
356
  'callback' => 'previewShape',
357
- 'prefix' => $prefix,
358
  'position' => $position,
359
  ),
360
  ),
361
- $prefix . 'size' => array(
362
- 'type' => 'dimension',
363
- 'label' => __( 'Size', 'fl-builder' ),
364
- 'units' => array( 'px', 'vw', 'vh', '%' ),
365
- 'slider' => array(
366
- 'width' => array(
367
  'px' => array(
368
- 'min' => 0,
369
- 'max' => 5000,
370
  'step' => 10,
371
  ),
372
  'vw' => array(
@@ -377,15 +381,15 @@ class FLBuilderArt {
377
  'min' => 0,
378
  'max' => 500,
379
  ),
380
- '%' => array(
381
  'min' => 0,
382
  'max' => 300,
383
  ),
384
  ),
385
  'height' => array(
386
  'px' => array(
387
- 'min' => 0,
388
- 'max' => 2000,
389
  'step' => 10,
390
  ),
391
  'vw' => array(
@@ -396,12 +400,12 @@ class FLBuilderArt {
396
  'min' => 0,
397
  'max' => 200,
398
  ),
399
- '%' => array(
400
  'min' => 0,
401
  'max' => 100,
402
  ),
403
  ),
404
- 'top' => array(
405
  'px' => array(
406
  'min' => -500,
407
  'max' => 500,
@@ -414,43 +418,43 @@ class FLBuilderArt {
414
  'min' => -20,
415
  'max' => 20,
416
  ),
417
- '%' => array(
418
  'min' => 0,
419
  'max' => 100,
420
  ),
421
  ),
422
  ),
423
- 'keys' => array(
424
- 'width' => __( 'Width', 'fl-builder' ),
425
  'height' => __( 'Height', 'fl-builder' ),
426
- 'top' => __( 'Y Offset', 'fl-builder' ),
427
  ),
428
  'preview' => array(
429
- 'type' => 'callback',
430
  'callback' => 'previewShapeLayerSize',
431
- 'prefix' => $prefix,
432
  'position' => $position,
433
  ),
434
  ),
435
  $prefix . 'align' => array(
436
- 'type' => 'select',
437
- 'label' => __( 'Align', 'fl-builder' ),
438
  'default' => $position . ' center',
439
  'options' => array(
440
- 'top left' => __( 'Top Left', 'fl-builder' ),
441
- 'top center' => __( 'Top Center', 'fl-builder' ),
442
- 'top right' => __( 'Top Right', 'fl-builder' ),
443
- 'center left' => __( 'Center Left', 'fl-builder' ),
444
  'center center' => __( 'Center', 'fl-builder' ),
445
- 'center right' => __( 'Center Right', 'fl-builder' ),
446
- 'bottom left' => __( 'Bottom Left', 'fl-builder' ),
447
  'bottom center' => __( 'Bottom Center', 'fl-builder' ),
448
- 'bottom right' => __( 'Bottom Right', 'fl-builder' ),
449
  ),
450
  'preview' => array(
451
- 'type' => 'callback',
452
  'callback' => 'previewShapeAlign',
453
- 'prefix' => $prefix,
454
  'selector' => ".fl-builder-$position-edge-layer > *",
455
  ),
456
  ),
@@ -459,66 +463,66 @@ class FLBuilderArt {
459
 
460
  // Shape Styles
461
  $sections[ $prefix . 'style' ] = array(
462
- 'title' => sprintf( __( '%s Shape Style', 'fl-builder' ), $position_label ),
463
  'fields' => array(
464
- $prefix . 'fill_style' => array(
465
- 'type' => 'button-group',
466
  'options' => array(
467
- 'color' => __( 'Color Fill', 'fl-builder' ),
468
  'gradient' => __( 'Gradient Fill', 'fl-builder' ),
469
  ),
470
  'default' => 'color',
471
  'preview' => array(
472
- 'type' => 'callback',
473
  'callback' => 'previewShapeFillStyle',
474
  'position' => $position,
475
- 'prefix' => $prefix,
476
  'selector' => ".fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
477
  ),
478
- 'toggle' => array(
479
- 'color' => array(
480
  'fields' => array(
481
- $prefix . 'fill_color'
482
  ),
483
  ),
484
  'gradient' => array(
485
  'fields' => array(
486
- $prefix . 'fill_gradient'
487
  ),
488
  ),
489
  ),
490
  ),
491
- $prefix . 'fill_color' => array(
492
- 'type' => 'color',
493
- 'connections' => array( 'color' ),
494
- 'label' => __( 'Color', 'fl-builder' ),
495
- 'show_reset' => true,
496
- 'show_alpha' => true,
497
- 'responsive' => true,
498
- 'default' => 'aaa',
499
- 'preview' => array(
500
- 'type' => 'css',
501
  'selector' => ".fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
502
  'property' => 'fill',
503
  ),
504
  ),
505
  $prefix . 'fill_gradient' => array(
506
- 'type' => 'gradient',
507
- 'label' => __( 'Gradient', 'fl-builder' ),
508
  'default' => '',
509
  'preview' => array(
510
- 'type' => 'callback',
511
  'callback' => 'previewShapeGradientFill',
512
  'position' => $position,
513
- 'prefix' => $prefix,
514
  ),
515
  ),
516
 
517
- $prefix . 'transform' => array(
518
- 'type' => 'shape-transform',
519
- 'label' => __( 'Transform', 'fl-builder' ),
520
  'preview' => array(
521
- 'type' => 'callback',
522
  'callback' => 'previewShapeTransform',
523
  'selector' => ".fl-builder-$position-edge-layer",
524
  'position' => $position,
@@ -529,17 +533,17 @@ class FLBuilderArt {
529
  }
530
 
531
  $sections['shapes_container'] = array(
532
- 'title' => __( 'Shape Container', 'fl-builder' ),
533
  'fields' => array(
534
  'container_overflow' => array(
535
- 'type' => 'select',
536
- 'label' => __( 'Clip Within Container', 'fl-builder' ),
537
  'options' => array(
538
- '' => __( 'No Clip', 'fl-builder' ),
539
  'hidden' => __( 'Clip Contents', 'fl-builder' ),
540
  ),
541
  'preview' => array(
542
- 'type' => 'css',
543
  'selector' => '.fl-row-content-wrap',
544
  'property' => 'overflow',
545
  ),
@@ -557,7 +561,7 @@ class FLBuilderArt {
557
  */
558
  static public function render_shape_layers_css( $node ) {
559
  $settings = $node->settings;
560
- $id = $node->node;
561
 
562
  $layers = array( 'top', 'bottom' );
563
 
@@ -567,44 +571,44 @@ class FLBuilderArt {
567
  if ( ! empty( $settings->{ $prefix . 'shape' } ) ) {
568
 
569
  $shape_name = $settings->{ $prefix . 'shape' };
570
- $presets = FLBuilderSettingsPresets::get_presets();
571
- $preset = $presets['shape'][ $shape_name ];
572
 
573
  FLBuilderCSS::rule( array(
574
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer",
575
- 'enabled' => $settings->{ $prefix . 'size_top'} && $settings->{ $prefix . 'size_unit' },
576
- 'props' => array(
577
  $position => $settings->{ $prefix . 'size_top'} . $settings->{ $prefix . 'size_unit' },
578
  ),
579
  ) );
580
 
581
  // Width, Height & Align
582
  $shape_selector = ".fl-node-$id .fl-builder-$position-edge-layer > *";
583
- $shape_align = explode( ' ', $settings->{ $prefix . 'align' } );
584
- $align_y = $shape_align[0];
585
- $align_x = $shape_align[1];
586
- $width = $settings->{ $prefix . 'size_width'};
587
- $height = $settings->{ $prefix . 'size_height' };
588
- $size_unit = $settings->{ $prefix . 'size_unit' };
589
 
590
  // Defaults
591
  $shape_size_rule = array(
592
  'selector' => $shape_selector,
593
- 'enabled' => true,
594
- 'props' => array(),
595
  );
596
- $size_props = array(
597
- 'width' => '100%',
598
- 'left' => 'auto',
599
- 'right' => 'auto',
600
  'height' => 'auto',
601
- 'top' => 'auto',
602
  'bottom' => 'auto',
603
  );
604
 
605
  if ( ! empty( $width ) ) {
606
  $size_props['width'] = $width . $size_unit;
607
- $width_offset = ( $width / 2 ) . $size_unit;
608
 
609
  switch ( $align_x ) {
610
  case 'left':
@@ -621,12 +625,12 @@ class FLBuilderArt {
621
 
622
  $height_offset = '';
623
  if ( ! empty( $height ) ) {
624
- $height_offset = ( $height / 2 ) . $size_unit;
625
  $size_props['height'] = $height . $size_unit;
626
  } elseif ( $width ) {
627
  $view_box_height = $preset['data']['viewBox']['width'];
628
- $implied_height = ( $width / $view_box_height ) * 100;
629
- $height_offset = ( $implied_height / 2 ) . $size_unit;
630
  }
631
 
632
  switch ( $align_y ) {
@@ -635,7 +639,7 @@ class FLBuilderArt {
635
  break;
636
  case 'bottom':
637
  $size_props['bottom'] = '0';
638
- $size_props['top'] = 'auto';
639
  break;
640
  case 'center':
641
  $size_props['top'] = "calc( 50% - $height_offset )";
@@ -647,10 +651,10 @@ class FLBuilderArt {
647
 
648
  // Shape Transforms
649
 
650
- $transforms = $settings->{ $prefix . 'transform' };
651
  $layer_transforms = array();
652
  $shape_transforms = array();
653
- $sign = '';
654
  if ( ! empty( $transforms ) ) {
655
 
656
  foreach ( $transforms as $prop => $value ) {
@@ -681,14 +685,14 @@ class FLBuilderArt {
681
  $value = abs( $value );
682
  }
683
 
684
- $value = $prop . '(' . $value . ')';
685
  $shape_transforms[] = $value;
686
  break;
687
 
688
  case 'translateX':
689
  case 'translateY':
690
  if ( ! empty( $value ) ) {
691
- $value = $prop . '(' . $value . 'px)';
692
  $shape_transforms[] = $value;
693
  }
694
  break;
@@ -710,9 +714,9 @@ class FLBuilderArt {
710
  // Shape Transforms
711
  FLBuilderCSS::rule( array(
712
  'settings' => $settings,
713
- 'enabled' => ! empty( $shape_transforms ),
714
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer > *",
715
- 'props' => array(
716
  'transform' => implode( ' ', $shape_transforms ),
717
  ),
718
  ) );
@@ -724,20 +728,20 @@ class FLBuilderArt {
724
 
725
  case 'color':
726
  FLBuilderCSS::responsive_rule( array(
727
- 'settings' => $settings,
728
  'setting_name' => $prefix . 'fill_color',
729
- 'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
730
- 'prop' => 'fill',
731
  ) );
732
  break;
733
 
734
  case 'gradient':
735
  $gradient_type = $settings->{ $prefix . 'fill_gradient' }['type'];
736
- $gradient_id = "fl-row-$id-$prefix-$gradient_type-gradient";
737
  FLBuilderCSS::rule( array(
738
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape",
739
- 'enabled' => $settings->{ $prefix . 'fill_gradient' },
740
- 'props' => array(
741
  'fill' => 'url(#' . $gradient_id . ')',
742
  ),
743
  ) );
@@ -746,15 +750,15 @@ class FLBuilderArt {
746
  $pattern_id = "fl-row-$id-$prefix-pattern";
747
  FLBuilderCSS::rule( array(
748
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
749
- 'enabled' => true,
750
- 'props' => array(
751
  'fill' => 'url(#' . $pattern_id . ')',
752
  ),
753
  ) );
754
  FLBuilderCSS::rule( array(
755
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer pattern .fl-shape",
756
- 'enabled' => true,
757
- 'props' => array(
758
  'fill' => $settings->{ $prefix . 'fill_pattern_shape_color' },
759
  ),
760
  ) );
@@ -766,10 +770,10 @@ class FLBuilderArt {
766
 
767
  // Shared styles
768
  FLBuilderCSS::responsive_rule( array(
769
- 'settings' => $settings,
770
  'setting_name' => 'container_overflow',
771
- 'selector' => ".fl-node-$id .fl-row-content-wrap",
772
- 'prop' => 'overflow',
773
  ) );
774
  }
775
 
41
  $art_dir = FL_BUILDER_DIR . 'includes/shapes/';
42
 
43
  self::register_shape(array(
44
+ 'label' => __( 'Slanted Edge', 'fl-builder' ),
45
+ 'name' => 'edge-slant',
46
+ 'width' => 422,
47
  'height' => 33.98,
48
  'render' => $art_dir . 'edge-slant.svg.php',
49
  ));
50
 
51
  self::register_shape(array(
52
+ 'label' => __( 'Waves', 'fl-builder' ),
53
+ 'name' => 'wavy',
54
+ 'width' => 800,
55
  'height' => 102,
56
  'render' => $art_dir . 'wavy.svg.php',
57
  ));
58
 
59
  self::register_shape( array(
60
+ 'label' => __( 'Midpoint', 'fl-builder' ),
61
+ 'name' => 'midpoint',
62
+ 'width' => 800,
63
  'height' => 50,
64
  'render' => $art_dir . 'midpoint.svg.php',
65
  ));
66
 
67
  self::register_shape( array(
68
+ 'label' => __( 'Triangle', 'fl-builder' ),
69
+ 'name' => 'triangle',
70
+ 'width' => 50,
71
  'height' => 34,
72
  'render' => $art_dir . 'triangle.svg.php',
73
  ));
74
  self::register_shape( array(
75
+ 'label' => __( 'Circle', 'fl-builder' ),
76
+ 'name' => 'circle',
77
+ 'width' => 100,
78
  'height' => 100,
79
  'render' => $art_dir . 'circle.svg.php',
80
  ));
81
  self::register_shape( array(
82
+ 'label' => __( 'Concave', 'fl-builder' ),
83
+ 'name' => 'concave',
84
+ 'width' => 800,
85
  'height' => 50,
86
  'render' => $art_dir . 'concave.svg.php',
87
  ));
88
  self::register_shape( array(
89
+ 'label' => __( 'Spots', 'fl-builder' ),
90
+ 'name' => 'dot-cluster',
91
+ 'width' => 800,
92
  'height' => 315,
93
  'render' => $art_dir . 'dot-cluster.svg.php',
94
  ));
95
  self::register_shape( array(
96
+ 'label' => __( 'Topography', 'fl-builder' ),
97
+ 'name' => 'topography',
98
+ 'width' => 600,
99
  'height' => 600,
100
  'render' => $art_dir . 'topography.svg.php',
101
  ));
102
  self::register_shape( array(
103
+ 'label' => __( 'Rectangle', 'fl-builder' ),
104
+ 'name' => 'rect',
105
+ 'width' => 800,
106
  'height' => 450,
107
  'render' => $art_dir . 'rect.svg.php',
108
  ));
109
 
110
+ /**
111
+ * Trigger registration process for external shapes.
112
+ * @see fl_register_art
113
+ * @link https://kb.wpbeaverbuilder.com/article/687-add-custom-shape-art
114
+ */
115
  do_action( 'fl_register_art' );
116
  }
117
 
123
  */
124
  static public function register_shape( $args = array() ) {
125
  $defaults = array(
126
+ 'label' => __( 'Untitled Shape', 'fl-builder' ),
127
+ 'name' => 'untitled-shape',
128
+ 'x' => 0,
129
+ 'y' => 0,
130
+ 'width' => 0,
131
+ 'height' => 0,
132
  'preserve_aspect_ratio' => 'none',
133
+ 'render' => '',
134
+ 'preset_settings' => array(),
135
  );
136
 
137
  $args = wp_parse_args( $args, $defaults );
138
+ $key = $args['name'];
139
 
140
  /**
141
  * Setup a preset to reference the shape's initial configuration later
142
  * This is so when you choose a shape, we can also setup other fields for the optimal inital appearance.
143
  */
144
  FLBuilderSettingsPresets::register( 'shape', array(
145
+ 'name' => $args['name'],
146
+ 'label' => $args['label'],
147
  'settings' => $args['preset_settings'],
148
+ 'data' => array(
149
  'viewBox' => array(
150
+ 'x' => $args['x'],
151
+ 'y' => $args['y'],
152
+ 'width' => $args['width'],
153
  'height' => $args['height'],
154
  ),
155
  ),
240
 
241
  if ( ! empty( $settings->{'top_edge_shape'} ) ) {
242
  $layers['top'] = array(
243
+ 'label' => __( 'Top Shape Layer', 'fl-builder' ),
244
+ 'type' => 'shape',
245
+ 'prefix' => 'top_edge_',
246
  'position' => 'top',
247
  );
248
  }
249
  if ( ! empty( $settings->{'bottom_edge_shape'} ) ) {
250
  $layers['bottom'] = array(
251
+ 'label' => __( 'Bottom Shape Layer', 'fl-builder' ),
252
+ 'type' => 'shape',
253
+ 'prefix' => 'bottom_edge_',
254
  'position' => 'bottom',
255
  );
256
  }
298
  */
299
  static public function render_node_shape_layer( $layer, $node ) {
300
 
301
+ $settings = $node->settings;
302
+ $id = $node->node;
303
+ $position = $layer['position'];
304
+ $prefix = $layer['prefix'];
305
  $shape_name = $settings->{ $prefix . 'shape' };
306
  $shape_args = self::get_art( $shape_name );
307
+ $content = self::render_art( $shape_args, $settings );
308
 
309
+ $x = $shape_args['x'];
310
+ $y = $shape_args['y'];
311
+ $width = $shape_args['width'];
312
+ $height = $shape_args['height'];
313
+ $view_box = "$x $y $width $height";
314
  $preserve_aspect_ratio = $shape_args['preserve_aspect_ratio'];
315
 
316
+ $align = $settings->{ $prefix . 'align' };
317
+ $ending = str_replace( ' ', '-', $align );
318
  $svg_class = 'fl-builder-layer-align-' . $ending;
319
  include FL_BUILDER_DIR . 'includes/shape-layer.php';
320
  }
327
  */
328
  static public function get_shape_settings_sections() {
329
  $sections = array();
330
+ $layers = array(
331
+ 'top' => __( 'Top', 'fl-builder' ),
332
  'bottom' => __( 'Bottom', 'fl-builder' ),
333
  );
334
 
337
 
338
  // Preset & Shape Section
339
  $sections[ $prefix . 'shape' ] = array(
340
+ 'title' => sprintf( __( '%s Shape', 'fl-builder' ), $position_label ),
341
  'fields' => array(
342
  $prefix . 'shape' => array(
343
+ 'type' => 'select',
344
+ 'label' => __( 'Shape', 'fl-builder' ),
345
  'options' => 'shapes',
346
+ 'hide' => array(
347
  '' => array(
348
  'sections' => array(
349
  $prefix . 'style',
350
  ),
351
+ 'fields' => array(
352
  $prefix . 'size',
353
  $prefix . 'align',
354
  $prefix . 'z_pos',
356
  ),
357
  ),
358
  'preview' => array(
359
+ 'type' => 'callback',
360
  'callback' => 'previewShape',
361
+ 'prefix' => $prefix,
362
  'position' => $position,
363
  ),
364
  ),
365
+ $prefix . 'size' => array(
366
+ 'type' => 'dimension',
367
+ 'label' => __( 'Size', 'fl-builder' ),
368
+ 'units' => array( 'px', 'vw', 'vh', '%' ),
369
+ 'slider' => array(
370
+ 'width' => array(
371
  'px' => array(
372
+ 'min' => 0,
373
+ 'max' => 5000,
374
  'step' => 10,
375
  ),
376
  'vw' => array(
381
  'min' => 0,
382
  'max' => 500,
383
  ),
384
+ '%' => array(
385
  'min' => 0,
386
  'max' => 300,
387
  ),
388
  ),
389
  'height' => array(
390
  'px' => array(
391
+ 'min' => 0,
392
+ 'max' => 2000,
393
  'step' => 10,
394
  ),
395
  'vw' => array(
400
  'min' => 0,
401
  'max' => 200,
402
  ),
403
+ '%' => array(
404
  'min' => 0,
405
  'max' => 100,
406
  ),
407
  ),
408
+ 'top' => array(
409
  'px' => array(
410
  'min' => -500,
411
  'max' => 500,
418
  'min' => -20,
419
  'max' => 20,
420
  ),
421
+ '%' => array(
422
  'min' => 0,
423
  'max' => 100,
424
  ),
425
  ),
426
  ),
427
+ 'keys' => array(
428
+ 'width' => __( 'Width', 'fl-builder' ),
429
  'height' => __( 'Height', 'fl-builder' ),
430
+ 'top' => __( 'Y Offset', 'fl-builder' ),
431
  ),
432
  'preview' => array(
433
+ 'type' => 'callback',
434
  'callback' => 'previewShapeLayerSize',
435
+ 'prefix' => $prefix,
436
  'position' => $position,
437
  ),
438
  ),
439
  $prefix . 'align' => array(
440
+ 'type' => 'select',
441
+ 'label' => __( 'Align', 'fl-builder' ),
442
  'default' => $position . ' center',
443
  'options' => array(
444
+ 'top left' => __( 'Top Left', 'fl-builder' ),
445
+ 'top center' => __( 'Top Center', 'fl-builder' ),
446
+ 'top right' => __( 'Top Right', 'fl-builder' ),
447
+ 'center left' => __( 'Center Left', 'fl-builder' ),
448
  'center center' => __( 'Center', 'fl-builder' ),
449
+ 'center right' => __( 'Center Right', 'fl-builder' ),
450
+ 'bottom left' => __( 'Bottom Left', 'fl-builder' ),
451
  'bottom center' => __( 'Bottom Center', 'fl-builder' ),
452
+ 'bottom right' => __( 'Bottom Right', 'fl-builder' ),
453
  ),
454
  'preview' => array(
455
+ 'type' => 'callback',
456
  'callback' => 'previewShapeAlign',
457
+ 'prefix' => $prefix,
458
  'selector' => ".fl-builder-$position-edge-layer > *",
459
  ),
460
  ),
463
 
464
  // Shape Styles
465
  $sections[ $prefix . 'style' ] = array(
466
+ 'title' => sprintf( __( '%s Shape Style', 'fl-builder' ), $position_label ),
467
  'fields' => array(
468
+ $prefix . 'fill_style' => array(
469
+ 'type' => 'button-group',
470
  'options' => array(
471
+ 'color' => __( 'Color Fill', 'fl-builder' ),
472
  'gradient' => __( 'Gradient Fill', 'fl-builder' ),
473
  ),
474
  'default' => 'color',
475
  'preview' => array(
476
+ 'type' => 'callback',
477
  'callback' => 'previewShapeFillStyle',
478
  'position' => $position,
479
+ 'prefix' => $prefix,
480
  'selector' => ".fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
481
  ),
482
+ 'toggle' => array(
483
+ 'color' => array(
484
  'fields' => array(
485
+ $prefix . 'fill_color',
486
  ),
487
  ),
488
  'gradient' => array(
489
  'fields' => array(
490
+ $prefix . 'fill_gradient',
491
  ),
492
  ),
493
  ),
494
  ),
495
+ $prefix . 'fill_color' => array(
496
+ 'type' => 'color',
497
+ 'connections' => array( 'color' ),
498
+ 'label' => __( 'Color', 'fl-builder' ),
499
+ 'show_reset' => true,
500
+ 'show_alpha' => true,
501
+ 'responsive' => true,
502
+ 'default' => 'aaa',
503
+ 'preview' => array(
504
+ 'type' => 'css',
505
  'selector' => ".fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
506
  'property' => 'fill',
507
  ),
508
  ),
509
  $prefix . 'fill_gradient' => array(
510
+ 'type' => 'gradient',
511
+ 'label' => __( 'Gradient', 'fl-builder' ),
512
  'default' => '',
513
  'preview' => array(
514
+ 'type' => 'callback',
515
  'callback' => 'previewShapeGradientFill',
516
  'position' => $position,
517
+ 'prefix' => $prefix,
518
  ),
519
  ),
520
 
521
+ $prefix . 'transform' => array(
522
+ 'type' => 'shape-transform',
523
+ 'label' => __( 'Transform', 'fl-builder' ),
524
  'preview' => array(
525
+ 'type' => 'callback',
526
  'callback' => 'previewShapeTransform',
527
  'selector' => ".fl-builder-$position-edge-layer",
528
  'position' => $position,
533
  }
534
 
535
  $sections['shapes_container'] = array(
536
+ 'title' => __( 'Shape Container', 'fl-builder' ),
537
  'fields' => array(
538
  'container_overflow' => array(
539
+ 'type' => 'select',
540
+ 'label' => __( 'Clip Within Container', 'fl-builder' ),
541
  'options' => array(
542
+ '' => __( 'No Clip', 'fl-builder' ),
543
  'hidden' => __( 'Clip Contents', 'fl-builder' ),
544
  ),
545
  'preview' => array(
546
+ 'type' => 'css',
547
  'selector' => '.fl-row-content-wrap',
548
  'property' => 'overflow',
549
  ),
561
  */
562
  static public function render_shape_layers_css( $node ) {
563
  $settings = $node->settings;
564
+ $id = $node->node;
565
 
566
  $layers = array( 'top', 'bottom' );
567
 
571
  if ( ! empty( $settings->{ $prefix . 'shape' } ) ) {
572
 
573
  $shape_name = $settings->{ $prefix . 'shape' };
574
+ $presets = FLBuilderSettingsPresets::get_presets();
575
+ $preset = $presets['shape'][ $shape_name ];
576
 
577
  FLBuilderCSS::rule( array(
578
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer",
579
+ 'enabled' => $settings->{ $prefix . 'size_top'} && $settings->{ $prefix . 'size_unit' },
580
+ 'props' => array(
581
  $position => $settings->{ $prefix . 'size_top'} . $settings->{ $prefix . 'size_unit' },
582
  ),
583
  ) );
584
 
585
  // Width, Height & Align
586
  $shape_selector = ".fl-node-$id .fl-builder-$position-edge-layer > *";
587
+ $shape_align = explode( ' ', $settings->{ $prefix . 'align' } );
588
+ $align_y = $shape_align[0];
589
+ $align_x = $shape_align[1];
590
+ $width = $settings->{ $prefix . 'size_width'};
591
+ $height = $settings->{ $prefix . 'size_height' };
592
+ $size_unit = $settings->{ $prefix . 'size_unit' };
593
 
594
  // Defaults
595
  $shape_size_rule = array(
596
  'selector' => $shape_selector,
597
+ 'enabled' => true,
598
+ 'props' => array(),
599
  );
600
+ $size_props = array(
601
+ 'width' => '100%',
602
+ 'left' => 'auto',
603
+ 'right' => 'auto',
604
  'height' => 'auto',
605
+ 'top' => 'auto',
606
  'bottom' => 'auto',
607
  );
608
 
609
  if ( ! empty( $width ) ) {
610
  $size_props['width'] = $width . $size_unit;
611
+ $width_offset = ( $width / 2 ) . $size_unit;
612
 
613
  switch ( $align_x ) {
614
  case 'left':
625
 
626
  $height_offset = '';
627
  if ( ! empty( $height ) ) {
628
+ $height_offset = ( $height / 2 ) . $size_unit;
629
  $size_props['height'] = $height . $size_unit;
630
  } elseif ( $width ) {
631
  $view_box_height = $preset['data']['viewBox']['width'];
632
+ $implied_height = ( $width / $view_box_height ) * 100;
633
+ $height_offset = ( $implied_height / 2 ) . $size_unit;
634
  }
635
 
636
  switch ( $align_y ) {
639
  break;
640
  case 'bottom':
641
  $size_props['bottom'] = '0';
642
+ $size_props['top'] = 'auto';
643
  break;
644
  case 'center':
645
  $size_props['top'] = "calc( 50% - $height_offset )";
651
 
652
  // Shape Transforms
653
 
654
+ $transforms = $settings->{ $prefix . 'transform' };
655
  $layer_transforms = array();
656
  $shape_transforms = array();
657
+ $sign = '';
658
  if ( ! empty( $transforms ) ) {
659
 
660
  foreach ( $transforms as $prop => $value ) {
685
  $value = abs( $value );
686
  }
687
 
688
+ $value = $prop . '(' . $value . ')';
689
  $shape_transforms[] = $value;
690
  break;
691
 
692
  case 'translateX':
693
  case 'translateY':
694
  if ( ! empty( $value ) ) {
695
+ $value = $prop . '(' . $value . 'px)';
696
  $shape_transforms[] = $value;
697
  }
698
  break;
714
  // Shape Transforms
715
  FLBuilderCSS::rule( array(
716
  'settings' => $settings,
717
+ 'enabled' => ! empty( $shape_transforms ),
718
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer > *",
719
+ 'props' => array(
720
  'transform' => implode( ' ', $shape_transforms ),
721
  ),
722
  ) );
728
 
729
  case 'color':
730
  FLBuilderCSS::responsive_rule( array(
731
+ 'settings' => $settings,
732
  'setting_name' => $prefix . 'fill_color',
733
+ 'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
734
+ 'prop' => 'fill',
735
  ) );
736
  break;
737
 
738
  case 'gradient':
739
  $gradient_type = $settings->{ $prefix . 'fill_gradient' }['type'];
740
+ $gradient_id = "fl-row-$id-$prefix-$gradient_type-gradient";
741
  FLBuilderCSS::rule( array(
742
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape",
743
+ 'enabled' => $settings->{ $prefix . 'fill_gradient' },
744
+ 'props' => array(
745
  'fill' => 'url(#' . $gradient_id . ')',
746
  ),
747
  ) );
750
  $pattern_id = "fl-row-$id-$prefix-pattern";
751
  FLBuilderCSS::rule( array(
752
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer .fl-shape-content .fl-shape",
753
+ 'enabled' => true,
754
+ 'props' => array(
755
  'fill' => 'url(#' . $pattern_id . ')',
756
  ),
757
  ) );
758
  FLBuilderCSS::rule( array(
759
  'selector' => ".fl-node-$id .fl-builder-$position-edge-layer pattern .fl-shape",
760
+ 'enabled' => true,
761
+ 'props' => array(
762
  'fill' => $settings->{ $prefix . 'fill_pattern_shape_color' },
763
  ),
764
  ) );
770
 
771
  // Shared styles
772
  FLBuilderCSS::responsive_rule( array(
773
+ 'settings' => $settings,
774
  'setting_name' => 'container_overflow',
775
+ 'selector' => ".fl-node-$id .fl-row-content-wrap",
776
+ 'prop' => 'overflow',
777
  ) );
778
  }
779
 
classes/class-fl-builder-auto-suggest.php CHANGED
@@ -21,19 +21,19 @@ final class FLBuilderAutoSuggest {
21
 
22
  case 'fl_as_posts':
23
  $data = self::posts();
24
- break;
25
 
26
  case 'fl_as_terms':
27
  $data = self::terms();
28
- break;
29
 
30
  case 'fl_as_users':
31
  $data = self::users();
32
- break;
33
 
34
  case 'fl_as_links':
35
  $data = self::links();
36
- break;
37
  }
38
 
39
  if ( isset( $data ) ) {
@@ -56,23 +56,22 @@ final class FLBuilderAutoSuggest {
56
 
57
  case 'fl_as_posts':
58
  $data = self::posts_value( $value );
59
- break;
60
 
61
  case 'fl_as_terms':
62
  $data = self::terms_value( $value, $data );
63
- break;
64
 
65
  case 'fl_as_users':
66
  $data = self::users_value( $value );
67
- break;
68
-
69
- default :
70
 
 
71
  if ( function_exists( $action . '_value' ) ) {
72
  $data = call_user_func_array( $action . '_value', array( $value, $data ) );
73
  }
74
 
75
- break;
76
  }
77
 
78
  return isset( $data ) ? str_replace( "'", '&#39;', json_encode( $data ) ) : '';
@@ -124,9 +123,9 @@ final class FLBuilderAutoSuggest {
124
  static public function posts() {
125
  global $wpdb;
126
 
127
- $data = array();
128
- $like = self::get_like();
129
- $types = explode( ',', esc_sql( $_REQUEST['fl_as_action_data'] ) );
130
  $types_in = join( "', '", array_map( 'esc_sql', $types ) );
131
 
132
  // @codingStandardsIgnoreStart
@@ -140,7 +139,7 @@ final class FLBuilderAutoSuggest {
140
 
141
  foreach ( $posts as $post ) {
142
  $data[] = array(
143
- 'name' => $post->post_title,
144
  'value' => $post->ID,
145
  );
146
  }
@@ -162,11 +161,11 @@ final class FLBuilderAutoSuggest {
162
 
163
  if ( ! empty( $ids ) ) {
164
 
165
- $order = implode( ',', array_filter( explode( ',', $ids ), 'intval' ) );
166
- $list = explode( ',', $ids );
167
- $how_many = count( $list );
168
  $placeholders = array_fill( 0, $how_many, '%d' );
169
- $format = implode( ', ', $placeholders );
170
 
171
  $query = "SELECT ID, post_title FROM {$wpdb->posts} WHERE ID IN ($format) ORDER BY FIELD(ID, $order)";
172
 
@@ -176,7 +175,7 @@ final class FLBuilderAutoSuggest {
176
 
177
  foreach ( $posts as $post ) {
178
  $data[] = array(
179
- 'name' => $post->post_title,
180
  'value' => $post->ID,
181
  );
182
  }
@@ -195,12 +194,12 @@ final class FLBuilderAutoSuggest {
195
  $data = array();
196
  $cats = get_categories(array(
197
  'hide_empty' => 0,
198
- 'taxonomy' => $_REQUEST['fl_as_action_data'],
199
  ));
200
 
201
  foreach ( $cats as $cat ) {
202
  $data[] = array(
203
- 'name' => $cat->name,
204
  'value' => $cat->term_id,
205
  );
206
  }
@@ -223,13 +222,13 @@ final class FLBuilderAutoSuggest {
223
 
224
  $cats = get_categories(array(
225
  'hide_empty' => 0,
226
- 'taxonomy' => $taxonomy,
227
- 'include' => $ids,
228
  ));
229
 
230
  foreach ( $cats as $cat ) {
231
  $data[] = array(
232
- 'name' => $cat->name,
233
  'value' => $cat->term_id,
234
  );
235
  }
@@ -253,7 +252,7 @@ final class FLBuilderAutoSuggest {
253
 
254
  foreach ( $users as $user ) {
255
  $data[] = array(
256
- 'name' => $user->user_login,
257
  'value' => $user->ID,
258
  );
259
  }
@@ -275,10 +274,10 @@ final class FLBuilderAutoSuggest {
275
 
276
  if ( ! empty( $ids ) ) {
277
 
278
- $list = explode( ',', $ids );
279
- $how_many = count( $list );
280
  $placeholders = array_fill( 0, $how_many, '%d' );
281
- $format = implode( ', ', $placeholders );
282
 
283
  $query = "SELECT * FROM {$wpdb->users} WHERE ID IN ($format)";
284
 
@@ -288,7 +287,7 @@ final class FLBuilderAutoSuggest {
288
 
289
  foreach ( $users as $user ) {
290
  $data[] = array(
291
- 'name' => $user->user_login,
292
  'value' => $user->ID,
293
  );
294
  }
@@ -305,10 +304,10 @@ final class FLBuilderAutoSuggest {
305
  static public function links() {
306
  global $wpdb;
307
 
308
- $data = array();
309
- $like = self::get_like();
310
- $types = FLBuilderLoop::post_types();
311
- $slugs = array();
312
 
313
  foreach ( $types as $slug => $type ) {
314
  $slugs[] = esc_sql( $slug );
@@ -328,7 +327,7 @@ final class FLBuilderAutoSuggest {
328
 
329
  foreach ( $posts as $post ) {
330
  $data[] = array(
331
- 'name' => $post->post_title,
332
  'value' => get_permalink( $post->ID ),
333
  );
334
  }
21
 
22
  case 'fl_as_posts':
23
  $data = self::posts();
24
+ break;
25
 
26
  case 'fl_as_terms':
27
  $data = self::terms();
28
+ break;
29
 
30
  case 'fl_as_users':
31
  $data = self::users();
32
+ break;
33
 
34
  case 'fl_as_links':
35
  $data = self::links();
36
+ break;
37
  }
38
 
39
  if ( isset( $data ) ) {
56
 
57
  case 'fl_as_posts':
58
  $data = self::posts_value( $value );
59
+ break;
60
 
61
  case 'fl_as_terms':
62
  $data = self::terms_value( $value, $data );
63
+ break;
64
 
65
  case 'fl_as_users':
66
  $data = self::users_value( $value );
67
+ break;
 
 
68
 
69
+ default:
70
  if ( function_exists( $action . '_value' ) ) {
71
  $data = call_user_func_array( $action . '_value', array( $value, $data ) );
72
  }
73
 
74
+ break;
75
  }
76
 
77
  return isset( $data ) ? str_replace( "'", '&#39;', json_encode( $data ) ) : '';
123
  static public function posts() {
124
  global $wpdb;
125
 
126
+ $data = array();
127
+ $like = self::get_like();
128
+ $types = explode( ',', esc_sql( $_REQUEST['fl_as_action_data'] ) );
129
  $types_in = join( "', '", array_map( 'esc_sql', $types ) );
130
 
131
  // @codingStandardsIgnoreStart
139
 
140
  foreach ( $posts as $post ) {
141
  $data[] = array(
142
+ 'name' => $post->post_title,
143
  'value' => $post->ID,
144
  );
145
  }
161
 
162
  if ( ! empty( $ids ) ) {
163
 
164
+ $order = implode( ',', array_filter( explode( ',', $ids ), 'intval' ) );
165
+ $list = explode( ',', $ids );
166
+ $how_many = count( $list );
167
  $placeholders = array_fill( 0, $how_many, '%d' );
168
+ $format = implode( ', ', $placeholders );
169
 
170
  $query = "SELECT ID, post_title FROM {$wpdb->posts} WHERE ID IN ($format) ORDER BY FIELD(ID, $order)";
171
 
175
 
176
  foreach ( $posts as $post ) {
177
  $data[] = array(
178
+ 'name' => $post->post_title,
179
  'value' => $post->ID,
180
  );
181
  }
194
  $data = array();
195
  $cats = get_categories(array(
196
  'hide_empty' => 0,
197
+ 'taxonomy' => $_REQUEST['fl_as_action_data'],
198
  ));
199
 
200
  foreach ( $cats as $cat ) {
201
  $data[] = array(
202
+ 'name' => $cat->name,
203
  'value' => $cat->term_id,
204
  );
205
  }
222
 
223
  $cats = get_categories(array(
224
  'hide_empty' => 0,
225
+ 'taxonomy' => $taxonomy,
226
+ 'include' => $ids,
227
  ));
228
 
229
  foreach ( $cats as $cat ) {
230
  $data[] = array(
231
+ 'name' => $cat->name,
232
  'value' => $cat->term_id,
233
  );
234
  }
252
 
253
  foreach ( $users as $user ) {
254
  $data[] = array(
255
+ 'name' => $user->user_login,
256
  'value' => $user->ID,
257
  );
258
  }
274
 
275
  if ( ! empty( $ids ) ) {
276
 
277
+ $list = explode( ',', $ids );
278
+ $how_many = count( $list );
279
  $placeholders = array_fill( 0, $how_many, '%d' );
280
+ $format = implode( ', ', $placeholders );
281
 
282
  $query = "SELECT * FROM {$wpdb->users} WHERE ID IN ($format)";
283
 
287
 
288
  foreach ( $users as $user ) {
289
  $data[] = array(
290
+ 'name' => $user->user_login,
291
  'value' => $user->ID,
292
  );
293
  }
304
  static public function links() {
305
  global $wpdb;
306
 
307
+ $data = array();
308
+ $like = self::get_like();
309
+ $types = FLBuilderLoop::post_types();
310
+ $slugs = array();
311
 
312
  foreach ( $types as $slug => $type ) {
313
  $slugs[] = esc_sql( $slug );
327
 
328
  foreach ( $posts as $post ) {
329
  $data[] = array(
330
+ 'name' => $post->post_title,
331
  'value' => get_permalink( $post->ID ),
332
  );
333
  }
classes/class-fl-builder-color.php CHANGED
@@ -63,15 +63,15 @@ final class FLBuilderColor {
63
  // Get rgb vars.
64
  if ( $is_rgb ) {
65
  $rgb = explode( ',', preg_replace( '/[a-z\(\)]/', '', $value ) );
66
- $r = $rgb[0];
67
- $g = $rgb[1];
68
- $b = $rgb[2];
69
- $a = count( $rgb ) > 3 ? $rgb[3] : false;
70
  } else {
71
  $rgb = self::hex_to_rgb( $value );
72
- $r = $rgb['r'];
73
- $g = $rgb['g'];
74
- $b = $rgb['b'];
75
  }
76
 
77
  // Should we darken the color?
@@ -83,9 +83,9 @@ final class FLBuilderColor {
83
 
84
  // Adjustr the rgb values.
85
  $steps = max( -255, min( 255, $steps ) );
86
- $r = max( 0, min( 255, $r + $steps ) );
87
- $g = max( 0, min( 255, $g + $steps ) );
88
- $b = max( 0, min( 255, $b + $steps ) );
89
 
90
  // Return the adjusted color value.
91
  if ( $is_rgb ) {
@@ -110,7 +110,7 @@ final class FLBuilderColor {
110
  */
111
  static public function gradient( $setting ) {
112
  $gradient = '';
113
- $values = array();
114
 
115
  if ( ! is_array( $setting ) ) {
116
  return $gradient;
@@ -175,7 +175,7 @@ final class FLBuilderColor {
175
  $setting['color'] = '#' . $setting['color'];
176
  }
177
 
178
- $shadow = $setting['horizontal'] . 'px ';
179
  $shadow .= $setting['vertical'] . 'px ';
180
  $shadow .= $setting['blur'] . 'px ';
181
 
@@ -202,25 +202,25 @@ final class FLBuilderColor {
202
  // Get rgb vars.
203
  if ( $is_rgb ) {
204
  $rgb = explode( ',', preg_replace( '/[a-z\(\)]/', '', $value ) );
205
- $r = $rgb[0];
206
- $g = $rgb[1];
207
- $b = $rgb[2];
208
- $a = count( $rgb ) > 3 ? $rgb[3] : false;
209
  } else {
210
  $rgb = self::hex_to_rgb( $value );
211
- $r = $rgb['r'];
212
- $g = $rgb['g'];
213
- $b = $rgb['b'];
214
- $a = 1;
215
  }
216
  if ( count( $rgb ) === 4 ) {
217
  $rgb = array_slice( $rgb, 0, 3 );
218
  }
219
  return array(
220
- 'r' => $r,
221
- 'g' => $g,
222
- 'b' => $b,
223
- 'a' => $a,
224
  'rgb' => 'rgb(' . implode( ',', $rgb ) . ')',
225
  );
226
  }
63
  // Get rgb vars.
64
  if ( $is_rgb ) {
65
  $rgb = explode( ',', preg_replace( '/[a-z\(\)]/', '', $value ) );
66
+ $r = $rgb[0];
67
+ $g = $rgb[1];
68
+ $b = $rgb[2];
69
+ $a = count( $rgb ) > 3 ? $rgb[3] : false;
70
  } else {
71
  $rgb = self::hex_to_rgb( $value );
72
+ $r = $rgb['r'];
73
+ $g = $rgb['g'];
74
+ $b = $rgb['b'];
75
  }
76
 
77
  // Should we darken the color?
83
 
84
  // Adjustr the rgb values.
85
  $steps = max( -255, min( 255, $steps ) );
86
+ $r = max( 0, min( 255, $r + $steps ) );
87
+ $g = max( 0, min( 255, $g + $steps ) );
88
+ $b = max( 0, min( 255, $b + $steps ) );
89
 
90
  // Return the adjusted color value.
91
  if ( $is_rgb ) {
110
  */
111
  static public function gradient( $setting ) {
112
  $gradient = '';
113
+ $values = array();
114
 
115
  if ( ! is_array( $setting ) ) {
116
  return $gradient;