| @@ -1,35 +1,23 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | namespace WPCoder\Admin; |
| 4 | 4 | |
| 5 | -use WPCoder\WPCoder; | |
| 6 | - | |
| 7 | 5 | defined( 'ABSPATH' ) || exit; |
| 8 | 6 | |
| 9 | 7 | class AdminNotices { |
| 10 | 8 | |
| 9 | + | |
| 11 | 10 | public function __construct() { |
| 12 | 11 | add_action( 'admin_notices', [ $this, 'admin_notice' ] ); |
| 13 | 12 | } |
| 14 | 13 | |
| 15 | 14 | public function admin_notice() { |
| 16 | - if ( ! isset( $_GET['page'], $_GET['notice'] ) ) { | |
| 17 | - return; | |
| 18 | - } | |
| 19 | - | |
| 20 | - $page = $_GET['page']; | |
| 21 | - $notice = $_GET['notice']; | |
| 22 | - | |
| 23 | - if ( in_array( $page, [ WPCoder::SLUG, WPCoder::SLUG . '-settings' ], true ) ) { | |
| 24 | - switch ( $notice ) { | |
| 25 | - case 'save_item': | |
| 26 | - $this->save_item(); | |
| 27 | - break; | |
| 28 | - case 'remove_item': | |
| 29 | - $this->remove_item(); | |
| 30 | - break; | |
| 31 | - } | |
| 15 | + $notice = $_GET['notice'] ?? ''; | |
| 16 | + if ( ! empty( $notice ) && $notice === 'save_item' ) { | |
| 17 | + $this->save_item(); | |
| 18 | + } elseif ( ! empty( $notice ) && $notice === 'remove_item' ) { | |
| 19 | + $this->remove_item(); | |
| 32 | 20 | } |
| 33 | 21 | } |
| 34 | 22 | |
| 35 | 23 | public function save_item() { |