โดย thatsawan » 25/10/2016 12:01 pm
Remove a Dashboard Widget
คือการลบ กล่องแสดงต่าง ๆ ที่ปรากฏอยู่ในส่วนแสดง Dashboard Widget
เราสามารถเขียน Plugin ลบการแสดงส่วนนั้นๆ ออกได้
ตัวอย่างการใช้งาน
โค้ด: เลือกทั้งหมด
remove_meta_box( string $id, string|array|WP_Screen $screen, string $context )
โค้ด: เลือกทั้งหมด
//Exsample API(wp_dashboard_setup)
add_action('wp_dashboard_setup', 'wpdocs_remove_dashboard_widgets');
/**
* Remove all dashboard widgets
*/
function wpdocs_remove_dashboard_widgets(){
remove_meta_box('dashboard_right_now', 'dashboard', 'normal'); // Right Now
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); // Recent Comments
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); // Incoming Links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); // Plugins
remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); // Quick Press
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side'); // Recent Drafts
remove_meta_box('dashboard_primary', 'dashboard', 'side'); // WordPress blog
remove_meta_box('dashboard_secondary', 'dashboard', 'side'); // Other WordPress News
// use 'dashboard-network' as the second parameter to remove widgets from a network dashboard.
}
Remove a Dashboard Widget
คือการลบ กล่องแสดงต่าง ๆ ที่ปรากฏอยู่ในส่วนแสดง Dashboard Widget
[img]http://snap.mindphp.com/index.php?view=2016Oct24_580dae42cf9df[/img]
เราสามารถเขียน Plugin ลบการแสดงส่วนนั้นๆ ออกได้
[b]ตัวอย่างการใช้งาน[/b]
[code=php]remove_meta_box( string $id, string|array|WP_Screen $screen, string $context ) [/code]
[code=php]//Exsample API(wp_dashboard_setup)
add_action('wp_dashboard_setup', 'wpdocs_remove_dashboard_widgets');
/**
* Remove all dashboard widgets
*/
function wpdocs_remove_dashboard_widgets(){
remove_meta_box('dashboard_right_now', 'dashboard', 'normal'); // Right Now
remove_meta_box('dashboard_recent_comments', 'dashboard', 'normal'); // Recent Comments
remove_meta_box('dashboard_incoming_links', 'dashboard', 'normal'); // Incoming Links
remove_meta_box('dashboard_plugins', 'dashboard', 'normal'); // Plugins
remove_meta_box('dashboard_quick_press', 'dashboard', 'side'); // Quick Press
remove_meta_box('dashboard_recent_drafts', 'dashboard', 'side'); // Recent Drafts
remove_meta_box('dashboard_primary', 'dashboard', 'side'); // WordPress blog
remove_meta_box('dashboard_secondary', 'dashboard', 'side'); // Other WordPress News
// use 'dashboard-network' as the second parameter to remove widgets from a network dashboard.
} [/code]
[img]http://snap.mindphp.com/index.php?view=2016Oct24_580db5b8b9a13[/img]