These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * WordPress Admin Notifications |
||
4 | * |
||
5 | * Add static/dismissible admin notifications to WordPress |
||
6 | * |
||
7 | * @package amarkal-admin-notification |
||
8 | * @author Askupa Software <[email protected]> |
||
9 | * @link https://github.com/askupasoftware/amarkal-admin-notification |
||
10 | * @copyright 2017 Askupa Software |
||
11 | */ |
||
12 | |||
13 | // Prevent direct file access |
||
14 | defined( 'ABSPATH' ) or die( 'No script kiddies please!' ); |
||
15 | |||
16 | if(!function_exists('_amarkal_admin_notification_init')) |
||
17 | { |
||
18 | /** |
||
19 | * Initiate admin notifications |
||
20 | */ |
||
21 | function _amarkal_admin_notification_init() |
||
22 | { |
||
23 | $notifier = Amarkal\Admin\Notifications::get_instance(); |
||
24 | $notifier->init(); |
||
25 | } |
||
26 | add_action( 'init', '_amarkal_admin_notification_init' ); |
||
27 | } |
||
28 | |||
29 | if(!function_exists('amarkal_admin_notification')) |
||
30 | { |
||
31 | /** |
||
32 | * Register an admin notification. |
||
33 | * |
||
34 | * @param type $handle |
||
35 | * @param type $html |
||
36 | * @param type $type |
||
37 | * @param type $dismissible |
||
38 | * @param type $class |
||
39 | * @param type $network |
||
40 | */ |
||
41 | function amarkal_admin_notification( $handle, $html, $type = 'success', $dismissible = false, $class = '', $network = false ) |
||
42 | { |
||
43 | $notifier = Amarkal\Admin\Notifications::get_instance(); |
||
44 | $notifier->register_notification($handle, array( |
||
45 | 'dismissible' => $dismissible, |
||
46 | 'class' => $class, |
||
47 | 'type' => $type, |
||
48 | 'html' => $html, |
||
49 | 'network' => $network |
||
50 | )); |
||
51 | } |
||
52 | } |
||
53 | |||
54 | if(!function_exists('amarkal_reset_admin_notification')) |
||
55 | { |
||
56 | /** |
||
57 | * Reset a dismissed admin notification. |
||
58 | * |
||
59 | * @param string $handle |
||
60 | */ |
||
61 | function amarkal_reset_admin_notification( $handle ) |
||
62 | { |
||
63 | $dismissed = get_site_option( 'amarkal_dismissed_notices', array() ); |
||
64 | $offset = 0; |
||
65 | foreach($dismissed as $id) |
||
66 | { |
||
67 | if( $id === $handle ) break; |
||
68 | $offset++; |
||
69 | } |
||
70 | array_splice( $dismissed, $offset, 1); |
||
71 | update_site_option( 'amarkal_dismissed_notices', $dismissed ); |
||
72 | } |
||
73 | } |
||
74 | |||
75 | if(!function_exists('wp_admin_notification')) |
||
76 | { |
||
77 | /** |
||
78 | * @deprecated use amarkal_admin_notification instead |
||
79 | */ |
||
80 | function wp_admin_notification( $handle, $html, $type = 'success', $dismissible = false, $class = '', $network = false ) |
||
81 | { |
||
82 | trigger_error('<b>wp_admin_notification()</b> has been deprecated. Use <b>amarkal_admin_notification</b> instead.'); |
||
83 | amarkal_admin_notification( $handle, $html, $type, $dismissible, $class, $network ); |
||
0 ignored issues
–
show
$network is of type boolean , but the function expects a false|object<type> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
84 | } |
||
85 | } |
||
86 | |||
87 | if(!function_exists('wp_reset_admin_notification')) |
||
88 | { |
||
89 | /** |
||
90 | * @deprecated use amarkal_reset_admin_notification instead |
||
91 | */ |
||
92 | function wp_reset_admin_notification( $handle ) |
||
93 | { |
||
94 | trigger_error('<b>wp_reset_admin_notification()</b> has been deprecated. Use <b>amarkal_reset_admin_notification</b> instead.'); |
||
95 | amarkal_reset_admin_notification( $handle ); |
||
96 | } |
||
97 | } |
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: