pluginPrefix = $pluginPrefix; $this->pluginName = $pluginName; $this->notificaitonMessage = $notificaitonMessage; $this->pluginSerialStatus = $pluginSerialStatus; add_action( 'admin_notices', array( $this, 'add_admin_notice' ) ); add_action( 'admin_init', array( $this, 'dismiss_notification' ) ); } // Display a notice that can be dismissed in case the serial number is inactive function add_admin_notice() { global $current_user ; global $pagenow; $user_id = $current_user->ID; do_action( $this->pluginPrefix.'_before_notification_displayed', $current_user, $pagenow ); if ( current_user_can( 'manage_options' ) ){ $plugin_serial_status = get_option( $this->pluginSerialStatus ); if ( $plugin_serial_status != 'found' ){ //we want to show the expiration notice on our plugin pages even if the user dismissed it on the rest of the site $force_show = false; if ( $plugin_serial_status == 'expired' ) { $notification_instance = WPPB_Plugin_Notifications::get_instance(); if ($notification_instance->is_plugin_page()){ $force_show = true; } } // Check that the user hasn't already clicked to ignore the message if ( ! get_user_meta($user_id, $this->pluginPrefix.'_dismiss_notification' ) || $force_show ) { echo wp_kses_post( $finalMessage = apply_filters($this->pluginPrefix.'_notification_message','
'.$this->notificaitonMessage.'
', $this->notificaitonMessage) ); } } do_action( $this->pluginPrefix.'_notification_displayed', $current_user, $pagenow, $plugin_serial_status ); } do_action( $this->pluginPrefix.'_after_notification_displayed', $current_user, $pagenow ); } function dismiss_notification() { if( empty( $_GET['_wpnonce'] ) || !wp_verify_nonce( sanitize_text_field( $_GET['_wpnonce'] ), 'wppb_license_notice_dismiss' ) ) return; global $current_user; $user_id = $current_user->ID; do_action( $this->pluginPrefix.'_before_notification_dismissed', $current_user ); // If user clicks to ignore the notice, add that to their user meta if ( isset( $_GET[$this->pluginPrefix.'_dismiss_notification']) && '0' == $_GET[$this->pluginPrefix.'_dismiss_notification'] ) add_user_meta( $user_id, $this->pluginPrefix.'_dismiss_notification', 'true', true ); do_action( $this->pluginPrefix.'_after_notification_dismissed', $current_user ); } } add_action( 'admin_init', 'wppb_admin_general_notices', 9 ); function wppb_admin_general_notices(){ if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ){ // Switch to the main site if( is_multisite() && function_exists( 'switch_to_blog' ) && function_exists( 'get_main_site_id' )) switch_to_blog( get_main_site_id() ); $wppb_serial_number = wppb_get_serial_number(); $wppb_serial_status = wppb_get_serial_number_status(); $license_details = get_option( 'wppb_license_details', false ); if( is_multisite() && function_exists( 'restore_current_blog' ) ) restore_current_blog(); if( empty( $wppb_serial_number ) || $wppb_serial_status == 'missing' ) { if( !is_multisite() ) $register_url = 'admin.php?page=profile-builder-general-settings'; else $register_url = network_admin_url( 'admin.php?page=profile-builder-general-settings' ); new WPPB_add_notices( 'wppb', 'profile_builder_pro', sprintf( '

' . __( 'Your Profile Builder serial number is invalid or missing.
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') . '

', "", "", "", "" ), 'wppb_license_status' ); } elseif ( $wppb_serial_status == 'expired' ){ /* on our plugin pages do not add the dismiss button for the expired notification*/ $notification_instance = WPPB_Plugin_Notifications::get_instance(); if( $notification_instance->is_plugin_page() ) $message = '

' . __( 'Your Profile Builder license has expired.
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') . '

'; else $message = '

' . __( 'Your Profile Builder license has expired.
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') . '

'; new WPPB_add_notices( 'wppb_expired', 'profile_builder_pro', sprintf( $message, "", "", "", "", "", "" ), 'wppb_license_status' ); } // Maybe add about to expire notice if( $wppb_serial_status != 'expired' && !empty( $license_details ) && !empty( $license_details->expires ) && $license_details->expires !== 'lifetime' ){ if( ( !isset( $license_details->subscription_status ) || $license_details->subscription_status != 'active' ) && strtotime( $license_details->expires ) < strtotime( '+14 days' ) ){ new WPPB_add_notices( 'wppb_about_to_expire', 'profile_builder_pro', sprintf( '

' . __( 'Your Profile Builder license is about to expire on %5$s.
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') . '

', "", "", "", "", date_i18n( get_option( 'date_format' ), strtotime( $license_details->expires ) ), "", "" ), 'wppb_license_status' ); } } if( isset( $license_details->license ) && $license_details->license == 'invalid' ){ if( isset( $license_details->error ) && $license_details->error == 'no_activations_left' ){ $activations_limit_message = '

' . sprintf( __( 'Your %s license has reached its activation limit.
Upgrade now for unlimited activations and extra features like multiple registration and edit profile forms, userlisting, custom redirects and more. Upgrade now', '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' ) ) . '

'; $notification_instance = WPPB_Plugin_Notifications::get_instance(); if( !$notification_instance->is_plugin_page() ) {//add the dismiss button only on other pages in admin $activations_limit_message .= sprintf(__(' %1$sDismiss%2$s', 'profile-builder'), "", ""); $force_show = false; } else { $force_show = true;//sets the forceShow parameter of WPPB_add_notices to true so we don't take into consideration the dismiss user meta } new WPPB_add_notices( 'wppb_basic_activations_limit', 'profile_builder_basic', $activations_limit_message, 'error', '', '', $force_show ); } } } /** * Black Friday * * Showing this to: * free users * users that have expired or disabled licenses */ if( wppb_bf_show_promotion() ){ $license_status = wppb_get_serial_number_status(); $notifications = WPPB_Plugin_Notifications::get_instance(); // Plugin pages if( $notifications->is_plugin_page() ){ $notification_id = 'wppb_bf_2024'; $message = '
'; if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' ){ $message .= '

' . 'Renew your Profile Builder license this Black Friday! ' . '

'; $message .= '

Don\'t miss out on our best prices & only sale of the year.
Get Deal

'; } else { $message .= '

' . 'Get the best price for Profile Builder PRO this Black Friday!' . '

'; $message .= '

This is a limited-time offer, so don\'t miss out on our only sale of the year.
Get Deal

'; } $message .= '
' . __( 'Dismiss this notice.', 'profile-builder' ) . ''; $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info' ); } else { if( wppb_bf_show_shared_promotion() ){ $notification_id = 'wppb_bf_2024_cross_promotion'; $message = ''; $message .= ''; if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' ) $message .= '

Upgrade to Profile Builder & Paid Member Subscriptions PRO this Black Friday! Don\'t miss our only sale of the year. Learn more

'; else $message .= '

Upgrade to Profile Builder & Paid Member Subscriptions PRO this Black Friday! Don\'t miss our only sale of the year. Learn more

'; $message .= '' . __( 'Dismiss this notice.', 'profile-builder' ) . ''; $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false, array(), true ); } else { $notification_id = 'wppb_bf_2024'; $message = ''; if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) && $license_status == 'expired' ) $message .= '

Upgrade to Profile Builder PRO this Black Friday! Don\'t miss our only sale of the year. Learn more

'; else $message .= '

Upgrade to Profile Builder PRO this Black Friday! Don\'t miss our only sale of the year. Learn more

'; $message .= '' . __( 'Dismiss this notice.', 'profile-builder' ) . ''; $notifications->add_notification( $notification_id, $message, 'wppb-notice notice notice-info', false, array(), true ); } } } } function wppb_bf_show_promotion(){ if( !wppb_bf_promotion_is_active() ) return false; if( !defined( 'WPPB_PAID_PLUGIN_DIR' ) ) return true; $license_details = get_option( 'wppb_license_details', false ); if( !empty( $license_details ) ){ if( isset( $license_details->error ) && in_array( $license_details->error, [ 'expired', 'disabled', 'revoked', 'missing', 'no_activations_left' ] ) ) return true; } return false; } function wppb_bf_show_shared_promotion(){ if( !wppb_bf_show_promotion() ) return false; // verify if the PMS promotion should be shown if( !defined( 'PAID_MEMBER_SUBSCRIPTIONS' ) ) return false; // make sure the promotion is not shown on the PMS pages, only on other Dashboard pages if( class_exists( 'PMS_Plugin_Notifications' ) ){ $pms_notifications_instance = PMS_Plugin_Notifications::get_instance(); if( $pms_notifications_instance->is_plugin_page() ) return false; } $license_details = get_option( 'pms_license_details', false ); if( !empty( $license_details ) ){ if( isset( $license_details->error ) && in_array( $license_details->error, [ 'expired', 'disabled', 'revoked', 'missing', 'no_activations_left' ] ) ) return true; } if( !defined( 'PMS_PAID_PLUGIN_DIR' ) ) return true; return false; } function wppb_bf_promotion_is_active(){ $black_friday = array( 'start_date' => '11/25/2024 00:00', 'end_date' => '12/03/2024 23:59', ); $current_date = time(); if( $current_date > strtotime( $black_friday['start_date'] ) && $current_date < strtotime( $black_friday['end_date'] ) ) return true; return false; }