有没有办法在后台管理区定制wordpress更新通知?
我想这样做,这样我就可以改变Please update now 到Please contact now 并链接到其他URL。因此,运行网站的人不会更新网站,因为他们不知道如何备份网站。
我已经找到了在线隐藏通知的方法,但没有办法实际编辑它。
有没有办法在后台管理区定制wordpress更新通知?
我想这样做,这样我就可以改变Please update now 到Please contact now 并链接到其他URL。因此,运行网站的人不会更新网站,因为他们不知道如何备份网站。
我已经找到了在线隐藏通知的方法,但没有办法实际编辑它。
我没有找到任何可用于自定义消息的挂钩。所以决定删除原来的更新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
与实际链接。我想在帖子页面中获取帖子ID。我需要这个自定义元框,这样我就可以在短代码中设置id。我可以在通知中显示结果,但不知道如何使其全局化以用于元输入。到目前为止,我得到的是:function foo(){ global $post; $nid = $post->ID; var_dump($nid); } add_action( \'admin_notices\', \'foo\' ); 显示id,但我需要它作为变量,以便以后使用。所以我试着$nid glo