admin管理员组文章数量:1130349
To this day I have been using CSS to hide unneeeded stuff from the dashboard area in the backend of Wordpress. But I don't like this way as it is easy to make it visible again. On things I have found a way, I have been using hooks to disable them.
But there are things I haven't managed to remove easily with hooks. For example the Primary Site selection under My Sites in a multisite network.
I found this way, which seems to remove it completely before site is loading.
if ( ! function_exists( 'remove_from_my_sites' ) ) {
function remove_from_my_sites( $subject ) {
if (get_current_screen()->id == 'my-sites') {
$subject = preg_replace('#<table class="form-table(.*?)</table>#s', '', $subject, 1);
}
return $subject;
}
function subject_start_my_sites() {
if ( current_user_can('read') ) {
ob_start( 'remove_from_my_sites' );
}
}
function subject_end_my_sites() {
if ( current_user_can('read') ) {
ob_end_flush();
}
}
}
add_action( 'admin_head', 'subject_start_my_sites' );
add_action( 'admin_footer', 'subject_end_my_sites' );
Is this a good way to remove stuff? Or will it reduce performance? I want to know before I continue using this!
To this day I have been using CSS to hide unneeeded stuff from the dashboard area in the backend of Wordpress. But I don't like this way as it is easy to make it visible again. On things I have found a way, I have been using hooks to disable them.
But there are things I haven't managed to remove easily with hooks. For example the Primary Site selection under My Sites in a multisite network.
I found this way, which seems to remove it completely before site is loading.
if ( ! function_exists( 'remove_from_my_sites' ) ) {
function remove_from_my_sites( $subject ) {
if (get_current_screen()->id == 'my-sites') {
$subject = preg_replace('#<table class="form-table(.*?)</table>#s', '', $subject, 1);
}
return $subject;
}
function subject_start_my_sites() {
if ( current_user_can('read') ) {
ob_start( 'remove_from_my_sites' );
}
}
function subject_end_my_sites() {
if ( current_user_can('read') ) {
ob_end_flush();
}
}
}
add_action( 'admin_head', 'subject_start_my_sites' );
add_action( 'admin_footer', 'subject_end_my_sites' );
Is this a good way to remove stuff? Or will it reduce performance? I want to know before I continue using this!
本文标签: Good way to remove unnecessary stuff from dashboard
版权声明:本文标题:Good way to remove unnecessary stuff from dashboard? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749226934a2335716.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论