Version Description
Download this release
Release Info
Developer | justinbusa |
Plugin | WordPress Page Builder – Beaver Builder |
Version | 1.5.6 |
Comparing to | |
See all releases |
Code changes from version 1.5.5 to 1.5.6
- changelog.txt +21 -0
- classes/class-fl-builder-admin-posts.php +89 -89
- classes/class-fl-builder-admin-settings.php +452 -441
- classes/class-fl-builder-admin.php +232 -185
- classes/class-fl-builder-auto-suggest.php +230 -192
- classes/class-fl-builder-color.php +53 -37
- classes/class-fl-builder-icons.php +373 -328
- classes/class-fl-builder-loop.php +182 -160
- classes/class-fl-builder-model.php +2883 -2450
- classes/class-fl-builder-module.php +240 -220
- classes/class-fl-builder-photo.php +84 -67
- classes/class-fl-builder-service-aweber.php +166 -166
- classes/class-fl-builder-service-campaign-monitor.php +172 -172
- classes/class-fl-builder-service-constant-contact.php +216 -216
- classes/class-fl-builder-service-getresponse.php +133 -133
- classes/class-fl-builder-service-icontact.php +193 -193
- classes/class-fl-builder-service-madmimi.php +156 -156
- classes/class-fl-builder-service-mailchimp.php +143 -141
- classes/class-fl-builder-service-mailpoet.php +85 -85
- classes/class-fl-builder-service-sendinblue.php +229 -0
- classes/class-fl-builder-service.php +27 -27
- classes/class-fl-builder-services.php +220 -220
- classes/class-fl-builder-update.php +379 -345
- classes/class-fl-builder-utils.php +92 -36
- classes/class-fl-builder.php +1654 -1409
- classes/class-fl-jsmin.php +238 -238
- css/colorpicker.css +4 -4
- css/editor.css +1 -1
- css/fl-builder-admin-posts-legacy.css +12 -12
- css/fl-builder-admin-posts.css +56 -56
- css/fl-builder-admin-settings.css +59 -59
- css/fl-builder-layout-auto-spacing.css +12 -12
- css/fl-builder-layout-medium.css +2 -2
- css/fl-builder-layout-responsive.css +11 -11
- css/fl-builder-layout.css +185 -185
- css/fl-builder-rtl.css +14 -14
- css/fl-builder.css +694 -693
- css/fl-icon-selector.css +36 -36
- css/fl-lightbox.css +64 -64
- css/fl-slideshow.css +41 -41
- css/font-awesome.min.css +2 -2
- css/foundation-icons.css +17 -17
- css/jquery.bxslider.css +3 -3
- css/jquery.magnificpopup.css +286 -286
- css/jquery.nanoscroller.css +33 -33
- css/jquery.tiptip.css +1 -1
- fl-builder.php +7 -7
- fonts/FontAwesome.otf +0 -0
- fonts/fontawesome-webfont.eot +0 -0
- fonts/fontawesome-webfont.svg +53 -8
- fonts/fontawesome-webfont.ttf +0 -0
- fonts/fontawesome-webfont.woff +0 -0
- fonts/fontawesome-webfont.woff2 +0 -0
- includes/admin-posts.php +8 -8
- includes/admin-settings-cache.php +15 -15
- includes/admin-settings-editing.php +16 -16
- includes/admin-settings-js-config.php +2 -2
- includes/admin-settings-modules.php +43 -43
- includes/admin-settings-post-types.php +59 -59
- includes/admin-settings-uninstall.php +11 -11
- includes/admin-settings-upgrade.php +4 -4
- includes/admin-settings.php +7 -7
- includes/column-css.php +28 -28
- includes/column-group.php +7 -7
- includes/column-settings.php +369 -369
- includes/compatibility.php +27 -27
- includes/field-code.php +12 -12
- includes/field-color.php +5 -5
- includes/field-editor.php +56 -56
- includes/field-form.php +25 -25
- includes/field-icon.php +9 -9
- includes/field-layout.php +7 -7
- includes/field-link.php +6 -6
- includes/field-multiple-photos.php +9 -9
- includes/field-photo-sizes.php +7 -7
- includes/field-photo.php +14 -14
- includes/field-post-type.php +3 -3
- includes/field-select.php +13 -13
- includes/field-video.php +18 -18
- includes/field.php +38 -38
- includes/global-settings.php +147 -147
- includes/icon-selector.php +22 -22
- includes/jquery.php +2 -2
- includes/js-config.php +98 -98
- includes/loop-settings.php +93 -93
- includes/module-settings.php +130 -130
- includes/module.php +3 -3
- includes/row-css.php +24 -24
- includes/row-js.php +23 -23
- includes/row-settings.php +620 -620
- includes/row-video.php +5 -5
- includes/row.php +12 -12
- includes/service-settings.php +11 -11
- includes/settings.php +63 -63
- includes/ui.php +103 -103
- includes/updater-config.php +6 -6
- includes/updater/classes/class-fl-updater.php +211 -152
- includes/updater/includes/config.php +4 -4
- includes/updater/includes/form.php +23 -23
- includes/user-template-settings.php +18 -18
- includes/vendor/sendinblue/Mailin.php +173 -0
changelog.txt
CHANGED
@@ -1,3 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
<h4>1.5.5 - 04/12/2015</h4>
|
2 |
<p><strong>Enhancements</strong></p>
|
3 |
<ul>
|
1 |
+
<h4>1.5.6 - 04/26/2015</h4>
|
2 |
+
<p><strong>Enhancements</strong></p>
|
3 |
+
<ul>
|
4 |
+
<li>Added SendinBlue integration.</li>
|
5 |
+
<li>Added filters for MailChimp single optin and disabling the welcome message.</li>
|
6 |
+
<li>Most of the builder's PHP and JavaScript files now have much better inline documentation of classes, properties and methods (we still need to do the modules).</li>
|
7 |
+
</ul>
|
8 |
+
<p><strong>Tweaks</strong></p>
|
9 |
+
<ul>
|
10 |
+
<li>Removed phone number validation from the Contact Form module to support international phone numbers.</li>
|
11 |
+
<li>Updated FontAwesome.</li>
|
12 |
+
<li>Tweaked the Heading module CSS to prevent Dynamik from overriding our styles.</li>
|
13 |
+
<li>Added CSS to fix margins issue with the WordPress editor link lightbox and some third party themes.</li>
|
14 |
+
</ul>
|
15 |
+
<p><strong>Bug Fixes</strong></p>
|
16 |
+
<ul>
|
17 |
+
<li>Fixed a bug that didn't allow backslashes to be saved.</li>
|
18 |
+
<li>Fixed a bug that prevented namespaced widgets from working.</li>
|
19 |
+
<li>Fixed a bug with the Posts module that prevented the date from being hidden in the gallery layout.</li>
|
20 |
+
</ul>
|
21 |
+
|
22 |
<h4>1.5.5 - 04/12/2015</h4>
|
23 |
<p><strong>Enhancements</strong></p>
|
24 |
<ul>
|
classes/class-fl-builder-admin-posts.php
CHANGED
@@ -3,51 +3,51 @@
|
|
3 |
/**
|
4 |
* Handles logic for the post edit screen.
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*/
|
8 |
final class FLBuilderAdminPosts {
|
9 |
-
|
10 |
-
|
11 |
* Sets the body class, loads assets and renders the UI
|
12 |
* if we are on a post type that supports the builder.
|
13 |
*
|
14 |
-
* @since 1.
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
|
34 |
/**
|
35 |
-
|
36 |
-
|
37 |
-
* @since 1.
|
38 |
-
|
39 |
-
|
40 |
static public function styles_scripts()
|
41 |
{
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
wp_enqueue_style( 'fl-builder-admin-posts', FL_BUILDER_URL . 'css/fl-builder-admin-posts.css', array(), FL_BUILDER_VERSION );
|
46 |
|
47 |
// Legacy WP Styles (3.7 and below)
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
|
52 |
// Scripts
|
53 |
wp_enqueue_script( 'json2' );
|
@@ -55,80 +55,80 @@ final class FLBuilderAdminPosts {
|
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
-
|
59 |
-
|
60 |
-
* @since 1.
|
61 |
* @param string $classes The existing body classes.
|
62 |
-
|
63 |
-
|
64 |
static public function body_class( $classes = '' )
|
65 |
{
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
-
|
83 |
-
|
84 |
-
* @since 1.
|
85 |
-
|
86 |
-
|
87 |
static public function render()
|
88 |
{
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
include FL_BUILDER_DIR . 'includes/admin-posts.php';
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
-
|
98 |
-
|
99 |
-
* @since 1.
|
100 |
* @param array $actions
|
101 |
-
|
102 |
-
|
103 |
static public function render_row_actions_link( $actions = array() )
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
|
119 |
/**
|
120 |
-
|
121 |
-
|
122 |
-
* @since 1.
|
123 |
* @param string $location
|
124 |
-
|
125 |
-
|
126 |
static public function redirect_post_location( $location )
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
}
|
3 |
/**
|
4 |
* Handles logic for the post edit screen.
|
5 |
*
|
6 |
+
* @since 1.0
|
7 |
*/
|
8 |
final class FLBuilderAdminPosts {
|
9 |
+
|
10 |
+
/**
|
11 |
* Sets the body class, loads assets and renders the UI
|
12 |
* if we are on a post type that supports the builder.
|
13 |
*
|
14 |
+
* @since 1.0
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
+
static public function init()
|
18 |
+
{
|
19 |
+
global $pagenow;
|
20 |
+
|
21 |
+
if ( in_array( $pagenow, array( 'post.php', 'post-new.php') ) ) {
|
22 |
+
|
23 |
+
$post_types = FLBuilderModel::get_post_types();
|
24 |
+
$screen = get_current_screen();
|
25 |
|
26 |
+
if ( in_array( $screen->post_type, $post_types ) ) {
|
27 |
+
add_filter( 'admin_body_class', 'FLBuilderAdminPosts::body_class' );
|
28 |
+
add_action( 'admin_enqueue_scripts', 'FLBuilderAdminPosts::styles_scripts' );
|
29 |
+
add_action( 'edit_form_after_title', 'FLBuilderAdminPosts::render' );
|
30 |
+
}
|
31 |
+
}
|
32 |
+
}
|
33 |
|
34 |
/**
|
35 |
+
* Enqueues the CSS/JS for the post edit screen.
|
36 |
+
*
|
37 |
+
* @since 1.0
|
38 |
+
* @return void
|
39 |
+
*/
|
40 |
static public function styles_scripts()
|
41 |
{
|
42 |
+
global $wp_version;
|
43 |
+
|
44 |
+
// Styles
|
45 |
wp_enqueue_style( 'fl-builder-admin-posts', FL_BUILDER_URL . 'css/fl-builder-admin-posts.css', array(), FL_BUILDER_VERSION );
|
46 |
|
47 |
// Legacy WP Styles (3.7 and below)
|
48 |
+
if ( version_compare( $wp_version, '3.7', '<=' ) ) {
|
49 |
+
wp_enqueue_style( 'fl-builder-admin-posts-legacy', FL_BUILDER_URL . 'css/fl-builder-admin-posts-legacy.css', array(), FL_BUILDER_VERSION );
|
50 |
+
}
|
51 |
|
52 |
// Scripts
|
53 |
wp_enqueue_script( 'json2' );
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* Adds classes to the post edit screen body class.
|
59 |
+
*
|
60 |
+
* @since 1.0
|
61 |
* @param string $classes The existing body classes.
|
62 |
+
* @return string The body classes.
|
63 |
+
*/
|
64 |
static public function body_class( $classes = '' )
|
65 |
{
|
66 |
+
global $wp_version;
|
67 |
+
|
68 |
+
// Builder body class
|
69 |
+
if ( FLBuilderModel::is_builder_enabled() ) {
|
70 |
+
$classes .= ' fl-builder-enabled';
|
71 |
+
}
|
72 |
+
|
73 |
+
// Pre WP 3.8 body class
|
74 |
+
if ( version_compare( $wp_version, '3.8', '<' ) ) {
|
75 |
+
$classes .= ' fl-pre-wp-3-8';
|
76 |
+
}
|
77 |
+
|
78 |
+
return $classes;
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
+
* Renders the HTML for the post edit screen.
|
83 |
+
*
|
84 |
+
* @since 1.0
|
85 |
+
* @return void
|
86 |
+
*/
|
87 |
static public function render()
|
88 |
{
|
89 |
+
global $post;
|
90 |
+
|
91 |
+
$enabled = FLBuilderModel::is_builder_enabled();
|
92 |
+
|
93 |
include FL_BUILDER_DIR . 'includes/admin-posts.php';
|
94 |
}
|
95 |
|
96 |
/**
|
97 |
+
* Renders the action link for post listing pages.
|
98 |
+
*
|
99 |
+
* @since 1.0
|
100 |
* @param array $actions
|
101 |
+
* @return array The array of action data.
|
102 |
+
*/
|
103 |
static public function render_row_actions_link( $actions = array() )
|
104 |
+
{
|
105 |
+
global $post;
|
106 |
+
|
107 |
+
if ( current_user_can( 'edit_post', $post->ID ) && wp_check_post_lock( $post->ID ) === false ) {
|
108 |
+
|
109 |
+
$post_types = FLBuilderModel::get_post_types();
|
110 |
|
111 |
+
if ( in_array( $post->post_type, $post_types ) ) {
|
112 |
+
$actions['fl-builder'] = '<a href="' . FLBuilderModel::get_edit_url() . '">' . FLBuilderModel::get_branding() . '</a>';
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
return $actions;
|
117 |
+
}
|
118 |
|
119 |
/**
|
120 |
+
* Where to redirect this post on save.
|
121 |
+
*
|
122 |
+
* @since 1.0
|
123 |
* @param string $location
|
124 |
+
* @return string The location to redirect this post on save.
|
125 |
+
*/
|
126 |
static public function redirect_post_location( $location )
|
127 |
+
{
|
128 |
+
if ( isset( $_POST['fl-builder-redirect'] ) ) {
|
129 |
+
$location = $_POST['fl-builder-redirect'];
|
130 |
+
}
|
131 |
+
|
132 |
+
return $location;
|
133 |
+
}
|
134 |
}
|
classes/class-fl-builder-admin-settings.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
/**
|
4 |
* Handles logic for the admin settings page.
|
5 |
*
|
6 |
-
* @since 1.
|
7 |
*/
|
8 |
final class FLBuilderAdminSettings {
|
9 |
|
@@ -11,37 +11,37 @@ final class FLBuilderAdminSettings {
|
|
11 |
* Holds any errors that may arise from
|
12 |
* saving admin settings.
|
13 |
*
|
14 |
-
* @since 1.
|
15 |
* @var array $errors
|
16 |
*/
|
17 |
static public $errors = array();
|
18 |
-
|
19 |
-
|
20 |
* Adds the admin menu and enqueues CSS/JS if we are on
|
21 |
* the builder admin settings page.
|
22 |
*
|
23 |
-
* @since 1.
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
38 |
*
|
39 |
-
* @since 1.
|
40 |
-
|
41 |
-
|
42 |
static public function styles_scripts()
|
43 |
{
|
44 |
-
|
45 |
wp_enqueue_style( 'fl-builder-admin-settings', FL_BUILDER_URL . 'css/fl-builder-admin-settings.css', array(), FL_BUILDER_VERSION );
|
46 |
|
47 |
// Scripts
|
@@ -50,44 +50,44 @@ final class FLBuilderAdminSettings {
|
|
50 |
// Media Uploader
|
51 |
wp_enqueue_media();
|
52 |
}
|
53 |
-
|
54 |
-
|
55 |
* Renders the admin settings menu.
|
56 |
*
|
57 |
-
* @since 1.
|
58 |
-
|
59 |
-
|
60 |
static public function menu()
|
61 |
{
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
}
|
71 |
}
|
72 |
-
|
73 |
-
|
74 |
* Renders the admin settings.
|
75 |
*
|
76 |
-
* @since 1.
|
77 |
-
|
78 |
-
|
79 |
static public function render()
|
80 |
{
|
81 |
-
|
82 |
include FL_BUILDER_DIR . 'includes/admin-settings.php';
|
83 |
}
|
84 |
-
|
85 |
-
|
86 |
* Renders the page class for network installs and single site installs.
|
87 |
*
|
88 |
-
* @since 1.
|
89 |
-
|
90 |
-
|
91 |
static public function render_page_class()
|
92 |
{
|
93 |
if ( self::multisite_support() ) {
|
@@ -97,13 +97,13 @@ final class FLBuilderAdminSettings {
|
|
97 |
echo 'fl-settings-single-install';
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
-
|
102 |
* Renders the admin settings page heading.
|
103 |
*
|
104 |
-
* @since 1.
|
105 |
-
|
106 |
-
|
107 |
static public function render_page_heading()
|
108 |
{
|
109 |
$icon = FLBuilderModel::get_branding_icon();
|
@@ -115,13 +115,13 @@ final class FLBuilderAdminSettings {
|
|
115 |
|
116 |
echo '<span>' . sprintf( _x( '%s Settings', '%s stands for custom branded "Page Builder" name.', 'fl-builder' ), FLBuilderModel::get_branding() ) . '</span>';
|
117 |
}
|
118 |
-
|
119 |
-
|
120 |
* Renders the update message.
|
121 |
*
|
122 |
-
* @since 1.
|
123 |
-
|
124 |
-
|
125 |
static public function render_update_message()
|
126 |
{
|
127 |
if ( ! empty( self::$errors ) ) {
|
@@ -133,58 +133,58 @@ final class FLBuilderAdminSettings {
|
|
133 |
echo '<div class="updated"><p>' . __( 'Settings updated!', 'fl-builder' ) . '</p></div>';
|
134 |
}
|
135 |
}
|
136 |
-
|
137 |
-
|
138 |
* Renders the nav items for the admin settings menu.
|
139 |
*
|
140 |
-
* @since 1.
|
141 |
-
|
142 |
-
|
143 |
static public function render_nav_items()
|
144 |
{
|
145 |
$item_data = array(
|
146 |
'license' => array(
|
147 |
-
'title'
|
148 |
'show' => FL_BUILDER_LITE !== true && ( is_network_admin() || ! self::multisite_support() )
|
149 |
),
|
150 |
'upgrade' => array(
|
151 |
-
'title'
|
152 |
'show' => FL_BUILDER_LITE === true
|
153 |
),
|
154 |
'modules' => array(
|
155 |
-
'title'
|
156 |
'show' => true
|
157 |
),
|
158 |
'templates' => array(
|
159 |
-
'title'
|
160 |
'show' => FL_BUILDER_LITE !== true
|
161 |
),
|
162 |
'post-types' => array(
|
163 |
-
'title'
|
164 |
'show' => true
|
165 |
),
|
166 |
'icons' => array(
|
167 |
-
'title'
|
168 |
'show' => FL_BUILDER_LITE !== true
|
169 |
),
|
170 |
'editing' => array(
|
171 |
-
'title'
|
172 |
'show' => true
|
173 |
),
|
174 |
'branding' => array(
|
175 |
-
'title'
|
176 |
'show' => self::has_support( 'branding' ) && ( is_network_admin() || ! self::multisite_support() )
|
177 |
),
|
178 |
'help-button' => array(
|
179 |
-
'title'
|
180 |
'show' => self::has_support( 'help-button' ) && ( is_network_admin() || ! self::multisite_support() )
|
181 |
),
|
182 |
'cache' => array(
|
183 |
-
'title'
|
184 |
'show' => true
|
185 |
),
|
186 |
'uninstall' => array(
|
187 |
-
'title'
|
188 |
'show' => is_network_admin() || ! self::multisite_support()
|
189 |
),
|
190 |
);
|
@@ -195,13 +195,13 @@ final class FLBuilderAdminSettings {
|
|
195 |
}
|
196 |
}
|
197 |
}
|
198 |
-
|
199 |
-
|
200 |
* Renders the admin settings forms.
|
201 |
*
|
202 |
-
* @since 1.
|
203 |
-
|
204 |
-
|
205 |
static public function render_forms()
|
206 |
{
|
207 |
// License
|
@@ -210,7 +210,7 @@ final class FLBuilderAdminSettings {
|
|
210 |
}
|
211 |
|
212 |
// Upgrade
|
213 |
-
if ( FL_BUILDER_LITE === true )
|
214 |
self::render_form( 'upgrade' );
|
215 |
}
|
216 |
|
@@ -241,28 +241,28 @@ final class FLBuilderAdminSettings {
|
|
241 |
// Uninstall
|
242 |
self::render_form( 'uninstall' );
|
243 |
}
|
244 |
-
|
245 |
-
|
246 |
* Renders an admin settings form based on the type specified.
|
247 |
*
|
248 |
-
* @since 1.
|
249 |
* @param string $type The type of form to render.
|
250 |
-
|
251 |
-
|
252 |
static public function render_form( $type )
|
253 |
{
|
254 |
if ( self::has_support( $type ) ) {
|
255 |
include FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php';
|
256 |
}
|
257 |
}
|
258 |
-
|
259 |
-
|
260 |
* Renders the action for a form.
|
261 |
*
|
262 |
-
* @since 1.
|
263 |
* @param string $type The type of form being rendered.
|
264 |
-
|
265 |
-
|
266 |
static public function render_form_action( $type = '' )
|
267 |
{
|
268 |
if ( is_network_admin() ) {
|
@@ -272,14 +272,14 @@ final class FLBuilderAdminSettings {
|
|
272 |
echo admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
273 |
}
|
274 |
}
|
275 |
-
|
276 |
-
|
277 |
* Returns the action for a form.
|
278 |
*
|
279 |
-
* @since 1.
|
280 |
* @param string $type The type of form being rendered.
|
281 |
-
|
282 |
-
|
283 |
static public function get_form_action( $type = '' )
|
284 |
{
|
285 |
if ( is_network_admin() ) {
|
@@ -289,55 +289,55 @@ final class FLBuilderAdminSettings {
|
|
289 |
return admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
290 |
}
|
291 |
}
|
292 |
-
|
293 |
-
|
294 |
* Checks to see if a settings form is supported.
|
295 |
*
|
296 |
-
* @since 1.
|
297 |
* @param string $type The type of form to check.
|
298 |
-
|
299 |
-
|
300 |
static public function has_support( $type )
|
301 |
{
|
302 |
return file_exists( FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php' );
|
303 |
}
|
304 |
-
|
305 |
-
|
306 |
* Checks to see if multisite is supported.
|
307 |
*
|
308 |
-
* @since 1.
|
309 |
-
|
310 |
-
|
311 |
static public function multisite_support()
|
312 |
{
|
313 |
return is_multisite() && class_exists( 'FLBuilderMultisiteSettings' );
|
314 |
}
|
315 |
-
|
316 |
-
|
317 |
* Adds an error message to be rendered.
|
318 |
*
|
319 |
-
* @since 1.
|
320 |
* @param string $message The error message to add.
|
321 |
-
|
322 |
-
|
323 |
static public function add_error( $message )
|
324 |
{
|
325 |
self::$errors[] = $message;
|
326 |
}
|
327 |
-
|
328 |
-
|
329 |
* Saves the admin settings.
|
330 |
*
|
331 |
-
* @since 1.
|
332 |
-
|
333 |
-
|
334 |
static public function save()
|
335 |
{
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
self::save_enabled_modules();
|
342 |
self::save_enabled_templates();
|
343 |
self::save_enabled_post_types();
|
@@ -348,401 +348,412 @@ final class FLBuilderAdminSettings {
|
|
348 |
self::clear_cache();
|
349 |
self::uninstall();
|
350 |
}
|
351 |
-
|
352 |
-
|
353 |
* Saves the enabled modules.
|
354 |
*
|
355 |
-
* @since 1.
|
356 |
-
|
357 |
-
|
|
|
358 |
static private function save_enabled_modules()
|
359 |
{
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
* Saves the enabled templates.
|
382 |
*
|
383 |
-
* @since 1.
|
384 |
-
|
385 |
-
|
|
|
386 |
static private function save_enabled_templates()
|
387 |
{
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
* Saves the enabled post types.
|
406 |
*
|
407 |
-
* @since 1.
|
408 |
-
|
409 |
-
|
|
|
410 |
static private function save_enabled_post_types()
|
411 |
{
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
* Saves the enabled icons.
|
440 |
*
|
441 |
-
* @since 1.
|
442 |
-
|
443 |
-
|
|
|
444 |
static private function save_enabled_icons()
|
445 |
{
|
446 |
-
|
447 |
|
448 |
// Make sure we have at least one enabled icon set.
|
449 |
if ( ! isset( $_POST['fl-enabled-icons'] ) && empty( $_POST['fl-new-icon-set'] ) ) {
|
450 |
self::add_error( __( "Error! You must have at least one icon set enabled.", 'fl-builder' ) );
|
451 |
-
|
452 |
}
|
453 |
-
|
454 |
-
$filesystem
|
455 |
$enabled_icons = array();
|
456 |
|
457 |
// Sanitize the enabled icons.
|
458 |
if ( isset( $_POST['fl-enabled-icons'] ) && is_array( $_POST['fl-enabled-icons'] ) ) {
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
|
484 |
-
$dir
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
|
501 |
$values = array_values( $files );
|
502 |
$subfolder_info = array_shift( $values );
|
503 |
-
$subfolder
|
504 |
|
505 |
if ( file_exists( $subfolder ) && is_dir( $subfolder ) ) {
|
506 |
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
}
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
* Updates the enabled icons in the database.
|
544 |
*
|
545 |
-
* @since 1.
|
546 |
-
|
547 |
-
|
|
|
548 |
static private function update_enabled_icons( $enabled_icons = array() )
|
549 |
{
|
550 |
if ( is_network_admin() ) {
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
}
|
561 |
-
|
562 |
-
|
563 |
* Saves the editing capability.
|
564 |
*
|
565 |
-
* @since 1.
|
566 |
-
|
567 |
-
|
|
|
568 |
static private function save_editing_capability()
|
569 |
{
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
|
576 |
-
|
577 |
-
|
578 |
-
|
579 |
-
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
* Saves the branding settings.
|
588 |
*
|
589 |
-
* @since 1.
|
590 |
-
|
591 |
-
|
|
|
592 |
static private function save_branding()
|
593 |
{
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
599 |
-
|
600 |
update_site_option( '_fl_builder_branding', $branding );
|
601 |
update_site_option( '_fl_builder_branding_icon', $branding_icon );
|
602 |
-
|
603 |
-
|
604 |
update_option( '_fl_builder_branding', $branding );
|
605 |
update_option( '_fl_builder_branding_icon', $branding_icon );
|
606 |
-
|
607 |
-
|
608 |
-
|
609 |
-
|
610 |
-
|
611 |
* Saves the help button settings.
|
612 |
*
|
613 |
-
* @since 1.
|
614 |
-
|
615 |
-
|
|
|
616 |
static private function save_help_button()
|
617 |
{
|
618 |
-
|
619 |
-
|
620 |
-
|
621 |
-
|
622 |
-
|
623 |
-
|
624 |
-
|
625 |
-
|
626 |
-
|
627 |
-
|
628 |
-
|
629 |
-
|
630 |
-
|
631 |
-
|
632 |
-
|
633 |
-
|
634 |
-
|
635 |
-
|
636 |
-
|
637 |
-
|
638 |
-
|
639 |
-
|
640 |
-
|
641 |
-
|
642 |
-
|
643 |
-
|
644 |
-
|
645 |
-
|
646 |
-
|
647 |
-
|
648 |
-
|
649 |
-
|
650 |
-
|
651 |
-
|
652 |
-
|
653 |
-
|
654 |
-
|
655 |
-
|
656 |
-
|
657 |
-
|
658 |
-
|
659 |
-
|
660 |
-
|
661 |
-
|
662 |
-
|
663 |
-
|
664 |
-
|
665 |
-
|
666 |
-
|
667 |
-
|
668 |
-
|
669 |
-
|
670 |
-
|
671 |
-
|
672 |
update_site_option( '_fl_builder_help_button', $settings );
|
673 |
-
|
674 |
-
|
675 |
update_option( '_fl_builder_help_button', $settings );
|
676 |
-
|
677 |
-
|
678 |
-
|
679 |
|
680 |
-
|
681 |
* Clears the builder cache.
|
682 |
*
|
683 |
* @since 1.5.3
|
684 |
-
|
685 |
-
|
|
|
686 |
static private function clear_cache()
|
687 |
{
|
688 |
-
|
689 |
-
|
690 |
-
|
691 |
-
|
692 |
-
|
693 |
-
|
694 |
-
|
695 |
-
|
696 |
-
|
697 |
-
|
698 |
-
|
699 |
-
|
700 |
|
701 |
-
|
702 |
* Clears the builder cache for all sites on a network.
|
703 |
*
|
704 |
* @since 1.5.3
|
705 |
-
|
706 |
-
|
|
|
707 |
static private function clear_cache_for_all_sites()
|
708 |
{
|
709 |
-
|
710 |
-
|
711 |
-
|
712 |
-
|
713 |
-
|
714 |
-
|
715 |
-
|
716 |
-
|
717 |
-
|
718 |
-
|
719 |
-
|
720 |
-
|
721 |
-
|
722 |
-
|
723 |
-
|
724 |
-
|
725 |
-
|
726 |
-
|
727 |
|
728 |
-
|
729 |
* Uninstalls the builder and all of its data.
|
730 |
*
|
731 |
-
* @since 1.
|
732 |
-
|
733 |
-
|
|
|
734 |
static private function uninstall()
|
735 |
{
|
736 |
-
|
737 |
-
|
738 |
-
|
739 |
-
|
740 |
-
|
741 |
-
|
742 |
-
|
743 |
-
|
744 |
-
|
745 |
-
|
746 |
-
|
747 |
-
|
748 |
}
|
3 |
/**
|
4 |
* Handles logic for the admin settings page.
|
5 |
*
|
6 |
+
* @since 1.0
|
7 |
*/
|
8 |
final class FLBuilderAdminSettings {
|
9 |
|
11 |
* Holds any errors that may arise from
|
12 |
* saving admin settings.
|
13 |
*
|
14 |
+
* @since 1.0
|
15 |
* @var array $errors
|
16 |
*/
|
17 |
static public $errors = array();
|
18 |
+
|
19 |
+
/**
|
20 |
* Adds the admin menu and enqueues CSS/JS if we are on
|
21 |
* the builder admin settings page.
|
22 |
*
|
23 |
+
* @since 1.0
|
24 |
+
* @return void
|
25 |
+
*/
|
26 |
+
static public function init()
|
27 |
+
{
|
28 |
+
add_action( 'admin_menu', 'FLBuilderAdminSettings::menu' );
|
29 |
+
|
30 |
+
if ( isset( $_REQUEST['page'] ) && 'fl-builder-settings' == $_REQUEST['page'] ) {
|
31 |
+
add_action( 'admin_enqueue_scripts', 'FLBuilderAdminSettings::styles_scripts' );
|
32 |
+
self::save();
|
33 |
+
}
|
34 |
+
}
|
35 |
+
|
36 |
+
/**
|
37 |
* Enqueues the needed CSS/JS for the builder's admin settings page.
|
38 |
*
|
39 |
+
* @since 1.0
|
40 |
+
* @return void
|
41 |
+
*/
|
42 |
static public function styles_scripts()
|
43 |
{
|
44 |
+
// Styles
|
45 |
wp_enqueue_style( 'fl-builder-admin-settings', FL_BUILDER_URL . 'css/fl-builder-admin-settings.css', array(), FL_BUILDER_VERSION );
|
46 |
|
47 |
// Scripts
|
50 |
// Media Uploader
|
51 |
wp_enqueue_media();
|
52 |
}
|
53 |
+
|
54 |
+
/**
|
55 |
* Renders the admin settings menu.
|
56 |
*
|
57 |
+
* @since 1.0
|
58 |
+
* @return void
|
59 |
+
*/
|
60 |
static public function menu()
|
61 |
{
|
62 |
+
if ( current_user_can( 'delete_plugins' ) ) {
|
63 |
+
|
64 |
+
$title = FLBuilderModel::get_branding();
|
65 |
+
$cap = 'delete_plugins';
|
66 |
+
$slug = 'fl-builder-settings';
|
67 |
+
$func = 'FLBuilderAdminSettings::render';
|
68 |
+
|
69 |
+
add_submenu_page( 'options-general.php', $title, $title, $cap, $slug, $func );
|
70 |
}
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
* Renders the admin settings.
|
75 |
*
|
76 |
+
* @since 1.0
|
77 |
+
* @return void
|
78 |
+
*/
|
79 |
static public function render()
|
80 |
{
|
81 |
+
include FL_BUILDER_DIR . 'includes/admin-settings-js-config.php';
|
82 |
include FL_BUILDER_DIR . 'includes/admin-settings.php';
|
83 |
}
|
84 |
+
|
85 |
+
/**
|
86 |
* Renders the page class for network installs and single site installs.
|
87 |
*
|
88 |
+
* @since 1.0
|
89 |
+
* @return void
|
90 |
+
*/
|
91 |
static public function render_page_class()
|
92 |
{
|
93 |
if ( self::multisite_support() ) {
|
97 |
echo 'fl-settings-single-install';
|
98 |
}
|
99 |
}
|
100 |
+
|
101 |
+
/**
|
102 |
* Renders the admin settings page heading.
|
103 |
*
|
104 |
+
* @since 1.0
|
105 |
+
* @return void
|
106 |
+
*/
|
107 |
static public function render_page_heading()
|
108 |
{
|
109 |
$icon = FLBuilderModel::get_branding_icon();
|
115 |
|
116 |
echo '<span>' . sprintf( _x( '%s Settings', '%s stands for custom branded "Page Builder" name.', 'fl-builder' ), FLBuilderModel::get_branding() ) . '</span>';
|
117 |
}
|
118 |
+
|
119 |
+
/**
|
120 |
* Renders the update message.
|
121 |
*
|
122 |
+
* @since 1.0
|
123 |
+
* @return void
|
124 |
+
*/
|
125 |
static public function render_update_message()
|
126 |
{
|
127 |
if ( ! empty( self::$errors ) ) {
|
133 |
echo '<div class="updated"><p>' . __( 'Settings updated!', 'fl-builder' ) . '</p></div>';
|
134 |
}
|
135 |
}
|
136 |
+
|
137 |
+
/**
|
138 |
* Renders the nav items for the admin settings menu.
|
139 |
*
|
140 |
+
* @since 1.0
|
141 |
+
* @return void
|
142 |
+
*/
|
143 |
static public function render_nav_items()
|
144 |
{
|
145 |
$item_data = array(
|
146 |
'license' => array(
|
147 |
+
'title' => __( 'License', 'fl-builder' ),
|
148 |
'show' => FL_BUILDER_LITE !== true && ( is_network_admin() || ! self::multisite_support() )
|
149 |
),
|
150 |
'upgrade' => array(
|
151 |
+
'title' => __( 'Upgrade', 'fl-builder' ),
|
152 |
'show' => FL_BUILDER_LITE === true
|
153 |
),
|
154 |
'modules' => array(
|
155 |
+
'title' => __( 'Modules', 'fl-builder' ),
|
156 |
'show' => true
|
157 |
),
|
158 |
'templates' => array(
|
159 |
+
'title' => __( 'Templates', 'fl-builder' ),
|
160 |
'show' => FL_BUILDER_LITE !== true
|
161 |
),
|
162 |
'post-types' => array(
|
163 |
+
'title' => __( 'Post Types', 'fl-builder' ),
|
164 |
'show' => true
|
165 |
),
|
166 |
'icons' => array(
|
167 |
+
'title' => __( 'Icons', 'fl-builder' ),
|
168 |
'show' => FL_BUILDER_LITE !== true
|
169 |
),
|
170 |
'editing' => array(
|
171 |
+
'title' => __( 'Editing', 'fl-builder' ),
|
172 |
'show' => true
|
173 |
),
|
174 |
'branding' => array(
|
175 |
+
'title' => __( 'Branding', 'fl-builder' ),
|
176 |
'show' => self::has_support( 'branding' ) && ( is_network_admin() || ! self::multisite_support() )
|
177 |
),
|
178 |
'help-button' => array(
|
179 |
+
'title' => __( 'Help Button', 'fl-builder' ),
|
180 |
'show' => self::has_support( 'help-button' ) && ( is_network_admin() || ! self::multisite_support() )
|
181 |
),
|
182 |
'cache' => array(
|
183 |
+
'title' => __( 'Cache', 'fl-builder' ),
|
184 |
'show' => true
|
185 |
),
|
186 |
'uninstall' => array(
|
187 |
+
'title' => __( 'Uninstall', 'fl-builder' ),
|
188 |
'show' => is_network_admin() || ! self::multisite_support()
|
189 |
),
|
190 |
);
|
195 |
}
|
196 |
}
|
197 |
}
|
198 |
+
|
199 |
+
/**
|
200 |
* Renders the admin settings forms.
|
201 |
*
|
202 |
+
* @since 1.0
|
203 |
+
* @return void
|
204 |
+
*/
|
205 |
static public function render_forms()
|
206 |
{
|
207 |
// License
|
210 |
}
|
211 |
|
212 |
// Upgrade
|
213 |
+
if ( FL_BUILDER_LITE === true ) {
|
214 |
self::render_form( 'upgrade' );
|
215 |
}
|
216 |
|
241 |
// Uninstall
|
242 |
self::render_form( 'uninstall' );
|
243 |
}
|
244 |
+
|
245 |
+
/**
|
246 |
* Renders an admin settings form based on the type specified.
|
247 |
*
|
248 |
+
* @since 1.0
|
249 |
* @param string $type The type of form to render.
|
250 |
+
* @return void
|
251 |
+
*/
|
252 |
static public function render_form( $type )
|
253 |
{
|
254 |
if ( self::has_support( $type ) ) {
|
255 |
include FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php';
|
256 |
}
|
257 |
}
|
258 |
+
|
259 |
+
/**
|
260 |
* Renders the action for a form.
|
261 |
*
|
262 |
+
* @since 1.0
|
263 |
* @param string $type The type of form being rendered.
|
264 |
+
* @return void
|
265 |
+
*/
|
266 |
static public function render_form_action( $type = '' )
|
267 |
{
|
268 |
if ( is_network_admin() ) {
|
272 |
echo admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
273 |
}
|
274 |
}
|
275 |
+
|
276 |
+
/**
|
277 |
* Returns the action for a form.
|
278 |
*
|
279 |
+
* @since 1.0
|
280 |
* @param string $type The type of form being rendered.
|
281 |
+
* @return string The URL for the form action.
|
282 |
+
*/
|
283 |
static public function get_form_action( $type = '' )
|
284 |
{
|
285 |
if ( is_network_admin() ) {
|
289 |
return admin_url( '/options-general.php?page=fl-builder-settings#' . $type );
|
290 |
}
|
291 |
}
|
292 |
+
|
293 |
+
/**
|
294 |
* Checks to see if a settings form is supported.
|
295 |
*
|
296 |
+
* @since 1.0
|
297 |
* @param string $type The type of form to check.
|
298 |
+
* @return bool
|
299 |
+
*/
|
300 |
static public function has_support( $type )
|
301 |
{
|
302 |
return file_exists( FL_BUILDER_DIR . 'includes/admin-settings-' . $type . '.php' );
|
303 |
}
|
304 |
+
|
305 |
+
/**
|
306 |
* Checks to see if multisite is supported.
|
307 |
*
|
308 |
+
* @since 1.0
|
309 |
+
* @return bool
|
310 |
+
*/
|
311 |
static public function multisite_support()
|
312 |
{
|
313 |
return is_multisite() && class_exists( 'FLBuilderMultisiteSettings' );
|
314 |
}
|
315 |
+
|
316 |
+
/**
|
317 |
* Adds an error message to be rendered.
|
318 |
*
|
319 |
+
* @since 1.0
|
320 |
* @param string $message The error message to add.
|
321 |
+
* @return void
|
322 |
+
*/
|
323 |
static public function add_error( $message )
|
324 |
{
|
325 |
self::$errors[] = $message;
|
326 |
}
|
327 |
+
|
328 |
+
/**
|
329 |
* Saves the admin settings.
|
330 |
*
|
331 |
+
* @since 1.0
|
332 |
+
* @return void
|
333 |
+
*/
|
334 |
static public function save()
|
335 |
{
|
336 |
+
// Only admins can save settings.
|
337 |
+
if(!current_user_can('delete_plugins')) {
|
338 |
+
return;
|
339 |
+
}
|
340 |
+
|
341 |
self::save_enabled_modules();
|
342 |
self::save_enabled_templates();
|
343 |
self::save_enabled_post_types();
|
348 |
self::clear_cache();
|
349 |
self::uninstall();
|
350 |
}
|
351 |
+
|
352 |
+
/**
|
353 |
* Saves the enabled modules.
|
354 |
*
|
355 |
+
* @since 1.0
|
356 |
+
* @access private
|
357 |
+
* @return void
|
358 |
+
*/
|
359 |
static private function save_enabled_modules()
|
360 |
{
|
361 |
+
if ( isset( $_POST['fl-modules-nonce'] ) && wp_verify_nonce( $_POST['fl-modules-nonce'], 'modules' ) ) {
|
362 |
+
|
363 |
+
$modules = array();
|
364 |
+
|
365 |
+
if ( is_array( $_POST['fl-modules'] ) ) {
|
366 |
+
$modules = array_map( 'sanitize_text_field', $_POST['fl-modules'] );
|
367 |
+
}
|
368 |
+
|
369 |
+
if ( is_network_admin() ) {
|
370 |
+
update_site_option( '_fl_builder_enabled_modules', $modules );
|
371 |
+
}
|
372 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
373 |
+
delete_option( '_fl_builder_enabled_modules' );
|
374 |
+
}
|
375 |
+
else {
|
376 |
+
update_option( '_fl_builder_enabled_modules', $modules );
|
377 |
+
}
|
378 |
+
}
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
* Saves the enabled templates.
|
383 |
*
|
384 |
+
* @since 1.0
|
385 |
+
* @access private
|
386 |
+
* @return void
|
387 |
+
*/
|
388 |
static private function save_enabled_templates()
|
389 |
{
|
390 |
+
if ( isset( $_POST['fl-templates-nonce'] ) && wp_verify_nonce( $_POST['fl-templates-nonce'], 'templates' ) ) {
|
391 |
+
|
392 |
+
$enabled_templates = sanitize_text_field( $_POST['fl-template-settings'] );
|
393 |
+
|
394 |
+
if ( is_network_admin() ) {
|
395 |
+
update_site_option( '_fl_builder_enabled_templates', $enabled_templates );
|
396 |
+
}
|
397 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
398 |
+
delete_option( '_fl_builder_enabled_templates' );
|
399 |
+
}
|
400 |
+
else {
|
401 |
+
update_option( '_fl_builder_enabled_templates', $enabled_templates );
|
402 |
+
}
|
403 |
+
}
|
404 |
+
}
|
405 |
+
|
406 |
+
/**
|
407 |
* Saves the enabled post types.
|
408 |
*
|
409 |
+
* @since 1.0
|
410 |
+
* @access private
|
411 |
+
* @return void
|
412 |
+
*/
|
413 |
static private function save_enabled_post_types()
|
414 |
{
|
415 |
+
if ( isset( $_POST['fl-post-types-nonce'] ) && wp_verify_nonce( $_POST['fl-post-types-nonce'], 'post-types' ) ) {
|
416 |
+
|
417 |
+
if ( is_network_admin() ) {
|
418 |
+
|
419 |
+
$post_types = sanitize_text_field( $_POST['fl-post-types'] );
|
420 |
+
$post_types = str_replace( ' ', '', $post_types );
|
421 |
+
$post_types = explode( ',', $post_types );
|
422 |
+
|
423 |
+
update_site_option( '_fl_builder_post_types', $post_types );
|
424 |
+
}
|
425 |
+
else if ( self::multisite_support() && ! isset($_POST['fl-override-ms'] ) ) {
|
426 |
+
delete_option( '_fl_builder_post_types' );
|
427 |
+
}
|
428 |
+
else {
|
429 |
+
|
430 |
+
$post_types = array();
|
431 |
+
|
432 |
+
if ( is_array( $_POST['fl-post-types'] ) ) {
|
433 |
+
$post_types = array_map( 'sanitize_text_field', $_POST['fl-post-types'] );
|
434 |
+
}
|
435 |
+
|
436 |
+
update_option( '_fl_builder_post_types', $post_types );
|
437 |
+
}
|
438 |
+
}
|
439 |
+
}
|
440 |
+
|
441 |
+
/**
|
442 |
* Saves the enabled icons.
|
443 |
*
|
444 |
+
* @since 1.0
|
445 |
+
* @access private
|
446 |
+
* @return void
|
447 |
+
*/
|
448 |
static private function save_enabled_icons()
|
449 |
{
|
450 |
+
if ( isset( $_POST['fl-icons-nonce'] ) && wp_verify_nonce( $_POST['fl-icons-nonce'], 'icons' ) ) {
|
451 |
|
452 |
// Make sure we have at least one enabled icon set.
|
453 |
if ( ! isset( $_POST['fl-enabled-icons'] ) && empty( $_POST['fl-new-icon-set'] ) ) {
|
454 |
self::add_error( __( "Error! You must have at least one icon set enabled.", 'fl-builder' ) );
|
455 |
+
return;
|
456 |
}
|
457 |
+
|
458 |
+
$filesystem = FLBuilderUtils::get_filesystem();
|
459 |
$enabled_icons = array();
|
460 |
|
461 |
// Sanitize the enabled icons.
|
462 |
if ( isset( $_POST['fl-enabled-icons'] ) && is_array( $_POST['fl-enabled-icons'] ) ) {
|
463 |
+
$enabled_icons = array_map( 'sanitize_text_field', $_POST['fl-enabled-icons'] );
|
464 |
+
}
|
465 |
+
|
466 |
+
// Update the enabled sets.
|
467 |
+
self::update_enabled_icons( $enabled_icons );
|
468 |
+
|
469 |
+
// Delete a set?
|
470 |
+
if ( ! empty( $_POST['fl-delete-icon-set'] ) ) {
|
471 |
+
|
472 |
+
$sets = FLBuilderIcons::get_sets();
|
473 |
+
$key = sanitize_text_field( $_POST['fl-delete-icon-set'] );
|
474 |
+
$index = array_search( $key, $enabled_icons );
|
475 |
+
|
476 |
+
if ( false !== $index ) {
|
477 |
+
unset( $enabled_icons[ $index ] );
|
478 |
+
}
|
479 |
+
if ( isset( $sets[ $key ] ) ) {
|
480 |
+
$filesystem->rmdir( $sets[ $key ]['path'], true );
|
481 |
+
FLBuilderIcons::remove_set( $key );
|
482 |
+
}
|
483 |
+
}
|
484 |
+
|
485 |
+
// Upload a new set?
|
486 |
+
if ( ! empty( $_POST['fl-new-icon-set'] ) ) {
|
487 |
|
488 |
+
$dir = FLBuilderModel::get_cache_dir( 'icons' );
|
489 |
+
$id = (int) $_POST['fl-new-icon-set'];
|
490 |
+
$path = get_attached_file( $id );
|
491 |
+
$new_path = $dir['path'] . 'icon-' . time() . '/';
|
492 |
+
$unzipped = unzip_file( $path, $new_path );
|
493 |
+
|
494 |
+
// Unzip failed.
|
495 |
+
if ( ! $unzipped ) {
|
496 |
+
self::add_error( __( "Error! Could not unzip file.", 'fl-builder' ) );
|
497 |
+
return;
|
498 |
+
}
|
499 |
+
|
500 |
+
// Move files if unzipped into a subfolder.
|
501 |
+
$files = $filesystem->dirlist( $new_path );
|
502 |
+
|
503 |
+
if ( 1 == count( $files ) ) {
|
504 |
|
505 |
$values = array_values( $files );
|
506 |
$subfolder_info = array_shift( $values );
|
507 |
+
$subfolder = $new_path . $subfolder_info['name'] . '/';
|
508 |
|
509 |
if ( file_exists( $subfolder ) && is_dir( $subfolder ) ) {
|
510 |
|
511 |
+
$files = $filesystem->dirlist( $subfolder );
|
512 |
+
|
513 |
+
if ( $files ) {
|
514 |
+
foreach ( $files as $file ) {
|
515 |
+
$filesystem->move( $subfolder . $file['name'], $new_path . $file['name'] );
|
516 |
+
}
|
517 |
+
}
|
518 |
+
|
519 |
+
$filesystem->rmdir( $subfolder );
|
520 |
}
|
521 |
+
}
|
522 |
+
|
523 |
+
// Check for supported sets.
|
524 |
+
$is_icomoon = file_exists( $new_path . 'selection.json' );
|
525 |
+
$is_fontello = file_exists( $new_path . 'config.json' );
|
526 |
+
|
527 |
+
// Show an error if we don't have a supported icon set.
|
528 |
+
if ( ! $is_icomoon && ! $is_fontello ) {
|
529 |
+
$filesystem->rmdir( $new_path, true );
|
530 |
+
self::add_error( __( "Error! Please upload an icon set from either Icomoon or Fontello.", 'fl-builder' ) );
|
531 |
+
return;
|
532 |
+
}
|
533 |
+
|
534 |
+
// Enable the new set.
|
535 |
+
if ( is_array( $enabled_icons ) ) {
|
536 |
+
$key = FLBuilderIcons::get_key_from_path( $new_path );
|
537 |
+
$enabled_icons[] = $key;
|
538 |
+
}
|
539 |
+
}
|
540 |
+
|
541 |
+
// Update the enabled sets again in case they have changed.
|
542 |
+
self::update_enabled_icons( $enabled_icons );
|
543 |
+
}
|
544 |
+
}
|
545 |
+
|
546 |
+
/**
|
547 |
* Updates the enabled icons in the database.
|
548 |
*
|
549 |
+
* @since 1.0
|
550 |
+
* @access private
|
551 |
+
* @return void
|
552 |
+
*/
|
553 |
static private function update_enabled_icons( $enabled_icons = array() )
|
554 |
{
|
555 |
if ( is_network_admin() ) {
|
556 |
+
update_site_option( '_fl_builder_enabled_icons', $enabled_icons );
|
557 |
+
update_option( '_fl_builder_enabled_icons', $enabled_icons );
|
558 |
+
}
|
559 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
560 |
+
delete_option( '_fl_builder_enabled_icons' );
|
561 |
+
}
|
562 |
+
else {
|
563 |
+
update_option( '_fl_builder_enabled_icons', $enabled_icons );
|
564 |
+
}
|
565 |
}
|
566 |
+
|
567 |
+
/**
|
568 |
* Saves the editing capability.
|
569 |
*
|
570 |
+
* @since 1.0
|
571 |
+
* @access private
|
572 |
+
* @return void
|
573 |
+
*/
|
574 |
static private function save_editing_capability()
|
575 |
{
|
576 |
+
if ( isset( $_POST['fl-editing-nonce'] ) && wp_verify_nonce( $_POST['fl-editing-nonce'], 'editing' ) ) {
|
577 |
+
|
578 |
+
$capability = sanitize_text_field( $_POST['fl-editing-capability'] );
|
579 |
+
|
580 |
+
if ( is_network_admin() ) {
|
581 |
+
update_site_option( '_fl_builder_editing_capability', $capability );
|
582 |
+
}
|
583 |
+
else if ( self::multisite_support() && ! isset( $_POST['fl-override-ms'] ) ) {
|
584 |
+
delete_option( '_fl_builder_editing_capability' );
|
585 |
+
}
|
586 |
+
else {
|
587 |
+
update_option( '_fl_builder_editing_capability', $capability );
|
588 |
+
}
|
589 |
+
}
|
590 |
+
}
|
591 |
+
|
592 |
+
/**
|
593 |
* Saves the branding settings.
|
594 |
*
|
595 |
+
* @since 1.0
|
596 |
+
* @access private
|
597 |
+
* @return void
|
598 |
+
*/
|
599 |
static private function save_branding()
|
600 |
{
|
601 |
+
if ( isset( $_POST['fl-branding-nonce'] ) && wp_verify_nonce( $_POST['fl-branding-nonce'], 'branding' ) ) {
|
602 |
+
|
603 |
+
$branding = wp_kses_post( $_POST['fl-branding'] );
|
604 |
+
$branding_icon = sanitize_text_field( $_POST['fl-branding-icon'] );
|
605 |
+
|
606 |
+
if ( is_network_admin() ) {
|
607 |
update_site_option( '_fl_builder_branding', $branding );
|
608 |
update_site_option( '_fl_builder_branding_icon', $branding_icon );
|
609 |
+
}
|
610 |
+
else {
|
611 |
update_option( '_fl_builder_branding', $branding );
|
612 |
update_option( '_fl_builder_branding_icon', $branding_icon );
|
613 |
+
}
|
614 |
+
}
|
615 |
+
}
|
616 |
+
|
617 |
+
/**
|
618 |
* Saves the help button settings.
|
619 |
*
|
620 |
+
* @since 1.0
|
621 |
+
* @access private
|
622 |
+
* @return void
|
623 |
+
*/
|
624 |
static private function save_help_button()
|
625 |
{
|
626 |
+
if ( isset( $_POST['fl-help-button-nonce'] ) && wp_verify_nonce( $_POST['fl-help-button-nonce'], 'help-button' ) ) {
|
627 |
+
|
628 |
+
$settings = FLBuilderModel::get_help_button_defaults();
|
629 |
+
$settings['enabled'] = isset( $_POST['fl-help-button-enabled'] ) ? true : false;
|
630 |
+
$settings['tour'] = isset( $_POST['fl-help-tour-enabled'] ) ? true : false;
|
631 |
+
$settings['video'] = isset( $_POST['fl-help-video-enabled'] ) ? true : false;
|
632 |
+
$settings['knowledge_base'] = isset( $_POST['fl-knowledge-base-enabled'] ) ? true : false;
|
633 |
+
$settings['forums'] = isset( $_POST['fl-forums-enabled'] ) ? true : false;
|
634 |
+
|
635 |
+
// Disable everything if the main button is disabled.
|
636 |
+
if ( ! $settings['enabled'] ) {
|
637 |
+
$settings['tour'] = false;
|
638 |
+
$settings['video'] = false;
|
639 |
+
$settings['knowledge_base'] = false;
|
640 |
+
$settings['forums'] = false;
|
641 |
+
}
|
642 |
+
|
643 |
+
// Clean the video embed.
|
644 |
+
$video_embed = wp_kses( $_POST['fl-help-video-embed'], array(
|
645 |
+
'iframe' => array(
|
646 |
+
'src' => array(),
|
647 |
+
'frameborder' => array(),
|
648 |
+
'webkitallowfullscreen' => array(),
|
649 |
+
'mozallowfullscreen' => array(),
|
650 |
+
'allowfullscreen' => array()
|
651 |
+
)
|
652 |
+
));
|
653 |
+
|
654 |
+
// Save the video embed.
|
655 |
+
if ( ! empty( $video_embed ) && ! stristr( $video_embed, 'iframe' ) ) {
|
656 |
+
self::add_error( __( "Error! Please enter an iframe for the video embed code.", 'fl-builder' ) );
|
657 |
+
}
|
658 |
+
else if ( ! empty( $video_embed ) ) {
|
659 |
+
$settings['video_embed'] = $video_embed;
|
660 |
+
}
|
661 |
+
|
662 |
+
// Save the knowledge base URL.
|
663 |
+
if ( ! empty( $_POST['fl-knowledge-base-url'] ) ) {
|
664 |
+
$settings['knowledge_base_url'] = sanitize_text_field( $_POST['fl-knowledge-base-url'] );
|
665 |
+
}
|
666 |
+
|
667 |
+
// Save the forums URL.
|
668 |
+
if ( ! empty( $_POST['fl-forums-url'] ) ) {
|
669 |
+
$settings['forums_url'] = sanitize_text_field( $_POST['fl-forums-url'] );
|
670 |
+
}
|
671 |
+
|
672 |
+
// Make sure we have at least one help feature enabled.
|
673 |
+
if ( $settings['enabled'] && ! $settings['tour'] && ! $settings['video'] && ! $settings['knowledge_base'] && ! $settings['forums'] ) {
|
674 |
+
self::add_error( __( "Error! You must have at least one feature of the help button enabled.", 'fl-builder' ) );
|
675 |
+
return;
|
676 |
+
}
|
677 |
+
|
678 |
+
// Save the settings.
|
679 |
+
if ( is_network_admin() ) {
|
680 |
update_site_option( '_fl_builder_help_button', $settings );
|
681 |
+
}
|
682 |
+
else {
|
683 |
update_option( '_fl_builder_help_button', $settings );
|
684 |
+
}
|
685 |
+
}
|
686 |
+
}
|
687 |
|
688 |
+
/**
|
689 |
* Clears the builder cache.
|
690 |
*
|
691 |
* @since 1.5.3
|
692 |
+
* @access private
|
693 |
+
* @return void
|
694 |
+
*/
|
695 |
static private function clear_cache()
|
696 |
{
|
697 |
+
if ( ! current_user_can( 'delete_plugins' ) ) {
|
698 |
+
return;
|
699 |
+
}
|
700 |
+
else if ( isset( $_POST['fl-cache-nonce'] ) && wp_verify_nonce( $_POST['fl-cache-nonce'], 'cache' ) ) {
|
701 |
+
if ( is_network_admin() ) {
|
702 |
+
self::clear_cache_for_all_sites();
|
703 |
+
}
|
704 |
+
else {
|
705 |
+
FLBuilderModel::delete_all_asset_cache();
|
706 |
+
}
|
707 |
+
}
|
708 |
+
}
|
709 |
|
710 |
+
/**
|
711 |
* Clears the builder cache for all sites on a network.
|
712 |
*
|
713 |
* @since 1.5.3
|
714 |
+
* @access private
|
715 |
+
* @return void
|
716 |
+
*/
|
717 |
static private function clear_cache_for_all_sites()
|
718 |
{
|
719 |
+
global $blog_id;
|
720 |
+
global $wpdb;
|
721 |
+
|
722 |
+
// Save the original blog id.
|
723 |
+
$original_blog_id = $blog_id;
|
724 |
+
|
725 |
+
// Get all blog ids.
|
726 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
727 |
+
|
728 |
+
// Loop through the blog ids and clear the cache.
|
729 |
+
foreach ( $blog_ids as $id ) {
|
730 |
+
switch_to_blog( $id );
|
731 |
+
FLBuilderModel::delete_all_asset_cache();
|
732 |
+
}
|
733 |
+
|
734 |
+
// Revert to the original blog.
|
735 |
+
switch_to_blog( $original_blog_id );
|
736 |
+
}
|
737 |
|
738 |
+
/**
|
739 |
* Uninstalls the builder and all of its data.
|
740 |
*
|
741 |
+
* @since 1.0
|
742 |
+
* @access private
|
743 |
+
* @return void
|
744 |
+
*/
|
745 |
static private function uninstall()
|
746 |
{
|
747 |
+
if ( ! current_user_can( 'delete_plugins' ) ) {
|
748 |
+
return;
|
749 |
+
}
|
750 |
+
else if ( isset( $_POST['fl-uninstall'] ) && wp_verify_nonce( $_POST['fl-uninstall'], 'uninstall' ) ) {
|
751 |
+
if ( is_multisite() && class_exists( 'FLBuilderMultisite' ) ) {
|
752 |
+
FLBuilderMultisite::uninstall();
|
753 |
+
}
|
754 |
+
else {
|
755 |
+
FLBuilderAdmin::uninstall();
|
756 |
+
}
|
757 |
+
}
|
758 |
+
}
|
759 |
}
|
classes/class-fl-builder-admin.php
CHANGED
@@ -3,214 +3,261 @@
|
|
3 |
/**
|
4 |
* Main builder admin class.
|
5 |
*
|
6 |
-
* @
|
7 |
*/
|
8 |
final class FLBuilderAdmin {
|
9 |
|
10 |
/**
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
|
|
|
|
|
|
|
|
|
|
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 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
|
59 |
/**
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
|
66 |
-
|
67 |
-
|
68 |
|
69 |
/**
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
82 |
|
83 |
/**
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
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 |
-
|
98 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
|
100 |
/**
|
101 |
-
|
102 |
-
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
|
105 |
/**
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
self::init_settings();
|
120 |
-
self::init_multisite();
|
121 |
-
self::init_templates();
|
122 |
-
self::show_activate_notice();
|
123 |
-
}
|
124 |
-
|
125 |
-
/**
|
126 |
-
* @method init_classes
|
127 |
-
*/
|
128 |
-
static public function init_classes()
|
129 |
-
{
|
130 |
-
$templates_class = FL_BUILDER_DIR . 'classes/class-fl-builder-templates.php';
|
131 |
-
$ms_class = FL_BUILDER_DIR . 'classes/class-fl-builder-multisite.php';
|
132 |
-
$ms_settings_class = FL_BUILDER_DIR . 'classes/class-fl-builder-multisite-settings.php';
|
133 |
-
|
134 |
-
if(file_exists($templates_class)) {
|
135 |
-
require_once $templates_class;
|
136 |
-
}
|
137 |
-
if(is_multisite()) {
|
138 |
-
|
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 |
-
}
|
146 |
-
|
147 |
-
require_once FL_BUILDER_DIR . 'classes/class-fl-builder-admin-settings.php';
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @method init_settings
|
152 |
-
*/
|
153 |
-
static public function init_settings()
|
154 |
-
{
|
155 |
-
FLBuilderAdminSettings::init();
|
156 |
-
}
|
157 |
-
|
158 |
-
/**
|
159 |
-
* @method init_multisite
|
160 |
-
*/
|
161 |
-
static public function init_multisite()
|
162 |
-
{
|
163 |
-
if(is_multisite()) {
|
164 |
-
|
165 |
-
if(class_exists('FLBuilderMultisite')) {
|
166 |
-
FLBuilderMultisite::init();
|
167 |
-
}
|
168 |
-
if(class_exists('FLBuilderMultisiteSettings')) {
|
169 |
-
FLBuilderMultisiteSettings::init();
|
170 |
-
}
|
171 |
-
}
|
172 |
-
}
|
173 |
-
|
174 |
-
/**
|
175 |
-
* @method init_templates
|
176 |
-
*/
|
177 |
-
static public function init_templates()
|
178 |
-
{
|
179 |
-
if(class_exists('FLBuilderTemplates')) {
|
180 |
-
FLBuilderTemplates::init();
|
181 |
-
}
|
182 |
-
}
|
183 |
|
184 |
/**
|
185 |
-
|
186 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
187 |
static public function render_plugin_action_links($actions)
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
$actions[] = '<a href="' . $url . '" style="color:#3db634;" target="_blank">' . _x( 'Upgrade', 'Plugin action link label.', 'fl-builder' ) . '</a>';
|
192 |
-
|
193 |
|
194 |
-
|
195 |
-
|
196 |
|
197 |
/**
|
198 |
-
|
199 |
-
|
|
|
|
|
|
|
|
|
200 |
static public function white_label_plugins_page($plugins)
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
}
|
3 |
/**
|
4 |
* Main builder admin class.
|
5 |
*
|
6 |
+
* @since 1.0
|
7 |
*/
|
8 |
final class FLBuilderAdmin {
|
9 |
|
10 |
/**
|
11 |
+
* Called on plugin activation and checks to see if the correct
|
12 |
+
* WordPress version is installed and multisite is supported. If
|
13 |
+
* all checks are passed the install method is called.
|
14 |
+
*
|
15 |
+
* @since 1.0
|
16 |
+
* @return void
|
17 |
+
*/
|
18 |
+
static public function activate()
|
19 |
+
{
|
20 |
+
global $wp_version;
|
21 |
+
|
22 |
+
// Check for WordPress 3.5 and above.
|
23 |
+
if(version_compare($wp_version, '3.5', '>=')) {
|
24 |
+
|
25 |
+
// Check for multisite.
|
26 |
+
if(is_multisite()) {
|
27 |
+
|
28 |
+
// Init multisite support.
|
29 |
+
self::init_classes();
|
30 |
+
self::init_multisite();
|
31 |
+
|
32 |
+
// This version has multisite support.
|
33 |
+
if(class_exists('FLBuilderMultisite')) {
|
34 |
+
|
35 |
+
if(is_network_admin()) {
|
36 |
+
FLBuilderMultisite::install();
|
37 |
+
}
|
38 |
+
else {
|
39 |
+
self::install();
|
40 |
+
}
|
41 |
+
}
|
42 |
+
// This version doesn't have multisite support.
|
43 |
+
else {
|
44 |
+
$url = FLBuilderModel::get_upgrade_url( array( 'utm_source' => 'external', 'utm_medium' => 'builder', 'utm_campaign' => 'no-multisite-support' ) );
|
45 |
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"' ) );
|
46 |
+
}
|
47 |
+
}
|
48 |
+
// No multisite, standard install.
|
49 |
+
else {
|
50 |
+
self::install();
|
51 |
+
}
|
52 |
+
}
|
53 |
+
// Wrong WordPress version.
|
54 |
+
else {
|
55 |
+
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'));
|
56 |
+
}
|
57 |
+
|
58 |
+
// Success! Trigger the activation notice.
|
59 |
+
if(FL_BUILDER_LITE !== true) {
|
60 |
+
update_site_option('_fl_builder_activation_admin_notice', true);
|
61 |
+
}
|
62 |
+
}
|
63 |
|
64 |
/**
|
65 |
+
* Show a message if there is an activation error and
|
66 |
+
* deactivates the plugin.
|
67 |
+
*
|
68 |
+
* @since 1.0
|
69 |
+
* @param string $message The message to show.
|
70 |
+
* @return void
|
71 |
+
*/
|
72 |
+
static public function show_activate_error($message)
|
73 |
+
{
|
74 |
+
deactivate_plugins( FLBuilderModel::plugin_basename(), false, is_network_admin() );
|
75 |
|
76 |
+
die( $message );
|
77 |
+
}
|
78 |
|
79 |
/**
|
80 |
+
* Sets the action to show the activation success message.
|
81 |
+
*
|
82 |
+
* @since 1.0
|
83 |
+
* @return void
|
84 |
+
*/
|
85 |
+
static public function show_activate_notice()
|
86 |
+
{
|
87 |
+
$notice = get_site_option('_fl_builder_activation_admin_notice');
|
88 |
+
|
89 |
+
if($notice) {
|
90 |
+
add_action('admin_notices', 'FLBuilderAdmin::activate_notice');
|
91 |
+
add_action('network_admin_notices', 'FLBuilderAdmin::activate_notice');
|
92 |
+
delete_site_option('_fl_builder_activation_admin_notice');
|
93 |
+
}
|
94 |
+
}
|
95 |
|
96 |
/**
|
97 |
+
* Shows the activation success message.
|
98 |
+
*
|
99 |
+
* @since 1.0
|
100 |
+
* @return void
|
101 |
+
*/
|
102 |
+
static public function activate_notice()
|
103 |
+
{
|
104 |
+
if ( class_exists('FLBuilderMultisiteSettings') && is_multisite() && current_user_can( 'manage_network_plugins' ) ) {
|
105 |
+
$href = esc_url( network_admin_url( '/settings.php?page=fl-builder-multisite-settings#license' ) );
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
$href = esc_url( admin_url( '/options-general.php?page=fl-builder-settings#license' ) );
|
109 |
+
}
|
110 |
+
|
111 |
+
echo '<div class="updated" style="background: #d3ebc1;">';
|
112 |
echo '<p><strong>' . sprintf( __( 'Page Builder activated! <a%s>Click here</a> to enable remote updates.', 'fl-builder' ), ' href="' . esc_url( $href ) . '"' ) . '</strong></p>';
|
113 |
+
echo '</div>';
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Installs the builder upon successful activation.
|
118 |
+
* Currently not used but may be in the future.
|
119 |
+
*
|
120 |
+
* @since 1.0
|
121 |
+
* @return void
|
122 |
+
*/
|
123 |
+
static public function install() {}
|
124 |
|
125 |
/**
|
126 |
+
* Uninstalls the builder.
|
127 |
+
*
|
128 |
+
* @since 1.0
|
129 |
+
* @return void
|
130 |
+
*/
|
131 |
+
static public function uninstall()
|
132 |
+
{
|
133 |
+
FLBuilderModel::uninstall_database();
|
134 |
+
}
|
135 |
|
136 |
/**
|
137 |
+
* Initializes builder logic for wp-admin.
|
138 |
+
*
|
139 |
+
* @since 1.0
|
140 |
+
* @return void
|
141 |
+
*/
|
142 |
+
static public function init()
|
143 |
+
{
|
144 |
+
self::init_classes();
|
145 |
+
self::init_settings();
|
146 |
+
self::init_multisite();
|
147 |
+
self::init_templates();
|
148 |
+
self::show_activate_notice();
|
149 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
|
151 |
/**
|
152 |
+
* Loads builder classes for wp-admin.
|
153 |
+
*
|
154 |
+
* @since 1.0
|
155 |
+
* @return void
|
156 |
+
*/
|
157 |
+
static public function init_classes()
|
158 |
+
{
|
159 |
+
$templates_class = FL_BUILDER_DIR . 'classes/class-fl-builder-templates.php';
|
160 |
+
$ms_class = FL_BUILDER_DIR . 'classes/class-fl-builder-multisite.php';
|
161 |
+
$ms_settings_class = FL_BUILDER_DIR . 'classes/class-fl-builder-multisite-settings.php';
|
162 |
+
|
163 |
+
if(file_exists($templates_class)) {
|
164 |
+
require_once $templates_class;
|
165 |
+
}
|
166 |
+
if(is_multisite()) {
|
167 |
+
|
168 |
+
if(file_exists($ms_class)) {
|
169 |
+
require_once $ms_class;
|
170 |
+
}
|
171 |
+
if(file_exists($ms_settings_class)) {
|
172 |
+
require_once $ms_settings_class;
|
173 |
+
}
|
174 |
+
}
|
175 |
+
|
176 |
+
require_once FL_BUILDER_DIR . 'classes/class-fl-builder-admin-settings.php';
|
177 |
+
}
|
178 |
+
|
179 |
+
/**
|
180 |
+
* Initializes the builder admin settings page.
|
181 |
+
*
|
182 |
+
* @since 1.0
|
183 |
+
* @return void
|
184 |
+
*/
|
185 |
+
static public function init_settings()
|
186 |
+
{
|
187 |
+
FLBuilderAdminSettings::init();
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Initializes the builder network admin settings page
|
192 |
+
* and additional multisite logic.
|
193 |
+
*
|
194 |
+
* @since 1.0
|
195 |
+
* @return void
|
196 |
+
*/
|
197 |
+
static public function init_multisite()
|
198 |
+
{
|
199 |
+
if(is_multisite()) {
|
200 |
+
|
201 |
+
if(class_exists('FLBuilderMultisite')) {
|
202 |
+
FLBuilderMultisite::init();
|
203 |
+
}
|
204 |
+
if(class_exists('FLBuilderMultisiteSettings')) {
|
205 |
+
FLBuilderMultisiteSettings::init();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
209 |
+
|
210 |
+
/**
|
211 |
+
* Initializes the interface for core builder templates.
|
212 |
+
*
|
213 |
+
* @since 1.0
|
214 |
+
* @return void
|
215 |
+
*/
|
216 |
+
static public function init_templates()
|
217 |
+
{
|
218 |
+
if(class_exists('FLBuilderTemplates')) {
|
219 |
+
FLBuilderTemplates::init();
|
220 |
+
}
|
221 |
+
}
|
222 |
+
|
223 |
+
/**
|
224 |
+
* Renders the link for the row actions on the plugins page.
|
225 |
+
*
|
226 |
+
* @since 1.0
|
227 |
+
* @param array $actions An array of row action links.
|
228 |
+
* @return array
|
229 |
+
*/
|
230 |
static public function render_plugin_action_links($actions)
|
231 |
+
{
|
232 |
+
if(FL_BUILDER_LITE === true) {
|
233 |
+
$url = FLBuilderModel::get_upgrade_url( array( 'utm_source' => 'external', 'utm_medium' => 'builder', 'utm_campaign' => 'plugins-page' ) );
|
234 |
$actions[] = '<a href="' . $url . '" style="color:#3db634;" target="_blank">' . _x( 'Upgrade', 'Plugin action link label.', 'fl-builder' ) . '</a>';
|
235 |
+
}
|
236 |
|
237 |
+
return $actions;
|
238 |
+
}
|
239 |
|
240 |
/**
|
241 |
+
* White labels the builder on the plugins page.
|
242 |
+
*
|
243 |
+
* @since 1.0
|
244 |
+
* @param array $plugins An array data for each plugin.
|
245 |
+
* @return array
|
246 |
+
*/
|
247 |
static public function white_label_plugins_page($plugins)
|
248 |
+
{
|
249 |
+
$default = __( 'Page Builder', 'fl-builder' );
|
250 |
+
$branding = FLBuilderModel::get_branding();
|
251 |
+
$key = FLBuilderModel::plugin_basename();
|
252 |
+
|
253 |
+
if ( isset( $plugins[ $key ] ) && $branding != $default ) {
|
254 |
+
$plugins[ $key ]['Name'] = $branding;
|
255 |
+
$plugins[ $key ]['Title'] = $branding;
|
256 |
+
$plugins[ $key ]['Author'] = '';
|
257 |
+
$plugins[ $key ]['AuthorName'] = '';
|
258 |
+
$plugins[ $key ]['PluginURI'] = '';
|
259 |
+
}
|
260 |
+
|
261 |
+
return $plugins;
|
262 |
+
}
|
263 |
}
|
classes/class-fl-builder-auto-suggest.php
CHANGED
@@ -1,79 +1,92 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* A class for working with auto suggest requests.
|
5 |
*
|
6 |
-
* @
|
7 |
*/
|
8 |
final class FLBuilderAutoSuggest {
|
9 |
|
10 |
-
|
11 |
-
|
12 |
-
|
|
|
|
|
|
|
|
|
13 |
static public function init()
|
14 |
{
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
}
|
42 |
|
43 |
/**
|
44 |
-
|
45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
static public function get_value($action = '', $value = '', $data = '')
|
47 |
{
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
}
|
73 |
|
74 |
/**
|
75 |
-
|
76 |
-
|
|
|
|
|
|
|
77 |
static public function get_like()
|
78 |
{
|
79 |
global $wpdb;
|
@@ -81,168 +94,193 @@ final class FLBuilderAutoSuggest {
|
|
81 |
$like = urldecode( $_REQUEST['fl_as_query'] );
|
82 |
|
83 |
if ( method_exists( $wpdb, 'esc_like' ) ) {
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
$like = like_escape( esc_sql( $like ) );
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
}
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
|
|
|
|
|
|
96 |
static public function posts()
|
97 |
{
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
}
|
117 |
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
|
|
|
|
|
|
|
|
122 |
{
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
}
|
138 |
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
142 |
static public function terms()
|
143 |
{
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
}
|
156 |
|
157 |
-
|
158 |
-
|
159 |
-
|
|
|
|
|
|
|
|
|
|
|
160 |
static public function terms_value($ids, $taxonomy)
|
161 |
{
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
}
|
179 |
|
180 |
-
|
181 |
-
|
182 |
-
|
|
|
|
|
|
|
183 |
static public function users()
|
184 |
{
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
}
|
197 |
|
198 |
-
|
199 |
-
|
200 |
-
|
|
|
|
|
|
|
|
|
201 |
static public function users_value($ids)
|
202 |
{
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
}
|
218 |
|
219 |
-
|
220 |
-
|
221 |
-
|
|
|
|
|
|
|
222 |
static public function links()
|
223 |
{
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
}
|
248 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* A class for working with auto suggest AJAX requests.
|
5 |
*
|
6 |
+
* @since 1.2.3
|
7 |
*/
|
8 |
final class FLBuilderAutoSuggest {
|
9 |
|
10 |
+
/**
|
11 |
+
* Checks for an auto suggest request. If one is found
|
12 |
+
* the data will be echoed as a JSON response.
|
13 |
+
*
|
14 |
+
* @since 1.2.3
|
15 |
+
* @return void
|
16 |
+
*/
|
17 |
static public function init()
|
18 |
{
|
19 |
+
if(isset($_REQUEST['fl_as_action']) && isset($_REQUEST['fl_as_query'])) {
|
20 |
+
|
21 |
+
switch($_REQUEST['fl_as_action']) {
|
22 |
+
|
23 |
+
case 'fl_as_posts':
|
24 |
+
$data = self::posts();
|
25 |
+
break;
|
26 |
+
|
27 |
+
case 'fl_as_terms':
|
28 |
+
$data = self::terms();
|
29 |
+
break;
|
30 |
+
|
31 |
+
case 'fl_as_users':
|
32 |
+
$data = self::users();
|
33 |
+
break;
|
34 |
+
|
35 |
+
case 'fl_as_links':
|
36 |
+
$data = self::links();
|
37 |
+
break;
|