สอนสร้าง Plugin WordPress (6) : ตัวอย่างการใช้งาน add_action ( Actions Hooks ) Add a Dashboard Widget

แชร์ ความรู้สำหรับพัฒนา plugin ของ Wordpress

Moderator: mindphp, ผู้ดูแลกระดาน

ภาพประจำตัวสมาชิก
thatsawan
PHP VIP Members
PHP VIP Members
โพสต์: 28508
ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
ติดต่อ:

สอนสร้าง Plugin WordPress (6) : ตัวอย่างการใช้งาน add_action ( Actions Hooks ) Add a Dashboard Widget

โพสต์ที่ยังไม่ได้อ่าน โดย thatsawan »

Dashboard Widget คือ ส่วนที่แสดงหน้าเเรกของ Admin ที่จะรวมสิ่งสำคัญต่างๆ ของ WordPress ไว้ หรือ Menu เพื่อเป็นช่องทางลัดเพื่อเข้าใช้งานได้อีกด้วย

รูปภาพ

เราสามารถเขียน Plugin คำสั่งเพื่อ Add ข้อมูลต่างๆ เข้าในหน้านี้ได้โดยใช้งาน API Dashboard Widget

ตัวอย่างการใช้งาน

โค้ด: เลือกทั้งหมด

wp_add_dashboard_widget( string $widget_id, string $widget_name, callable $callback, callable $control_callback = null, array $callback_args = null ) 

โค้ด: เลือกทั้งหมด

/**
 * Add a new dashboard widget.
 */
function wpdocs_add_dashboard_widgets() {
    wp_add_dashboard_widget( 'dashboard_widget', 'Example Dashboard Widget', 'dashboard_widget_function' );
}

add_action( 'wp_dashboard_setup', 'wpdocs_add_dashboard_widgets' );
 
/**
 * Output the contents of the dashboard widget
 */
function dashboard_widget_function( $post, $callback_args ) {
    esc_html_e( "Hello World, this is my first Dashboard Widget!", "textdomain" );
}


ผลที่ได้
รูปภาพ

ศึกษาเพิ่มเติมที่
https://developer.wordpress.org/referen ... rd_widget/
ภาพประจำตัวสมาชิก
mindphp
ผู้ดูแลระบบ MindPHP
ผู้ดูแลระบบ MindPHP
โพสต์: 41131
ลงทะเบียนเมื่อ: 22/09/2008 6:18 pm
ติดต่อ:

Re: สอนสร้าง Plugin WordPress (6) : ตัวอย่างการใช้งาน add_action ( Actions Hooks ) Add a Dashboard Widget

โพสต์ที่ยังไม่ได้อ่าน โดย mindphp »

รวมกระทู้ บทความสอนสร้าง Plugin WordPress
https://www.mindphp.com/forums/viewtopic ... 25&t=36079
ติดตาม VDO: http://www.youtube.com/c/MindphpVideoman
ติดตาม FB: https://www.facebook.com/pages/MindphpC ... 9517401606
หมวดแชร์ความรู้: https://www.mindphp.com/forums/viewforum.php?f=29
รับอบรม และพัฒนาระบบ: https://www.mindphp.com/forums/viewtopic.php?f=6&t=2042
ตอบกลับโพส
  • Similar Topics
    ตอบกลับ
    แสดง
    โพสต์ล่าสุด

ผู้ใช้งานขณะนี้

สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 25