由于没有用于自定义消息以获取可用更新的筛选器,因此您需要首先删除该消息并显示您的消息:
删除将显示更新通知的操作:
function hide_original_update_notice()
{
remove_action( \'admin_notices\', \'update_nag\', 3 );
remove_action( \'network_admin_notices\', \'update_nag\', 3 );
}
add_action( \'admin_head\', \'hide_original_update_notice\', 1 );
创建通知操作:
function my_custom_update_nag() {
if ( is_multisite() && !current_user_can(\'update_core\') )
return false;
global $pagenow;
if ( \'update-core.php\' == $pagenow )
return;
$cur = get_preferred_from_update_core();
if ( ! isset( $cur->response ) || $cur->response != \'upgrade\' )
return false;
if ( current_user_can(\'update_core\') ) {
$msg = sprintf( __(\'<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! <a href="%2$s">Please update now</a>.\'), $cur->current, network_admin_url( \'update-core.php\' ) );
} else {
$msg = sprintf( __(\'<a href="http://codex.wordpress.org/Version_%1$s">WordPress %1$s</a> is available! Please notify the site administrator.\'), $cur->current );
}
echo "<div class=\'update-nag\'>$msg</div>";
}
add_action( \'admin_notices\', \'my_custom_update_nag\', 3 );
add_action( \'network_admin_notices\', \'my_custom_update_nag\', 3 );