PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.6
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 2.0.7 All 340 releases
profile-builder / index.php

index.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.6, at index.php

590 lines 31.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
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: 3.16.6
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: 10.9
14 * Elementor tested up to: 4.2.0
15 * Elementor Pro tested up to: 4.2.0
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 */
32
33 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
34
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 }
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 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php' ) ) {
162
163 include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/add-ons.php');
164 // include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/repeater-field/repeater-module.php');
165 include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/custom-redirects/custom-redirects.php');
166 include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/multiple-forms/multiple-forms.php');
167 include_once(WPPB_PAID_PLUGIN_DIR . '/add-ons/user-listing/userlisting.php');
168
169 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/file-restriction/index.php' ) )
170 include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/file-restriction/index.php' );
171
172 $wppb_module_settings = get_option('wppb_module_settings');
173 if (isset($wppb_module_settings['wppb_userListing']) && ($wppb_module_settings['wppb_userListing'] == 'show')) {
174 add_shortcode('wppb-list-users', 'wppb_user_listing_shortcode');
175 } else
176 add_shortcode('wppb-list-users', 'wppb_list_all_users_display_error');
177
178 }
179
180 // Email Customizer is in free since 3.8.1
181 if( file_exists( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' ) ){
182 include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/email-customizer.php' );
183 include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/admin-email-customizer.php' );
184 include_once( WPPB_PLUGIN_DIR . '/features/email-customizer/user-email-customizer.php' );
185 }
186
187 include_once(WPPB_PLUGIN_DIR . '/admin/add-ons.php');
188 include_once(WPPB_PLUGIN_DIR . '/assets/misc/plugin-compatibilities.php');
189
190 /* added recaptcha and user role field since version 2.6.2 */
191 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
192
193 /* added turnstile field since version 3.15. */
194 include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/turnstile/turnstile.php');
195
196 // Elementor PRO
197 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/features/elementor-pro/elementor-pro.php' ) ) {
198 $active_wp_plugins = get_option('active_plugins');
199
200 if ( !empty( $active_wp_plugins ) && in_array( 'elementor-pro/elementor-pro.php', $active_wp_plugins ) )
201 include_once(WPPB_PAID_PLUGIN_DIR . '/features/elementor-pro/elementor-pro.php');
202 }
203
204 //Elementor Widgets
205 if ( did_action( 'elementor/loaded' ) ) {
206 if (file_exists(WPPB_PLUGIN_DIR . 'assets/misc/elementor/class-elementor.php'))
207 include_once WPPB_PLUGIN_DIR . 'assets/misc/elementor/class-elementor.php';
208 }
209
210 //Divi Extension
211 if (file_exists(WPPB_PLUGIN_DIR . 'assets/misc/divi/profile-builder-divi-extension.php'))
212 include_once WPPB_PLUGIN_DIR . 'assets/misc/divi/profile-builder-divi-extension.php';
213
214 //Block Editor Assets
215 global $wp_version;
216 if ( version_compare( $wp_version, "5.0.0", ">=" ) ) {
217 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/enqueue-block-editor-assets.php' ) )
218 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/enqueue-block-editor-assets.php';
219 }
220
221 //Block Content Restriction
222 global $content_restriction_activated;
223 if ( $content_restriction_activated == 'yes' && version_compare( $wp_version, "5.0.0", ">=" ) ) {
224 if( file_exists( WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/block-content-restriction/block-content-restriction.php' ) )
225 include_once WPPB_PLUGIN_DIR . 'assets/misc/gutenberg/block-content-restriction/block-content-restriction.php';
226 }
227
228 //Elementor Content Restriction
229 if ( $content_restriction_activated == 'yes' && did_action( 'elementor/loaded' ) ) {
230 if( file_exists( WPPB_PLUGIN_DIR . 'features/content-restriction/class-elementor-content-restriction.php' ) )
231 include_once WPPB_PLUGIN_DIR . 'features/content-restriction/class-elementor-content-restriction.php';
232 }
233
234 //Include Free Add-ons
235 $wppb_free_add_ons_settings = get_option( 'wppb_free_add_ons_settings', array() );
236 if( !empty( $wppb_free_add_ons_settings ) ){
237
238 if( isset( $wppb_free_add_ons_settings['custom-css-classes-on-fields'] ) && $wppb_free_add_ons_settings['custom-css-classes-on-fields'] ){
239 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/custom-css-classes-on-fields/custom-css-classes-on-fields.php' ) )
240 include_once WPPB_PLUGIN_DIR . 'add-ons-free/custom-css-classes-on-fields/custom-css-classes-on-fields.php';
241 }
242
243 if( isset( $wppb_free_add_ons_settings['gdpr-communication-preferences'] ) && $wppb_free_add_ons_settings['gdpr-communication-preferences'] ){
244 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/gdpr-communication-preferences/gdpr-communication-preferences.php' ) )
245 include_once WPPB_PLUGIN_DIR . 'add-ons-free/gdpr-communication-preferences/gdpr-communication-preferences.php';
246 }
247
248 if( isset( $wppb_free_add_ons_settings['import-export'] ) && $wppb_free_add_ons_settings['import-export'] ){
249 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/import-export/import-export.php' ) )
250 include_once WPPB_PLUGIN_DIR . 'add-ons-free/import-export/import-export.php';
251 }
252
253 if( isset( $wppb_free_add_ons_settings['labels-edit'] ) && $wppb_free_add_ons_settings['labels-edit'] ){
254 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/labels-edit/labels-edit.php' ) )
255 include_once WPPB_PLUGIN_DIR . 'add-ons-free/labels-edit/labels-edit.php';
256 }
257
258 if( isset( $wppb_free_add_ons_settings['maximum-character-length'] ) && $wppb_free_add_ons_settings['maximum-character-length'] ){
259 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/maximum-character-length/maximum-character-length.php' ) )
260 include_once WPPB_PLUGIN_DIR . 'add-ons-free/maximum-character-length/maximum-character-length.php';
261 }
262
263 if( isset( $wppb_free_add_ons_settings['user-profile-picture'] ) && $wppb_free_add_ons_settings['user-profile-picture'] ){
264 if( file_exists( WPPB_PLUGIN_DIR . 'add-ons-free/user-profile-picture/metronet-profile-picture.php' ) )
265 include_once WPPB_PLUGIN_DIR . 'add-ons-free/user-profile-picture/metronet-profile-picture.php';
266 }
267
268 }
269
270 //Include Advanced Add-ons
271
272 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){
273
274 $wppb_advanced_add_ons_settings = get_option( 'wppb_advanced_add_ons_settings', array() );
275 if( !empty( $wppb_advanced_add_ons_settings ) ){
276
277 if( isset( $wppb_advanced_add_ons_settings['buddypress'] ) && $wppb_advanced_add_ons_settings['buddypress'] ){
278 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/index.php' ) )
279 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/index.php';
280 }
281
282 if( isset( $wppb_advanced_add_ons_settings['social-connect'] ) && $wppb_advanced_add_ons_settings['social-connect'] ){
283 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/social-connect/index.php' ) )
284 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/social-connect/index.php';
285 }
286
287 if( isset( $wppb_advanced_add_ons_settings['woocommerce'] ) && $wppb_advanced_add_ons_settings['woocommerce'] ){
288 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/index.php' ) )
289 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/index.php';
290 }
291
292 if( isset( $wppb_advanced_add_ons_settings['multi-step-forms'] ) && $wppb_advanced_add_ons_settings['multi-step-forms'] ){
293 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/index.php' ) )
294 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/index.php';
295 }
296
297 if( isset( $wppb_advanced_add_ons_settings['form-fields-in-columns'] ) && $wppb_advanced_add_ons_settings['form-fields-in-columns'] ){
298 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/index.php' ) )
299 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/index.php';
300 }
301
302 if( isset( $wppb_advanced_add_ons_settings['mailchimp-integration'] ) && $wppb_advanced_add_ons_settings['mailchimp-integration'] ){
303 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp-integration/index.php' ) )
304 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp-integration/index.php';
305 }
306
307 if( isset( $wppb_advanced_add_ons_settings['bbpress'] ) && $wppb_advanced_add_ons_settings['bbpress'] ){
308 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/bbpress/index.php' ) )
309 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/bbpress/index.php';
310 }
311
312 if( isset( $wppb_advanced_add_ons_settings['campaign-monitor'] ) && $wppb_advanced_add_ons_settings['campaign-monitor'] ){
313 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/index.php' ) )
314 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/index.php';
315 }
316
317 if( isset( $wppb_advanced_add_ons_settings['field-visibility'] ) && $wppb_advanced_add_ons_settings['field-visibility'] ){
318 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/index.php' ) )
319 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/index.php';
320 }
321
322 if( isset( $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] ) && $wppb_advanced_add_ons_settings['edit-profile-approved-by-admin'] ){
323 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/edit-profile-approved-by-admin/index.php' ) )
324 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/edit-profile-approved-by-admin/index.php';
325 }
326
327 if( isset( $wppb_advanced_add_ons_settings['custom-profile-menus'] ) && $wppb_advanced_add_ons_settings['custom-profile-menus'] ){
328 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/custom-profile-menus/index.php' ) )
329 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/custom-profile-menus/index.php';
330 }
331
332 if( isset( $wppb_advanced_add_ons_settings['mailpoet-integration'] ) && $wppb_advanced_add_ons_settings['mailpoet-integration'] ){
333 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailpoet-integration/index.php' ) )
334 include_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailpoet-integration/index.php';
335 }
336
337 }
338
339 /**
340 * Include add-on files that contain activation hooks even when add-ons are deactivated
341 *
342 * Necessary in order to perform actions during the operation of activation or deactivation of that add-on
343 */
344 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/buddypress-activator.php') )
345 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/buddypress/buddypress-activator.php';
346
347 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/campaign-monitor-activator.php') )
348 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/campaign-monitor/campaign-monitor-activator.php';
349
350 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/field-visibility-activator.php') )
351 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/field-visibility/field-visibility-activator.php';
352
353 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp/mailchimp-activator.php') )
354 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/mailchimp/mailchimp-activator.php';
355
356 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/multi-step-forms-activator.php') )
357 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/multi-step-forms/multi-step-forms-activator.php';
358
359 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/form-fields-in-columns-activator.php') )
360 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/form-fields-in-columns/form-fields-in-columns-activator.php';
361
362 if( file_exists( WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/woocommerce-activator.php') )
363 require_once WPPB_PAID_PLUGIN_DIR . '/add-ons-advanced/woocommerce/woocommerce-activator.php';
364
365 }
366
367
368 /**
369 * Add explanatory message on the plugins page when updates are not available
370 *
371 */
372 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && ! wppb_paid_plugin_owns_updates() && file_exists( WPPB_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php' ) ) {
373
374 if ( class_exists( 'WPPB_EDD_SL_Plugin_Updater' ) ) {
375
376 $serial = wppb_get_serial_number();
377
378 if( ! function_exists('get_plugin_data') ){
379 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
380 }
381
382 $plugin_data = get_plugin_data( WPPB_PAID_PLUGIN_DIR . '/index.php', false, false );
383 $pb_plugin_version = ( $plugin_data && $plugin_data['Version'] ) ? $plugin_data['Version'] : '3.7.6' ;
384
385 if( PROFILE_BUILDER == 'Profile Builder Pro' )
386 $pb_cl_plugin_id = '30695';
387 else if( PROFILE_BUILDER == 'Profile Builder Basic' )
388 $pb_cl_plugin_id = '30697';
389 else if( PROFILE_BUILDER == 'Profile Builder Agency' )
390 $pb_cl_plugin_id = '416191';
391 else if( PROFILE_BUILDER == 'Profile Builder Unlimited' )
392 $pb_cl_plugin_id = '30699';
393
394 // setup the updater
395 $wppb_edd_updater = new WPPB_EDD_SL_Plugin_Updater('https://cozmoslabs.com', WPPB_PAID_PLUGIN_DIR . '/index.php', array(
396 'version' => $pb_plugin_version, // current version number
397 'license' => $serial,
398 'item_name' => PROFILE_BUILDER, // name of this plugin
399 'item_id' => $pb_cl_plugin_id,
400 'author' => 'Cozmoslabs', // author of this plugin
401 'beta' => false
402 )
403 );
404
405 }
406
407 if ( ! function_exists( 'wppb_plugin_update_message' ) ) {
408 function wppb_plugin_update_message( $plugin_data, $new_data ) {
409
410 $wppb_profile_builder_serial = wppb_get_serial_number();
411 $wppb_profile_builder_serial_status = wppb_get_serial_number_status();
412
413 if( empty( $wppb_profile_builder_serial ) ){
414
415 echo '<br />' . wp_kses_post( sprintf( __('To enable updates, please enter your license key on the %sSettings%s page. If you don\'t have a license key, you can %sbuy one now%s.', 'profile-builder' ), '<a href="'.esc_url( admin_url('admin.php?page=profile-builder-general-settings') ).'">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=license-updates-disabled-notification&utm_campaign=PBPro#pricing" target="_blank">', '</a>' ) );
416
417 } else if( $wppb_profile_builder_serial_status == 'expired' ) {
418
419 echo '<br />' . wp_kses_post( sprintf( __('To enable updates, your licence needs to be renewed. Please go to the <a href="%s">Cozmoslabs Account</a> page and login to renew.', 'profile-builder' ), 'https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_content=license-updates-disabled-notification&utm_campaign=PBPro' ) );
420
421 } else if ( $wppb_profile_builder_serial_status != 'valid' ) {
422
423 echo '<br />' . wp_kses_post( sprintf( __('To enable updates, you need an active license. %1$sRenew%2$s or %3$spurchase a new license%4$s.', 'profile-builder' ), '<a href="https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_content=license-updates-disabled-notification&utm_campaign=PBPro" target="_blank">', '</a>', '<a href="https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wpbackend&utm_medium=clientsite&utm_content=license-updates-disabled-notification&utm_campaign=PBPro#pricing" target="_blank">', '</a>' ) );
424
425 }
426
427 }
428 }
429
430 $update_message_hook = 'in_plugin_update_message-' . plugin_basename( WPPB_PAID_PLUGIN_DIR . '/index.php' );
431
432 if ( ! has_action( $update_message_hook, 'wppb_plugin_update_message' ) && ! function_exists( 'wppb_paid_plugin_update_message' ) )
433 add_action( $update_message_hook, 'wppb_plugin_update_message', 10, 2 );
434 }
435
436
437 // these settings are important, so besides running them on page load, we also need to do a check on plugin activation
438 add_action('init', 'wppb_generate_default_settings_defaults'); //prepoulate general settings
439 add_action('init', 'wppb_prepopulate_fields'); //prepopulate manage fields list
440
441 }
442 } //end wppb_plugin_init
443 add_action( 'plugins_loaded', 'wppb_plugin_init' );
444
445 /**
446 * Definitions
447 *
448 *
449 */
450 define('PROFILE_BUILDER_VERSION', '3.16.6' );
451 define('WPPB_PLUGIN_DIR', plugin_dir_path(__FILE__));
452 define('WPPB_PLUGIN_URL', plugin_dir_url(__FILE__));
453 define('WPPB_PLUGIN_BASENAME', plugin_basename(__FILE__));
454 define('WPPB_TRANSLATE_DIR', WPPB_PLUGIN_DIR . '/translation');
455 define('WPPB_TRANSLATE_DOMAIN', 'profile-builder');
456
457 // Determine which plugin version is active
458 $active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
459 $active_network_plugins = get_site_option('active_sitewide_plugins');
460
461 if ( in_array( 'profile-builder-pro/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-pro/index.php'] ) ){
462
463 define('PROFILE_BUILDER', 'Profile Builder Pro');
464 define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-pro' );
465 define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-pro/' );
466
467 } elseif ( in_array( 'profile-builder-dev/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-dev/index.php'] ) ){
468
469 define('PROFILE_BUILDER', 'Profile Builder Pro');
470 define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-dev' );
471 define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-dev/' );
472 define('PROFILE_BUILDER_PAID_VERSION', 'dev' );
473
474 } elseif ( in_array( 'profile-builder-agency/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-agency/index.php'] ) ){
475
476 define('PROFILE_BUILDER', 'Profile Builder Agency');
477 define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-agency' );
478 define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-agency/' );
479
480 } elseif ( in_array( 'profile-builder-unlimited/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-unlimited/index.php'] ) ){
481
482 define('PROFILE_BUILDER', 'Profile Builder Unlimited');
483 define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-unlimited' );
484 define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-unlimited/' );
485
486 } elseif ( in_array( 'profile-builder-hobbyist/index.php', $active_plugins ) || isset( $active_network_plugins['profile-builder-hobbyist/index.php'] ) ){
487
488 define('PROFILE_BUILDER', 'Profile Builder Basic');
489 define('WPPB_PAID_PLUGIN_DIR', WP_PLUGIN_DIR . '/profile-builder-hobbyist' );
490 define('WPPB_PAID_PLUGIN_URL', plugins_url() . '/profile-builder-hobbyist/' );
491
492 } else
493 define('PROFILE_BUILDER', 'Profile Builder Free');
494
495 if ( ! function_exists( 'wppb_paid_plugin_owns_updates' ) ) {
496 function wppb_paid_plugin_owns_updates() {
497
498 if ( ! defined( 'WPPB_PAID_PLUGIN_DIR' ) || ! defined( 'WPPB_PLUGIN_DIR' ) )
499 return false;
500
501 if ( trailingslashit( WPPB_PAID_PLUGIN_DIR ) === trailingslashit( WPPB_PLUGIN_DIR ) )
502 return false;
503
504 return file_exists( WPPB_PAID_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php' );
505
506 }
507 }
508
509 if ( ! function_exists( 'wppb_paid_plugin_load_updater' ) ) {
510 function wppb_paid_plugin_load_updater() {
511
512 if ( class_exists( 'WPPB_Plugin_Updater', false ) )
513 return;
514
515 if ( function_exists( 'wppb_paid_plugin_owns_updates' ) && wppb_paid_plugin_owns_updates() ) {
516 $wppb_updater_file = WPPB_PAID_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php';
517 } elseif ( file_exists( WPPB_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php' ) ) {
518 $wppb_updater_file = WPPB_PLUGIN_DIR . '/update/class-edd-sl-plugin-updater.php';
519 } else {
520 return;
521 }
522
523 if ( file_exists( $wppb_updater_file ) ) {
524 require_once $wppb_updater_file;
525 }
526
527 }
528 }
529
530 add_action( 'plugins_loaded', 'wppb_paid_plugin_load_updater', 0 );
531
532 // Needs to be loaded early for Upload fields to work correctly
533 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' ) )
534 include_once( WPPB_PAID_PLUGIN_DIR . '/add-ons/repeater-field/repeater-module.php' );
535
536 // This needs to be loaded here since we try to plug some functions, not suited for plugins_loaded hook
537 if ( file_exists( WPPB_PLUGIN_DIR . '/front-end/default-fields/upload/upload_helper_functions.php' ) )
538 include_once( WPPB_PLUGIN_DIR . '/front-end/default-fields/upload/upload_helper_functions.php' );
539
540 /* add a redirect when plugin is activated */
541 if( !function_exists( 'wppb_activate_plugin_redirect' ) ){
542 function wppb_activate_plugin_redirect( $plugin ) {
543 if( !wp_doing_ajax() && $plugin == plugin_basename( __FILE__ ) ) {
544 wp_safe_redirect( admin_url( 'admin.php?page=profile-builder-basic-info' ) );
545 exit();
546 }
547 }
548 add_action( 'activated_plugin', 'wppb_activate_plugin_redirect' );
549 }
550
551 /**
552 * Check if Setup Wizard should run
553 *
554 */
555 function wppb_set_setup_wizard_transient() {
556
557 $slugs = array(
558 '/profile-builder-pro/index.php',
559 '/profile-builder-dev/index.php',
560 '/profile-builder-agency/index.php',
561 '/profile-builder-unlimited/index.php',
562 '/profile-builder-hobbyist/index.php',
563 '/metronet-profile-picture/metronet-profile-picture.php',
564 '/user-profile-picture-dev/metronet-profile-picture.php',
565 '/user-profile-picture/metronet-profile-picture.php',
566 );
567
568 $paid_plugin_active = false;
569
570 foreach( $slugs as $slug ){
571 if( file_exists( WP_PLUGIN_DIR . $slug ) ){
572 $paid_plugin_active = true;
573 break;
574 }
575 }
576
577 // Run Setup Wizard ?
578 if ( !$paid_plugin_active )
579 set_transient( 'wppb_run_setup_wizard', 'true', 120 );
580
581 do_action( 'wppb_register_activation_hook' );
582
583 }
584 register_activation_hook( __FILE__, 'wppb_set_setup_wizard_transient' );
585
586 function wppb_register_deactivation_hook() {
587 do_action( 'wppb_register_deactivation_hook' );
588 }
589 register_deactivation_hook( __FILE__, 'wppb_register_deactivation_hook' );
590