PluginProbe
Adminimize / 1.9.1
Adminimize v1.9.1
1.11.14 1.11.13 1.11.1 1.11.10 1.11.11 1.11.12 1.11.2 1.11.3 1.11.4 1.11.5 1.11.6 1.11.7 1.11.8 1.11.9 1.3 1.4.7 1.6 1.7.12 1.7.13 1.7.14 1.7.15 1.7.16 1.7.17 1.7.18 1.7.19 All 53 releases
← All changes | inc-setup/remove-admin-notices.php +9 -41 1.11.11 → 1.9.1 View file →
@@ -1,12 +1,10 @@
1 1 <?php
2 2 /**
3 - * Remove the admin notices from the global options settings.
3 + * Remove the admin notices from global options settings
4 4 *
5 - * @package Adminimize
6 - * @since 2015-12-09
5 + * @since 2015-12-09
7 6 */
8 -
9 7 if ( ! function_exists( 'add_action' ) ) {
10 8 die( "Hi there! I'm just a part of plugin, not much I can do when called directly." );
11 9 }
12 10
@@ -11,21 +9,11 @@
11 9 }
12 10
13 11 // Need only on admin area
14 12 if ( ! is_admin() ) {
15 - return;
13 + return NULL;
16 14 }
17 15
18 -// If is AJAX Call.
19 -if ( defined('DOING_AJAX') && DOING_AJAX ) {
20 - return;
21 -}
22 -
23 -// If is AJAX Call.
24 -if ( defined('DOING_AJAX') && DOING_AJAX ) {
25 - return;
26 -}
27 -
28 16 add_action( 'admin_init', '_mw_adminimize_init_to_remove_admin_notices' );
29 17 /**
30 18 * Fire all hooks to remove admin notices.
31 19 */
@@ -31,22 +19,20 @@
31 19 */
32 20 function _mw_adminimize_init_to_remove_admin_notices() {
33 21
34 22 if ( _mw_adminimize_check_to_remove_admin_notices() ) {
35 - add_action( 'admin_head', '_mw_adminimize_remove_admin_notices', PHP_INT_MAX + 1 );
23 + add_action( 'admin_head', '_mw_adminimize_remove_admin_notices' );
36 24 }
37 25 }
38 26
39 27 /**
40 - * Remove Admin Notices.
41 - *
42 - * @return boolean
28 + * @return bool|null
43 29 */
44 30 function _mw_adminimize_check_to_remove_admin_notices() {
45 31
46 32 // Exclude super admin.
47 33 if ( _mw_adminimize_exclude_super_admin() ) {
48 - return false;
34 + return;
49 35 }
50 36
51 37 $user_roles = _mw_adminimize_get_all_user_roles();
52 38
@@ -61,9 +47,9 @@
61 47 $disabled_global_option_[ $role ][ '0' ] = '';
62 48 }
63 49 }
64 50
65 - $remove_admin_notices = false;
51 + $remove_admin_notices = FALSE;
66 52 foreach ( $user_roles as $role ) {
67 53
68 54 $user = wp_get_current_user();
69 55
@@ -78,13 +64,9 @@
78 64 }
79 65 }
80 66 }
81 67
82 - if ( $remove_admin_notices ) {
83 - return true;
84 - }
85 -
86 - return false;
68 + return $remove_admin_notices;
87 69 }
88 70
89 71 /**
90 72 * Remove different admin notices.
@@ -94,19 +76,5 @@
94 76 remove_action( 'admin_notices', 'update_nag', 3 );
95 77 remove_action( 'admin_notices', 'maintenance_nag', 10 );
96 78 remove_action( 'admin_notices', 'new_user_email_admin_notice' );
97 79 remove_action( 'admin_notices', 'site_admin_notice' );
98 -
99 - // @ToDo, if we will use this.
100 - // Catch all admin notices.
101 - /*
102 - add_action( 'admin_notices', function () {
103 - ob_start();
104 - }, PHP_INT_MAX + 1 );
105 - $adm_notices = trim( ob_get_clean() );
106 - $adm_notices = preg_replace(
107 - '/(\sclass=["\'][^"\']*?notice)(["\'\s])/',
108 - '$1 inline$2',
109 - $adm_notices
110 - );
111 - */
112 -}
80 +}