PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
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 | admin/register-version.php +396 -225 2.0.24.0.3 View file →
@@ -1,225 +1,396 @@
1 -<?php
2 -/**
3 - * Function that creates the "Register your version" submenu page
4 - *
5 - * @since v.2.0
6 - *
7 - * @return void
8 - */
9 -function wppb_register_your_version_submenu_page() {
10 - if ( PROFILE_BUILDER != 'Profile Builder Free' )
11 - add_submenu_page( 'profile-builder', __( 'Register Your Version', 'profilebuilder' ), __( 'Register Version', 'profilebuilder' ), 'manage_options', 'profile-builder-register', 'wppb_register_your_version_content' );
12 -}
13 -add_action( 'admin_menu', 'wppb_register_your_version_submenu_page', 20 );
14 -
15 -
16 -/**
17 - * Function that adds content to the "Register your Version" submenu page
18 - *
19 - * @since v.2.0
20 - *
21 - * @return string
22 - */
23 -function wppb_register_your_version_content() {
24 -
25 - ?>
26 - <div class="wrap wppb-wrap">
27 - <?php
28 - if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
29 - wppb_serial_form('pro', 'Profile Builder Pro');
30 - }elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' ){
31 - wppb_serial_form('hobbyist', 'Profile Builder Hobbyist');
32 - }
33 - ?>
34 -
35 - </div>
36 -<?php
37 -}
38 -
39 -/**
40 - * Function that creates the "Register your version" form depending on Pro or Hobbyist version
41 - *
42 - * @since v.2.0
43 - *
44 - * @return void
45 - */
46 -function wppb_serial_form($version, $fullname){
47 - ?>
48 -
49 - <h2><?php _e( "Register your version of $fullname", 'profilebuilder' ); ?></h2>
50 -
51 - <form method="post" action="options.php">
52 -
53 - <?php $wppb_profile_builder_serial = get_option( 'wppb_profile_builder_'.$version.'_serial' ); ?>
54 - <?php $wppb_profile_builder_serial_status = get_option( 'wppb_profile_builder_'.$version.'_serial_status' ); ?>
55 - <?php settings_fields( 'wppb_profile_builder_'.$version.'_serial' ); ?>
56 -
57 - <p><?php _e( "Now that you acquired a copy of $fullname, you should take the time and register it with the serial number you received", 'profilebuilder' );?></p>
58 - <p><?php _e( "If you register this version of Profile Builder, you'll receive information regarding upgrades, patches, and technical support.", 'profilebuilder' );?></p>
59 - <p class="wppb-serial-wrap">
60 - <label for="wppb_profile_builder_<?php echo $version; ?>_serial"><?php _e(' Serial Number:', 'profilebuilder' );?></label>
61 - <input type="text" size="50" name="wppb_profile_builder_<?php echo $version; ?>_serial" id="wppb_profile_builder_<?php echo $version; ?>_serial" class="regular-text" <?php if ( $wppb_profile_builder_serial != ''){ echo ' value="'.$wppb_profile_builder_serial.'"';} ?>/>
62 -
63 - <?php
64 - if( $wppb_profile_builder_serial_status == 'found' )
65 - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/accept.png" title="'.__( 'The serial number was successfully validated!', 'profilebuilder' ).'"/></span>';
66 - elseif ( $wppb_profile_builder_serial_status == 'notFound' )
67 - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number entered couldn\'t be validated!','profilebuilder' ).'"/></span>';
68 - elseif ( $wppb_profile_builder_serial_status == 'expired' )
69 - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because it expired!','profilebuilder' ).'"/></span>';
70 - elseif ( $wppb_profile_builder_serial_status == 'serverDown' )
71 - echo '<span class="validateStatus"><img src="'.WPPB_PLUGIN_URL.'/assets/images/icon_error.png" title="'.__( 'The serial number couldn\'t be validated because process timed out. This is possible due to the server being down. Please try again later!','profilebuilder' ).'"/></span>';
72 - ?>
73 - <span class="wppb-serialnumber-descr"><?php _e( '(e.g. RMPB-15-SN-253a55baa4fbe7bf595b2aabb8d72985)', 'profilebuilder' );?></span>
74 - </p>
75 -
76 -
77 - <div id="wppb_submit_button_div">
78 - <input type="hidden" name="action" value="update" />
79 - <p class="submit">
80 - <?php wp_nonce_field( 'wppb_register_version_nonce', 'wppb_register_version_nonce' ); ?>
81 - <input type="submit" name="wppb_serial_number_activate" class="button-primary" value="<?php _e('Save Changes') ?>" />
82 - </p>
83 - </div>
84 -
85 - </form>
86 -<?php
87 -}
88 -
89 -
90 -//the function to check the validity of the serial number and save a variable in the DB; purely visual
91 -function wppb_check_serial_number($oldVal, $newVal){
92 -
93 - $serial_number_set = $newVal;
94 -
95 - $response = wp_remote_get( 'http://updatemetadata.cozmoslabs.com/checkserial/?serialNumberSent='.$serial_number_set );
96 -
97 - if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
98 - wppb_update_serial_status($response, 'pro');
99 - wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-pro-update" );
100 - } else {
101 - wppb_update_serial_status($response, 'hobbyist');
102 - wp_clear_scheduled_hook( "check_plugin_updates-profile-builder-hobbyist-update" );
103 - }
104 - $user_ID = get_current_user_id();
105 - delete_user_meta( $user_ID, 'wppb_dismiss_notification' );
106 -
107 -}
108 -
109 -add_action( 'update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
110 -add_action( 'update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
111 -
112 -add_action( 'add_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number', 10, 2 );
113 -add_action( 'add_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number', 10, 2 );
114 -
115 -/**
116 - * @param $response
117 - */
118 -function wppb_update_serial_status($response, $version)
119 -{
120 - if (is_wp_error($response)) {
121 - update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //server down
122 - } elseif ((trim($response['body']) != 'notFound') && (trim($response['body']) != 'found') && (trim($response['body']) != 'expired')) {
123 - update_option('wppb_profile_builder_'.$version.'_serial_status', 'serverDown'); //unknown response parameter
124 - update_option('wppb_profile_builder_'.$version.'_serial', ''); //reset the entered password, since the user will need to try again later
125 -
126 - } else {
127 - update_option('wppb_profile_builder_'.$version.'_serial_status', trim($response['body'])); //either found, notFound or expired
128 - }
129 -}
130 -
131 -//the update didn't work when the old value = new value, so we need to apply a filter on get_option (that is run before update_option), that resets the old value
132 -function wppb_check_serial_number_fix($newvalue, $oldvalue){
133 -
134 - if ( $newvalue == $oldvalue )
135 - wppb_check_serial_number( $oldvalue, $newvalue );
136 -
137 - return $newvalue;
138 -}
139 -add_filter( 'pre_update_option_wppb_profile_builder_pro_serial', 'wppb_check_serial_number_fix', 10, 2 );
140 -add_filter( 'pre_update_option_wppb_profile_builder_hobbyist_serial', 'wppb_check_serial_number_fix', 10, 2 );
141 -
142 -
143 -/**
144 - * Class that adds a notice when either the serial number wasn't found, or it has expired
145 - *
146 - * @since v.2.0
147 - *
148 - * @return void
149 - */
150 -class wppb_add_notices{
151 - public $pluginPrefix = '';
152 - public $pluginName = '';
153 - public $notificaitonMessage = '';
154 - public $pluginSerialStatus = '';
155 -
156 - function __construct( $pluginPrefix, $pluginName, $notificaitonMessage, $pluginSerialStatus ){
157 - $this->pluginPrefix = $pluginPrefix;
158 - $this->pluginName = $pluginName;
159 - $this->notificaitonMessage = $notificaitonMessage;
160 - $this->pluginSerialStatus = $pluginSerialStatus;
161 -
162 - add_action( 'admin_notices', array( $this, 'add_admin_notice' ) );
163 - add_action( 'admin_init', array( $this, 'dismiss_notification' ) );
164 - }
165 -
166 -
167 - // Display a notice that can be dismissed in case the serial number is inactive
168 - function add_admin_notice() {
169 - global $current_user ;
170 - global $pagenow;
171 -
172 - $user_id = $current_user->ID;
173 -
174 - do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow );
175 -
176 - if ( current_user_can( 'manage_options' ) ){
177 -
178 - $plugin_serial_status = get_option( $this->pluginSerialStatus );
179 - if ( $plugin_serial_status != 'found' ){
180 - // Check that the user hasn't already clicked to ignore the message
181 - if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) ) {
182 - echo $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','<div class="error wppb-serial-notification" >'.$this->notificaitonMessage.'</div>', $this->notificaitonMessage);
183 - }
184 - }
185 -
186 - do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status );
187 -
188 - }
189 -
190 - do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow );
191 -
192 - }
193 -
194 - function dismiss_notification() {
195 - global $current_user;
196 -
197 - $user_id = $current_user->ID;
198 -
199 - do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user );
200 -
201 - // If user clicks to ignore the notice, add that to their user meta
202 - if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] )
203 - add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true );
204 -
205 - do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user );
206 - }
207 -}
208 -
209 -if ( PROFILE_BUILDER == 'Profile Builder Pro' ){
210 - $wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_pro_serial_status', 'empty' );
211 -} elseif( PROFILE_BUILDER == 'Profile Builder Hobbyist' ) {
212 - $wppb_profile_builder_pro_hobbyist_serial_status = get_option( 'wppb_profile_builder_hobbyist_serial_status', 'empty' );
213 -}
214 -
215 -if ( $wppb_profile_builder_pro_hobbyist_serial_status == 'notFound' || $wppb_profile_builder_pro_hobbyist_serial_status == 'empty' ){
216 - 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 of Profile Builder to receive access to automatic updates and support. Need a license key? %3$sPurchase one now%4$s</p>', 'profilebuilder'), "<a href='admin.php?page=profile-builder-register'>", "</a>", "<a href='http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Purchase' target='_blank' class='button-primary'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
217 -}
218 -elseif ( $wppb_profile_builder_pro_hobbyist_serial_status == 'expired' ){
219 - $wppb_notice = new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> licence has expired. <br/>Please %1$sRenew Your Licence%2$s to receive access to automatic updates and support. %3$sPurchase one now%4$s %5$sDismiss%6$s</p>', 'profilebuilder'), "<a href='http://www.cozmoslabs.com/downloads/profile-builder-pro-1-year/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank'>", "</a>", "<a href='http://www.cozmoslabs.com/downloads/profile-builder-pro-1-year/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Renewal' target='_blank' class='button-primary'>", "</a>", "<a href='". add_query_arg( 'wppb_dismiss_notification', '0' ) ."' class='wppb-dismiss-notification'>", "</a>" ), 'wppb_profile_builder_pro_serial_status' );
220 -}
221 -elseif( strpos( $wppb_profile_builder_pro_hobbyist_serial_status, 'aboutToExpire' ) === 0 ){
222 - $serial_status_parts = explode( '#', $wppb_profile_builder_pro_hobbyist_serial_status );
223 - $date = $serial_status_parts[1];
224 - new wppb_add_notices( 'wppb', 'profile_builder_pro', sprintf( __( '<p>Your <strong>Profile Builder</strong> serial number is about to expire on %5$s. <br/>Please %1$sRenew Your Licence%2$s to receive access to automatic updates and support. %3$sPurchase one now%4$s</p>', 'profilebuilder'), "<a href='admin.php?page=profile-builder-register'>", "</a>", "<a href='http://www.cozmoslabs.com/wordpress-profile-builder/?utm_source=PB&utm_medium=dashboard&utm_campaign=PB-Purchase' target='_blank' class='button-primary'>", "</a>", $date ), 'wppb_profile_builder_pro_serial_status' );
225 -}
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_2026';
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-2026" 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-2026" 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_2026_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-2026" 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-2026" 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_2026';
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-2026" 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-2026" 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/23/2026 00:00',
386 + 'end_date' => '12/01/2026 09: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 apply_filters( 'wppb_bf_promotion_is_active', false );
395 +
396 +}