First, we have to register the dashboard widget by using the wp_dashboard_setup action, instead of the widgets_init we used on the frontend widgets. Consider the following code for the widget registration process:
add_action( 'wp_dashboard_setup', array( $this, 'dashboard_widgets' ) );public function dashboard_widgets() { wp_add_dashboard_widget( 'wqkm_post_attachments', __('Post Attachments','wqkm'), array( $this, 'post_attachments_widget' ) );}
Inside the callback function, we use the wp_add_dashboard_widget function to register a new widget. The parameters for this function contain a unique widget ID, widget title, and the callback function. Then, we have to implement the function to display the ...