Last active
April 17, 2019 00:44
-
-
Save simongcc/8573461 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Custom admin dashboard | |
remove unnecessary admin dashboard panel | |
remove welcome panel | |
remove help tab | |
remove screen optons tab | |
remove color scheme picker | |
redirect after login | |
add custom widgets | |
with capabilities check example | |
Version Tested: 3.6,3.8 | |
Reference: | |
http://codex.wordpress.org/Roles_and_Capabilities#manage_options | |
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_dashboard_setup | |
*/ | |
// Remove WordPress Welcome Panel | |
remove_action('welcome_panel', 'wp_welcome_panel'); | |
if ( !current_user_can('manage_options') ) { | |
//custom dashboard widgets | |
/** | |
* Add a widget to the dashboard to substitute the blank page after removing all widgets. | |
* | |
* This function is hooked into the 'wp_dashboard_setup' action below. | |
* | |
* Reference: http://codex.wordpress.org/Dashboard_Widgets_API | |
*/ | |
// Remove widgets | |
function wo_shop_user_dashboard_widgets() { | |
global $wp_meta_boxes; | |
// print_r( $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_activity']); | |
// unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']); | |
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']); | |
// unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_recent_drafts']); | |
// unset($wp_meta_boxes['dashboard']['normal']); | |
wp_add_dashboard_widget( | |
'wo_shop_intro_dashboard_widget', // Widget slug. | |
// 'Welcome to shop and profile administration', // Title. | |
'render_wo_shop_intro_widgets' // Display function. | |
); | |
} | |
add_action('wp_dashboard_setup', 'wo_shop_user_dashboard_widgets' ); | |
/** | |
* Create the function to output the contents of our Dashboard Widget. | |
*/ | |
function render_wo_shop_intro_widgets() { | |
// Display whatever it is you want to show. | |
} | |
/* | |
remove unnecessary option for normal user | |
*/ | |
// Hide 'Screen Options' tab | |
function remove_screen_options_tab() { | |
return false; | |
} | |
add_filter('screen_options_show_screen', 'remove_screen_options_tab'); | |
//profile | |
remove_action( 'admin_color_scheme_picker', 'admin_color_scheme_picker' ); | |
//redirect to default landing page after login | |
function admin_default_page() { | |
$landing_page = '/wp-admin/profile.php'; | |
return $landing_page; | |
} | |
add_filter('login_redirect', 'admin_default_page'); | |
function wo_shop_remove_help($old_help, $screen_id, $screen){ | |
$screen->remove_help_tabs(); | |
return $old_help; | |
} | |
add_filter( 'contextual_help', 'wo_shop_remove_help', 999, 3 ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment