PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.2
4.0.3 4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 All 341 releases
← All changes | index.php +496 -133 2.0.44.0.2 View file →
@@ -1,162 +1,525 @@
1 1 <?php
2 -/*
3 -Plugin Name: Profile Builder
4 -Plugin URI: http://www.cozmoslabs.com/wordpress-profile-builder/
5 -Description: Login, registration and edit profile shortcodes for the front-end. Also you can chose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
6 -Version: 2.0.4
7 -Author: Cozmoslabs, Madalin Ungureanu, Antohe Cristian, Barina Gabriel
8 -Author URI: http://www.cozmoslabs.com/
9 -License: GPL2
2 +/**
3 + * Plugin Name: Profile Builder
4 + * Plugin URI: https://www.cozmoslabs.com/wordpress-profile-builder/
5 + * Description: Login, registration and edit profile shortcodes for the front-end. Also you can choose what fields should be displayed or add new (custom) ones both in the front-end and in the dashboard.
6 + * Version: 4.0.2
7 + * Author: Cozmoslabs
8 + * Author URI: https://www.cozmoslabs.com/
9 + * Text Domain: profile-builder
10 + * Domain Path: /translation
11 + * License: GPL2
12 + * WC requires at least: 3.0.0
13 + * WC tested up to: 11.1
14 + * Elementor tested up to: 4.2.3
15 + * Elementor Pro tested up to: 4.2.3
16 + *
17 + * == Copyright ==
18 + * Copyright 2014 Cozmoslabs (www.cozmoslabs.com)
19 + *
20 + * This program is free software; you can redistribute it and/or modify
21 + * it under the terms of the GNU General Public License as published by
22 + * the Free Software Foundation; either version 2 of the License, or
23 + * (at your option) any later version.
24 + * This program is distributed in the hope that it will be useful,
25 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
26 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27 + * GNU General Public License for more details.
28 + * You should have received a copy of the GNU General Public License
29 + * along with this program; if not, write to the Free Software
30 + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 +*/
10 32
11 -== Copyright ==
12 -Copyright 2014 Cozmoslabs (www.cozmoslabs.com)
33 +if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
13 34
14 -This program is free software; you can redistribute it and/or modify
15 -it under the terms of the GNU General Public License as published by
16 -the Free Software Foundation; either version 2 of the License, or
17 -(at your option) any later version.
18 -This program is distributed in the hope that it will be useful,
19 -but WITHOUT ANY WARRANTY; without even the implied warranty of
20 -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 -GNU General Public License for more details.
22 -You should have received a copy of the GNU General Public License
23 -along with this program; if not, write to the Free Software
24 -Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 -*/
35 +/* Check if another version of Profile Builder is activated, to prevent fatal errors*/
36 +function wppb_plugin_init() {
37 + if (function_exists('wppb_return_bytes')) {
38 + function wppb_admin_notice()
39 + {
40 + ?>
41 + <div class="error">
42 + <p>
43 + <?php
44 + /* translators: %s is the plugin version name */
45 + echo wp_kses_post( sprintf( __( '%s is also activated. You need to deactivate it before activating this version of the plugin.', 'profile-builder'), PROFILE_BUILDER ) );
46 + ?>
47 + </p>
48 + </div>
49 + <?php
50 + }
51 + function wppb_plugin_deactivate() {
52 + deactivate_plugins( plugin_basename( __FILE__ ) );
53 + unset($_GET['activate']);
54 + }
26 55
56 + add_action('admin_notices', 'wppb_admin_notice');
57 + add_action( 'admin_init', 'wppb_plugin_deactivate' );
58 + } else {
59 +
60 + /**
61 + * Convert memory value from ini file to a readable form
62 + *
63 + * @since v.1.0
64 + *
65 + * @return integer
66 + */
67 + function wppb_return_bytes($val)
68 + {
69 + return wp_convert_hr_to_bytes($val);
70 + }
71 +
72 + /* include notices class */
73 + if ( file_exists(WPPB_PLUGIN_DIR . '/assets/lib/class_notices.php') )
74 + include_once(WPPB_PLUGIN_DIR . '/assets/lib/class_notices.php');
75 +
76 + /* include review class */
77 + if (file_exists(WPPB_PLUGIN_DIR . '/admin/review.php')){
78 + include_once(WPPB_PLUGIN_DIR . '/admin/review.php');
79 + $wppb_review_request = new WPPB_Review_Request ();
80 + }
81 +
82 + /**
83 + * Initialize the translation for the Plugin.
84 + *
85 + * @since v.1.0
86 + *
87 + * @return null
88 + */
89 + function wppb_init_translation(){
90 + $current_theme = wp_get_theme();
91 + if( !empty( $current_theme->stylesheet ) && file_exists( get_theme_root().'/'. $current_theme->stylesheet .'/local_pb_lang' ) )
92 + load_plugin_textdomain( 'profile-builder', false, basename( dirname( __FILE__ ) ).'/../../themes/'.$current_theme->stylesheet.'/local_pb_lang' );
93 + else
94 + load_plugin_textdomain( 'profile-builder', false, basename(dirname(__FILE__)) . '/translation/' );
95 + }
96 +
97 + add_action('init', 'wppb_init_translation', 8);
98 +
99 +
100 + /**
101 + * Required files
102 + *
103 + *
104 + */
105 + include_once(WPPB_PLUGIN_DIR . '/assets/lib/wck-api/wordpress-creation-kit.php');
106 + include_once(WPPB_PLUGIN_DIR . '/features/upgrades/upgrades.php');
107 + include_once(WPPB_PLUGIN_DIR . '/features/functions.php');
108 + include_once(WPPB_PLUGIN_DIR . '/admin/admin-functions.php');
109 + include_once(WPPB_PLUGIN_DIR . '/admin/setup-wizard.php');
110 + include_once(WPPB_PLUGIN_DIR . '/admin/dashboard.php');
111 + include_once(WPPB_PLUGIN_DIR . '/admin/basic-info.php');
112 + include_once(WPPB_PLUGIN_DIR . '/admin/general-settings.php');
113 + include_once(WPPB_PLUGIN_DIR . '/admin/advanced-settings/advanced-settings.php');
114 + include_once(WPPB_PLUGIN_DIR . '/admin/private-website.php');
115 + include_once(WPPB_PLUGIN_DIR . '/admin/manage-fields.php');
116 + include_once(WPPB_PLUGIN_DIR . '/admin/pms-cross-promotion.php');
117 + include_once(WPPB_PLUGIN_DIR . '/admin/support-chat.php');
118 + //include_once(WPPB_PLUGIN_DIR . '/admin/feedback.php');//removed in version 2.9.7
119 + include_once(WPPB_PLUGIN_DIR . '/features/email-confirmation/email-confirmation.php');
120 + include_once(WPPB_PLUGIN_DIR . '/features/email-confirmation/class-email-confirmation.php');
121 +
122 + if( file_exists( WPPB_PLUGIN_DIR . '/admin/plugin-optin/class-plugin-optin.php' ) ){
123 + include_once( WPPB_PLUGIN_DIR . '/admin/plugin-optin/class-plugin-optin.php' );
124 + }
125 +
126 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/admin-approval/admin-approval.php' ) ) {
127 + include_once(WPPB_PAID_PLUGIN_DIR . '/features/admin-approval/admin-approval.php');
128 + include_once(WPPB_PAID_PLUGIN_DIR . '/features/admin-approval/class-admin-approval.php');
129 + }
130 +
131 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/form-designs.php' ) ) {
132 + include_once(WPPB_PAID_PLUGIN_DIR . '/features/form-designs/form-designs.php');
133 + }
134 +
135 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/color-switcher.php' ) ) {
136 + include_once( WPPB_PAID_PLUGIN_DIR . '/features/form-designs/color-switcher.php' );
137 + }
138 +
139 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/ajax/ajax-functions.php' ) ) {
140 + include_once( WPPB_PAID_PLUGIN_DIR . '/features/ajax/ajax-functions.php' );
141 + }
142 +
143 + if ( wppb_conditional_fields_exists() ) {
144 + include_once(WPPB_PAID_PLUGIN_DIR . '/features/conditional-fields/conditional-fields.php');
145 + }
146 +
147 + include_once(WPPB_PLUGIN_DIR . '/features/login-widget/login-widget.php');
148 + include_once(WPPB_PLUGIN_DIR . '/features/roles-editor/roles-editor.php');
149 + include_once(WPPB_PLUGIN_DIR . '/features/content-restriction/content-restriction.php');
150 +
151 + /* include 2fa class */
152 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php' ) ){
153 + include_once( WPPB_PAID_PLUGIN_DIR . '/features/two-factor-authentication/class-two-factor-authentication.php' );
154 + new WPPB_Two_Factor_Authenticator();
155 + }
156 +
157 + if ( file_exists( WPPB_PLUGIN_DIR . '/admin/register-version.php' ) ) {
158 + include_once( WPPB_PLUGIN_DIR . '/admin/register-version.php' );
159 + }
160 +
161 + // Forms Rework (free): default forms always; extra forms need paid
162 + // (wppb_fb_multiple_forms_available). require_once — silent skip would
163 + // break per-form field lists with no error.
164 + require_once( WPPB_PLUGIN_DIR . 'form-builder/form-builder-init.php' );
165 +
166 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) ) {
167 +
168 + include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php');
169 + // include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/repeater-field/repeater-module.php');
170 + include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/custom-redirects/custom-redirects.php');
171 + include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/user-listing/userlisting.php');
172 +
173 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/file-restriction/index.php' ) )
174 + include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/file-restriction/index.php' );
175 +
176 + $wppb_module_settings = get_option('wppb_module_settings');
177 + if (isset($wppb_module_settings['wppb_userListing']) && ($wppb_module_settings['wppb_userListing'] == 'show')) {
178 + add_shortcode('wppb-list-users', 'wppb_user_listing_shortcode');
179 + } else
180 + add_shortcode('wppb-list-users', 'wppb_list_all_users_display_error');
181 +
182 + }
183 +
184 + // Email Customizer is in free since 3.8.1
185 + if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){
186 + include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' );
187 + include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/admin-email-customizer.php' );
188 + include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/user-email-customizer.php' );
189 + }
190 +
191 + include_once(WPPB_PLUGIN_DIR . '/admin/add-ons.php');
192 + include_once(WPPB_PLUGIN_DIR . '/assets/misc/plugin-compatibilities.php');
193 +
194 + /* added recaptcha and user role field since version 2.6.2 */
195 + include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/recaptcha/recaptcha.php'); //need to load this here for displaying reCAPTCHA on Login and Recover Password forms
196 +
197 + /* added turnstile field since version 3.15. */
198 + include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/turnstile/turnstile.php');
199 +
200 + // Elementor PRO
201 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/elementor-pro/elementor-pro.php' ) ) {
202 + $active_wp_plugins = get_option('active_plugins');
203 +
204 + if ( !empty( $active_wp_plugins ) && in_array( 'elementor-pro/elementor-pro.php', $active_wp_plugins ) )
205 + include_once(WPPB_PAID_PLUGIN_DIR . '/features/elementor-pro/elementor-pro.php');
206 + }
207 +
208 + //Elementor Widgets
209 + if ( did_action( 'elementor/loaded' ) ) {
210 + if (file_exists(WPPB_PLUGIN_DIR . 'assets/misc/elementor/class-elementor.php'))
211 + include_once WPPB_PLUGIN_DIR . 'assets/misc/elementor/class-elementor.php';
212 + }
213 +
214 + //Divi Extension
215 + if (file_exists(WPPB_PLUGIN_DIR . 'assets/misc/divi/profile-builder-divi-extension.php'))
216 + include_once WPPB_PLUGIN_DIR . 'assets/misc/divi/profile-builder-divi-extension.php';
217 +
218 + //Block Editor Assets
219 + global $wp_version;
220 + if ( version_compare( $wp_version, "5.0.0", ">=" ) ) {
221 + if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/enqueue-block-editor-assets.php' ) )
222 + include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/enqueue-block-editor-assets.php';
223 + }
224 +
225 + //Block Content Restriction
226 + global $content_restriction_activated;
227 + if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
228 + if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/block-content-restriction/block-content-restriction.php' ) )
229 + include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/block-content-restriction/block-content-restriction.php';
230 + }
231 +
232 + //Elementor Content Restriction
233 + if ( $content_restriction_activated == 'yes' && did_action( 'elementor/loaded' ) ) {
234 + if( file_exists( WPPB_PLUGIN_DIR . 'features/content-restriction/class-elementor-content-restriction.php' ) )
235 + include_once WPPB_PLUGIN_DIR . 'features/content-restriction/class-elementor-content-restriction.php';
236 + }
237 +
238 + //Include Free Add-ons
239 + $wppb_free_add_ons_settings = get_option( 'wppb_free_add_ons_settings', array() );
240 + if( !empty( $wppb_free_add_ons_settings ) ){
241 +
242 + if( isset( $wppb_free_add_ons_settings['custom-css-classes-on-fields'] ) && $wppb_free_add_ons_settings['custom-css-classes-on-fields'] ){
243 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/custom-css-classes-on-fields/custom-css-classes-on-fields.php' ) )
244 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/custom-css-classes-on-fields/custom-css-classes-on-fields.php';
245 + }
246 +
247 + if( isset( $wppb_free_add_ons_settings['gdpr-communication-preferences'] ) && $wppb_free_add_ons_settings['gdpr-communication-preferences'] ){
248 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/gdpr-communication-preferences/gdpr-communication-preferences.php' ) )
249 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/gdpr-communication-preferences/gdpr-communication-preferences.php';
250 + }
251 +
252 + if( isset( $wppb_free_add_ons_settings['import-export'] ) && $wppb_free_add_ons_settings['import-export'] ){
253 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/import-export/import-export.php' ) )
254 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/import-export/import-export.php';
255 + }
256 +
257 + if( isset( $wppb_free_add_ons_settings['labels-edit'] ) && $wppb_free_add_ons_settings['labels-edit'] ){
258 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/labels-edit/labels-edit.php' ) )
259 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/labels-edit/labels-edit.php';
260 + }
261 +
262 + if( isset( $wppb_free_add_ons_settings['maximum-character-length'] ) && $wppb_free_add_ons_settings['maximum-character-length'] ){
263 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/maximum-character-length/maximum-character-length.php' ) )
264 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/maximum-character-length/maximum-character-length.php';
265 + }
266 +
267 + if( isset( $wppb_free_add_ons_settings['user-profile-picture'] ) && $wppb_free_add_ons_settings['user-profile-picture'] ){
268 + if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/user-profile-picture/metronet-profile-picture.php' ) )
269 + include_once WPPB_PLUGIN_DIR . 'add-ons-free/user-profile-picture/metronet-profile-picture.php';
270 + }
271 +
272 + }
273 +
274 + //Include Advanced Add-ons
275 +
276 + if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){
277 +
278 + $wppb_advanced_add_ons_settings = get_option( 'wppb_advanced_add_ons_settings', array() );
279 + if( !empty( $wppb_advanced_add_ons_settings ) ){
280 +
281 + if( isset( $wppb_advanced_add_ons_settings['buddypress'] ) && $wppb_advanced_add_ons_settings['buddypress'] ){
282 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/index.php' ) )
283 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/index.php';
284 + }
285 +
286 + if( isset( $wppb_advanced_add_ons_settings['social-connect'] ) && $wppb_advanced_add_ons_settings['social-connect'] ){
287 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/social-connect/index.php' ) )
288 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/social-connect/index.php';
289 + }
290 +
291 + if( isset( $wppb_advanced_add_ons_settings['woocommerce'] ) && $wppb_advanced_add_ons_settings['woocommerce'] ){
292 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/index.php' ) )
293 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/index.php';
294 + }
295 +
296 + if( isset( $wppb_advanced_add_ons_settings['multi-step-forms'] ) && $wppb_advanced_add_ons_settings['multi-step-forms'] ){
297 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/index.php' ) )
298 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/index.php';
299 + }
300 +
301 + if( isset( $wppb_advanced_add_ons_settings['form-fields-in-columns'] ) && $wppb_advanced_add_ons_settings['form-fields-in-columns'] ){
302 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/index.php' ) )
303 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/index.php';
304 + }
305 +
306 + if( isset( $wppb_advanced_add_ons_settings['mailchimp-integration'] ) && $wppb_advanced_add_ons_settings['mailchimp-integration'] ){
307 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp-integration/index.php' ) )
308 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp-integration/index.php';
309 + }
310 +
311 + if( isset( $wppb_advanced_add_ons_settings['bbpress'] ) && $wppb_advanced_add_ons_settings['bbpress'] ){
312 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/bbpress/index.php' ) )
313 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/bbpress/index.php';
314 + }
315 +
316 + if( isset( $wppb_advanced_add_ons_settings['campaign-monitor'] ) && $wppb_advanced_add_ons_settings['campaign-monitor'] ){
317 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/index.php' ) )
318 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/index.php';
319 + }
320 +
321 + if( isset( $wppb_advanced_add_ons_settings['field-visibility'] ) && $wppb_advanced_add_ons_settings['field-visibility'] ){
322 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/index.php' ) )
323 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/index.php';
324 + }
325 +
326 + if( isset( $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] ) && $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] ){
327 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/edit-profile-approved-by-admin/index.php' ) )
328 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/edit-profile-approved-by-admin/index.php';
329 + }
330 +
331 + if( isset( $wppb_advanced_add_ons_settings['custom-profile-menus'] ) && $wppb_advanced_add_ons_settings['custom-profile-menus'] ){
332 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/custom-profile-menus/index.php' ) )
333 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/custom-profile-menus/index.php';
334 + }
335 +
336 + if( isset( $wppb_advanced_add_ons_settings['mailpoet-integration'] ) && $wppb_advanced_add_ons_settings['mailpoet-integration'] ){
337 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailpoet-integration/index.php' ) )
338 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailpoet-integration/index.php';
339 + }
340 +
341 + if( isset( $wppb_advanced_add_ons_settings['progress-bar'] ) && $wppb_advanced_add_ons_settings['progress-bar'] ){
342 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/progress-bar/index.php' ) )
343 + include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/progress-bar/index.php';
344 + }
345 +
346 + }
347 +
348 + /**
349 + * Include add-on files that contain activation hooks even when add-ons are deactivated
350 + *
351 + * Necessary in order to perform actions during the operation of activation or deactivation of that add-on
352 + */
353 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/buddypress-activator.php') )
354 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/buddypress-activator.php';
355 +
356 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/campaign-monitor-activator.php') )
357 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/campaign-monitor-activator.php';
358 +
359 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/field-visibility-activator.php') )
360 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/field-visibility-activator.php';
361 +
362 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp/mailchimp-activator.php') )
363 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp/mailchimp-activator.php';
364 +
365 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/multi-step-forms-activator.php') )
366 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/multi-step-forms-activator.php';
367 +
368 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/form-fields-in-columns-activator.php') )
369 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/form-fields-in-columns-activator.php';
370 +
371 + if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/woocommerce-activator.php') )
372 + require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/woocommerce-activator.php';
373 +
374 + }
375 +
376 +
377 +// these settings are important, so besides running them on page load, we also need to do a check on plugin activation
378 + add_action('init', 'wppb_generate_default_settings_defaults'); //prepoulate general settings
379 + add_action('init', 'wppb_prepopulate_fields'); //prepopulate manage fields list
380 +
381 + }
382 +} //end wppb_plugin_init
383 +add_action( 'plugins_loaded', 'wppb_plugin_init' );
384 +
27 385 /**
28 - * Convert memory value from ini file to a readable form
386 + * Definitions
29 387 *
30 - * @since v.1.0
31 388 *
32 - * @return integer
33 389 */
34 -function wppb_return_bytes( $val ) {
35 - $val = trim( $val );
36 -
37 - switch( strtolower( $val[strlen( $val )-1] ) ) {
38 - // The 'G' modifier is available since PHP 5.1.0
39 - case 'g':
40 - $val *= 1024;
41 - case 'm':
42 - $val *= 1024;
43 - case 'k':
44 - $val *= 1024;
390 +define('PROFILE_BUILDER_VERSION', '4.0.2' );
391 +define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__));
392 +define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__));
393 +define('WPPB_PLUGIN_BASENAME', plugin_basename(__FILE__));
394 +define('WPPB_TRANSLATE_DIR', WPPB_PLUGIN_DIR . '/translation');
395 +define('WPPB_TRANSLATE_DOMAIN', 'profile-builder');
396 +
397 +// Determine which plugin version is active
398 +$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
399 +$active_network_plugins = get_site_option('active_sitewide_plugins');
400 +
401 +if ( in_array( 'profile-builder-pro/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-pro/index.php'] ) ){
402 +
403 + define('PROFILE_BUILDER', 'Profile Builder Pro');
404 + define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-pro' );
405 + define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-pro/' );
406 +
407 +} elseif ( in_array( 'profile-builder-dev/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-dev/index.php'] ) ){
408 +
409 + define('PROFILE_BUILDER', 'Profile Builder Pro');
410 + define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-dev' );
411 + define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-dev/' );
412 + define('PROFILE_BUILDER_PAID_VERSION', 'dev' );
413 +
414 +} elseif ( in_array( 'profile-builder-agency/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-agency/index.php'] ) ){
415 +
416 + define('PROFILE_BUILDER', 'Profile Builder Agency');
417 + define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-agency' );
418 + define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-agency/' );
419 +
420 +} elseif ( in_array( 'profile-builder-unlimited/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-unlimited/index.php'] ) ){
421 +
422 + define('PROFILE_BUILDER', 'Profile Builder Unlimited');
423 + define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-unlimited' );
424 + define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-unlimited/' );
425 +
426 +} elseif ( in_array( 'profile-builder-hobbyist/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-hobbyist/index.php'] ) ){
427 +
428 + define('PROFILE_BUILDER', 'Profile Builder Basic');
429 + define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-hobbyist' );
430 + define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-hobbyist/' );
431 +
432 +} else
433 + define('PROFILE_BUILDER', 'Profile Builder Free');
434 +
435 +if ( ! function_exists( 'wppb_paid_plugin_owns_updates' ) ) {
436 + function wppb_paid_plugin_owns_updates() {
437 +
438 + if ( ! defined( 'WPPB_PAID_PLUGIN_DIR' ) || ! defined( 'WPPB_PLUGIN_DIR' ) )
439 + return false;
440 +
441 + if ( trailingslashit( WPPB_PAID_PLUGIN_DIR ) === trailingslashit( WPPB_PLUGIN_DIR ) )
442 + return false;
443 +
444 + return file_exists( WPPB_PAID_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php' );
445 +
45 446 }
46 -
47 - return $val;
48 447 }
49 448
50 449 /**
51 - * Definitions
52 - *
53 - *
450 + * Load the EDD updater from the paid wrapper when it owns updates.
54 451 */
55 -define( 'PROFILE_BUILDER_VERSION', '2.0.4' );
56 -define( 'WPPB_PLUGIN_DIR', WP_PLUGIN_DIR . '/' . dirname( plugin_basename( __FILE__ ) ) );
57 -define( 'WPPB_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
58 -define( 'WPPB_SERVER_MAX_UPLOAD_SIZE_BYTE', apply_filters( 'wppb_server_max_upload_size_byte_constant', wppb_return_bytes( ini_get( 'upload_max_filesize') ) ) );
59 -define( 'WPPB_SERVER_MAX_UPLOAD_SIZE_MEGA', apply_filters( 'wppb_server_max_upload_size_mega_constant', ini_get( 'upload_max_filesize') ) );
60 -define( 'WPPB_SERVER_MAX_POST_SIZE_BYTE', apply_filters( 'wppb_server_max_post_size_byte_constant', wppb_return_bytes( ini_get( 'post_max_size') ) ) );
61 -define( 'WPPB_SERVER_MAX_POST_SIZE_MEGA', apply_filters( 'wppb_server_max_post_size_mega_constant', ini_get( 'post_max_size') ) );
62 -define( 'WPPB_TRANSLATE_DIR', WPPB_PLUGIN_DIR.'/translation' );
63 -define( 'WPPB_TRANSLATE_DOMAIN', 'profilebuilder' );
452 +if ( ! function_exists( 'wppb_paid_plugin_load_updater' ) ) {
453 + function wppb_paid_plugin_load_updater() {
64 454
65 -/* include notices class */
66 -if ( file_exists ( WPPB_PLUGIN_DIR.'/assets/lib/class_notices.php' ) )
67 - include_once(WPPB_PLUGIN_DIR . '/assets/lib/class_notices.php' );
455 + if ( class_exists( 'WPPB_Plugin_Updater', false ) )
456 + return;
68 457
69 -if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) )
70 - define( 'PROFILE_BUILDER', 'Profile Builder Pro' );
71 -elseif ( file_exists ( WPPB_PLUGIN_DIR.'/front-end/extra-fields/extra-fields.php' ) )
72 - define( 'PROFILE_BUILDER', 'Profile Builder Hobbyist' );
73 -else
74 - define( 'PROFILE_BUILDER', 'Profile Builder Free' );
458 + if ( ! function_exists( 'wppb_paid_plugin_owns_updates' ) || ! wppb_paid_plugin_owns_updates() )
459 + return;
75 460
76 -/**
77 - * Initialize the translation for the Plugin.
78 - *
79 - * @since v.1.0
80 - *
81 - * @return null
82 - */
83 -function wppb_init_translation(){
84 - load_plugin_textdomain( 'profilebuilder', false, basename( dirname( __FILE__ ) ) . '/translation/' );
461 + require_once WPPB_PAID_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php';
462 +
463 + }
85 464 }
86 -add_action( 'init', 'wppb_init_translation' );
87 465
466 +add_action( 'plugins_loaded', 'wppb_paid_plugin_load_updater', 0 );
88 467
468 +// Needs to be loaded early for Upload fields to work correctly
469 +if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/repeater-field/repeater-module.php' ) )
470 + include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons/repeater-field/repeater-module.php' );
471 +
472 +// This needs to be loaded here since we try to plug some functions, not suited for plugins_loaded hook
473 +if ( file_exists( WPPB_PLUGIN_DIR . '/front-end/default-fields/upload/upload_helper_functions.php' ) )
474 + include_once( WPPB_PLUGIN_DIR . '/front-end/default-fields/upload/upload_helper_functions.php' );
475 +
476 +/* add a redirect when plugin is activated */
477 +if( !function_exists( 'wppb_activate_plugin_redirect' ) ){
478 + function wppb_activate_plugin_redirect( $plugin ) {
479 + if( !wp_doing_ajax() && $plugin == plugin_basename( __FILE__ ) ) {
480 + wp_safe_redirect( admin_url( 'admin.php?page=profile-builder-basic-info' ) );
481 + exit();
482 + }
483 + }
484 + add_action( 'activated_plugin', 'wppb_activate_plugin_redirect' );
485 +}
486 +
89 487 /**
90 - * Required files
488 + * Check if Setup Wizard should run
91 489 *
92 - *
93 490 */
94 -include_once( WPPB_PLUGIN_DIR.'/assets/lib/wck-api/wordpress-creation-kit.php' );
95 -include_once( WPPB_PLUGIN_DIR.'/features/upgrades/upgrades.php' );
96 -include_once( WPPB_PLUGIN_DIR.'/features/functions.php' );
97 -include_once( WPPB_PLUGIN_DIR.'/admin/admin-functions.php' );
98 -include_once( WPPB_PLUGIN_DIR.'/admin/basic-info.php' );
99 -include_once( WPPB_PLUGIN_DIR.'/admin/general-settings.php' );
100 -include_once( WPPB_PLUGIN_DIR.'/admin/admin-bar.php' );
101 -include_once( WPPB_PLUGIN_DIR.'/admin/manage-fields.php' );
102 -include_once( WPPB_PLUGIN_DIR.'/features/email-confirmation/email-confirmation.php' );
103 -include_once( WPPB_PLUGIN_DIR.'/features/email-confirmation/class-email-confirmation.php' );
104 -if ( file_exists ( WPPB_PLUGIN_DIR.'/features/admin-approval/admin-approval.php' ) ) {
105 - include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/admin-approval.php');
106 - include_once(WPPB_PLUGIN_DIR . '/features/admin-approval/class-admin-approval.php');
107 -}
108 -include_once( WPPB_PLUGIN_DIR.'/features/login-widget/login-widget.php' );
491 +function wppb_set_setup_wizard_transient() {
109 492
110 -if ( file_exists ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ) ){
111 - include_once ( WPPB_PLUGIN_DIR.'/update/update-checker.php' );
112 - include_once ( WPPB_PLUGIN_DIR.'/admin/register-version.php' );
113 -}
493 + $slugs = array(
494 + '/profile-builder-pro/index.php',
495 + '/profile-builder-dev/index.php',
496 + '/profile-builder-agency/index.php',
497 + '/profile-builder-unlimited/index.php',
498 + '/profile-builder-hobbyist/index.php',
499 + '/metronet-profile-picture/metronet-profile-picture.php',
500 + '/user-profile-picture-dev/metronet-profile-picture.php',
501 + '/user-profile-picture/metronet-profile-picture.php',
502 + );
114 503
115 -if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ){
116 - include_once ( WPPB_PLUGIN_DIR.'/modules/modules.php' );
117 - include_once ( WPPB_PLUGIN_DIR.'/modules/custom-redirects/custom-redirects.php' );
118 - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/email-customizer.php' );
119 - include_once ( WPPB_PLUGIN_DIR.'/modules/multiple-forms/multiple-forms.php' );
120 -
121 - $wppb_module_settings = get_option( 'wppb_module_settings' );
122 - if ( isset( $wppb_module_settings['wppb_userListing'] ) && ( $wppb_module_settings['wppb_userListing'] == 'show' ) ){
123 - include_once ( WPPB_PLUGIN_DIR.'/modules/user-listing/userlisting.php' );
124 - add_shortcode( 'wppb-list-users', 'wppb_user_listing_shortcode' );
125 - }else
126 - add_shortcode( 'wppb-list-users', 'wppb_list_all_users_display_error' );
127 -
128 - if ( isset( $wppb_module_settings['wppb_emailCustomizerAdmin'] ) && ( $wppb_module_settings['wppb_emailCustomizerAdmin'] == 'show' ) )
129 - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/admin-email-customizer.php' );
130 -
131 - if ( isset( $wppb_module_settings['wppb_emailCustomizer'] ) && ( $wppb_module_settings['wppb_emailCustomizer'] == 'show' ) )
132 - include_once ( WPPB_PLUGIN_DIR.'/modules/email-customizer/user-email-customizer.php' );
133 -}
504 + $paid_plugin_active = false;
134 505
506 + foreach( $slugs as $slug ){
507 + if( file_exists( WP_PLUGIN_DIR . $slug ) ){
508 + $paid_plugin_active = true;
509 + break;
510 + }
511 + }
135 512
136 -/**
137 - * Check for updates
138 - *
139 - *
140 - */
141 -if ( file_exists ( WPPB_PLUGIN_DIR.'/update/update-checker.php' ) ){
142 - if ( file_exists ( WPPB_PLUGIN_DIR.'/modules/modules.php' ) ){
143 - $localSerial = get_option( 'wppb_profile_builder_pro_serial' );
144 - $wppb_update = new wppb_PluginUpdateChecker( 'http://updatemetadata.cozmoslabs.com/?localSerialNumber='.$localSerial.'&uniqueproduct=CLPBP', __FILE__, 'profile-builder-pro-update' );
145 -
146 - }else{
147 - $localSerial = get_option( 'wppb_profile_builder_hobbyist_serial' );
148 - $wppb_update = new wppb_PluginUpdateChecker( 'http://updatemetadata.cozmoslabs.com/?localSerialNumber='.$localSerial.'&uniqueproduct=CLPBH', __FILE__, 'profile-builder-hobbyist-update' );
149 - }
150 -}
513 + // Run Setup Wizard ?
514 + if ( !$paid_plugin_active )
515 + set_transient( 'wppb_run_setup_wizard', 'true', 120 );
151 516
517 + do_action( 'wppb_register_activation_hook' );
152 518
153 -// these settings are important, so besides running them on page load, we also need to do a check on plugin activation
154 -register_activation_hook( __FILE__, 'wppb_generate_default_settings_defaults' ); //prepoulate general settings
155 -register_activation_hook( __FILE__, 'wppb_prepopulate_fields' ); //prepopulate manage fields list
519 +}
520 +register_activation_hook( __FILE__, 'wppb_set_setup_wizard_transient' );
156 521
157 -/* Add a halloween notice */
158 -new WPPB_Add_General_Notices( 'wppb_halloween',
159 - sprintf( __( '<p style="position:relative;">Halloween treat: 30&#37; OFF on all Profile Builder purchases 29 - 30 -31 October over at %1$swww.cozmslabs.com%2$s Get your discount code! %3$sDismiss%4$s</p>', 'profilebuilder'), "<a href='http://www.cozmoslabs.com/' target='_blank' class='button-primary'>", "</a>", "<a href='". add_query_arg( 'wppb_halloween_dismiss_notification', '0' ) ."' class='wppb-dismiss-notification' style='position: absolute;right: 0;top: 50%;margin-top: -7px;'>", "</a>" ),
160 - 'updated halloween',
161 - '28 October 2014',
162 - '1 November 2014' );
522 +function wppb_register_deactivation_hook() {
523 + do_action( 'wppb_register_deactivation_hook' );
524 +}
525 +register_deactivation_hook( __FILE__, 'wppb_register_deactivation_hook' );