PluginProbe
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! / trunk
Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! vtrunk
3.8.0 3.7.5 3.7.4 3.7.3 3.7.2 1-final 3.7.1 3.7.0 3.6.8 3.6.7 3.6.6 3.6.5 3.6.4 3.6.3 3.6.2 3.6.1 3.0.3 3.0.4 3.0.5 3.0.6 3.0.7 3.0.8 3.0.9 3.1.0 3.1.1 All 112 releases
templately / vendor / priyomukul / wp-notice / src / Utils / NoticeRemover.php

NoticeRemover.php in Templately – Elementor & Gutenberg Template Library: 6500+ Free & Pro Ready Templates And Cloud! trunk, at vendor/priyomukul/wp-notice/src/Utils/NoticeRemover.php

40 lines 1017 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 if(!isset($wp_filter['admin_notices']->callbacks[10])) return;
27
28 foreach ( $wp_filter['admin_notices']->callbacks[10] as $callback ) {
29 if ( is_array( $callback['function'] ) && $callback['function'][0] instanceof $instanceOf ) {
30 $notice = $callback['function'][0];
31
32 if ( $notice->version === $version ) {
33 remove_action( 'admin_notices', [ $notice, 'notices' ] );
34 remove_action( 'admin_footer', [ $notice, 'scripts' ] );
35 }
36 }
37 }
38 } );
39 }
40 }