我正在尝试向后端用户(而非管理员)WordPress仪表板隐藏详细信息,例如Recently Published
From our Blog
WordPress Events and News
Admin Colour Scheme
Help
{{1} } Activity
我一直无法找到其中的html(php / javascript?),但是为配色方案选择器找到了一些html,如下所示:
Screen Options
尝试过CSS:
<h2>Personal Options</h2>
<table class="form-table">
<tr class="user-admin-color-wrap">
<th scope="row">Admin Color Scheme</th>
<td>
<fieldset id="color-picker" class="scheme-list">
<legend class="screen-reader-text"><span>Admin Color Scheme</span>.
</legend>
<input type="hidden" id="color-nonce" name="color-nonce"
value="98ec68455d" /><div class="color-option selected">
<input name="admin_color" id="admin_color_fresh" type="radio"
value="fresh" class="tog" checked='checked' />
<input type="hidden" class="css_url" value="" />
<input type="hidden" class="icon_colors" value="{"icons":
{"base":"#a0a5aa",
"focus":"#00a0d2","
current":"#fff"}}" />
<label for="admin_color_fresh">Default</label>
<table class="color-palette">
<tr>
<td style="background-color: #222"> </td>
<td style="background-color: #333"> </td>
<td style="background-color: #0073aa"> </td>
<td style="background-color: #00a0d2"> </td>
</tr>
</table>
</div>
<div class="color-option ">
<input name="admin_color" id="admin_color_light" type="radio"
value="light" class="tog" />
<input type="hidden" class="css_url" value="https://adsler.co.uk/wp-
admin/css/colors/light/colors.min.css" />
<input type="hidden" class="icon_colors" value="{"icons":
{"base":"#999","focus"
:"#ccc","current":"#ccc"}}" />
<label for="admin_color_light">Light</label>
<table class="color-palette">
<tr>
<td style="background-color: #e5e5e5"> </td>
也尝试过:
#tab-panel-overview {visibility: hidden;}
.help-tab-content active {visibility: hidden;}
.form-table {visibility:hidden; display:none;}
.user-admin-color-wrap {visibility: hidden; display: none;}
一无所有。
答案 0 :(得分:0)
您的意思是管理仪表板小部件? 您可以通过以下wordpress操作隐藏它们。
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_quick_press']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_drafts']);
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
答案 1 :(得分:0)
请通过插件添加此代码,或将代码添加到您的functions.php中。 经过测试,可以正常工作。请参见所附的屏幕截图
function stackinnerflow_remove_dashboard_widgets() {
global $wp_meta_boxes;
// Remove At a glance
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
// Remove Activity
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_activity']);
// Remove News and Events
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
}
add_action('wp_dashboard_setup', 'stackinnerflow_remove_dashboard_widgets' );
// removes the `profile.php` admin color scheme options
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' );
// Remove thanks WP
add_action('admin_head', 'stackinnerflow_footer_remove');
function stackinnerflow_footer_remove() {
echo '<style>
#footer-thankyou,
#footer-upgrade {
display:none;
}
</style>';
}
// remove the Help Tab use
add_action('admin_head', 'stackinnerflow_remove_help_tabs');
function stackinnerflow_remove_help_tabs() {
$screen = get_current_screen();
$screen->remove_help_tabs();
}
//remove the Screen Options Tab
add_filter('screen_options_show_screen', '__return_false');
如果将所有用户代码打包为低于管理员功能级别的用户,则任何级别的编辑者或更低权限的用户都不会看到这些内容。
if (current_user_can('editor')) {}
如果您要遍历许多其他功能,请检查以下问题:https://wordpress.stackexchange.com/questions/131814/if-the-current-user-is-an-administrator-or-editor