| 1 |
<?php |
| 2 |
|
| 3 |
namespace WPCoder\Admin; |
| 4 |
|
| 5 |
use WPCoder\WOW_Plugin; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || exit; |
| 8 |
|
| 9 |
class AdminNotices { |
| 10 |
|
| 11 |
|
| 12 |
public function __construct() { |
| 13 |
add_action( 'admin_notices', [ $this, 'admin_notice' ] ); |
| 14 |
} |
| 15 |
|
| 16 |
public function admin_notice() { |
| 17 |
$notice = $_GET['notice'] ?? ''; |
| 18 |
|
| 19 |
if(!isset($_GET['page'])) { |
| 20 |
return false; |
| 21 |
} |
| 22 |
|
| 23 |
if($_GET['page'] !== WOW_Plugin::SLUG) { |
| 24 |
return false; |
| 25 |
} |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
if ( ! empty( $notice ) && $notice === 'save_item' ) { |
| 30 |
$this->save_item(); |
| 31 |
} elseif ( ! empty( $notice ) && $notice === 'remove_item' ) { |
| 32 |
$this->remove_item(); |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
public function save_item() { |
| 37 |
$text = __( 'Item saved.', 'wpcoder' ); |
| 38 |
echo '<div class="wowp-notice notice notice-success is-dismissible">' . esc_html( $text ) . '</div>'; |
| 39 |
} |
| 40 |
|
| 41 |
public function remove_item() { |
| 42 |
$text = __( 'Item delete.', 'wpcoder' ); |
| 43 |
echo '<div class="wowp-notice notice notice-warning is-dismissible">' . esc_html( $text ) . '</div>'; |
| 44 |
} |
| 45 |
|
| 46 |
} |