forked from vincentorback/clean-wordpress-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotifications.php
More file actions
47 lines (39 loc) · 1.21 KB
/
notifications.php
File metadata and controls
47 lines (39 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
* Hide core updates
*/
add_action( 'after_setup_theme', function () {
// Still show updates to superadmins
if ( (! current_user_can( 'update_core' )) || is_super_admin() ) {
return;
}
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', '__return_null' );
add_filter( 'pre_site_transient_update_core', '__return_null' );
}, 1 );
/**
* Disable plugin update notifications
*/
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_plugins', '__return_null' );
/**
* Disable inactive plugins update notifications
*/
add_filter( 'transient_update_plugins', function ( $value = '' ) {
if ((isset($value->response)) && (count($value->response))) {
$active_plugins = get_option( 'active_plugins' );
if ($active_plugins) {
foreach($value->response as $plugin_idx => $plugin_item) {
if (!in_array($plugin_idx, $active_plugins)) {
unset($value->response[$plugin_idx]);
}
}
}
else {
foreach($value->response as $plugin_idx => $plugin_item) {
unset($value->response);
}
}
}
return $value;
});