| @@ -17,17 +17,9 @@ | ||
| 17 | 17 | /** |
| 18 | 18 | * Add dashboard page to admin menu |
| 19 | 19 | */ |
| 20 | 20 | public static function setup_admin_page () { |
| 21 | - add_menu_page( | |
| 22 | - 'WANotifier', | |
| 23 | - 'WANotifier', | |
| 24 | - 'manage_options', | |
| 25 | - NOTIFIER_NAME, | |
| 26 | - array( __CLASS__ , 'output'), | |
| 27 | - 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(NOTIFIER_PATH . 'assets/images/menu-icon.svg')), | |
| 28 | - '51' | |
| 29 | - ); | |
| 21 | + add_menu_page( 'WANotifier', 'WANotifier', 'manage_options', NOTIFIER_NAME, array( __CLASS__ , 'output'), 'dashicons-megaphone', '51' ); | |
| 30 | 22 | } |
| 31 | 23 | |
| 32 | 24 | /** |
| 33 | 25 | * Output |
| @@ -70,21 +62,23 @@ | ||
| 70 | 62 | ); |
| 71 | 63 | |
| 72 | 64 | $response = Notifier::send_api_request( 'verify_api', $params, 'POST' ); |
| 73 | 65 | |
| 74 | - if(isset($response->error) && $response->error == false){ | |
| 75 | - update_option('notifier_api_activated', 'yes'); | |
| 76 | - $message_text = isset($response->data) ? $response->data : 'API key validated and saved successfully'; | |
| 77 | - $message_type = 'success'; | |
| 78 | - } | |
| 79 | - else { | |
| 80 | - $message_text = isset($response->message) ? $response->message : 'There was an error validating your API key.'; | |
| 81 | - $message_type = 'error'; | |
| 66 | + if($response->error){ | |
| 67 | + $notices[] = array( | |
| 68 | + 'message' => $response->message, | |
| 69 | + 'type' => 'error' | |
| 70 | + ); | |
| 71 | + new Notifier_Admin_Notices($notices, true); | |
| 72 | + wp_redirect(admin_url('admin.php?page=notifier')); | |
| 73 | + die; | |
| 82 | 74 | } |
| 83 | 75 | |
| 76 | + update_option('notifier_api_activated', 'yes'); | |
| 77 | + | |
| 84 | 78 | $notices[] = array( |
| 85 | - 'message' => $message_text, | |
| 86 | - 'type' => $message_type | |
| 79 | + 'message' => $response->data, | |
| 80 | + 'type' => 'success' | |
| 87 | 81 | ); |
| 88 | 82 | new Notifier_Admin_Notices($notices, true); |
| 89 | 83 | wp_redirect(admin_url('admin.php?page=notifier')); |
| 90 | 84 | die; |