All-in-One Collection of WordPress Functions I Use Daily

This all-in-one WordPress function collection is designed to streamline and declutter the admin interface, enhance privacy, and optimize performance. It hides unnecessary dashboard elements like help tabs, admin bar items, and dashboard widgets, while also removing version numbers and disabling update notifications. It improves the user profile experience by hiding Yoast SEO fields and personal options, limits admin menu access for contributors, and customizes the admin footer and greeting. Additionally, it cleans up the front end by removing Gutenberg block CSS and tweaking the comment form layout. Ideal for minimalist and secure WordPress setups.

Essential WordPress Functions I Use Daily

// Hide Help tab
function hide_help() {
echo '<style type="text/css">
#contextual-help-link-wrap { display: none !important; }
</style>';
}
add_action('admin_head', 'hide_help');
function remove_admin_bar_links() {
global $wp_admin_bar;
$wp_admin_bar->remove_menu('wp-logo'); // Remove the WordPress logo
$wp_admin_bar->remove_menu('about'); // Remove the about WordPress link
$wp_admin_bar->remove_menu('wporg'); // Remove the WordPress.org link
$wp_admin_bar->remove_menu('documentation'); // Remove the WordPress documentation link
$wp_admin_bar->remove_menu('support-forums'); // Remove the support forums link
$wp_admin_bar->remove_menu('feedback'); // Remove the feedback link
$wp_admin_bar->remove_menu('updates'); // Remove the updates link
$wp_admin_bar->remove_menu('comments'); // Remove the comments link
$wp_admin_bar->remove_menu('new-content'); // Remove the content link
$wp_admin_bar->remove_menu('w3tc'); // If you use w3 total cache remove the performance link
}
add_action( 'wp_before_admin_bar_render', 'remove_admin_bar_links' );
add_filter('show_admin_bar', '__return_false');
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' );
remove_action('welcome_panel', 'wp_welcome_panel');
/* Remove WordPress Version Number */
function remove_version() {
return '';
}
add_filter('the_generator', 'remove_version');
//*Disable the Application Passwords Feature
add_filter( 'wp_is_application_passwords_available', '__return_false' );
//*Hide yoast seo settings on user profile
add_action('admin_head', 'lubus_hide_yoast_profile');
function lubus_hide_yoast_profile() {
echo '<style>
.yoast-settings {
display: none;
}
</style>';
}
//* Remove Personal Options on user profile
function hide_personal_options(){
echo "\n" . '<script type="text/javascript">jQuery(document).ready(function($) { $(\'form#your-profile > h3:first\').hide(); $(\'form#your-profile > table:first\').hide(); $(\'form#your-profile\').show(); });</script>' . "\n";
}
add_action('admin_head','hide_personal_options');
//*Remove additional capabilities on user profile
add_filter('additional_capabilities_display', 'remove_additional_capabilities_func');

function remove_additional_capabilities_func()
{
return false;
}
//* Remove generator from head
remove_action('wp_head', 'wp_generator');
//* Remove WordPress version from RSS feed
function remove_feed_generator() {
return '';
}
add_filter('the_generator', 'remove_feed_generator');
//* Exclude Pages from WordPress Search Results
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'post');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
//* Hide admin footer from admin
function change_footer_admin () {
return ' ';
}
add_filter('admin_footer_text', 'change_footer_admin', 9999);
function change_footer_version() {
return ' ';
}
add_filter( 'update_footer', 'change_footer_version', 9999);
function remove_the_dashboard () {
if (current_user_can('level_10')) {
return;}else {
global $menu, $submenu, $user_ID;
$the_user = new WP_User($user_ID);
reset($menu); $page = key($menu);
while ((__('Dashboard') != $menu[$page][0]) && next($menu))
$page = key($menu);
if (__('Dashboard') == $menu[$page][0]) unset($menu[$page]);
reset($menu); $page = key($menu);
while (!$the_user->has_cap($menu[$page][1]) && next($menu))
$page = key($menu);
if (preg_match('#wp-admin/?(index.php)?$#',$_SERVER['REQUEST_URI']) && ('index.php' != $menu[$page][2]))
wp_redirect(get_option('siteurl') . '/wp-admin/post-new.php');}}
add_action('admin_menu', 'remove_the_dashboard');
//Hide the "Related Posts" meta box.
function plt_hide_yet_another_related_posts_plugin_metaboxes() {
$screen = get_current_screen();
if ( !$screen ) {
return;
}
remove_meta_box('yarpp_relatedposts', $screen->id, 'normal');
}
add_action('add_meta_boxes', 'plt_hide_yet_another_related_posts_plugin_metaboxes', 20);
// Hide yoast_seo_admin_filters
add_action( 'admin_init', 'bb_remove_yoast_seo_admin_filters', 20 );
function bb_remove_yoast_seo_admin_filters() {
global $wpseo_meta_columns ;
if ( $wpseo_meta_columns ) {
remove_action( 'restrict_manage_posts', array( $wpseo_meta_columns , 'posts_filter_dropdown' ) );
remove_action( 'restrict_manage_posts', array( $wpseo_meta_columns , 'posts_filter_dropdown_readability' ) );
}
}
//* Remove admin menus for contributor
function remove_menus(){
$author = wp_get_current_user();
if(isset($author->roles[0])){
$current_role = $author->roles[0];
}else{
$current_role = 'no_role';
}
if($current_role == 'contributor'){
remove_menu_page( 'index.php' ); //Dashboard
remove_menu_page( 'upload.php' ); //Media
remove_menu_page( 'tools.php' ); //Tools
}
}
add_action( 'admin_menu', 'remove_menus' );
//* Removing social networking links from profile fields
add_filter('user_contactmethods', 'yoast_seo_admin_user_remove_social');
function yoast_seo_admin_user_remove_social ( $contactmethods ) {
//unset( $contactmethods['website'] );//
//unset( $contactmethods['facebook'] );//
unset( $contactmethods['pinterest'] );
unset( $contactmethods['linkedin'] );
//unset( $contactmethods['twitter'] );//
unset( $contactmethods['youtube'] );
unset( $contactmethods['soundcloud'] );
unset( $contactmethods['tumblr'] );
unset( $contactmethods['instagram'] );
unset( $contactmethods['myspace'] );
unset( $contactmethods['wikipedia'] );
return $contactmethods;
}
//*Customize Howdy In WordPress Admin
function replace_howdy( $wp_admin_bar ) {
$my_account=$wp_admin_bar->get_node('my-account');
$newtitle = str_replace( 'Howdy,', 'Logged in as', $my_account->title );
$wp_admin_bar->add_node( array(
'id' => 'my-account',
'title' => $newtitle,
) );
}
add_filter( 'admin_bar_menu', 'replace_howdy',25 );
//Disable All Update Notifications + Thesis Theme Update Notice
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');
//Remove Gutenberg Block Library CSS from loading on the frontend
function smartwp_remove_wp_block_library_css(){
wp_dequeue_style( 'wp-block-library' );
wp_dequeue_style( 'wp-block-library-theme' );
wp_dequeue_style( 'wc-block-style' ); // Remove WooCommerce block CSS
}
add_action( 'wp_enqueue_scripts', 'smartwp_remove_wp_block_library_css', 100 );
//* Post meta custom author page link
function author_page_redirect( $link ) {
$link = '/';
return $link;
}
//Remove Checkbox Save my name email and website in this browser
add_filter( 'comment_form_default_fields', 'wc_comment_form_hide_cookies' );
function wc_comment_form_hide_cookies( $fields ) {
unset( $fields['cookies'] );
return $fields;
}
// Move Comment Textfield after Name and Email field
add_filter( 'comment_form_fields', 'move_comment_field' );
function move_comment_field( $fields ) {
$comment_field = $fields['comment'];
unset( $fields['comment'] );
$fields['comment'] = $comment_field;
return $fields;
}