Ich suche ein vollständiges leeres Dashboard. Keine Widgets und vorzugsweise eine Spalte.
Es gibt Schnipsel zum Entfernen der Standard-WordPress-Widgets, aber keine Informationen zu den von Plugins hinzugefügten. Überall gesucht und scheint, dass dies nicht gefragt wurde.
Aus dieser Frage und Antwort habe ich etwas über die globale Variable$wp_meta_boxes
gelernt. Und da drüben ist auch der Code zu entferne die Standard-Meta-Boxen.
Nachdem ich die Variable untersucht habe, ist dies der Code, den ich geschrieben habe, um alle Dashboard-Widgets zu entfernen, einschließlich der von Plugins hinzugefügten :
add_action('wp_dashboard_setup', 'wpse_73561_remove_all_dashboard_meta_boxes', 9999 );
function wpse_73561_remove_all_dashboard_meta_boxes()
{
global $wp_meta_boxes;
$wp_meta_boxes['dashboard']['normal']['core'] = array();
$wp_meta_boxes['dashboard']['side']['core'] = array();
}
Die Antwort auf eine Spalte erzwingen als Bildschirmoption lautet von hier :
add_filter( 'get_user_option_screen_layout_dashboard', 'wpse_4552_one_column_layout' );
function wpse_4552_one_column_layout( $cols ) {
if( current_user_can( 'basic_contributor' ) )
return 1;
return $cols;
}
Dieser hat den Code zum Ausblenden der Registerkarten Bildschirmoptionen und Hilfe bereitgestellt:
add_filter( 'contextual_help', 'wpse_25034_remove_dashboard_help_tab', 999, 3 );
add_filter( 'screen_options_show_screen', 'wpse_25034_remove_help_tab' );
function wpse_25034_remove_dashboard_help_tab( $old_help, $screen_id, $screen )
{
if( 'dashboard' != $screen->base )
return $old_help;
$screen->remove_help_tabs();
return $old_help;
}
function wpse_25034_remove_help_tab( $visible )
{
global $current_screen;
if( 'dashboard' == $current_screen->base )
return false;
return $visible;
}
Ok, jetzt ist fast nichts im Dashboard, was kommt als nächstes?
Ein bisschen CSS zu hide the icon-index
and H2 title
, und etwas jQuery zu fill the void :
add_action( 'admin_head-index.php', 'wpse_73561_dashboard_scripts' );
function wpse_73561_dashboard_scripts() {
?>
<style>#icon-index, .wrap h2 {display:none}</style>
<script language="javascript" type="text/javascript">
jQuery(document).ready(function($) {
fillTheVoid(); // soon in StackOverflow
});
</script>
<?php
}
[Update]
Die gefüllte Lücke befindet sich in StackOverflow .
Verwenden Sie anstelle dieser Funktion die Funktion wpse_73561_dashboard_scripts
.
Das wird gut funktionieren
add_action('wp_dashboard_setup', 'remove_dashboard_widgets' );
function remove_dashboard_widgets() {
global $wp_meta_boxes;
unset($wp_meta_boxes['dashboard']);
}