In the article on customizing the WordPress login page, we succeeded in changing the logo and changing the overall color of that page. Continuing from this article, we will proceed to customize the components inside the admin page, and first we will change the text under the footer of the admin page and add a website logo in it for the look. more branding.
[alert color=”orange” type=”alert-message-background” title=”Note” size=”small”]In this article, you will write code into the plugin that we created in lesson 2 of this series.[/alert]
Add logo to admin page
Still familiar, we first create a function to do this and hook into the action hook name admin_notices.
/**
* Thêm logo vào trang quản trị WordPress
*/
function tp_admin_logo() {}
add_action( ‘admin_notices’, ‘tp_admin_logo’ );
In this hook, if we print something out, it will show to the top of the admin page, so if we print a logo image we will have the logo, simple right?
/**
* Thêm logo vào trang quản trị WordPress
*/
function tp_admin_logo() {
echo ‘<br/> <img src="https://TechtipsNReview.com/wordpress/wordpress-tutorials/’ .plugins_url(‘images/logo.png’, __FILE__). ‘"/>’;
}
add_action( ‘admin_notices’, ‘tp_admin_logo’ );
As a result we have:
And based on this, we can insert anything else on top of that area.
Change the text under the footer of the admin page
Reference first: Filter Hook Guide
Unlike the logo, by default WordPress has a text in the footer of the admin page that you can see when scrolling to the bottom of the page. Now we can easily change it back using the filter hook and hook into the hook admin_footer_text . I repeat, why use filter hooks and not action? Since it already has the content available, now we need to “filter” it through to insert the content we want to display instead of the default filter hook.
/**
* Sửa chữ dưới footer của trang quản trị
*/
function tp_admin_footer_credits( $text ) {
$text = ‘<p>Chào mừng bạn đến với website TechtipsNReview.com</p>’;
return $text;
}
add_filter( ‘admin_footer_text’, ‘tp_admin_footer_credits’ );
When filtering we should assign the function an arbitrary name parameter, then set the content to that parameter and use return to display the content, that’s the most common way to use filter.
As a result we have:
That’s it, in this article we just do that to reduce fatigue. In the following articles, I will have more instructions for you to customize the WordPress admin page even more.
Source: Add logo and edit footer in WordPress admin page
– TechtipsnReview