1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90:
<?php
if (!class_exists('Leads_Admin_Notices')) {
class Leads_Admin_Notices {
function __construct() {
add_action( 'admin_init', array( __CLASS__ , 'dismiss_notices') );
add_action( 'admin_notices', array( __CLASS__ , 'define_notices') );
}
public static function dismiss_notices() {
global $current_user;
$user_id = $current_user->ID;
if ( isset($_GET['leads_user_message_ignore']) && '0' == $_GET['leads_user_message_ignore'] ) {
add_user_meta($user_id, 'leads_user_message_ignore', 'true', true);
}
}
public static function define_notices() {
global $post_type, $pagenow , $current_user;
$user_id = $current_user->ID;
if ( isset( $_GET['inbound-message'] ) && 'user-id-does-not-exits' == $_GET['inbound-message'] ) {
self::throw_notice( __( 'User ID provided does not exist.', 'inbound-pro' ) , 'error' );
}
if ( isset( $_GET['inbound-message'] ) && 'api-key-generated' == $_GET['inbound-message'] ) {
self::throw_notice( __( 'API keys successfully generated.', 'inbound-pro' ) , 'updated' );
}
if ( isset( $_GET['inbound-message'] ) && 'api-key-exists' == $_GET['inbound-message'] ) {
self::throw_notice( __( 'The specified user already has API keys.', 'inbound-pro' ), 'error' );
}
if ( isset( $_GET['inbound-message'] ) && 'api-key-regenerated' == $_GET['inbound-message'] ) {
self::throw_notice( __( 'API keys successfully regenerated.', 'inbound-pro' ), 'updated' );
}
if ( isset( $_GET['inbound-message'] ) && 'api-key-revoked' == $_GET['inbound-message'] ) {
self::throw_notice( __( 'API keys successfully revoked.', 'inbound-pro' ), 'updated' );
}
if ($pagenow == 'edit.php' && $post_type == 'wp-lead' && isset($_REQUEST['exported']) && (int)$_REQUEST['exported']) {
$message = sprintf(_n('Lead exported.', '%s lead exported.', $_REQUEST['exported']), number_format_i18n($_REQUEST['exported']));
self::throw_notice( $message , 'updated' );
}
if ($pagenow == 'edit.php' && $post_type == 'wp-lead' && isset($_REQUEST['added']) && (int)$_REQUEST['added']) {
$message = sprintf(_n('Lead Added.', '%s leads added to list.', $_REQUEST['added']), number_format_i18n($_REQUEST['added']));
self::throw_notice( $message , 'updated' );
}
}
public static function throw_notice( $message , $type = 'updated' ) {
?>
<div class="<?php echo $type; ?>">
<p><?php echo $message ?></p>
</div>
<?php
}
}
new Leads_Admin_Notices();
}