wordpress

WordPress移除后台底部版权和版本信息

admin · 2月26日 · 2021年 962次已读

很多WordPress站点在使用过程中需要隐藏WordPress的字样,尤其是WordPress后台底部的两块,每个后台页面都存在,左侧是版权信息,右侧是WordPress版本号。接下来我给大家提供一种解决方案,可以移除WordPress底部版权信息。

在主题的 functions.php 文件中加入以下代码:

/**
 * 移除WordPress后台底部左文字
 * https://www.caochen.net/129.html
 */
add_filter('admin_footer_text', '_admin_footer_left_text');
function _admin_footer_left_text($text) {
	$text = '';
	return $text;
}

/**
 * 移除WordPress后台底部右文字
 *https://www.caochen.net/129.html
 */
add_filter('update_footer', '_admin_footer_right_text', 11);
function _admin_footer_right_text($text) {
	$text = '';
	return $text;
}

移除版权固然很清爽,除非必要,否则不建议大家移除,也是对开发者的尊重。

如何自定义后台底部文字,其实只要将上述代码中返回的text 值更改为相应文字即可,比如下面我将后台底部右侧文字更改为博客标题”寒梅博客网 | 一个wordpress主题技术分享博客”,则代码如下:

//自定义 WordPress 后台底部右侧文字
add_filter('update_footer', 'qgg_admin_footer_right_text', 11);
function qgg_admin_footer_right_text($text) {
 $text = '<span><a href="https://www.hanmei.biz/">寒梅博客网</a> | 一个wordpress主题技术分享博客</span>';
 return $text;
}

移除wordpress后台左上角logo信息:

/*移除后台左上角logo信息*/
function _admin_bar_remove() {
        global $wp_admin_bar;
        $wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', '_admin_bar_remove', 0);