我没有找到任何可用于自定义消息的挂钩。所以决定删除原来的更新nag,并将我们的自定义nag放在那里。
让我们先删除原始nag
// Admin menu hook
add_action( \'admin_menu\', \'remove_core_update_nag\', 2 );
/**
* Remove the original update nag
*/
function remove_core_update_nag() {
remove_action( \'admin_notices\', \'update_nag\', 3 );
remove_action( \'network_admin_notices\', \'update_nag\', 3 );
}
一旦移除,我们将放置自定义nag。
// Admin notice hook
add_action( \'admin_notices\', \'custom_update_nag\', 99 );
add_action( \'network_admin_notices\', \'custom_update_nag\', 99 );
/**
* Custom update nag
*/
function 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 contact now</a>.\'), $cur->current, \'your_custom_url\' );
} 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>";
}
请确保您需要更换
your_custom_url
与实际链接。