Skip links

7 Functions to Modify WordPress Admin Panel

Share

WordPress admin panel is the powerful area where capable users control the content or settings of a WordPress website. As a WordPress website owner or developer, you might wish to modify WordPress admin panel in some way.

So here we’re presenting you 7 handy functions to modify few things in WordPress admin panel and the dashboard. You need to copy these functions in your theme’s functions.php file or site-specific WordPress plugin. Also, don’t forget to change content wherever applicable.

1. Add a Custom Dashboard Logo

Want to replace WordPress logo in the top left corner with your own? Use the following code in your theme’s functions.php or specific plugin. First, upload a 16x16px png logo in the images folder of your theme with name “dashboard-logo.png”. Alternatively, specify the complete logo URL to the background-image property in the function.

function tr_dashboard_logo() {
	echo '<style type="text/css"> #wpadminbar #wp-admin-bar-wp-logo > .ab-item .ab-icon:before{color:rgba(0, 0, 0, 0); background-position: 0 0; background-image: url('.get_bloginfo('stylesheet_directory').'/images/dashboard-logo.png) !important;} #wpadminbar #wp-admin-bar-wp-logo.hover > .ab-item .ab-icon{background-position: 0 0;}</style>';
}
add_action('wp_before_admin_bar_render', 'tr_dashboard_logo');

2. Change the Footer in WordPress Admin Panel

Use this function to replace the text “Thank you for creating with WordPress.”  in the footer.  Place your own text in the echo construct as shown.

function change_footer_admin () { 
	echo 'Dashboard | By <a href="http://www.wordpress.org" target="_blank">WordPress</a>'; 
} 
add_filter('admin_footer_text', 'change_footer_admin');

 3. Add a Dashboard Widget

The code below allows you to add custom widgets in WordPress dashboard. We have used two functions and a WordPress hook here. The first function specifies the content of the widget and second one creates the widget. You can create as many as dashboard widgets using wp_add_dashboard_widget() function.

function tr_custom_dashboard() {
	echo '<p>Welcome to Awesome Blog! Your mentor Mr. John is just a message away. Email him at <a href="mailto:john@yourwebsite.com">john@yourwebsite.com</a>.</p>';
}

function my_dashboard_widgets() {
	global $wp_meta_boxes;
 	wp_add_dashboard_widget('custom_help_widget', 'Admin Contact', 'tr_custom_dashboard');
}
add_action('wp_dashboard_setup', 'my_dashboard_widgets');

4. Remove the Welcome Panel

WordPress admin panel hide dashboard

WordPress dashboard shows the welcome panel as shown in the image above. It is a meta box present at the dashboard of WordPress admin panel. This area consists useful shortcuts for beginners to start. However, you can easily hide this meta box by placing the one line code in the functions.php or specific plugin.

remove_action('welcome_panel', 'wp_welcome_panel');

5. Support Additional File Types Upload

WordPress allows you to only upload the most commonly used file types for security purpose. General image files, PDF, audio/ video, Microsoft Office and OpenOffice documents are such common file types. Check the full list of allowed file types and extensions at WordPress official document.

We are adding SVG and PSD file types uploads to WordPress using the code below. You require providing right mime type. Also, a list of common mime types is available at this page.

function mine_mime_types($mimes){
    $mimes['svg'] = 'image/svg+xml'; //Add SVG extension
	$mimes['psd'] = 'image/vnd.adobe.photoshop'; //Add photoshop files
    return $mimes;
}
add_filter('upload_mimes', 'mine_mime_types', 1, 1);

6. Enable Shortcode Execution in Text Widgets

By default, shortcodes do not work in sidebar text widgets. However, you can easily use shortcodes in WordPress sidebar widgets. Place this WordPress filter in functions.php or plugin file to enable shortcodes in text widgets.

add_filter('widget_text','do_shortcode');

7. Change the Default Gravatar in WordPress

Wondering how do some websites show branded custom gravatar in comment forms? No more mystery. First, upload the image you want to use as default avatar and copy its URL. Then add this code to functions.php. Also, change the URL given with the copied URL.

function tr_site_gravatar ($avatars) {
	$siteavtar = 'http://yourwebsite.com/wp-content/uploads/2018/03/site-default-gravatar.png';
	$avatars[$siteavatar] = 'Site Gravatar';
	return $avatars;
}
add_filter( 'avatar_defaults', 'tr_site_gravatar' );

Finally, go to Settings » Discussion page and select your default avatar. The branded avatar will be there in the list.

Hope this article introduced you some useful code to modify things in the WordPress admin panel. You may also want to enrich WordPress Post Editor or visit ultimate guide to boost WordPress speed and performance.

If you find this article useful then subscribe to our YouTube channel as well as Facebook and Twitter pages. Your questions and comments are most welcome as well.

Join the Discussion

Return to top of page