PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.9
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.9
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
profile-builder / admin / register-version.php

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

268 lines 13.1 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.png');
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">
30 <?php wppb_serial_form(); ?>
31 </div>
32 <?php
33 }
34
35
36 /**
37 * Function that creates the "Register your version" form
38 *
39 * @since v.2.0
40 *
41 * @return void
42 */
43 function wppb_serial_form(){
44 $status = wppb_get_serial_number_status();
45 $license = wppb_get_serial_number();
46 ?>
47 <div id="wppb-register-version-page" class="wrap">
48 <h2>
49 <?php esc_html_e( "Register your version of Profile Builder", 'profile-builder' ); ?>
50 <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>
51 </h2>
52 <p><?php esc_html_e( 'Now that you acquired a copy of Profile Builder Pro, you should take the time and register it with the serial number you received.', 'profile-builder' ) ?></p>
53 <p><?php esc_html_e( 'If you register this version of Profile Builder, you\'ll receive information regarding upgrades, patches, and technical support.', 'profile-builder' ) ?></p>
54 <div class="wppb-serial-wrap">
55 <form method="post" action="<?php echo !is_multisite() ? 'options.php' : 'edit.php'; ?>">
56 <?php settings_fields( 'wppb_license_key' ); ?>
57 <label for="wppb_license_key"><?php esc_html_e( 'License key', 'profile-builder' ); ?></label>
58 <div class="wppb-serial-wrap__holder">
59 <input id="wppb_license_key" name="wppb_license_key" type="password" class="regular-text" value="<?php echo esc_attr( $license ); ?>" />
60 <?php wp_nonce_field( 'wppb_license_nonce', 'wppb_license_nonce' ); ?>
61 <?php if( $status !== false && $status == 'valid' ) {
62 $button_name = 'wppb_edd_license_deactivate';
63 $button_value = __('Deactivate License', 'profile-builder' );
64 if( empty( $details['invalid'] ) )
65 echo '<span title="'. esc_html__( 'Active on this site', 'profile-builder' ) .'" class="wppb-active-license dashicons dashicons-yes"></span>';
66 else
67 echo '<span title="'. esc_html__( 'Your license is invalid', 'profile-builder' ) .'" class="wppb-invalid-license dashicons dashicons-warning"></span>';
68 } else {
69 $button_name = 'wppb_edd_license_activate';
70 $button_value = __('Activate License', 'profile-builder');
71 }
72 ?>
73 <input type="submit" class="button-secondary" name="<?php echo esc_attr( $button_name ); ?>" value="<?php echo esc_attr( $button_value ); ?>"/>
74 </div>
75 </form>
76 </div>
77 </div>
78 <?php
79 }
80
81
82 /**
83 * Retrieve saved license key
84 */
85 function wppb_get_serial_number(){
86
87 $license = get_option( 'wppb_license_key', false );
88
89 // try to grab the license from the old options if it's not available
90 if( empty( $license ) ){
91 $versions = array( 'Profile Builder Pro', 'Profile Builder Agency', 'Profile Builder Unlimited', 'Profile Builder Dev' );
92
93 if( in_array( PROFILE_BUILDER, $versions ) )
94 $version = 'pro';
95 elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' || PROFILE_BUILDER == 'Profile Builder Basic' )
96 $version = 'hobbyist';
97
98 $old_license = get_option( 'wppb_profile_builder_'.$version.'_serial' );
99
100 if( !empty( $old_license ) ){
101 update_option( 'wppb_license_key', $old_license );
102 $license = $old_license;
103 }
104
105 }
106
107 return $license;
108
109 }
110
111 /**
112 * Retrieve license key status
113 */
114 function wppb_get_serial_number_status(){
115 return get_option( 'wppb_license_status' );
116 }
117
118 /**
119 * Class that adds a notice when either the serial number wasn't found, or it has expired
120 *
121 * @since v.2.0
122 *
123 * @return void
124 */
125 class WPPB_add_notices{
126 public $pluginPrefix = '';
127 public $pluginName = '';
128 public $notificaitonMessage = '';
129 public $pluginSerialStatus = '';
130
131 function __construct( $pluginPrefix, $pluginName, $notificaitonMessage, $pluginSerialStatus ){
132 $this->pluginPrefix = $pluginPrefix;
133 $this->pluginName = $pluginName;
134 $this->notificaitonMessage = $notificaitonMessage;
135 $this->pluginSerialStatus = $pluginSerialStatus;
136
137 add_action( 'admin_notices', array( $this, 'add_admin_notice' ) );
138 add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
139 }
140
141
142 // Display a notice that can be dismissed in case the serial number is inactive
143 function add_admin_notice() {
144 global $current_user ;
145 global $pagenow;
146
147 $user_id = $current_user->ID;
148
149 do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow );
150
151 if ( current_user_can( 'manage_options' ) ){
152
153 $plugin_serial_status = get_option( $this->pluginSerialStatus );
154 if ( $plugin_serial_status != 'found' ){
155
156 //we want to show the expiration notice on our plugin pages even if the user dismissed it on the rest of the site
157 $force_show = false;
158 if ( $plugin_serial_status == 'expired' ) {
159 $notification_instance = WPPB_Plugin_Notifications::get_instance();
160 if ($notification_instance->is_plugin_page()){
161 $force_show = true;
162 }
163 }
164
165 // Check that the user hasn't already clicked to ignore the message
166 if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) || $force_show ) {
167 echo wp_kses_post( $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','<div class="error wppb-serial-notification" >'.$this->notificaitonMessage.'</div>', $this->notificaitonMessage) );
168 }
169 }
170
171 do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status );
172
173 }
174
175 do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow );
176
177 }
178
179 function dismiss_notification() {
180 global $current_user;
181
182 $user_id = $current_user->ID;
183
184 do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user );
185
186 // If user clicks to ignore the notice, add that to their user meta
187 if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] )
188 add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true );
189
190 do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user );
191 }
192 }
193
194 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){
195
196 // Switch to the main site
197 if( is_multisite() && function_exists( 'switch_to_blog' )
198 && function_exists( 'get_main_site_id' ))
199 switch_to_blog( get_main_site_id() );
200
201 $wppb_serial_number = wppb_get_serial_number();
202 $wppb_serial_status = wppb_get_serial_number_status();
203 $license_details = get_option( 'wppb_license_details', false );
204
205 if( is_multisite() && function_exists( 'restore_current_blog' ) )
206 restore_current_blog();
207
208 if( empty( $wppb_serial_number ) || $wppb_serial_status == 'missing' ) {
209
210 if( !is_multisite() )
211 $register_url = 'admin.php?page=profile-builder-general-settings';
212 else
213 $register_url = network_admin_url( 'admin.php?page=profile-builder-general-settings' );
214
215 new WPPB_add_notices( 'wppb', 'profile_builder_pro', sprintf( '<p>' . __( 'Your <strong>Profile Builder</strong> serial number is invalid or missing. <br/>Please %1$sregister your copy%2$s to receive access to 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=PB&utm_medium=dashboard&utm_campaign=PB-SN-Purchase#pricing' target='_blank' class='button-primary'>", "</a>" ), 'wppb_license_status' );
216
217 }
218 elseif ( $wppb_serial_status == 'expired' ){
219 /* on our plugin pages do not add the dismiss button for the expired notification*/
220 $notification_instance = WPPB_Plugin_Notifications::get_instance();
221 if( $notification_instance->is_plugin_page() )
222 $message = '<p>' . __( 'Your <strong>Profile Builder</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s', 'profile-builder') . '</p>';
223 else
224 $message = '<p>' . __( 'Your <strong>Profile Builder</strong> license has expired. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s %5$sDismiss%6$s', 'profile-builder') . '</p>';
225
226 new WPPB_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( $message, "<a href='https://www.cozmoslabs.com/account/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/account/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". esc_url( add_query_arg( 'wppb_expired_dismiss_notification', '0' ) ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_license_status' );
227 }
228
229
230 // Maybe add about to expire notice
231 if( !empty( $license_details ) && !empty( $license_details->expires ) && $license_details->expires !== 'lifetime' ){
232
233 if( ( !isset( $license_details->subscription_status ) || $license_details->subscription_status != 'active' ) && strtotime( $license_details->expires ) < strtotime( '+14 days' ) ){
234 new WPPB_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( '<p>' . __( 'Your <strong>Profile Builder</strong> license is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to continue receiving access to product downloads, automatic updates and support. %3$sRenew now %4$s %6$sDismiss%7$s', 'profile-builder') . '</p>', "<a href='https://www.cozmoslabs.com/account/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='https://www.cozmoslabs.com/account/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", date_i18n( get_option( 'date_format' ), strtotime( $license_details->expires ) ), "<a href='". esc_url( add_query_arg( 'wppb_about_to_expire_dismiss_notification', '0' ) )."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_license_status' );
235 }
236
237 }
238
239 if( isset( $license_details->license ) && $license_details->license == 'invalid' ){
240
241 if( isset( $license_details->error ) && $license_details->error == 'no_activations_left' ){
242
243 $activations_limit_message = '<p>' . sprintf( __( 'Your <strong>Profile Builder Basic</strong> license has reached its activation limit.<br> Upgrade now to <strong>Pro</strong> 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' ), esc_url( 'https://www.cozmoslabs.com/account/?utm_source=wpbackend&utm_medium=clientsite&utm_campaign=WPPB&utm_content=add-on-page-license-activation-limit' ) ) . '</p>';
244
245 $notification_instance = WPPB_Plugin_Notifications::get_instance();
246 if( !$notification_instance->is_plugin_page() ) {//add the dismiss button only on other pages in admin
247 $activations_limit_message .= sprintf(__(' %1$sDismiss%2$s', 'profile-builder'), "<a class='dismiss-right' href='" . esc_url(add_query_arg('wppb_basic_activations_limit_dismiss_notification', '0')) . "'>", "</a>");
248 $force_show = false;
249 } else {
250 $force_show = true;//sets the forceShow parameter of WPPB_add_notices to true so we don't take into consideration the dismiss user meta
251 }
252
253 new WPPB_add_notices( 'wppb_basic_activations_limit',
254 'profile_builder_basic',
255 $activations_limit_message,
256 'error',
257 '',
258 '',
259 $force_show );
260 }
261
262 }
263
264
265
266 }
267
268