WordPress网站创建主题后可以设置用户在后台发布文章,但是对于恶意攻击网站的用户来说,可能会在后台进行不安全操作,为了保护WordPress后台安全性需要屏蔽用户在后台不可操作的功能。

将下方代码添加进你正在使用的WordPress主题的functions.php中:

//屏蔽后台无用项

function remove_menus() {

global $menu;

$restricted = array(

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Dashboard\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’),

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Posts\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’),

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Tools\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’),

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Settings\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’),

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Comments\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’),

__(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’Plugins\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’)

);

end ($menu);

while (prev($menu)){

$value = explode(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,$menu[key($menu)][0]);

if(strpos($value[0], \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’) === FALSE) {

if(in_array($value[0] != NULL ? $value[0]:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” , $restricted)){

unset($menu[key($menu)]);

}

}else {

$value2 = explode(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'<\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, $value[0]);

if(in_array($value2[0] != NULL ? $value2[0]:\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” , $restricted)){

unset($menu[key($menu)]);

}

}

}

}

if (is_admin()){

// 屏蔽左侧菜单

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’admin_menu\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’remove_menus\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

}

function remove_screen_options(){ return false;}

add_filter(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’screen_options_show_screen\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’remove_screen_options\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’contextual_help\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’wpse50723_remove_help\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 999, 3 );

function wpse50723_remove_help($old_help, $screen_id, $screen){

$screen->remove_help_tabs();

return $old_help;

}

function wp_hide_nag() {

remove_action( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’admin_notices\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’update_nag\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 3 );

}

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’admin_menu\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’,\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’wp_hide_nag\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

function example_remove_dashboard_widgets() {

// Globalize the metaboxes array, this holds all the widgets for wp-admin

global $wp_meta_boxes;

// 以下这一行代码将删除 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”快速发布\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” 模块

unset($wp_meta_boxes[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’side\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’core\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard_quick_press\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’]);

// 以下这一行代码将删除 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”WordPress 开发日志\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” 模块

unset($wp_meta_boxes[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’side\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’core\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard_primary\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’]);

// 以下这一行代码将删除 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”其它 WordPress 新闻\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” 模块

unset($wp_meta_boxes[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’side\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’core\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard_secondary\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’]);

// 以下这一行代码将删除 \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\”概况\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\” 模块

unset($wp_meta_boxes[\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’normal\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’core\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’][\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’dashboard_right_now\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’]);

}

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’wp_dashboard_setup\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’example_remove_dashboard_widgets\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’ );

function change_footer_admin () {return \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’;}

add_filter(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’admin_footer_text\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’change_footer_admin\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 9999);

function change_footer_version() {return \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’;}

add_filter( \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’update_footer\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’change_footer_version\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 9999);

function annointed_admin_bar_remove() {

global $wp_admin_bar;

/* Remove their stuff */

$wp_admin_bar->remove_menu(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’wp-logo\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’);

}

add_action(\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’wp_before_admin_bar_render\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’annointed_admin_bar_remove\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\’, 0);

相关新闻

发表评论

您的电子邮箱地址不会被公开。 必填项已用*标注

联系我们

联系我们

151-1101-0018

在线咨询:
邮件:30115776@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信
关注微信
分享本页
返回顶部