I'm wondering how I can make a plugin to output some data via the admin panel. Just to get me going what code would make a page in the admin panel (for only administrators) to display time()?
It's actually very easy, you only need two things:
admin_footer
action will cause your plugin's output to be displayed in the footer of the admin page. There's a wide range of actions for all kinds of situations and conditions.The PHP date()
function will give you the current time, so you just need to write a function in your plugin that does echo date()
, and then use add_action
to get your PHP function executed in response to the appropriate Wordpress action.
So to make it completely clear, your plugin code would look like this (not tested!):
/*
Plugin Name: Admin Date Displayer
Plugin URI: http://example.com/
Description: Displays the current datetime on the admin page
Author: Stewart
Version: 1.0
Author URI: http://bolidian.com/
*/
function display_date()
{
echo date();
}
add_action('admin_footer', 'display_date');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With