essential-addons-for-elementor-lite
/
vendor
/
priyomukul
/
wp-notice
/
src
/
Utils
/
NoticeRemover.php
essential-addons-for-elementor-lite
/
vendor
/
priyomukul
/
wp-notice
/
src
/
Utils
Last commit date
Base.php
2 years ago
CacheBank.php
2 years ago
Helper.php
2 years ago
NoticeRemover.php
2 years ago
Storage.php
2 years ago
NoticeRemover.php
38 lines
| 1 | <?php |
| 2 | |
| 3 | namespace PriyoMukul\WPNotice\Utils; |
| 4 | |
| 5 | use PriyoMukul\WPNotice\Notices; |
| 6 | |
| 7 | class NoticeRemover { |
| 8 | private static $instance = null; |
| 9 | |
| 10 | public static function get_instance( $version ) { |
| 11 | if ( self::$instance == null ) { |
| 12 | self::$instance = new static( $version ); |
| 13 | } |
| 14 | |
| 15 | return self::$instance; |
| 16 | } |
| 17 | |
| 18 | public function __construct( $version = '1.0.0', $instanceOf = null ) { |
| 19 | add_action( 'init', function () use ( $version, $instanceOf ) { |
| 20 | global $wp_filter; |
| 21 | |
| 22 | if ( $instanceOf === null ) { |
| 23 | $instanceOf = Notices::class; |
| 24 | } |
| 25 | |
| 26 | foreach ( $wp_filter['admin_notices']->callbacks[10] as $callback ) { |
| 27 | if ( is_array( $callback['function'] ) && $callback['function'][0] instanceof $instanceOf ) { |
| 28 | $notice = $callback['function'][0]; |
| 29 | |
| 30 | if ( $notice->version === $version ) { |
| 31 | remove_action( 'admin_notices', [ $notice, 'notices' ] ); |
| 32 | remove_action( 'admin_footer', [ $notice, 'scripts' ] ); |
| 33 | } |
| 34 | } |
| 35 | } |
| 36 | } ); |
| 37 | } |
| 38 | } |