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:
<?php
class Inbound_Pro_Notifications {
function __construct() {
self::load_hooks();
}
public static function load_hooks() {
add_action('admin_notices', array( __CLASS__ , 'prompt_key_notifications' ) );
}
public static function check_if_viewed( $notificaiton_id ) {
global $current_user;
$user_id = $current_user->ID;
return get_user_meta($user_id, 'inbound_notification_' . $notificaiton_id ) ;
}
public static function prompt_key_notifications() {
global $post;
global $inbound_settings;
global $pagenow;
global $current_user;
if (
isset($inbound_settings['api-key']['api-key'])
&&
trim($inbound_settings['api-key']['api-key'])
||
(
isset($_REQUEST['page'])
&&
$_REQUEST['page'] == 'inbound-pro'
)
){
return false;
}
if( !current_user_can('activate_plugins') ) {
return;
}
$message_id = 'api-key-empty';
$settings_url = admin_url('admin.php?page=inbound-pro');
if (Inbound_Notifications::check_if_viewed($message_id)) {
return;
}
echo '<div class="updated" id="inbound_notice_'.$message_id.'">
<h2>' . __('Inbound Pro has been installed!', 'inbound-pro') . '</h2>
<p style="width:80%;">' . __( 'Inbound Pro requires an API Key to enable automatic updates and subscriber ready components.' , 'inbound-pro') . '</p>
<a class="button button-primary button-large" href="'. $settings_url .'" >' . __('Setup API Key', 'inbound-pro') . '</a>
<a class="button button-large inbound_dismiss" href="#" id="'.$message_id.'" data-notification-id="'.$message_id.'" >' . __('Do This Later', 'inbound-pro') . '</a>
<br><br>
</div>';
Inbound_Notifications::javascript_dismiss_notice();
}
}
new Inbound_Pro_Notifications;