<?php
/*
Plugin Name: MU-Plugin
Description: Must Use custom functions plugin
Author: frizzel
*/
/* $user_id = get_current_user_id();
if($user_id !== 1){
// the code for all users except with ID 1
*/
function restrict_access(){
$user = wp_get_current_user();
$allowed_roles = array( 'editor', 'administrator', 'author' );
if ( array_intersect( $allowed_roles, $user->roles ) ) {
// the code for allowed users here
}
function remove_hoteller_from_admin_bar( $wp_admin_bar ) {
$wp_admin_bar->remove_menu( 'hoteller_admin' );
}
add_action( 'admin_bar_menu', 'remove_hoteller_from_admin_bar', 2200 );
show_admin_bar(false);
function customize_my_wp_admin_bar( $wp_admin_bar ) {
$node = $wp_admin_bar->get_node('site-name');
$node->meta['target'] = '_blank';
$node->title = 'Home Page';
$wp_admin_bar->add_node($node);
$wp_admin_bar->remove_node('updates');
$wp_admin_bar->remove_node('comments');
$wp_admin_bar->remove_node('new-content');
$wp_admin_bar->remove_node('wp-logo');
$wp_admin_bar->remove_node('view-site');
}
add_action( 'admin_bar_menu', 'customize_my_wp_admin_bar', 999 );
function wporg_remove_all_dashboard_metaboxes() {
remove_action('welcome_panel','wp_welcome_panel');
remove_meta_box('dashboard_primary','dashboard','side');
remove_meta_box('dashboard_quick_press','dashboard','side');
remove_meta_box('dashboard_site_health','dashboard','normal');
remove_meta_box('dashboard_right_now','dashboard','normal');
remove_meta_box('dashboard_activity','dashboard','normal');
remove_meta_box('e-dashboard-overview','dashboard','normal'); // WooCommerce
remove_meta_box('wpdm_dashboard_widget','dashboard','normal');
}
add_action( 'wp_dashboard_setup', 'wporg_remove_all_dashboard_metaboxes' );
function remove_screen_options(){
return current_user_can( 'manage_options' );
}
add_filter('screen_options_show_screen', 'remove_screen_options');
function oz_remove_help_tabs( $old_help, $screen_id, $screen ){
$screen->remove_help_tabs();
return $old_help;
}
add_filter( 'contextual_help', 'oz_remove_help_tabs', 999, 3 );
add_action("admin_head" , function(){
echo "<style>#dashboard-widgets-wrap .empty-container{display:none}</style>";
});
// Customizing the default WordPress logo on the Admin Header
function add_my_own_logo( $wp_admin_bar ) {
$args = array(
'id' => 'my-logo',
'meta' => array( 'class' => 'my-logo', 'title' => 'logo' )
);
$wp_admin_bar->add_node( $args );
}
add_action( 'admin_bar_menu', 'add_my_own_logo', 1 );
// Customizing the Default footer of Admin Dashboard
function remove_footer_admin () {
return 'Welcome to SD Hotel Booking System';
}
add_filter('admin_footer_text', 'remove_footer_admin', 99);
function remove_footer_update () {
return 'Version 1.0';
}
add_filter('update_footer', 'remove_footer_update', 99);
// CSS for styling and path of my own logo instead of default WordPress Logo on the Admin Header
/*#wp-admin-bar-my-logo div{
background-image: url( /path/to/your/logo.png );
background-repeat: no-repeat;
background-size: 20px;
background-position: center;
margin-left:10px!important;
} */
}
add_action('init','restrict_access');