[Module] Admin Area

1.1 Dashboard Widgets


add_action( 'wp_dashboard_setup', 'wpex_remove_dashboard' );
function wpex_remove_dashboard () {
	global $wp_meta_boxes;
	$wp_meta_boxes['dashboard']['side']['core'] = array();
	$wp_meta_boxes['dashboard']['normal']['core'] = array();
	if(class_exists('WooCommerce')) {
		$wp_meta_boxes['dashboard']['normal']['core']['woocommerce_dashboard_status'] = array();
		$wp_meta_boxes['dashboard']['normal']['core']['woocommerce_dashboard_recent_reviews'] = array();
	}
}

1.2 Dashboard Welcome

remove_action( 'welcome_panel', 'wp_welcome_panel' );

Custom Text

add_action( 'welcome_panel', 'wpex_custom_welcome_panel' );
function wpex_custom_welcome_panel() {
	echo 'Nội dung';
}

2.1 Auto Hide Admin Bar

add_action( 'wp_head', 'wpex_admin_bar_css_front' );
function wpex_admin_bar_css_front () {
	?><style type="text/css">
	@media(min-width:768px) {
		body.admin-bar {
			margin-top: -32px !important;
		}
		html #wpadminbar {
			opacity: 0.5;
			width: 36px;
			min-width: auto;
			overflow: hidden;
			-webkit-transition-delay: 250ms;
			transition-delay: 250ms;
			-webkit-transition: all .3s ease;
			transition: all .3s ease
		}

		html #wpadminbar:hover {
			opacity: 1;
			width: 100%;
			overflow: visible;
		}
		html #wpadminbar #wp-admin-bar-site-name > .ab-item:before {
			content: "\f349";
			padding-right: 5px;
		}
	}
	</style>
	<?php
}

2.2 Remove Menu Items

function remove_from_admin_bar($wp_admin_bar) {
    /*
     * Placing items in here will only remove them from admin bar
     * when viewing the fronte end of the site
    */
    if ( ! is_admin() ) {
        // Example of removing item generated by plugin. Full ID is #wp-admin-bar-si_menu
        $wp_admin_bar->remove_node('si_menu');
 
        // WordPress Core Items (uncomment to remove)
        $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('site-name');
        //$wp_admin_bar->remove_node('my-account');
        //$wp_admin_bar->remove_node('search');
        //$wp_admin_bar->remove_node('customize');
    }
 
    /*
     * Items placed outside the if statement will remove it from both the frontend
     * and backend of the site
    */
    $wp_admin_bar->remove_node('wp-logo');
}
add_action('admin_bar_menu', 'remove_from_admin_bar', 999);