Version Description
Download this release
Release Info
Developer | justinbusa |
Plugin | WordPress Page Builder – Beaver Builder |
Version | 1.4.6 |
Comparing to | |
See all releases |
Code changes from version 1.4.5 to 1.4.6
- changelog.txt +19 -0
- classes/class-fl-builder-admin-settings.php +399 -61
- classes/class-fl-builder-admin.php +24 -25
- classes/class-fl-builder-icons.php +263 -17
- classes/class-fl-builder-model.php +168 -32
- classes/class-fl-builder-module.php +0 -1
- classes/class-fl-builder-update.php +23 -0
- classes/class-fl-builder-utils.php +30 -14
- classes/class-fl-builder.php +84 -53
- css/fl-builder-admin-settings.css +3 -132
- css/fl-builder.css +11 -4
- css/fl-lightbox.css +1 -1
- fl-builder.php +9 -9
- includes/admin-settings-editing.php +26 -0
- includes/admin-settings-js-config.php +8 -0
- includes/admin-settings-modules.php +47 -0
- includes/admin-settings-post-types.php +74 -0
- includes/admin-settings-uninstall.php +19 -0
- includes/admin-settings-upgrade.php +11 -0
- includes/admin-settings.php +8 -270
- includes/column-group.php +4 -4
- includes/column-settings.php +98 -90
- includes/field-form.php +21 -10
- includes/field.php +2 -2
- includes/js-config.php +50 -47
- includes/module-settings.php +43 -30
- includes/module.php +1 -1
- includes/row-settings.php +43 -30
- includes/row.php +5 -5
- includes/updater-config.php +1 -1
- includes/updater/includes/form.php +2 -2
- js/fl-builder-admin-settings.js +52 -1
- js/fl-builder-preview.js +4 -1
- js/fl-builder.js +134 -23
- languages/fr_FR.mo +0 -0
- languages/fr_FR.po +3480 -0
- languages/it_IT.mo +0 -0
- languages/it_IT.po +4392 -0
- languages/pt_BR.mo +0 -0
- languages/pt_BR.po +4152 -0
- languages/sk_SK.mo +0 -0
- languages/sk_SK.po +589 -444
- languages/xx_XX.mo +0 -0
- languages/xx_XX.pot +482 -379
- readme.txt +8 -8
changelog.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<h4>1.4.5 - 01/26/2015</h4>
|
2 |
<p><strong>Enhancements</strong></p>
|
3 |
<ul>
|
1 |
+
<h4>1.4.6 - 02/15/2015</h4>
|
2 |
+
<p><strong>Enhancements</strong></p>
|
3 |
+
<ul>
|
4 |
+
<li>Added the ability to upload Icomoon and Fontello font icons under Settings > Page Builder > Icons.</li>
|
5 |
+
<li>Added the ability to disable core font icons.</li>
|
6 |
+
<li>Added an ID field to row, column and module settings.</li>
|
7 |
+
<li>Added French translation.</li>
|
8 |
+
<li>Added Itailian translation.</li>
|
9 |
+
<li>Added fl_builder_upgrade_url filter. This filter can be used by theme developers to add their affiliate link to the upgrade buttons in the lite version.</li>
|
10 |
+
<li>Added fl_builder_settings_form_defaults filter for overriding default form settings.</li>
|
11 |
+
<li>Enhanced SSL check for servers behind load balancers.</li>
|
12 |
+
<li>Single repeater fields can now be duplicated.</li>
|
13 |
+
</ul>
|
14 |
+
<p><strong>Bug Fixes</strong></p>
|
15 |
+
<ul>
|
16 |
+
<li>Row text color no longer overrides heading text color.</li>
|
17 |
+
<li>Preview text for form fields now shows the option label for select inputs instead of the option value.</li>
|
18 |
+
</ul>
|
19 |
+
|
20 |
<h4>1.4.5 - 01/26/2015</h4>
|
21 |
<p><strong>Enhancements</strong></p>
|
22 |
<ul>
|
classes/class-fl-builder-admin-settings.php
CHANGED
@@ -6,6 +6,11 @@
|
|
6 |
* @class FLBuilderAdminSettings
|
7 |
*/
|
8 |
final class FLBuilderAdminSettings {
|
|
|
|
|
|
|
|
|
|
|
9 |
|
10 |
/**
|
11 |
* @method init
|
@@ -30,6 +35,9 @@ final class FLBuilderAdminSettings {
|
|
30 |
|
31 |
// Scripts
|
32 |
wp_enqueue_script('fl-builder-admin-settings', FL_BUILDER_URL . 'js/fl-builder-admin-settings.js', array(), FL_BUILDER_VERSION);
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
@@ -53,131 +61,461 @@ final class FLBuilderAdminSettings {
|
|
53 |
*/
|
54 |
static public function render()
|
55 |
{
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
/**
|
62 |
* @method save
|
63 |
-
* @private
|
64 |
*/
|
65 |
-
static
|
66 |
{
|
67 |
// Only admins can save settings.
|
68 |
if(!current_user_can('delete_plugins')) {
|
69 |
return;
|
70 |
}
|
71 |
|
72 |
-
self::
|
73 |
-
self::
|
74 |
-
self::
|
75 |
-
self::
|
76 |
-
self::
|
|
|
77 |
self::uninstall();
|
78 |
}
|
79 |
|
80 |
/**
|
81 |
-
* @method
|
82 |
* @private
|
83 |
*/
|
84 |
-
static private function
|
85 |
{
|
86 |
-
$modules
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
89 |
|
90 |
-
|
91 |
-
|
|
|
|
|
|
|
92 |
}
|
93 |
else {
|
94 |
-
|
95 |
-
if(is_array($_POST['fl-modules'])) {
|
96 |
-
$modules = array_map('sanitize_text_field', $_POST['fl-modules']);
|
97 |
-
}
|
98 |
-
|
99 |
-
update_option('_fl_builder_enabled_modules', $modules);
|
100 |
}
|
101 |
}
|
102 |
}
|
103 |
|
104 |
/**
|
105 |
-
* @method
|
106 |
* @private
|
107 |
*/
|
108 |
-
static private function
|
109 |
{
|
110 |
-
if(isset($_POST['fl-templates-nonce']) && wp_verify_nonce($_POST['fl-templates-nonce'], 'templates')) {
|
|
|
|
|
111 |
|
112 |
-
|
113 |
-
|
|
|
|
|
|
|
114 |
}
|
115 |
else {
|
116 |
-
|
117 |
-
$enabled_templates = sanitize_text_field($_POST['fl-template-settings']);
|
118 |
-
|
119 |
-
update_option('_fl_builder_enabled_templates', $enabled_templates);
|
120 |
}
|
121 |
}
|
122 |
}
|
123 |
|
124 |
/**
|
125 |
-
* @method
|
126 |
* @private
|
127 |
*/
|
128 |
-
static private function
|
129 |
{
|
130 |
-
$
|
131 |
-
|
132 |
-
if(isset($_POST['fl-post-types-nonce']) && wp_verify_nonce($_POST['fl-post-types-nonce'], 'post-types')) {
|
133 |
|
134 |
-
|
135 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
}
|
137 |
else {
|
|
|
|
|
138 |
|
139 |
-
if(is_array($_POST['fl-post-types'])) {
|
140 |
-
$post_types = array_map('sanitize_text_field', $_POST['fl-post-types']);
|
141 |
}
|
142 |
|
143 |
-
update_option('_fl_builder_post_types', $post_types);
|
144 |
}
|
145 |
}
|
146 |
}
|
147 |
|
148 |
/**
|
149 |
-
* @method
|
150 |
* @private
|
151 |
*/
|
152 |
-
static private function
|
153 |
{
|
154 |
-
if(isset($_POST['fl-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
|
156 |
-
|
157 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
}
|
159 |
else {
|
160 |
-
|
161 |
-
$capability = sanitize_text_field($_POST['fl-editing-capability']);
|
162 |
-
|
163 |
-
update_option('_fl_builder_editing_capability', $capability);
|
164 |
}
|
165 |
}
|
166 |
}
|
167 |
|
168 |
/**
|
169 |
-
* @method
|
170 |
* @private
|
171 |
*/
|
172 |
-
static private function
|
173 |
{
|
174 |
-
if(isset($_POST['fl-branding-nonce']) && wp_verify_nonce($_POST['fl-branding-nonce'], 'branding')) {
|
175 |
|
176 |
-
$branding = wp_kses_post($_POST['fl-branding']);
|
177 |
-
$branding_icon = sanitize_text_field($_POST['fl-branding-icon']);
|
178 |
|
179 |
-
|
180 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
181 |
}
|
182 |
}
|
183 |
|
@@ -187,15 +525,15 @@ final class FLBuilderAdminSettings {
|
|
187 |
*/
|
188 |
static private function uninstall()
|
189 |
{
|
190 |
-
if(!current_user_can('delete_plugins')) {
|
191 |
return;
|
192 |
}
|
193 |
-
else if(isset($_POST['fl-uninstall']) && wp_verify_nonce($_POST['fl-uninstall'], 'uninstall')) {
|
194 |
-
if(is_multisite() && class_exists('FLBuilderMultisite')) {
|
195 |
FLBuilderMultisite::uninstall();
|
196 |
}
|
197 |
else {
|
198 |
-
|
199 |
}
|
200 |
}
|
201 |
}
|
6 |
* @class FLBuilderAdminSettings
|
7 |
*/
|
8 |
final class FLBuilderAdminSettings {
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @property $errors
|
12 |
+
*/
|
13 |
+
static public $errors = array();
|
14 |
|
15 |
/**
|
16 |
* @method init
|
35 |
|
36 |
// Scripts
|
37 |
wp_enqueue_script('fl-builder-admin-settings', FL_BUILDER_URL . 'js/fl-builder-admin-settings.js', array(), FL_BUILDER_VERSION);
|
38 |
+
|
39 |
+
// Media Uploader
|
40 |
+
wp_enqueue_media();
|
41 |
}
|
42 |
|
43 |
/**
|
61 |
*/
|
62 |
static public function render()
|
63 |
{
|
64 |
+
include FL_BUILDER_DIR . 'includes/admin-settings-js-config.php';
|
65 |
+
include FL_BUILDER_DIR . 'includes/admin-settings.php';
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* @method render_page_class
|
70 |
+
*/
|
71 |
+
static public function render_page_class()
|
72 |
+
{
|
73 |
+
if ( self::multisite_support() ) {
|
74 |
+
echo 'fl-settings-network-admin';
|
75 |
+
}
|
76 |
+
else {
|
77 |
+
echo 'fl-settings-single-install';
|
78 |
+
}
|
79 |
+
}
|
80 |
+
|
81 |
+
/**
|
82 |
+
* @method render_page_heading
|
83 |
+
*/
|
84 |
+
static public function render_page_heading()
|
85 |
+
{
|
86 |
+
$icon = FLBuilderModel::get_branding_icon();
|
87 |
+
$name = FLBuilderModel::get_branding();
|
88 |
+
|
89 |
+
if ( ! empty( $icon ) ) {
|
90 |
+
echo '<img src="' . $icon . '" />';
|
91 |
+
}
|
92 |
+
|
93 |
+
echo '<span>' . sprintf( _x( '%s Settings', '%s stands for custom branded "Page Builder" name.', 'fl-builder' ), FLBuilderModel::get_branding() ) . '</span>';
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* @method render_update_message
|
98 |
+
*/
|
99 |
+
static public function render_update_message()
|
100 |
+
{
|
101 |
+
if ( ! empty( self::$errors ) ) {
|
102 |
+
foreach ( self::$errors as $message ) {
|
103 |
+
echo '<div class="error"><p>' . $message . '</p></div>';
|
104 |
+
}
|
105 |
+
}
|
106 |
+
else if( ! empty( $_POST ) && ! isset( $_POST['email'] ) ) {
|
107 |
+
echo '<div class="updated"><p>' . __( 'Settings updated!', 'fl-builder' ) . '</p></div>';
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
/**
|
112 |
+
* @method render_nav_items
|
113 |
+
*/
|
114 |
+
static public function render_nav_items()
|
115 |
+
{
|
116 |
+
$item_data = array(
|
117 |
+
'license' => array(
|
118 |
+
'title' => __( 'License', 'fl-builder' ),
|
119 |
+
'show' => FL_BUILDER_LITE !== true && ( is_network_admin() || ! self::multisite_support() )
|
120 |
+
),
|
121 |
+
'upgrade' => array(
|
122 |
+
'title' => __( 'Upgrade', 'fl-builder' ),
|
123 |
+
'show' => FL_BUILDER_LITE === true
|
124 |
+
),
|
125 |
+
'modules' => array(
|
126 |
+
'title' => __( 'Modules', 'fl-builder' ),
|
127 |
+
'show' => true
|
128 |
+
),
|
129 |
+
'templates' => array(
|
130 |
+
'title' => __( 'Templates', 'fl-builder' ),
|
131 |
+
'show' => FL_BUILDER_LITE !== true
|
132 |
+
),
|
133 |
+
'post-types' => array(
|
134 |
+
'title' => __( 'Post Types', 'fl-builder' ),
|
135 |
+
'show' => true
|
136 |
+
),
|
137 |
+
'icons' => array(
|
138 |
+
'title' => __( 'Icons', 'fl-builder' ),
|
139 |
+
'show' => FL_BUILDER_LITE !== true
|
140 |
+
),
|
141 |
+
'editing' => array(
|
142 |
+
'title' => __( 'Editing', 'fl-builder' ),
|
143 |
+
'show' => true
|
144 |
+
),
|
145 |
+
'branding' => array(
|
146 |
+
'title' => __( 'Branding', 'fl-builder' ),
|
147 |
+
'show' => self::has_support( 'branding' ) && ( is_network_admin() || ! self::multisite_support() )
|
148 |
+
),
|
149 |
+
'uninstall' => array(
|
150 |
+
'title' => __( 'Uninstall', 'fl-builder' ),
|
151 |
+
'show' => is_network_admin() || ! self::multisite_support()
|
152 |
+
),
|
153 |
+
);
|
154 |
+
|
155 |
+
foreach ( $item_data as $key => $data ) {
|
156 |
+
if ( $data['show'] ) {
|
157 |
+
echo '<li><a href="#' . $key . '">' . $data['title'] . '</a></li>';
|
158 |
+
}
|
159 |
+
}
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* @method render_forms
|
164 |
+
*/
|
165 |
+
static public function render_forms()
|
166 |
+
{
|
167 |
+
// License
|
168 |
+
if ( is_network_admin() || ! self::multisite_support() ) {
|
169 |
+
self::render_form( 'license' );
|
170 |
+
}
|
171 |
+
|
172 |
+
// Upgrade
|
173 |
+
if ( FL_BUILDER_LITE === true ) {
|
174 |
+
self::render_form( 'upgrade' );
|
175 |
+
}
|
176 |
+
|
177 |
+
// Modules
|
178 |
+
self::render_form( 'modules' );
|
179 |
+
|
180 |
+
// Templates
|
181 |
+
self::render_form( 'templates' );
|
182 |
+
|
183 |
+
// Post Types
|
184 |
+
self::render_form( 'post-types' );
|
185 |
+
|
186 |
+
// Icons
|
187 |
+
self::render_form( 'icons' );
|
188 |
+
|
189 |
+
// Editing
|
190 |
+
self::render_form( 'editing' );
|
191 |
+
|
192 |
+
// Branding
|
193 |
+
self::render_form( 'branding' );
|
194 |
+
|
195 |
+
// Uninstall
|
196 |
+
self::render_form( 'uninstall' );
|
197 |
+
}
|
198 |
+
|
199 |
+
/**
|
200 |
+
* @method render_form
|
201 |
+
*/
|
202 |
+
static public function render_form( $type )
|
203 |
+
{
|
204 |
+
if ( self::has_support( $type ) ) {
|
205 |
+
include FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php';
|
206 |
+
}
|
207 |
+
}
|
208 |
+
|
209 |
+
/**
|
210 |
+
* @method render_form_action
|
211 |
+
*/
|
212 |
+
static public function render_form_action( $type = '' )
|
213 |
+
{
|
214 |
+
if ( is_network_admin() ) {
|
215 |
+
echo network_admin_url( '/settings.php?page=fl-builder-multisite-settings#' . $type );
|
216 |
+
}
|
217 |
+
else {
|
218 |
+
echo admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
219 |
+
}
|
220 |
+
}
|
221 |
+
|
222 |
+
/**
|
223 |
+
* @method get_form_action
|
224 |
+
*/
|
225 |
+
static public function get_form_action( $type = '' )
|
226 |
+
{
|
227 |
+
if ( is_network_admin() ) {
|
228 |
+
return network_admin_url( '/settings.php?page=fl-builder-multisite-settings#' . $type );
|
229 |
+
}
|
230 |
+
else {
|
231 |
+
return admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
232 |
}
|
233 |
}
|
234 |
|
235 |
+
/**
|
236 |
+
* @method supports
|
237 |
+
*/
|
238 |
+
static public function has_support( $type )
|
239 |
+
{
|
240 |
+
return file_exists( FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php' );
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @method multisite_support
|
245 |
+
*/
|
246 |
+
static public function multisite_support()
|
247 |
+
{
|
248 |
+
return is_multisite() && class_exists( 'FLBuilderMultisiteSettings' );
|
249 |
+
}
|
250 |
+
|
251 |
+
/**
|
252 |
+
* @method add_error
|
253 |
+
*/
|
254 |
+
static public function add_error( $message )
|
255 |
+
{
|
256 |
+
self::$errors[] = $message;
|
257 |
+
}
|
258 |
+
|
259 |
/**
|
260 |
* @method save
|
|
|
261 |
*/
|
262 |
+
static public function save()
|
263 |
{
|
264 |
// Only admins can save settings.
|
265 |
if(!current_user_can('delete_plugins')) {
|
266 |
return;
|
267 |
}
|
268 |
|
269 |
+
self::save_enabled_modules();
|
270 |
+
self::save_enabled_templates();
|
271 |
+
self::save_enabled_post_types();
|
272 |
+
self::save_enabled_icons();
|
273 |
+
self::save_editing_capability();
|
274 |
+
self::save_branding();
|
275 |
self::uninstall();
|
276 |
}
|
277 |
|
278 |
/**
|
279 |
+
* @method save_enabled_modules
|
280 |
* @private
|
281 |
*/
|
282 |
+
static private function save_enabled_modules()
|
283 |
{
|
284 |
+
if ( isset( $_POST['fl-modules-nonce'] ) && wp_verify_nonce( $_POST['fl-modules-nonce'], 'modules' ) ) {
|
285 |
+
|
286 |
+
$modules = array();
|
287 |
+
|
288 |
+
if ( is_array( $_POST['fl-modules'] ) ) {
|
289 |
+
$modules = array_map( 'sanitize_text_field', $_POST['fl-modules'] );
|
290 |
+
}
|
291 |
|
292 |
+
if ( is_network_admin() ) {
|
293 |
+
update_site_option( '_fl_builder_enabled_modules', $modules );
|
294 |
+
}
|
295 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
296 |
+
delete_option( '_fl_builder_enabled_modules' );
|
297 |
}
|
298 |
else {
|
299 |
+
update_option( '_fl_builder_enabled_modules', $modules );
|
|
|
|
|
|
|
|
|
|
|
300 |
}
|
301 |
}
|
302 |
}
|
303 |
|
304 |
/**
|
305 |
+
* @method save_enabled_templates
|
306 |
* @private
|
307 |
*/
|
308 |
+
static private function save_enabled_templates()
|
309 |
{
|
310 |
+
if ( isset( $_POST['fl-templates-nonce'] ) && wp_verify_nonce( $_POST['fl-templates-nonce'], 'templates' ) ) {
|
311 |
+
|
312 |
+
$enabled_templates = sanitize_text_field( $_POST['fl-template-settings'] );
|
313 |
|
314 |
+
if ( is_network_admin() ) {
|
315 |
+
update_site_option( '_fl_builder_enabled_templates', $enabled_templates );
|
316 |
+
}
|
317 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
318 |
+
delete_option( '_fl_builder_enabled_templates' );
|
319 |
}
|
320 |
else {
|
321 |
+
update_option( '_fl_builder_enabled_templates', $enabled_templates );
|
|
|
|
|
|
|
322 |
}
|
323 |
}
|
324 |
}
|
325 |
|
326 |
/**
|
327 |
+
* @method save_enabled_post_types
|
328 |
* @private
|
329 |
*/
|
330 |
+
static private function save_enabled_post_types()
|
331 |
{
|
332 |
+
if ( isset( $_POST['fl-post-types-nonce'] ) && wp_verify_nonce( $_POST['fl-post-types-nonce'], 'post-types' ) ) {
|
|
|
|
|
333 |
|
334 |
+
if ( is_network_admin() ) {
|
335 |
+
|
336 |
+
$post_types = sanitize_text_field( $_POST['fl-post-types'] );
|
337 |
+
$post_types = str_replace( ' ', '', $post_types );
|
338 |
+
$post_types = explode( ',', $post_types );
|
339 |
+
|
340 |
+
update_site_option( '_fl_builder_post_types', $post_types );
|
341 |
+
}
|
342 |
+
else if ( self::multisite_support() && ! isset($_POST['fl-override-ms'] ) ) {
|
343 |
+
delete_option( '_fl_builder_post_types' );
|
344 |
}
|
345 |
else {
|
346 |
+
|
347 |
+
$post_types = array();
|
348 |
|
349 |
+
if ( is_array( $_POST['fl-post-types'] ) ) {
|
350 |
+
$post_types = array_map( 'sanitize_text_field', $_POST['fl-post-types'] );
|
351 |
}
|
352 |
|
353 |
+
update_option( '_fl_builder_post_types', $post_types );
|
354 |
}
|
355 |
}
|
356 |
}
|
357 |
|
358 |
/**
|
359 |
+
* @method save_enabled_icons
|
360 |
* @private
|
361 |
*/
|
362 |
+
static private function save_enabled_icons()
|
363 |
{
|
364 |
+
if ( isset( $_POST['fl-icons-nonce'] ) && wp_verify_nonce( $_POST['fl-icons-nonce'], 'icons' ) ) {
|
365 |
+
|
366 |
+
// Make sure we have at least one enabled icon set.
|
367 |
+
if ( ! isset( $_POST['fl-enabled-icons'] ) && empty( $_POST['fl-new-icon-set'] ) ) {
|
368 |
+
self::add_error( __( "Error! You must have at least one icon set enabled.", 'fl-builder' ) );
|
369 |
+
return;
|
370 |
+
}
|
371 |
+
|
372 |
+
$filesystem = FLBuilderUtils::get_filesystem();
|
373 |
+
$enabled_icons = array();
|
374 |
+
|
375 |
+
// Sanitize the enabled icons.
|
376 |
+
if ( isset( $_POST['fl-enabled-icons'] ) && is_array( $_POST['fl-enabled-icons'] ) ) {
|
377 |
+
$enabled_icons = array_map( 'sanitize_text_field', $_POST['fl-enabled-icons'] );
|
378 |
+
}
|
379 |
+
|
380 |
+
// Update the enabled sets.
|
381 |
+
self::update_enabled_icons( $enabled_icons );
|
382 |
|
383 |
+
// Delete a set?
|
384 |
+
if ( ! empty( $_POST['fl-delete-icon-set'] ) ) {
|
385 |
+
|
386 |
+
$sets = FLBuilderIcons::get_sets();
|
387 |
+
$key = sanitize_text_field( $_POST['fl-delete-icon-set'] );
|
388 |
+
$index = array_search( $key, $enabled_icons );
|
389 |
+
|
390 |
+
if ( false !== $index ) {
|
391 |
+
unset( $enabled_icons[ $index ] );
|
392 |
+
}
|
393 |
+
if ( isset( $sets[ $key ] ) ) {
|
394 |
+
$filesystem->rmdir( $sets[ $key ]['path'], true );
|
395 |
+
FLBuilderIcons::remove_set( $key );
|
396 |
+
}
|
397 |
+
}
|
398 |
+
|
399 |
+
// Upload a new set?
|
400 |
+
if ( ! empty( $_POST['fl-new-icon-set'] ) ) {
|
401 |
+
|
402 |
+
$dir = FLBuilderModel::get_cache_dir( 'icons' );
|
403 |
+
$id = (int) $_POST['fl-new-icon-set'];
|
404 |
+
$path = get_attached_file( $id );
|
405 |
+
$new_path = $dir['path'] . 'icon-' . time() . '/';
|
406 |
+
$unzipped = unzip_file( $path, $new_path );
|
407 |
+
|
408 |
+
// Unzip failed.
|
409 |
+
if ( ! $unzipped ) {
|
410 |
+
self::add_error( __( "Error! Could not unzip file.", 'fl-builder' ) );
|
411 |
+
return;
|
412 |
+
}
|
413 |
+
|
414 |
+
// Move files if unzipped into a subfolder.
|
415 |
+
$files = $filesystem->dirlist( $new_path );
|
416 |
+
|
417 |
+
if ( 1 == count( $files ) ) {
|
418 |
+
|
419 |
+
$values = array_values( $files );
|
420 |
+
$subfolder_info = array_shift( $values );
|
421 |
+
$subfolder = $new_path . $subfolder_info['name'] . '/';
|
422 |
+
|
423 |
+
if ( file_exists( $subfolder ) && is_dir( $subfolder ) ) {
|
424 |
+
|
425 |
+
$files = $filesystem->dirlist( $subfolder );
|
426 |
+
|
427 |
+
if ( $files ) {
|
428 |
+
foreach ( $files as $file ) {
|
429 |
+
$filesystem->move( $subfolder . $file['name'], $new_path . $file['name'] );
|
430 |
+
}
|
431 |
+
}
|
432 |
+
|
433 |
+
$filesystem->rmdir( $subfolder );
|
434 |
+
}
|
435 |
+
}
|
436 |
+
|
437 |
+
// Check for supported sets.
|
438 |
+
$is_icomoon = file_exists( $new_path . 'selection.json' );
|
439 |
+
$is_fontello = file_exists( $new_path . 'config.json' );
|
440 |
+
|
441 |
+
// Show an error if we don't have a supported icon set.
|
442 |
+
if ( ! $is_icomoon && ! $is_fontello ) {
|
443 |
+
$filesystem->rmdir( $new_path, true );
|
444 |
+
self::add_error( __( "Error! Please upload an icon set from either Icomoon or Fontello.", 'fl-builder' ) );
|
445 |
+
return;
|
446 |
+
}
|
447 |
+
|
448 |
+
// Enable the new set.
|
449 |
+
if ( is_array( $enabled_icons ) ) {
|
450 |
+
$key = FLBuilderIcons::get_key_from_path( $new_path );
|
451 |
+
$enabled_icons[] = $key;
|
452 |
+
}
|
453 |
+
}
|
454 |
+
|
455 |
+
// Update the enabled sets again in case they have changed.
|
456 |
+
self::update_enabled_icons( $enabled_icons );
|
457 |
+
}
|
458 |
+
}
|
459 |
+
|
460 |
+
/**
|
461 |
+
* @method update_enabled_icons
|
462 |
+
* @private
|
463 |
+
*/
|
464 |
+
static private function update_enabled_icons( $enabled_icons = array() )
|
465 |
+
{
|
466 |
+
if ( is_network_admin() ) {
|
467 |
+
update_site_option( '_fl_builder_enabled_icons', $enabled_icons );
|
468 |
+
update_option( '_fl_builder_enabled_icons', $enabled_icons );
|
469 |
+
}
|
470 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
471 |
+
delete_option( '_fl_builder_enabled_icons' );
|
472 |
+
}
|
473 |
+
else {
|
474 |
+
update_option( '_fl_builder_enabled_icons', $enabled_icons );
|
475 |
+
}
|
476 |
+
}
|
477 |
+
|
478 |
+
/**
|
479 |
+
* @method save_editing_capability
|
480 |
+
* @private
|
481 |
+
*/
|
482 |
+
static private function save_editing_capability()
|
483 |
+
{
|
484 |
+
if ( isset( $_POST['fl-editing-nonce'] ) && wp_verify_nonce( $_POST['fl-editing-nonce'], 'editing' ) ) {
|
485 |
+
|
486 |
+
$capability = sanitize_text_field( $_POST['fl-editing-capability'] );
|
487 |
+
|
488 |
+
if ( is_network_admin() ) {
|
489 |
+
update_site_option( '_fl_builder_editing_capability', $capability );
|
490 |
+
}
|
491 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
492 |
+
delete_option( '_fl_builder_editing_capability' );
|
493 |
}
|
494 |
else {
|
495 |
+
update_option( '_fl_builder_editing_capability', $capability );
|
|
|
|
|
|
|
496 |
}
|
497 |
}
|
498 |
}
|
499 |
|
500 |
/**
|
501 |
+
* @method save_branding
|
502 |
* @private
|
503 |
*/
|
504 |
+
static private function save_branding()
|
505 |
{
|
506 |
+
if ( isset( $_POST['fl-branding-nonce'] ) && wp_verify_nonce( $_POST['fl-branding-nonce'], 'branding' ) ) {
|
507 |
|
508 |
+
$branding = wp_kses_post( $_POST['fl-branding'] );
|
509 |
+
$branding_icon = sanitize_text_field( $_POST['fl-branding-icon'] );
|
510 |
|
511 |
+
if ( is_network_admin() ) {
|
512 |
+
update_site_option( '_fl_builder_branding', $branding );
|
513 |
+
update_site_option( '_fl_builder_branding_icon', $branding_icon );
|
514 |
+
}
|
515 |
+
else {
|
516 |
+
update_option( '_fl_builder_branding', $branding );
|
517 |
+
update_option( '_fl_builder_branding_icon', $branding_icon );
|
518 |
+
}
|
519 |
}
|
520 |
}
|
521 |
|
525 |
*/
|
526 |
static private function uninstall()
|
527 |
{
|
528 |
+
if ( ! current_user_can( 'delete_plugins' ) ) {
|
529 |
return;
|
530 |
}
|
531 |
+
else if ( isset( $_POST['fl-uninstall'] ) && wp_verify_nonce( $_POST['fl-uninstall'], 'uninstall' ) ) {
|
532 |
+
if ( is_multisite() && class_exists( 'FLBuilderMultisite' ) ) {
|
533 |
FLBuilderMultisite::uninstall();
|
534 |
}
|
535 |
else {
|
536 |
+
FLBuilderAdmin::uninstall();
|
537 |
}
|
538 |
}
|
539 |
}
|
classes/class-fl-builder-admin.php
CHANGED
@@ -36,7 +36,8 @@ final class FLBuilderAdmin {
|
|
36 |
}
|
37 |
// This version doesn't have multisite support.
|
38 |
else {
|
39 |
-
|
|
|
40 |
}
|
41 |
}
|
42 |
// No multisite, standard install.
|
@@ -60,9 +61,9 @@ final class FLBuilderAdmin {
|
|
60 |
*/
|
61 |
static public function show_activate_error($message)
|
62 |
{
|
63 |
-
deactivate_plugins(plugin_basename(
|
64 |
|
65 |
-
die($message);
|
66 |
}
|
67 |
|
68 |
/**
|
@@ -84,8 +85,13 @@ final class FLBuilderAdmin {
|
|
84 |
*/
|
85 |
static public function activate_notice()
|
86 |
{
|
87 |
-
|
88 |
-
|
|
|
|
|
|
|
|
|
|
|
89 |
echo '<div class="updated" style="background: #d3ebc1;">';
|
90 |
echo '<p><strong>' . sprintf( __( 'Page Builder activated! <a%s>Click here</a> to enable remote updates.', 'fl-builder' ), ' href="' . esc_url( $href ) . '"' ) . '</strong></p>';
|
91 |
echo '</div>';
|
@@ -109,11 +115,11 @@ final class FLBuilderAdmin {
|
|
109 |
*/
|
110 |
static public function init()
|
111 |
{
|
112 |
-
self::show_activate_notice();
|
113 |
self::init_classes();
|
114 |
self::init_settings();
|
115 |
self::init_multisite();
|
116 |
self::init_templates();
|
|
|
117 |
}
|
118 |
|
119 |
/**
|
@@ -133,7 +139,7 @@ final class FLBuilderAdmin {
|
|
133 |
if(file_exists($ms_class)) {
|
134 |
require_once $ms_class;
|
135 |
}
|
136 |
-
if(file_exists($ms_settings_class)
|
137 |
require_once $ms_settings_class;
|
138 |
}
|
139 |
}
|
@@ -181,7 +187,8 @@ final class FLBuilderAdmin {
|
|
181 |
static public function render_plugin_action_links($actions)
|
182 |
{
|
183 |
if(FL_BUILDER_LITE === true) {
|
184 |
-
|
|
|
185 |
}
|
186 |
|
187 |
return $actions;
|
@@ -192,24 +199,16 @@ final class FLBuilderAdmin {
|
|
192 |
*/
|
193 |
static public function white_label_plugins_page($plugins)
|
194 |
{
|
|
|
195 |
$branding = FLBuilderModel::get_branding();
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
$plugins['fl-builder/fl-builder.php']['PluginURI'] = '';
|
205 |
-
}
|
206 |
-
else if(isset($plugins['bb-plugin/fl-builder.php'])) {
|
207 |
-
$plugins['bb-plugin/fl-builder.php']['Name'] = $branding;
|
208 |
-
$plugins['bb-plugin/fl-builder.php']['Title'] = $branding;
|
209 |
-
$plugins['bb-plugin/fl-builder.php']['Author'] = '';
|
210 |
-
$plugins['bb-plugin/fl-builder.php']['AuthorName'] = '';
|
211 |
-
$plugins['bb-plugin/fl-builder.php']['PluginURI'] = '';
|
212 |
-
}
|
213 |
}
|
214 |
|
215 |
return $plugins;
|
36 |
}
|
37 |
// This version doesn't have multisite support.
|
38 |
else {
|
39 |
+
$url = FLBuilderModel::get_upgrade_url( array( 'utm_source' => 'external', 'utm_medium' => 'builder', 'utm_campaign' => 'no-multisite-support' ) );
|
40 |
+
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"' ) );
|
41 |
}
|
42 |
}
|
43 |
// No multisite, standard install.
|
61 |
*/
|
62 |
static public function show_activate_error($message)
|
63 |
{
|
64 |
+
deactivate_plugins( FLBuilderModel::plugin_basename(), false, is_network_admin() );
|
65 |
|
66 |
+
die( $message );
|
67 |
}
|
68 |
|
69 |
/**
|
85 |
*/
|
86 |
static public function activate_notice()
|
87 |
{
|
88 |
+
if ( class_exists('FLBuilderMultisiteSettings') && is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
|
89 |
+
$href = esc_url( network_admin_url( '/settings.php?page=fl-builder-multisite-settings#license' ) );
|
90 |
+
}
|
91 |
+
else {
|
92 |
+
$href = esc_url( admin_url( '/options-general.php?page=fl-builder-settings#license' ) );
|
93 |
+
}
|
94 |
+
|
95 |
echo '<div class="updated" style="background: #d3ebc1;">';
|
96 |
echo '<p><strong>' . sprintf( __( 'Page Builder activated! <a%s>Click here</a> to enable remote updates.', 'fl-builder' ), ' href="' . esc_url( $href ) . '"' ) . '</strong></p>';
|
97 |
echo '</div>';
|
115 |
*/
|
116 |
static public function init()
|
117 |
{
|
|
|
118 |
self::init_classes();
|
119 |
self::init_settings();
|
120 |
self::init_multisite();
|
121 |
self::init_templates();
|
122 |
+
self::show_activate_notice();
|
123 |
}
|
124 |
|
125 |
/**
|
139 |
if(file_exists($ms_class)) {
|
140 |
require_once $ms_class;
|
141 |
}
|
142 |
+
if(file_exists($ms_settings_class)) {
|
143 |
require_once $ms_settings_class;
|
144 |
}
|
145 |
}
|
187 |
static public function render_plugin_action_links($actions)
|
188 |
{
|
189 |
if(FL_BUILDER_LITE === true) {
|
190 |
+
$url = FLBuilderModel::get_upgrade_url( array( 'utm_source' => 'external', 'utm_medium' => 'builder', 'utm_campaign' => 'plugins-page' ) );
|
191 |
+
$actions[] = '<a href="' . $url . '" style="color:#3db634;" target="_blank">' . _x( 'Upgrade', 'Plugin action link label.', 'fl-builder' ) . '</a>';
|
192 |
}
|
193 |
|
194 |
return $actions;
|
199 |
*/
|
200 |
static public function white_label_plugins_page($plugins)
|
201 |
{
|
202 |
+
$default = __( 'Page Builder', 'fl-builder' );
|
203 |
$branding = FLBuilderModel::get_branding();
|
204 |
+
$key = FLBuilderModel::plugin_basename();
|
205 |
+
|
206 |
+
if ( isset( $plugins[ $key ] ) && $branding != $default ) {
|
207 |
+
$plugins[ $key ]['Name'] = $branding;
|
208 |
+
$plugins[ $key ]['Title'] = $branding;
|
209 |
+
$plugins[ $key ]['Author'] = '';
|
210 |
+
$plugins[ $key ]['AuthorName'] = '';
|
211 |
+
$plugins[ $key ]['PluginURI'] = '';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
212 |
}
|
213 |
|
214 |
return $plugins;
|
classes/class-fl-builder-icons.php
CHANGED
@@ -19,32 +19,245 @@ final class FLBuilderIcons {
|
|
19 |
*/
|
20 |
static public function get_sets()
|
21 |
{
|
|
|
22 |
if ( self::$sets ) {
|
23 |
return self::$sets;
|
24 |
}
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
'name' => 'WordPress Dashicons',
|
37 |
-
'prefix' => 'dashicons dashicons-before'
|
38 |
-
)
|
39 |
-
);
|
40 |
|
41 |
-
|
42 |
-
|
43 |
-
|
|
|
|
|
|
|
|
|
44 |
}
|
45 |
|
|
|
46 |
return self::$sets;
|
47 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
|
49 |
/**
|
50 |
* @method enqueue_styles_for_module
|
@@ -89,6 +302,7 @@ final class FLBuilderIcons {
|
|
89 |
*/
|
90 |
static private function enqueue_styles_for_icon( $icon )
|
91 |
{
|
|
|
92 |
if ( stristr( $icon, 'fa-' ) ) {
|
93 |
wp_enqueue_style( 'font-awesome' );
|
94 |
}
|
@@ -98,5 +312,37 @@ final class FLBuilderIcons {
|
|
98 |
else if ( stristr( $icon, 'dashicon' ) ) {
|
99 |
wp_enqueue_style( 'dashicons' );
|
100 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
101 |
}
|
102 |
}
|
19 |
*/
|
20 |
static public function get_sets()
|
21 |
{
|
22 |
+
// Return the sets if already registered.
|
23 |
if ( self::$sets ) {
|
24 |
return self::$sets;
|
25 |
}
|
26 |
|
27 |
+
// Check to see if we should pull sets from the main site.
|
28 |
+
if ( is_multisite()) {
|
29 |
+
|
30 |
+
$blog_id = defined( 'BLOG_ID_CURRENT_SITE' ) ? BLOG_ID_CURRENT_SITE : 1;
|
31 |
+
$enabled_icons = get_option( '_fl_builder_enabled_icons' );
|
32 |
+
|
33 |
+
if ( empty( $enabled_icons ) ) {
|
34 |
+
switch_to_blog( $blog_id );
|
35 |
+
}
|
36 |
+
}
|
|
|
|
|
|
|
|
|
37 |
|
38 |
+
// Register the icon sets.
|
39 |
+
self::register_custom_sets();
|
40 |
+
self::register_core_sets();
|
41 |
+
|
42 |
+
// Revert to the current site if we pulled from the main site.
|
43 |
+
if ( is_multisite() && empty( $enabled_icons ) ) {
|
44 |
+
restore_current_blog();
|
45 |
}
|
46 |
|
47 |
+
// Return the sets.
|
48 |
return self::$sets;
|
49 |
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* @method get_sets
|
53 |
+
*/
|
54 |
+
static public function get_sets_for_current_site()
|
55 |
+
{
|
56 |
+
if ( ! is_multisite() ) {
|
57 |
+
return self::get_sets();
|
58 |
+
}
|
59 |
+
|
60 |
+
// Store the original sets.
|
61 |
+
$original_sets = self::$sets;
|
62 |
+
|
63 |
+
// Register the icon sets.
|
64 |
+
self::register_custom_sets();
|
65 |
+
self::register_core_sets();
|
66 |
+
|
67 |
+
// Get the new sets.
|
68 |
+
$sets = self::$sets;
|
69 |
+
|
70 |
+
// Revert to the original sets.
|
71 |
+
self::$sets = $original_sets;
|
72 |
+
|
73 |
+
// Return the sets.
|
74 |
+
return $sets;
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* @method remove_set
|
79 |
+
*/
|
80 |
+
static public function remove_set( $key )
|
81 |
+
{
|
82 |
+
if ( self::$sets && isset( self::$sets[ $key ] ) ) {
|
83 |
+
unset( self::$sets[ $key ] );
|
84 |
+
}
|
85 |
+
}
|
86 |
+
|
87 |
+
/**
|
88 |
+
* @method get_key_from_path
|
89 |
+
*/
|
90 |
+
static public function get_key_from_path( $path )
|
91 |
+
{
|
92 |
+
$sets = self::get_sets();
|
93 |
+
|
94 |
+
foreach ( $sets as $key => $set ) {
|
95 |
+
if ( $path == $set['path'] ) {
|
96 |
+
return $key;
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* @method register_core_sets
|
103 |
+
* @private
|
104 |
+
*/
|
105 |
+
static private function register_core_sets()
|
106 |
+
{
|
107 |
+
$enabled_icons = FLBuilderModel::get_enabled_icons();
|
108 |
+
$core_sets = array(
|
109 |
+
'font-awesome' => array(
|
110 |
+
'name' => 'Font Awesome',
|
111 |
+
'prefix' => 'fa'
|
112 |
+
),
|
113 |
+
'foundation-icons' => array(
|
114 |
+
'name' => 'Foundation Icons',
|
115 |
+
'prefix' => ''
|
116 |
+
),
|
117 |
+
'dashicons' => array(
|
118 |
+
'name' => 'WordPress Dashicons',
|
119 |
+
'prefix' => 'dashicons dashicons-before'
|
120 |
+
)
|
121 |
+
);
|
122 |
+
|
123 |
+
// Add the core sets.
|
124 |
+
foreach ( $core_sets as $set_key => $set_data ) {
|
125 |
+
if ( is_admin() || in_array( $set_key, $enabled_icons ) ) {
|
126 |
+
self::$sets[ $set_key ] = array(
|
127 |
+
'name' => $set_data['name'],
|
128 |
+
'prefix' => $set_data['prefix'],
|
129 |
+
'type' => 'core'
|
130 |
+
);
|
131 |
+
}
|
132 |
+
}
|
133 |
+
|
134 |
+
// Loop through core sets and add icons.
|
135 |
+
foreach ( self::$sets as $set_key => $set_data ) {
|
136 |
+
if ( 'core' == $set_data['type'] ) {
|
137 |
+
$icons = json_decode( file_get_contents( FL_BUILDER_DIR . 'json/' . $set_key . '.json' ) );
|
138 |
+
self::$sets[ $set_key ]['icons'] = $icons;
|
139 |
+
}
|
140 |
+
}
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @method register_custom_sets
|
145 |
+
* @private
|
146 |
+
*/
|
147 |
+
static private function register_custom_sets()
|
148 |
+
{
|
149 |
+
// Get uploaded sets.
|
150 |
+
$enabled_icons = FLBuilderModel::get_enabled_icons();
|
151 |
+
$upload_info = FLBuilderModel::get_cache_dir( 'icons' );
|
152 |
+
$folders = glob( $upload_info['path'] . '*' );
|
153 |
+
|
154 |
+
// Loop through uploaded sets.
|
155 |
+
foreach ( $folders as $folder ) {
|
156 |
+
|
157 |
+
$folder = trailingslashit( $folder );
|
158 |
+
|
159 |
+
// This is an Icomoon font.
|
160 |
+
if ( file_exists( $folder . 'selection.json' ) ) {
|
161 |
+
|
162 |
+
$data = json_decode( file_get_contents( $folder . 'selection.json' ) );
|
163 |
+
$key = basename( $folder );
|
164 |
+
$url = str_ireplace( $upload_info['path'], $upload_info['url'], $folder );
|
165 |
+
|
166 |
+
if ( isset( $data->icons ) ) {
|
167 |
+
|
168 |
+
if ( is_admin() || in_array( $key, $enabled_icons ) ) {
|
169 |
+
|
170 |
+
self::$sets[ $key ] = array(
|
171 |
+
'name' => $data->metadata->name,
|
172 |
+
'prefix' => '',
|
173 |
+
'type' => 'icomoon',
|
174 |
+
'path' => $folder,
|
175 |
+
'url' => $url,
|
176 |
+
'stylesheet' => $url . 'style.css',
|
177 |
+
'icons' => array()
|
178 |
+
);
|
179 |
+
|
180 |
+
foreach ( $data->icons as $icon ) {
|
181 |
+
|
182 |
+
$prefs = $data->preferences->fontPref;
|
183 |
+
$postfix = isset( $prefs->postfix ) ? $prefs->postfix : '';
|
184 |
+
|
185 |
+
if ( isset( $prefs->selector ) && 'class' == $prefs->selector ) {
|
186 |
+
$selector = trim( str_replace( '.', ' ', $prefs->classSelector ) ) . ' ';
|
187 |
+
}
|
188 |
+
else {
|
189 |
+
$selector = '';
|
190 |
+
}
|
191 |
+
|
192 |
+
self::$sets[ $key ]['icons'][] = $selector . $prefs->prefix . $icon->properties->name . $postfix;
|
193 |
+
}
|
194 |
+
}
|
195 |
+
}
|
196 |
+
}
|
197 |
+
// This is a Fontello font.
|
198 |
+
else if ( file_exists( $folder . 'config.json' ) ) {
|
199 |
+
|
200 |
+
$data = json_decode( file_get_contents( $folder . 'config.json' ) );
|
201 |
+
$key = basename( $folder );
|
202 |
+
$name = empty( $data->name ) ? 'Fontello' : $data->name;
|
203 |
+
$url = str_ireplace( $upload_info['path'], $upload_info['url'], $folder );
|
204 |
+
$style = empty( $data->name ) ? 'fontello' : $data->name;
|
205 |
+
|
206 |
+
// Append the date to the name?
|
207 |
+
if ( empty( $data->name ) ) {
|
208 |
+
$time = str_replace( 'icon-', '', $key );
|
209 |
+
$date_format = get_option( 'date_format' );
|
210 |
+
$time_format = get_option( 'time_format' );
|
211 |
+
$date = date( $date_format . ' ' . $time_format );
|
212 |
+
$name .= ' (' . $date . ')';
|
213 |
+
}
|
214 |
+
|
215 |
+
if ( isset( $data->glyphs ) ) {
|
216 |
+
|
217 |
+
if ( is_admin() || in_array( $key, $enabled_icons ) ) {
|
218 |
+
|
219 |
+
self::$sets[ $key ] = array(
|
220 |
+
'name' => $name,
|
221 |
+
'prefix' => '',
|
222 |
+
'type' => 'fontello',
|
223 |
+
'path' => $folder,
|
224 |
+
'url' => $url,
|
225 |
+
'stylesheet' => $url . 'css/' . $style . '.css',
|
226 |
+
'icons' => array()
|
227 |
+
);
|
228 |
+
|
229 |
+
foreach ( $data->glyphs as $icon ) {
|
230 |
+
if ( $data->css_use_suffix ) {
|
231 |
+
self::$sets[ $key ]['icons'][] = $icon->css . $data->css_prefix_text;
|
232 |
+
}
|
233 |
+
else {
|
234 |
+
self::$sets[ $key ]['icons'][] = $data->css_prefix_text . $icon->css;
|
235 |
+
}
|
236 |
+
}
|
237 |
+
}
|
238 |
+
}
|
239 |
+
}
|
240 |
+
}
|
241 |
+
}
|
242 |
+
|
243 |
+
/**
|
244 |
+
* @method enqueue_all_custom_icons_styles
|
245 |
+
*/
|
246 |
+
static public function enqueue_all_custom_icons_styles()
|
247 |
+
{
|
248 |
+
$sets = self::get_sets();
|
249 |
+
|
250 |
+
foreach ( $sets as $key => $data ) {
|
251 |
+
|
252 |
+
// Don't enqueue core icons.
|
253 |
+
if ( 'core' == $data['type'] ) {
|
254 |
+
continue;
|
255 |
+
}
|
256 |
+
|
257 |
+
// Enqueue the custom icon styles.
|
258 |
+
self::enqueue_custom_styles_by_key( $key );
|
259 |
+
}
|
260 |
+
}
|
261 |
|
262 |
/**
|
263 |
* @method enqueue_styles_for_module
|
302 |
*/
|
303 |
static private function enqueue_styles_for_icon( $icon )
|
304 |
{
|
305 |
+
// Is this a core icon?
|
306 |
if ( stristr( $icon, 'fa-' ) ) {
|
307 |
wp_enqueue_style( 'font-awesome' );
|
308 |
}
|
312 |
else if ( stristr( $icon, 'dashicon' ) ) {
|
313 |
wp_enqueue_style( 'dashicons' );
|
314 |
}
|
315 |
+
// It must be a custom icon.
|
316 |
+
else {
|
317 |
+
|
318 |
+
$sets = self::get_sets();
|
319 |
+
|
320 |
+
foreach ( $sets as $key => $data ) {
|
321 |
+
if ( in_array( $icon, $data['icons'] ) ) {
|
322 |
+
self::enqueue_custom_styles_by_key( $key );
|
323 |
+
}
|
324 |
+
}
|
325 |
+
}
|
326 |
+
}
|
327 |
+
|
328 |
+
/**
|
329 |
+
* @method enqueue_custom_styles_by_key
|
330 |
+
* @private
|
331 |
+
*/
|
332 |
+
static private function enqueue_custom_styles_by_key( $key )
|
333 |
+
{
|
334 |
+
$sets = self::get_sets();
|
335 |
+
|
336 |
+
if ( isset( $sets[ $key ] ) ) {
|
337 |
+
|
338 |
+
$set = $sets[ $key ];
|
339 |
+
|
340 |
+
if ( 'icomoon' == $set['type'] ) {
|
341 |
+
wp_enqueue_style( $key, $set['stylesheet'], array(), FL_BUILDER_VERSION );
|
342 |
+
}
|
343 |
+
if ( 'fontello' == $set['type'] ) {
|
344 |
+
wp_enqueue_style( $key, $set['stylesheet'], array(), FL_BUILDER_VERSION );
|
345 |
+
}
|
346 |
+
}
|
347 |
}
|
348 |
}
|
classes/class-fl-builder-model.php
CHANGED
@@ -30,6 +30,12 @@ final class FLBuilderModel {
|
|
30 |
*/
|
31 |
static public $settings_forms = array();
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
* @property $modules
|
35 |
* @type array
|
@@ -141,6 +147,16 @@ final class FLBuilderModel {
|
|
141 |
return set_url_scheme( $url );
|
142 |
}
|
143 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
/**
|
145 |
* @method get_post_data
|
146 |
*/
|
@@ -242,7 +258,17 @@ final class FLBuilderModel {
|
|
242 |
*/
|
243 |
static public function is_ssl()
|
244 |
{
|
245 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
246 |
}
|
247 |
|
248 |
/**
|
@@ -408,26 +434,59 @@ final class FLBuilderModel {
|
|
408 |
}
|
409 |
|
410 |
/**
|
411 |
-
* @method
|
412 |
*/
|
413 |
-
static public function
|
414 |
{
|
415 |
-
$wp_info
|
|
|
|
|
|
|
|
|
|
|
|
|
416 |
|
417 |
// SSL workaround.
|
418 |
-
if(self::is_ssl()) {
|
419 |
-
$wp_info['baseurl'] = str_ireplace('http://', 'https://', $wp_info['baseurl']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
420 |
}
|
421 |
|
422 |
// Build the paths.
|
423 |
$dir_info = array(
|
424 |
-
'path' => $
|
425 |
-
'url' => $
|
426 |
);
|
427 |
|
428 |
// Create the cache dir if it doesn't exist.
|
429 |
-
if(!file_exists($dir_info['path'])) {
|
430 |
-
mkdir($dir_info['path']);
|
431 |
}
|
432 |
|
433 |
return $dir_info;
|
@@ -985,7 +1044,7 @@ final class FLBuilderModel {
|
|
985 |
*/
|
986 |
static public function get_row_defaults()
|
987 |
{
|
988 |
-
return self::get_settings_form_defaults(
|
989 |
}
|
990 |
|
991 |
/**
|
@@ -1248,7 +1307,7 @@ final class FLBuilderModel {
|
|
1248 |
*/
|
1249 |
static public function get_col_defaults()
|
1250 |
{
|
1251 |
-
return self::get_settings_form_defaults(
|
1252 |
}
|
1253 |
|
1254 |
/**
|
@@ -1298,16 +1357,25 @@ final class FLBuilderModel {
|
|
1298 |
|
1299 |
// Create a new instance of the module.
|
1300 |
$instance = new $class();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1301 |
|
1302 |
// Only register modules that are enabled.
|
1303 |
-
if($
|
1304 |
|
1305 |
// Save the instance in the modules array.
|
1306 |
self::$modules[$instance->slug] = $instance;
|
1307 |
|
1308 |
// Add the form to the instance.
|
1309 |
self::$modules[$instance->slug]->form = $form;
|
1310 |
-
self::$modules[$instance->slug]->form['advanced'] = self::$settings_forms['
|
1311 |
}
|
1312 |
}
|
1313 |
}
|
@@ -1369,7 +1437,7 @@ final class FLBuilderModel {
|
|
1369 |
if(!isset($categories[$module->category])) {
|
1370 |
$categories[$module->category] = array();
|
1371 |
}
|
1372 |
-
|
1373 |
$categories[$module->category][$module->name] = $module;
|
1374 |
}
|
1375 |
else {
|
@@ -1591,7 +1659,7 @@ final class FLBuilderModel {
|
|
1591 |
$defaults = new StdClass();
|
1592 |
|
1593 |
if(isset(self::$modules[$type]->form)) {
|
1594 |
-
$defaults = self::get_settings_form_defaults(
|
1595 |
$defaults->type = $type;
|
1596 |
}
|
1597 |
|
@@ -1655,6 +1723,14 @@ final class FLBuilderModel {
|
|
1655 |
self::$settings_forms[$id] = $form;
|
1656 |
}
|
1657 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1658 |
/**
|
1659 |
* @method get_settings_form_fields
|
1660 |
*/
|
@@ -1680,10 +1756,32 @@ final class FLBuilderModel {
|
|
1680 |
/**
|
1681 |
* @method get_settings_form_defaults
|
1682 |
*/
|
1683 |
-
static public function get_settings_form_defaults($
|
1684 |
{
|
1685 |
-
|
1686 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1687 |
foreach($tabs as $tab) {
|
1688 |
if(isset($tab['sections'])) {
|
1689 |
foreach($tab['sections'] as $section) {
|
@@ -1705,8 +1803,11 @@ final class FLBuilderModel {
|
|
1705 |
}
|
1706 |
}
|
1707 |
}
|
|
|
|
|
|
|
1708 |
|
1709 |
-
return $
|
1710 |
}
|
1711 |
|
1712 |
/**
|
@@ -1796,7 +1897,7 @@ final class FLBuilderModel {
|
|
1796 |
*/
|
1797 |
static public function get_global_defaults()
|
1798 |
{
|
1799 |
-
return self::get_settings_form_defaults(
|
1800 |
}
|
1801 |
|
1802 |
/**
|
@@ -2478,6 +2579,35 @@ final class FLBuilderModel {
|
|
2478 |
}
|
2479 |
}
|
2480 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2481 |
/**
|
2482 |
* @method get_editing_capability
|
2483 |
*/
|
@@ -2507,6 +2637,14 @@ final class FLBuilderModel {
|
|
2507 |
}
|
2508 |
}
|
2509 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2510 |
/**
|
2511 |
* We don't delete _fl_builder_enabled, _fl_builder_data and _fl_builder_draft
|
2512 |
* so layouts can be recovered should the plugin be installed again.
|
@@ -2522,25 +2660,23 @@ final class FLBuilderModel {
|
|
2522 |
delete_option('_fl_builder_enabled_modules');
|
2523 |
delete_option('_fl_builder_enabled_templates');
|
2524 |
delete_option('_fl_builder_post_types');
|
|
|
2525 |
delete_option('_fl_builder_branding');
|
2526 |
delete_option('_fl_builder_editing_capability');
|
2527 |
|
2528 |
-
// Delete
|
2529 |
-
$
|
2530 |
-
$
|
2531 |
-
|
2532 |
-
foreach($cache_files as $file) {
|
2533 |
-
unlink($file);
|
2534 |
-
}
|
2535 |
-
|
2536 |
-
rmdir($cache_dir['path']);
|
2537 |
|
2538 |
// Deactivate and delete the plugin.
|
2539 |
-
deactivate_plugins(array(
|
2540 |
-
delete_plugins(array(
|
2541 |
|
2542 |
// Redirect to the plugins page.
|
2543 |
wp_redirect(admin_url('plugins.php?deleted=true&plugin_status=all&paged=1&s='));
|
|
|
|
|
2544 |
}
|
2545 |
}
|
2546 |
}
|
30 |
*/
|
31 |
static public $settings_forms = array();
|
32 |
|
33 |
+
/**
|
34 |
+
* @property $settings_form_defaults
|
35 |
+
* @type array
|
36 |
+
*/
|
37 |
+
static public $settings_form_defaults = array();
|
38 |
+
|
39 |
/**
|
40 |
* @property $modules
|
41 |
* @type array
|
147 |
return set_url_scheme( $url );
|
148 |
}
|
149 |
|
150 |
+
/**
|
151 |
+
* @method get_upgrade_url
|
152 |
+
*/
|
153 |
+
static public function get_upgrade_url( $params = array() )
|
154 |
+
{
|
155 |
+
$url = FL_BUILDER_UPGRADE_URL . '?' . http_build_query( $params, '', '&' );
|
156 |
+
|
157 |
+
return apply_filters( 'fl_builder_upgrade_url', $url );
|
158 |
+
}
|
159 |
+
|
160 |
/**
|
161 |
* @method get_post_data
|
162 |
*/
|
258 |
*/
|
259 |
static public function is_ssl()
|
260 |
{
|
261 |
+
if ( is_ssl() ) {
|
262 |
+
return true;
|
263 |
+
}
|
264 |
+
else if ( 0 === stripos( get_option( 'siteurl' ), 'https://' ) ) {
|
265 |
+
return true;
|
266 |
+
}
|
267 |
+
else if ( isset( $_SERVER['HTTP_X_FORWARDED_PROTO'] ) && 'https' == $_SERVER['HTTP_X_FORWARDED_PROTO'] ) {
|
268 |
+
return true;
|
269 |
+
}
|
270 |
+
|
271 |
+
return false;
|
272 |
}
|
273 |
|
274 |
/**
|
434 |
}
|
435 |
|
436 |
/**
|
437 |
+
* @method get_upload_dir
|
438 |
*/
|
439 |
+
static public function get_upload_dir()
|
440 |
{
|
441 |
+
$wp_info = wp_upload_dir();
|
442 |
+
$dir_name = basename( FL_BUILDER_DIR );
|
443 |
+
|
444 |
+
// We use bb-plugin for the lite version as well.
|
445 |
+
if ( $dir_name == 'beaver-builder-lite-version' ) {
|
446 |
+
$dir_name = 'bb-plugin';
|
447 |
+
}
|
448 |
|
449 |
// SSL workaround.
|
450 |
+
if ( self::is_ssl() ) {
|
451 |
+
$wp_info['baseurl'] = str_ireplace( 'http://', 'https://', $wp_info['baseurl'] );
|
452 |
+
}
|
453 |
+
|
454 |
+
// Build the paths.
|
455 |
+
$dir_info = array(
|
456 |
+
'path' => $wp_info['basedir'] . '/' . $dir_name . '/',
|
457 |
+
'url' => $wp_info['baseurl'] . '/' . $dir_name . '/'
|
458 |
+
);
|
459 |
+
|
460 |
+
// Create the upload dir if it doesn't exist.
|
461 |
+
if ( ! file_exists( $dir_info['path'] ) ) {
|
462 |
+
mkdir( $dir_info['path'] );
|
463 |
+
}
|
464 |
+
|
465 |
+
return $dir_info;
|
466 |
+
}
|
467 |
+
|
468 |
+
/**
|
469 |
+
* @method get_cache_dir
|
470 |
+
*/
|
471 |
+
static public function get_cache_dir( $name = 'cache' )
|
472 |
+
{
|
473 |
+
$upload_info = self::get_upload_dir();
|
474 |
+
$allowed = array( 'cache', 'icons' );
|
475 |
+
|
476 |
+
// Make sure the dir name is allowed.
|
477 |
+
if ( ! in_array( $name, $allowed ) ) {
|
478 |
+
return false;
|
479 |
}
|
480 |
|
481 |
// Build the paths.
|
482 |
$dir_info = array(
|
483 |
+
'path' => $upload_info['path'] . $name . '/',
|
484 |
+
'url' => $upload_info['url'] . $name . '/'
|
485 |
);
|
486 |
|
487 |
// Create the cache dir if it doesn't exist.
|
488 |
+
if( ! file_exists( $dir_info['path'] ) ) {
|
489 |
+
mkdir( $dir_info['path'] );
|
490 |
}
|
491 |
|
492 |
return $dir_info;
|
1044 |
*/
|
1045 |
static public function get_row_defaults()
|
1046 |
{
|
1047 |
+
return self::get_settings_form_defaults( 'row' );
|
1048 |
}
|
1049 |
|
1050 |
/**
|
1307 |
*/
|
1308 |
static public function get_col_defaults()
|
1309 |
{
|
1310 |
+
return self::get_settings_form_defaults( 'col' );
|
1311 |
}
|
1312 |
|
1313 |
/**
|
1357 |
|
1358 |
// Create a new instance of the module.
|
1359 |
$instance = new $class();
|
1360 |
+
|
1361 |
+
// Log an error if a module with this slug already exists.
|
1362 |
+
if ( isset( self::$modules[ $instance->slug ] ) ) {
|
1363 |
+
error_log( sprintf( _x( 'A module with the filename %s.php already exists! Please namespace your module filenames to ensure compatibility with Beaver Builder.', '%s stands for the module filename', 'fl-builder' ), $instance->slug ) );
|
1364 |
+
return;
|
1365 |
+
}
|
1366 |
+
|
1367 |
+
// See if the module is enabled or not.
|
1368 |
+
$enabled = apply_filters( 'fl_builder_register_module', $instance->enabled, $instance );
|
1369 |
|
1370 |
// Only register modules that are enabled.
|
1371 |
+
if( $enabled ) {
|
1372 |
|
1373 |
// Save the instance in the modules array.
|
1374 |
self::$modules[$instance->slug] = $instance;
|
1375 |
|
1376 |
// Add the form to the instance.
|
1377 |
self::$modules[$instance->slug]->form = $form;
|
1378 |
+
self::$modules[$instance->slug]->form['advanced'] = self::$settings_forms['module_advanced'];
|
1379 |
}
|
1380 |
}
|
1381 |
}
|
1437 |
if(!isset($categories[$module->category])) {
|
1438 |
$categories[$module->category] = array();
|
1439 |
}
|
1440 |
+
|
1441 |
$categories[$module->category][$module->name] = $module;
|
1442 |
}
|
1443 |
else {
|
1659 |
$defaults = new StdClass();
|
1660 |
|
1661 |
if(isset(self::$modules[$type]->form)) {
|
1662 |
+
$defaults = self::get_settings_form_defaults( $type );
|
1663 |
$defaults->type = $type;
|
1664 |
}
|
1665 |
|
1723 |
self::$settings_forms[$id] = $form;
|
1724 |
}
|
1725 |
|
1726 |
+
/**
|
1727 |
+
* @method get_settings_form
|
1728 |
+
*/
|
1729 |
+
static public function get_settings_form( $id )
|
1730 |
+
{
|
1731 |
+
return self::$settings_forms[ $id ];
|
1732 |
+
}
|
1733 |
+
|
1734 |
/**
|
1735 |
* @method get_settings_form_fields
|
1736 |
*/
|
1756 |
/**
|
1757 |
* @method get_settings_form_defaults
|
1758 |
*/
|
1759 |
+
static public function get_settings_form_defaults( $type )
|
1760 |
{
|
1761 |
+
// Check to see if the defaults are cached first.
|
1762 |
+
if ( isset( self::$settings_form_defaults[ $type ] ) ) {
|
1763 |
+
return self::$settings_form_defaults[ $type ];
|
1764 |
+
}
|
1765 |
+
|
1766 |
+
// They aren't cached, let's get them.
|
1767 |
+
$defaults = new StdClass();
|
1768 |
+
|
1769 |
+
// Check the registered forms first.
|
1770 |
+
if ( isset( self::$settings_forms[ $type ] ) ) {
|
1771 |
+
$form_type = $type;
|
1772 |
+
$tabs = self::$settings_forms[ $type ]['tabs'];
|
1773 |
+
}
|
1774 |
+
// If it's not a registered form, it must be a module form.
|
1775 |
+
else if ( isset( self::$modules[ $type ] ) ) {
|
1776 |
+
$form_type = $type . '-module';
|
1777 |
+
$tabs = self::$modules[ $type ]->form;
|
1778 |
+
}
|
1779 |
+
// The form can't be found.
|
1780 |
+
else {
|
1781 |
+
return $defaults;
|
1782 |
+
}
|
1783 |
+
|
1784 |
+
// Loop through the tabs and get the defaults.
|
1785 |
foreach($tabs as $tab) {
|
1786 |
if(isset($tab['sections'])) {
|
1787 |
foreach($tab['sections'] as $section) {
|
1803 |
}
|
1804 |
}
|
1805 |
}
|
1806 |
+
|
1807 |
+
// Cache the defaults.
|
1808 |
+
self::$settings_form_defaults[ $type ] = apply_filters( 'fl_builder_settings_form_defaults', $defaults, $form_type );
|
1809 |
|
1810 |
+
return self::$settings_form_defaults[ $type ];
|
1811 |
}
|
1812 |
|
1813 |
/**
|
1897 |
*/
|
1898 |
static public function get_global_defaults()
|
1899 |
{
|
1900 |
+
return self::get_settings_form_defaults( 'global' );
|
1901 |
}
|
1902 |
|
1903 |
/**
|
2579 |
}
|
2580 |
}
|
2581 |
|
2582 |
+
/**
|
2583 |
+
* @method get_enabled_icons
|
2584 |
+
*/
|
2585 |
+
static public function get_enabled_icons()
|
2586 |
+
{
|
2587 |
+
$key = '_fl_builder_enabled_icons';
|
2588 |
+
$default = array( 'font-awesome', 'foundation-icons', 'dashicons' );
|
2589 |
+
|
2590 |
+
// Get the value.
|
2591 |
+
if(is_network_admin()) {
|
2592 |
+
$value = get_site_option($key);
|
2593 |
+
}
|
2594 |
+
else if(class_exists('FLBuilderMultisiteSettings')) {
|
2595 |
+
$value = get_option($key);
|
2596 |
+
$value = !$value ? get_site_option($key) : $value;
|
2597 |
+
}
|
2598 |
+
else {
|
2599 |
+
$value = get_option($key);
|
2600 |
+
}
|
2601 |
+
|
2602 |
+
// Return the value.
|
2603 |
+
if(!$value) {
|
2604 |
+
return $default;
|
2605 |
+
}
|
2606 |
+
else {
|
2607 |
+
return $value;
|
2608 |
+
}
|
2609 |
+
}
|
2610 |
+
|
2611 |
/**
|
2612 |
* @method get_editing_capability
|
2613 |
*/
|
2637 |
}
|
2638 |
}
|
2639 |
|
2640 |
+
/**
|
2641 |
+
* @method plugin_basename
|
2642 |
+
*/
|
2643 |
+
static public function plugin_basename()
|
2644 |
+
{
|
2645 |
+
return plugin_basename( FL_BUILDER_DIR . 'fl-builder.php' );
|
2646 |
+
}
|
2647 |
+
|
2648 |
/**
|
2649 |
* We don't delete _fl_builder_enabled, _fl_builder_data and _fl_builder_draft
|
2650 |
* so layouts can be recovered should the plugin be installed again.
|
2660 |
delete_option('_fl_builder_enabled_modules');
|
2661 |
delete_option('_fl_builder_enabled_templates');
|
2662 |
delete_option('_fl_builder_post_types');
|
2663 |
+
delete_option('_fl_builder_enabled_icons');
|
2664 |
delete_option('_fl_builder_branding');
|
2665 |
delete_option('_fl_builder_editing_capability');
|
2666 |
|
2667 |
+
// Delete uploaded files and folders.
|
2668 |
+
$upload_dir = self::get_upload_dir();
|
2669 |
+
$filesystem = FLBuilderUtils::get_filesystem();
|
2670 |
+
$filesystem->rmdir( $upload_dir['path'], true );
|
|
|
|
|
|
|
|
|
|
|
2671 |
|
2672 |
// Deactivate and delete the plugin.
|
2673 |
+
deactivate_plugins(array(self::plugin_basename()), false, is_network_admin());
|
2674 |
+
delete_plugins(array(self::plugin_basename()));
|
2675 |
|
2676 |
// Redirect to the plugins page.
|
2677 |
wp_redirect(admin_url('plugins.php?deleted=true&plugin_status=all&paged=1&s='));
|
2678 |
+
|
2679 |
+
exit;
|
2680 |
}
|
2681 |
}
|
2682 |
}
|
classes/class-fl-builder-module.php
CHANGED
@@ -151,7 +151,6 @@ class FLBuilderModule {
|
|
151 |
else if(stristr($dir_path, get_template_directory())) {
|
152 |
$this->url = str_replace(get_template_directory(), get_template_directory_uri(), $dir_path) . '/';
|
153 |
$this->dir = $dir_path . '/';
|
154 |
-
error_log($this->url);
|
155 |
}
|
156 |
else {
|
157 |
$this->url = isset($params['url']) ? $params['url'] : FL_BUILDER_URL . 'modules/' . $this->slug . '/';
|
151 |
else if(stristr($dir_path, get_template_directory())) {
|
152 |
$this->url = str_replace(get_template_directory(), get_template_directory_uri(), $dir_path) . '/';
|
153 |
$this->dir = $dir_path . '/';
|
|
|
154 |
}
|
155 |
else {
|
156 |
$this->url = isset($params['url']) ? $params['url'] : FL_BUILDER_URL . 'modules/' . $this->slug . '/';
|
classes/class-fl-builder-update.php
CHANGED
@@ -55,6 +55,11 @@ final class FLBuilderUpdate {
|
|
55 |
self::v_1_2_8();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
58 |
// Clear all asset cache.
|
59 |
FLBuilderModel::delete_all_asset_cache();
|
60 |
|
@@ -347,4 +352,22 @@ final class FLBuilderUpdate {
|
|
347 |
|
348 |
return $settings;
|
349 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
350 |
}
|
55 |
self::v_1_2_8();
|
56 |
}
|
57 |
|
58 |
+
// Update to 1.4.6 or greater.
|
59 |
+
if(version_compare($version, '1.4.6', '<')) {
|
60 |
+
self::v_1_4_6();
|
61 |
+
}
|
62 |
+
|
63 |
// Clear all asset cache.
|
64 |
FLBuilderModel::delete_all_asset_cache();
|
65 |
|
352 |
|
353 |
return $settings;
|
354 |
}
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Update to version 1.4.6 or later.
|
358 |
+
*
|
359 |
+
* @method v_1_4_6
|
360 |
+
* @private
|
361 |
+
*/
|
362 |
+
static private function v_1_4_6()
|
363 |
+
{
|
364 |
+
// Remove the old fl-builder uploads folder.
|
365 |
+
$filesystem = FLBuilderUtils::get_filesystem();
|
366 |
+
$upload_dir = wp_upload_dir();
|
367 |
+
$path = trailingslashit( $upload_dir['basedir'] ) . 'fl-builder';
|
368 |
+
|
369 |
+
if ( file_exists( $path ) ) {
|
370 |
+
$filesystem->rmdir( $path, true );
|
371 |
+
}
|
372 |
+
}
|
373 |
}
|
classes/class-fl-builder-utils.php
CHANGED
@@ -9,6 +9,36 @@
|
|
9 |
final class FLBuilderUtils {
|
10 |
|
11 |
/**
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
* @method snippetwop
|
13 |
*/
|
14 |
static public function snippetwop($text, $length = 64, $tail = "...")
|
@@ -28,18 +58,4 @@ final class FLBuilderUtils {
|
|
28 |
|
29 |
return $text;
|
30 |
}
|
31 |
-
|
32 |
-
/**
|
33 |
-
* @method array_to_object
|
34 |
-
*/
|
35 |
-
static public function array_to_object($array)
|
36 |
-
{
|
37 |
-
$object = new StdClass();
|
38 |
-
|
39 |
-
foreach($array as $key => $val) {
|
40 |
-
$object->$key = $val;
|
41 |
-
}
|
42 |
-
|
43 |
-
return $object;
|
44 |
-
}
|
45 |
}
|
9 |
final class FLBuilderUtils {
|
10 |
|
11 |
/**
|
12 |
+
* Get an instance of WP_Filesystem_Direct.
|
13 |
+
*
|
14 |
+
* @method get_filesystem
|
15 |
+
*/
|
16 |
+
static public function get_filesystem()
|
17 |
+
{
|
18 |
+
global $wp_filesystem;
|
19 |
+
|
20 |
+
require_once ABSPATH .'/wp-admin/includes/file.php';
|
21 |
+
|
22 |
+
add_filter('filesystem_method', 'FLBuilderUtils::filesystem_method');
|
23 |
+
|
24 |
+
WP_Filesystem();
|
25 |
+
|
26 |
+
remove_filter('filesystem_method', 'FLBuilderUtils::filesystem_method');
|
27 |
+
|
28 |
+
return $wp_filesystem;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* @method filesystem_method
|
33 |
+
*/
|
34 |
+
static public function filesystem_method()
|
35 |
+
{
|
36 |
+
return 'direct';
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Return a snippet without punctuation at the end.
|
41 |
+
*
|
42 |
* @method snippetwop
|
43 |
*/
|
44 |
static public function snippetwop($text, $length = 64, $tail = "...")
|
58 |
|
59 |
return $text;
|
60 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
classes/class-fl-builder.php
CHANGED
@@ -25,7 +25,7 @@ final class FLBuilder {
|
|
25 |
$mofile_global = trailingslashit( WP_LANG_DIR ) . 'plugins/beaver-builder/' . $locale . '.mo';
|
26 |
|
27 |
if ( file_exists( $mofile_local ) ) {
|
28 |
-
|
29 |
return load_textdomain( 'fl-builder', $mofile_local );
|
30 |
}
|
31 |
else if ( file_exists( $mofile_global ) ) {
|
@@ -352,6 +352,9 @@ final class FLBuilder {
|
|
352 |
wp_enqueue_style('fl-lightbox', $css_url . 'fl-lightbox.css', array(), $ver);
|
353 |
wp_enqueue_style('fl-icon-selector', $css_url . 'fl-icon-selector.css', array(), $ver);
|
354 |
wp_enqueue_style('fl-builder', $css_url . 'fl-builder.css', array(), $ver);
|
|
|
|
|
|
|
355 |
|
356 |
/* RTL Support */
|
357 |
if(is_rtl()) {
|
@@ -716,14 +719,14 @@ final class FLBuilder {
|
|
716 |
$post_data = FLBuilderModel::get_post_data();
|
717 |
$type = isset($post_data['type']) ? $post_data['type'] : $type;
|
718 |
$settings = isset($post_data['settings']) ? $post_data['settings'] : $settings;
|
719 |
-
$form = FLBuilderModel
|
720 |
|
721 |
if(isset($settings) && !empty($settings)) {
|
722 |
-
$defaults = FLBuilderModel::get_settings_form_defaults($
|
723 |
$settings = (object)array_merge((array)$defaults, (array)$settings);
|
724 |
}
|
725 |
else {
|
726 |
-
$settings = FLBuilderModel::get_settings_form_defaults($
|
727 |
}
|
728 |
|
729 |
self::render_settings(array(
|
@@ -806,8 +809,8 @@ final class FLBuilder {
|
|
806 |
*/
|
807 |
static public function render_user_template_settings()
|
808 |
{
|
809 |
-
$defaults = FLBuilderModel::get_settings_form_defaults(
|
810 |
-
$form = FLBuilderModel
|
811 |
|
812 |
FLBuilder::render_settings(array(
|
813 |
'class' => 'fl-builder-user-template-settings',
|
@@ -889,41 +892,34 @@ final class FLBuilder {
|
|
889 |
}
|
890 |
|
891 |
/**
|
892 |
-
* @method
|
893 |
*/
|
894 |
-
static public function
|
895 |
{
|
896 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
897 |
echo ' fl-row-' . $row->settings->width . '-width';
|
898 |
echo ' fl-row-bg-' . $row->settings->bg_type;
|
899 |
echo ' fl-node-' . $row->node;
|
900 |
|
901 |
-
if(!empty($row->settings->class)) {
|
902 |
echo apply_filters( 'fl_builder_row_custom_class', ' ' . $row->settings->class, $row );
|
903 |
}
|
904 |
-
if(!empty($row->settings->responsive_display)) {
|
905 |
echo ' fl-visible-' . $row->settings->responsive_display;
|
906 |
}
|
907 |
-
|
908 |
-
|
909 |
-
|
910 |
-
|
911 |
-
*/
|
912 |
-
static public function render_row_content_class($row)
|
913 |
-
{
|
914 |
-
echo 'fl-row-content';
|
915 |
-
echo ' fl-row-' . $row->settings->content_width . '-width';
|
916 |
-
echo ' fl-node-content';
|
917 |
-
}
|
918 |
-
|
919 |
-
/**
|
920 |
-
* @method render_row_data_attrs
|
921 |
-
*/
|
922 |
-
static public function render_row_data_attrs($row)
|
923 |
-
{
|
924 |
echo ' data-node="' . $row->node . '"';
|
925 |
|
926 |
-
if($row->settings->bg_type == 'parallax' && !empty($row->settings->bg_parallax_image_src)) {
|
927 |
echo ' data-parallax-speed="' . $row->settings->bg_parallax_speed . '"';
|
928 |
echo ' data-parallax-image="' . $row->settings->bg_parallax_image_src . '"';
|
929 |
}
|
@@ -947,6 +943,16 @@ final class FLBuilder {
|
|
947 |
}
|
948 |
}
|
949 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
950 |
/**
|
951 |
* @method render_row_settings
|
952 |
*/
|
@@ -994,6 +1000,15 @@ final class FLBuilder {
|
|
994 |
}
|
995 |
}
|
996 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
997 |
/**
|
998 |
* @method render_column_settings
|
999 |
*/
|
@@ -1014,23 +1029,38 @@ final class FLBuilder {
|