PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.15.2
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.15.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 2.0.8 All 339 releases
profile-builder / admin / register-version.php

register-version.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.15.2, at admin/register-version.php

397 lines 19.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
3
4 /**
5 * Function that creates the "Register your version" submenu page for Multisite Environment
6 *
7 * @since v.2.0
8 *
9 * @return void
10 */
11 if( is_multisite() ) {
12 function wppb_multisite_register_your_version_page() {
13 if ( PROFILE_BUILDER != 'Profile Builder Free' )
14 add_menu_page(__('Profile Builder Register', 'profile-builder'), __('Profile Builder Register', 'profile-builder'), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content', WPPB_PLUGIN_URL . 'assets/images/pb-menu-icon.svg');
15 }
16 add_action('network_admin_menu', 'wppb_multisite_register_your_version_page', 29);
17 }
18
19
20 /**
21 * Function that adds content to the "Register your Version" submenu page
22 *
23 * @since v.2.0
24 *
25 * @return string
26 */
27 function wppb_register_your_version_content() {
28 ?>
29 <div class="wrap wppb-wrap cozmoslabs-wrap">
30 <div id="wppb-register-version-page">
31
32 <h1></h1>
33 <!-- WordPress Notices are added after the h1 tag -->
34
35 <div class="cozmoslabs-page-header">
36 <div class="cozmoslabs-section-title">
37 <h2 class="cozmoslabs-page-title"><?php esc_html_e( "Register your version of Profile Builder", 'profile-builder' ); ?></h2>
38 <a href="https://www.cozmoslabs.com/docs/profile-builder/basic-information-installation?utm_source=wpbackend&utm_medium=pb-documentation&utm_campaign=PBDocs#Register_your_version" target="_blank" data-code="f223" class="wppb-docs-link dashicons dashicons-editor-help"></a>
39 </div>
40 </div>
41
42 <div class="cozmoslabs-form-subsection-wrapper" id="wppb-register-version">
43 <?php wppb_add_register_version_form(); ?>
44 </div>
45 </div>
46 </div>
47 <?php
48 }
49
50 /**
51 * Retrieve saved license key
52 */
53 function wppb_get_serial_number(){
54
55 if( is_multisite() ){
56 $license = get_site_option( 'wppb_license_key', false );
57
58 if( empty( $license ) )
59 $license = get_option( 'wppb_license_key', false );
60 }
61 else
62 $license = get_option( 'wppb_license_key', false );
63
64 // try to grab the license from the old options if it's not available
65 if( empty( $license ) ){
66 $versions = array( 'Profile Builder Pro', 'Profile Builder Agency', 'Profile Builder Unlimited', 'Profile Builder Dev' );
67
68 if( in_array( PROFILE_BUILDER, $versions ) )
69 $version = 'pro';
70 elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' || PROFILE_BUILDER == 'Profile Builder Basic' )
71 $version = 'hobbyist';
72 else
73 $version = '';
74
75 $old_license = get_option( 'wppb_profile_builder_'.$version.'_serial' );
76
77 if( !empty( $old_license ) ){
78 update_option( 'wppb_license_key', $old_license );
79 $license = $old_license;
80 }
81
82 }
83
84 return $license;
85
86 }
87
88 /**
89 * Retrieve license key status
90 */
91 function wppb_get_serial_number_status(){
92
93 if( is_multisite() )
94 return get_site_option( 'wppb_license_status' );
95 else
96 return get_option( 'wppb_license_status' );
97
98 }
99
100 /**
101 * Class that adds a notice when either the serial number wasn't found, or it has expired
102 *
103 * @since v.2.0
104 *
105 * @return void
106 */
107 class WPPB_add_notices{
108 public $pluginPrefix = '';
109 public $pluginName = '';
110 public $notificaitonMessage = '';
111 public $pluginSerialStatus = '';
112
113 function __construct( $pluginPrefix, $pluginName, $notificaitonMessage, $pluginSerialStatus ){
114 $this->pluginPrefix = $pluginPrefix;
115 $this->pluginName = $pluginName;
116 $this->notificaitonMessage = $notificaitonMessage;
117 $this->pluginSerialStatus = $pluginSerialStatus;
118
119 add_action( 'admin_notices', array( $this, 'add_admin_notice' ) );
120 add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
121 }
122
123
124 // Display a notice that can be dismissed in case the serial number is inactive
125 function add_admin_notice() {
126 global $current_user ;
127 global $pagenow;
128
129 $user_id = $current_user->ID;
130
131 do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow );
132
133 if ( current_user_can( 'manage_options' ) ){
134
135 $plugin_serial_status = get_option( $this->pluginSerialStatus );
136 if ( $plugin_serial_status != 'found' ){
137
138 //we want to show the expiration notice on our plugin pages even if the user dismissed it on the rest of the site
139 $force_show = false;
140 if ( $plugin_serial_status == 'expired' ) {
141 $notification_instance = WPPB_Plugin_Notifications::get_instance();
142 if ($notification_instance->is_plugin_page()){
143 $force_show = true;
144 }
145 }
146
147 // Check that the user hasn't already clicked to ignore the message
148 if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) || $force_show ) {
149 echo wp_kses_post( $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','<div class="error wppb-serial-notification" >'.$this->notificaitonMessage.'</div>', $this->notificaitonMessage) );
150 }
151 }
152
153 do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status );
154
155 }
156
157 do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow );
158
159 }
160
161 function dismiss_notification() {
162
163 if( empty( $_GET['_wpnonce'] ) || !wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wppb_license_notice_dismiss' ) )
164 return;
165
166 global $current_user;
167
168 $user_id = $current_user->ID;
169
170 do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user );
171
172 // If user clicks to ignore the notice, add that to their user meta
173 if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] )
174 add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true );
175
176 do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user );
177 }
178 }
179
180 add_action( 'admin_init', 'wppb_admin_general_notices', 9 );
181 function wppb_admin_general_notices(){
182
183 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){
184
185 // Switch to the main site
186 if( is_multisite() && function_exists( 'switch_to_blog' )
187 && function_exists( 'get_main_site_id' ))
188 switch_to_blog( get_main_site_id() );
189
190 $wppb_serial_number = wppb_get_serial_number();
191 $wppb_serial_status = wppb_get_serial_number_status();
192 $license_details = get_option( 'wppb_license_details', false );
193
194 if( is_multisite() && function_exists( 'restore_current_blog' ) )
195 restore_current_blog();
196
197 if( empty( $wppb_serial_number ) || $wppb_serial_status == 'missing' ) {
198
199 if( !is_multisite() )
200 $register_url = 'admin.php?page=profile-builder-general-settings';
201 else
202 $register_url = network_admin_url( 'admin.php?page=profile-builder-general-settings' );
203
204 new WPPB_add_notices( 'wppb', 'profile_builder_pro', sprintf( '<p>' . __( 'Your <strong>Profile Builder</strong> license is missing or invalid. <br/>Please %1$sRegister Your Copy%2$s to get access to premium features & addons, automatic updates and support. Need a license key? %3$sPurchase one now%4$s', 'profile-builder') . '</p>', "<a href='". esc_url( $register_url ) ."'>", "</a>", "<a href='https://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=wp-dashboard&utm_medium=client-site&utm_campaign=pb-pro-no-active-license#pricing' target='_blank' class='button-primary'>", "</a>" ), 'wppb_license_status' );
205
206 }
207 elseif ( $wppb_serial_status == 'expired' ){
208 /* on our plugin pages do not add the dismiss button for the expired notification*/
209 $notification_instance = WPPB_Plugin_Notifications::get_instance();
210 if( $notification_instance->is_plugin_page() )
211 $message = '<p>' . __( 'Your <strong>Profile Builder license has expired</strong>. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to new features, premium addons, product downloads & automatic updates — including important security patches and WordPress compatibility. %3$sRenew now %4$s', 'profile-builder') . '</p>';
212 else
213 $message = '<p>' . __( 'Your <strong>Profile Builder license has expired</strong>. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to new features, premium addons, product downloads & automatic updates — including important security patches and WordPress compatibility. %3$sRenew now %4$s %5$sDismiss%6$s', 'profile-builder') . '</p>';
214
215 new WPPB_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( $message, "<a href='https://www.cozmoslabs.com/account/?utm_source=wp-dashboard&utm_medium=client-site&utm_campaign=pb-expired-license' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/account/?utm_source=wp-dashboard&utm_medium=client-site&utm_campaign=pb-expired-license' target='_blank' class='button-primary'>", "</a>", "<a href='". esc_url( wp_nonce_url( add_query_arg( 'wppb_expired_dismiss_notification', '0' ), 'wppb_license_notice_dismiss' ) ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_license_status' );
216 }
217
218
219 // Maybe add about to expire notice
220 if( $wppb_serial_status != 'expired' && !empty( $license_details ) && !empty( $license_details->expires ) && $license_details->expires !== 'lifetime' ){
221
222 if( ( !isset( $license_details->subscription_status ) || $license_details->subscription_status != 'active' ) && strtotime( $license_details->expires ) < strtotime( '+14 days' ) ){
223 new WPPB_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( '<p>' . __( 'Your <strong>Profile Builder license is about to expire on %5$s</strong>. <br/>Please %1$sRenew Your Licence%2$s to maintain access to new features, premium addons, product downloads & automatic updates — including important security patches and WordPress compatibility. %3$sRenew now %4$s %6$sDismiss%7$s', 'profile-builder') . '</p>', "<a href='https://www.cozmoslabs.com/account/?utm_source=wp-dashboard&utm_medium=client-site&utm_campaign=pb-expire-soon' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/account/?utm_source=wp-dashboard&utm_medium=client-site&utm_campaign=pb-expire-soon' target='_blank' class='button-primary'>", "</a>", date_i18n( get_option( 'date_format' ), strtotime( $license_details->expires ) ), "<a href='". esc_url( wp_nonce_url( add_query_arg( 'wppb_about_to_expire_dismiss_notification', '0' ), 'wppb_license_notice_dismiss' ) )."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_license_status' );
224 }
225
226 }
227
228 if( isset( $license_details->license ) && $license_details->license == 'invalid' ){
229
230 if( isset( $license_details->error ) && $license_details->error == 'no_activations_left' ){
231
232 $activations_limit_message = '<p>' . sprintf( __( 'Your <strong>%s</strong> license has reached its activation limit.<br> Upgrade now for unlimited activations and extra features like multiple registration and edit profile forms, userlisting, custom redirects and more. <a class="button-primary" href="%s">Upgrade now</a>', 'profile-builder' ), PROFILE_BUILDER, esc_url( 'https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=PBPro&utm_content=license-activation-limit' ) ) . '</p>';
233
234 $notification_instance = WPPB_Plugin_Notifications::get_instance();
235 if( !$notification_instance->is_plugin_page() ) {//add the dismiss button only on other pages in admin
236 $activations_limit_message .= sprintf(__(' %1$sDismiss%2$s', 'profile-builder'), "<a class='dismiss-right' href='" . esc_url( wp_nonce_url( add_query_arg('wppb_basic_activations_limit_dismiss_notification', '0' ), 'wppb_license_notice_dismiss' ) ) . "'>", "</a>");
237 $force_show = false;
238 } else {
239 $force_show = true;//sets the forceShow parameter of WPPB_add_notices to true so we don't take into consideration the dismiss user meta
240 }
241
242 new WPPB_add_notices( 'wppb_basic_activations_limit',
243 'profile_builder_basic',
244 $activations_limit_message,
245 'error',
246 '',
247 '',
248 $force_show );
249 }
250
251 }
252
253 }
254
255
256 /**
257 * Black Friday
258 *
259 * Showing this to:
260 * free users
261 * users that have expired or disabled licenses
262 */
263 if( wppb_bf_show_promotion() ){
264
265 $license_status = wppb_get_serial_number_status();
266 $notifications = WPPB_Plugin_Notifications::get_instance();
267
268 // Plugin pages
269 if( $notifications->is_plugin_page() ){
270
271 $notification_id = 'wppb_bf_2025';
272
273 $message = '<div class="wppb-bf-notice-container"><img style="max-width: 60px;width: 60px;" src="' . WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg" />';
274
275 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' ){
276 $message .= '<div><p style="font-size: 110%;margin-top:0px;margin-bottom:4px;padding:0px;">' . '<strong>Renew your Profile Builder license this Black Friday! </strong>' . '</p>';
277 $message .= '<p style="font-size: 110%;margin-top:0px;margin-bottom: 0px;padding:0px;">Don\'t miss out on our <strong>best prices & only sale of the year</strong>. <br><a class="button-primary" style="margin-top:6px;margin-left: 0px !important;" href="https://www.cozmoslabs.com/account/?utm_source=pb-settings&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Get Deal</a></p></div>';
278 } else {
279 $message .= '<div><p style="font-size: 110%;margin-top:0px;margin-bottom:4px;padding:0px;">' . '<strong>Get the best price for Profile Builder PRO this Black Friday!</strong>' . '</p>';
280 $message .= '<p style="font-size: 110%;margin-top:0px;margin-bottom: 0px;padding:0px;">This is a <strong>limited-time offer</strong>, so don\'t miss out on our <strong>only sale of the year</strong>. <br><a class="button-primary" style="margin-top:6px;margin-left: 0px !important;" href="https://www.cozmoslabs.com/black-friday/?utm_source=pb-settings&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Get Deal</a></p></div>';
281 }
282
283 $message .= '</div><a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>';
284
285 $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info' );
286
287 } else {
288
289 if( wppb_bf_show_shared_promotion() ){
290
291 $notification_id = 'wppb_bf_2025_cross_promotion';
292
293 $message = '<img style="float: left; margin: 10px 8px 10px 0px; max-width: 20px;" src="' . WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg" />';
294 $message .= '<img style="float: left; margin: 10px 8px 10px 0px; max-width: 20px;" src="' . WPPB_PLUGIN_URL . 'assets/images/pms-logo.svg" />';
295
296 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' )
297 $message .= '<p style="padding-right:30px;font-size: 110%;"><strong>Upgrade to Profile Builder & Paid Member Subscriptions PRO this Black Friday!</strong> Don\'t miss our only sale of the year. <a href="https://www.cozmoslabs.com/black-friday/?utm_source=wpdashboard&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Learn more</a></p>';
298 else
299 $message .= '<p style="padding-right:30px;font-size: 110%;"><strong>Upgrade to Profile Builder & Paid Member Subscriptions PRO this Black Friday!</strong> Don\'t miss our only sale of the year. <a href="https://www.cozmoslabs.com/black-friday/?utm_source=wpdashboard&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Learn more</a></p>';
300
301 $message .= '<a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>';
302
303 $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false, array(), true );
304
305 } else {
306
307 $notification_id = 'wppb_bf_2025';
308
309 $message = '<img style="float: left; margin: 10px 8px 10px 0px; max-width: 20px;" src="' . WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg" />';
310
311 if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' )
312 $message .= '<p style="padding-right:30px;font-size: 110%;"><strong>Upgrade to Profile Builder PRO this Black Friday!</strong> Don\'t miss our only sale of the year. <a href="https://www.cozmoslabs.com/black-friday/?utm_source=wpdashboard&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Learn more</a></p>';
313 else
314 $message .= '<p style="padding-right:30px;font-size: 110%;"><strong>Upgrade to Profile Builder PRO this Black Friday!</strong> Don\'t miss our only sale of the year. <a href="https://www.cozmoslabs.com/black-friday/?utm_source=wpdashboard&utm_medium=clientsite&utm_campaign=BF-2025" target="_blank">Learn more</a></p>';
315
316 $message .= '<a href="' . wp_nonce_url( add_query_arg( array( 'wppb_dismiss_admin_notification' => $notification_id ) ), 'wppb_plugin_notice_dismiss' ) . '" type="button" class="notice-dismiss"><span class="screen-reader-text">' . __( 'Dismiss this notice.', 'profile-builder' ) . '</span></a>';
317
318 $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false, array(), true );
319
320 }
321
322 }
323
324 }
325
326 }
327
328 function wppb_bf_show_promotion(){
329
330 if( !wppb_bf_promotion_is_active() )
331 return false;
332
333 if( !defined( 'WPPB_PAID_PLUGIN_DIR' ) )
334 return true;
335
336 $license_details = get_option( 'wppb_license_details', false );
337
338 if( !empty( $license_details ) ){
339
340 if( isset( $license_details->error ) && in_array( $license_details->error, [ 'expired', 'disabled', 'revoked', 'missing', 'no_activations_left' ] ) )
341 return true;
342
343 }
344
345 return false;
346
347 }
348
349 function wppb_bf_show_shared_promotion(){
350
351 if( !wppb_bf_show_promotion() )
352 return false;
353
354 // verify if the PMS promotion should be shown
355 if( !defined( 'PAID_MEMBER_SUBSCRIPTIONS' ) )
356 return false;
357
358 // make sure the promotion is not shown on the PMS pages, only on other Dashboard pages
359 if( class_exists( 'PMS_Plugin_Notifications' ) ){
360 $pms_notifications_instance = PMS_Plugin_Notifications::get_instance();
361
362 if( $pms_notifications_instance->is_plugin_page() )
363 return false;
364 }
365
366 $license_details = get_option( 'pms_license_details', false );
367
368 if( !empty( $license_details ) ){
369
370 if( isset( $license_details->error ) && in_array( $license_details->error, [ 'expired', 'disabled', 'revoked', 'missing', 'no_activations_left' ] ) )
371 return true;
372
373 }
374
375 if( !defined( 'PMS_PAID_PLUGIN_DIR' ) )
376 return true;
377
378 return false;
379
380 }
381
382 function wppb_bf_promotion_is_active(){
383
384 $black_friday = array(
385 'start_date' => '11/24/2025 00:00',
386 'end_date' => '12/02/2025 23:59',
387 );
388
389 $current_date = time();
390
391 if( $current_date > strtotime( $black_friday['start_date'] ) && $current_date < strtotime( $black_friday['end_date'] ) )
392 return true;
393
394 return false;
395
396 }
397