| @@ -10,9 +10,9 @@ | ||
| 10 | 10 | */ |
| 11 | 11 | if( is_multisite() ) { |
| 12 | 12 | function wppb_multisite_register_your_version_page() { |
| 13 | 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'); | |
| 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 | 15 | } |
| 16 | 16 | add_action('network_admin_menu', 'wppb_multisite_register_your_version_page', 29); |
| 17 | 17 | } |
| 18 | 18 | |
| @@ -25,68 +25,43 @@ | ||
| 25 | 25 | * @return string |
| 26 | 26 | */ |
| 27 | 27 | function wppb_register_your_version_content() { |
| 28 | 28 | ?> |
| 29 | - <div class="wrap wppb-wrap"> | |
| 30 | - <?php wppb_serial_form(); ?> | |
| 31 | - </div> | |
| 32 | - <?php | |
| 33 | -} | |
| 29 | + <div class="wrap wppb-wrap cozmoslabs-wrap"> | |
| 30 | + <div id="wppb-register-version-page"> | |
| 34 | 31 | |
| 32 | + <h1></h1> | |
| 33 | + <!-- WordPress Notices are added after the h1 tag --> | |
| 35 | 34 | |
| 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 ); ?>"/> | |
| 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> | |
| 74 | 39 | </div> |
| 75 | - </form> | |
| 40 | + </div> | |
| 41 | + | |
| 42 | + <div class="cozmoslabs-form-subsection-wrapper" id="wppb-register-version"> | |
| 43 | + <?php wppb_add_register_version_form(); ?> | |
| 44 | + </div> | |
| 76 | 45 | </div> |
| 77 | 46 | </div> |
| 78 | 47 | <?php |
| 79 | 48 | } |
| 80 | 49 | |
| 81 | - | |
| 82 | 50 | /** |
| 83 | 51 | * Retrieve saved license key |
| 84 | 52 | */ |
| 85 | 53 | function wppb_get_serial_number(){ |
| 86 | 54 | |
| 87 | - $license = get_option( 'wppb_license_key', false ); | |
| 55 | + if( is_multisite() ){ | |
| 56 | + $license = get_site_option( 'wppb_license_key', false ); | |
| 88 | 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 | + | |
| 89 | 64 | // try to grab the license from the old options if it's not available |
| 90 | 65 | if( empty( $license ) ){ |
| 91 | 66 | $versions = array( 'Profile Builder Pro', 'Profile Builder Agency', 'Profile Builder Unlimited', 'Profile Builder Dev' ); |
| 92 | 67 | |
| @@ -93,8 +68,10 @@ | ||
| 93 | 68 | if( in_array( PROFILE_BUILDER, $versions ) ) |
| 94 | 69 | $version = 'pro'; |
| 95 | 70 | elseif ( PROFILE_BUILDER == 'Profile Builder Hobbyist' || PROFILE_BUILDER == 'Profile Builder Basic' ) |
| 96 | 71 | $version = 'hobbyist'; |
| 72 | + else | |
| 73 | + $version = ''; | |
| 97 | 74 | |
| 98 | 75 | $old_license = get_option( 'wppb_profile_builder_'.$version.'_serial' ); |
| 99 | 76 | |
| 100 | 77 | if( !empty( $old_license ) ){ |
| @@ -111,9 +88,14 @@ | ||
| 111 | 88 | /** |
| 112 | 89 | * Retrieve license key status |
| 113 | 90 | */ |
| 114 | 91 | function wppb_get_serial_number_status(){ |
| 115 | - return get_option( 'wppb_license_status' ); | |
| 92 | + | |
| 93 | + if( is_multisite() ) | |
| 94 | + return get_site_option( 'wppb_license_status' ); | |
| 95 | + else | |
| 96 | + return get_option( 'wppb_license_status' ); | |
| 97 | + | |
| 116 | 98 | } |
| 117 | 99 | |
| 118 | 100 | /** |
| 119 | 101 | * Class that adds a notice when either the serial number wasn't found, or it has expired |
| @@ -176,8 +158,12 @@ | ||
| 176 | 158 | |
| 177 | 159 | } |
| 178 | 160 | |
| 179 | 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 | + | |
| 180 | 166 | global $current_user; |
| 181 | 167 | |
| 182 | 168 | $user_id = $current_user->ID; |
| 183 | 169 | |
| @@ -190,78 +176,221 @@ | ||
| 190 | 176 | do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user ); |
| 191 | 177 | } |
| 192 | 178 | } |
| 193 | 179 | |
| 194 | -if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){ | |
| 180 | +add_action( 'admin_init', 'wppb_admin_general_notices', 9 ); | |
| 181 | +function wppb_admin_general_notices(){ | |
| 195 | 182 | |
| 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() ); | |
| 183 | + if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){ | |
| 200 | 184 | |
| 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 ); | |
| 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 | + } | |
| 204 | 254 | |
| 205 | - if( is_multisite() && function_exists( 'restore_current_blog' ) ) | |
| 206 | - restore_current_blog(); | |
| 207 | 255 | |
| 208 | - if( empty( $wppb_serial_number ) || $wppb_serial_status == 'missing' ) { | |
| 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() ){ | |
| 209 | 264 | |
| 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' ); | |
| 265 | + $license_status = wppb_get_serial_number_status(); | |
| 266 | + $notifications = WPPB_Plugin_Notifications::get_instance(); | |
| 214 | 267 | |
| 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' ); | |
| 268 | + // Plugin pages | |
| 269 | + if( $notifications->is_plugin_page() ){ | |
| 216 | 270 | |
| 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>'; | |
| 271 | + $notification_id = 'wppb_bf_2026'; | |
| 225 | 272 | |
| 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' ){ | |
| 273 | + $message = '<div class="wppb-bf-notice-container"><img style="max-width: 60px;width: 60px;" src="' . WPPB_PLUGIN_URL . 'assets/images/pb-logo.svg" />'; | |
| 232 | 274 | |
| 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 | - } | |
| 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 | + } | |
| 236 | 282 | |
| 237 | - } | |
| 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>'; | |
| 238 | 284 | |
| 239 | - if( isset( $license_details->license ) && $license_details->license == 'invalid' ){ | |
| 285 | + $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info' ); | |
| 240 | 286 | |
| 241 | - if( isset( $license_details->error ) && $license_details->error == 'no_activations_left' ){ | |
| 287 | + } else { | |
| 242 | 288 | |
| 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>'; | |
| 289 | + if( wppb_bf_show_shared_promotion() ){ | |
| 244 | 290 | |
| 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; | |
| 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 | + | |
| 249 | 305 | } 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 | |
| 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 | + | |
| 251 | 320 | } |
| 252 | 321 | |
| 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 | 322 | } |
| 261 | 323 | |
| 262 | 324 | } |
| 263 | 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(){ | |
| 264 | 383 | |
| 384 | + $black_friday = array( | |
| 385 | + 'start_date' => '11/23/2026 00:00', | |
| 386 | + 'end_date' => '12/01/2026 09:59', | |
| 387 | + ); | |
| 265 | 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 | + | |
| 266 | 396 | } |
| 267 | - | |