Monday 13 November 2017

How to make your own WordPress dashboard widget


Do you build a plugin and want to easily display some general information? Or perhaps you are building a theme and want your customers to keep up with your blog? If you don’t want to build a dedicated settings page, then a simple (or complex, your call) widget on the WordPress dashboard should be enough. It’s very easy and very fast, too! We’ll be creating a plugin that holds our code for this tutorial. While there is no specific goal, we’ll show how to handle some common use-cases.
Creating a dashboard widget
The code needed to register a dashboard widget is pretty much boilerplate:
<?php
/*
Plugin Name: Dashboard Widget
Plugin URI:
Description: Dashboard widget tutorial code
Version: 1.0
Author: CSSIgniter
Author URI: https://www.cssigniter.com
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/

add_action( ‘wp_dashboard_setup’, ‘ci_dashboard_add_widgets’ );
function ci_dashboard_add_widgets() {
wp_add_dashboard_widget( ‘dw_dashboard_widget_news’, __( ‘CSSIgniter News’, ‘dw’ ), ‘dw_dashboard_widget_news_handler’ );
}

function dw_dashboard_widget_news_handler() {
_e( ‘This is some text.’, ‘dw’ );
}
Ignoring lines 1-11 that
Source: https://managewp.org/articles/16592/how-to-make-your-own-wordpress-dashboard-widget




source https://williechiu40.wordpress.com/2017/11/13/how-to-make-your-own-wordpress-dashboard-widget/

No comments:

Post a Comment