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’ ){
// Check that the user hasn’t already clicked to ignore the message
if ( ! get_user_meta($user_id, $this->pluginPrefix.’_dismiss_notification’ ) ) {
echo $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() {
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 );
}
}
if( is_multisite() && function_exists( ‘switch_to_blog’ ) )
switch_to_blog(1);
if ( PROFILE_BUILDER == ‘Profile Builder Pro’ ){
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( ‘wppb_profile_builder_pro_serial_status’, ’empty’ );
$version = ‘pro’;
} elseif( PROFILE_BUILDER == ‘Profile Builder Hobbyist’ ) {
$wppb_profile_builder_pro_hobbyist_serial_status = get_option( ‘wppb_profile_builder_hobbyist_serial_status’, ’empty’ );
$version = ‘hobbyist’;
}
if( is_multisite() && function_exists( ‘restore_current_blog’ ) )
restore_current_blog();
if ( $wppb_profile_builder_pro_hobbyist_serial_status == ‘notFound’ || $wppb_profile_builder_pro_hobbyist_serial_status == ’empty’ ){
if( !is_multisite() )
$register_url = ‘admin.php?page=profile-builder-register’;
else
$register_url = network_admin_url( ‘admin.php?page=profile-builder-register’ );
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_profile_builder_pro_serial_status’ );
}
elseif ( $wppb_profile_builder_pro_hobbyist_serial_status == ‘expired’ ){
new wppb_add_notices( ‘wppb_expired’, ‘profile_builder_pro’, sprintf( __( ‘
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 and get 50% off %4$s %5$sDismiss%6$s
‘, ‘profile-builder’), ««, ««, ««, ««, ««, «» ), ‘wppb_profile_builder_pro_serial_status’ );
}
elseif( strpos( $wppb_profile_builder_pro_hobbyist_serial_status, ‘aboutToExpire’ ) === 0 ){
$serial_status_parts = explode( ‘#’, $wppb_profile_builder_pro_hobbyist_serial_status );
$date = $serial_status_parts[1];
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 and get 50% off %4$s %6$sDismiss%7$s
‘, ‘profile-builder’), ««, ««, ««, ««, $date, ««, «» ), ‘wppb_profile_builder_pro_serial_status’ );
}