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

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: สอนสร้าง Plugin WordPress (6) : ตัวอย่างการใช้งาน add_action ( Actions Hooks ) Add a Dashboard Widget

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

โดย mindphp » 25/10/2016 9:54 pm

รวมกระทู้ บทความสอนสร้าง Plugin WordPress
https://www.mindphp.com/forums/viewtopic ... 25&t=36079

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

โดย thatsawan » 25/10/2016 12:01 pm

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/

ข้างบน