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: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126:
<?php
class Inbound_Mailer_Notifications {
function __construct() {
self::load_hooks();
}
public static function load_hooks() {
add_action( 'admin_init' , array( __CLASS__ , 'ignore_notifications' ) );
add_action('admin_notices', array( __CLASS__ , 'prompt_key_notifications' ) );
}
public static function ignore_notifications() {
if (!isset($_REQUEST['mailer-disable-notification'])) {
return;
}
global $current_user;
$user_id = $current_user->ID;
$ignore_check = get_transient('inbound_pro_ignore_email_errors' , array());
$ignore_check[] = $user_id;
set_transient( 'inbound_pro_ignore_email_errors' , array_unique($ignore_check) , 60 * 60 * 24 * 3 );
}
public static function prompt_key_notifications() {
global $post , $inbound_settings;
if (!isset($post)||$post->post_type!='inbound-email'){
return false;
}
$settings_url = Inbound_Mailer_Settings::get_settings_url();
switch($inbound_settings['mailer']['mail-service']) {
case 'sparkpost':
if ( isset($inbound_settings['mailer']['sparkpost-key']) && $inbound_settings['mailer']['sparkpost-key'] ) {
return;
}
?>
<div class="updated">
<p><?php _e( sprintf( 'Email requires a SparkPost API Key. Head to your %s to input your SparkPost API key.' , '<a href="'.$settings_url.'">'.__( 'settings page' , 'inbound-pro' ).'</a>') , 'inbound-email'); ?></p>
</div>
<?php
break;
default:
?>
<div class="updated">
<p><?php _e( sprintf( 'An email service is required to send emails. Head to your %s to select a mail service.' , '<a href="'.$settings_url.'">'.__( 'settings page' , 'inbound-pro' ).'</a>') , 'inbound-email'); ?></p>
</div>
<?php
break;
}
}
public static function prompt_email_send_error() {
global $current_user, $post;
$user_id = $current_user->ID;
$errors = Inbound_Options_API::get_option('inbound-email', 'errors-detected', false);
if (!$errors) {
return;
}
$ignore_check = get_transient('inbound_pro_ignore_email_errors' , array());
if ($ignore_check && in_array( $user_id , $ignore_check ) && (!isset($post) || $post->post_type != 'inbound-email')) {
return;
}
echo '<div class="error">';
if ((!isset($post) || $post->post_type != 'inbound-email')) {
echo '<div style="float:right;margin-top:10px;"><a href="?mailer-disable-notification=true" title="'. __('Disable this notification. Note this error message will still appear in the email listing area until all scheduled emails are canceled or the error itself resolves.', 'inbound-pro') . '"><strong>x</strong></a> </div>';
}
echo '<p>' . __( sprintf( 'The selected email service is rejecting email send attempts and returning the message below: <pre>%s</pre>' , $errors) , 'inbound-pro') .'</p>';
echo ' </div>';
}
}
new Inbound_Mailer_Notifications;