Sure, here is a sample code for creating a dashboard widget plugin that will display the number of online users:
Step 1: Create a new folder in the “wp-content/plugins” directory and name it as “online-users-widget”
Step 2: In this folder, create a PHP file and name it as “online-users-widget.php”
Step 3: Add the below code in the “online-users-widget.php” file:
__( ‘Displays the number of online users on the dashboard’, ‘text_domain’ ), ) // Widget description
);
}
// Creating widget front-end
public function widget( $args, $instance ) {
$title = apply_filters( ‘widget_title’, $instance[‘title’] );
// Widget content
echo $args[‘before_widget’];
if ( ! empty( $title ) )
echo $args