問題描述

有沒有從 WordPress 管理員頁腳右側刪除版本號?

我知道這個代碼將在版本號之前添加一些文本,但不會刪除它:

function change_footer_version() {
    echo 'Anything';
}
add_filter( 'update_footer', 'change_footer_version', 9999 );

以下代碼什麼也不做:

function change_footer_version() {
    return ' ';
}
add_filter( 'update_footer', 'change_footer_version', 9999 );

那麼,是否還有從 functions.php 文件中刪除整個<div>

最佳解決方案

將其添加到您的 functions.php 中:

function my_footer_shh() {
    remove_filter( 'update_footer', 'core_update_footer' );
}

add_action( 'admin_menu', 'my_footer_shh' );

或者,如果您希望將其隱藏除管理員以外的所有人員:

function my_footer_shh() {
    if ( ! current_user_can('manage_options') ) { // 'update_core' may be more appropriate
        remove_filter( 'update_footer', 'core_update_footer' );
    }
}
add_action( 'admin_menu', 'my_footer_shh' );

次佳解決方案

另一個答案不適用於我的網站。我嘗試這個腳本,它可以正常從正確的頁腳管理頁面中刪除 WordPress 版本號:

add_filter( 'admin_footer_text', '__return_empty_string', 11 );
add_filter( 'update_footer', '__return_empty_string', 11 );

參考文獻

注:本文內容整合自 Google/Baidu/Bing 輔助翻譯的英文資料結果。如果您對結果不滿意,可以加入我們改善翻譯效果:薇曉朵技術論壇。