mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Administration: Allow context and priority to be specified when adding dashboard widgets.
Props davidjlaietta, soulseekah, johnbillion Fixes #42791 git-svn-id: https://develop.svn.wordpress.org/trunk@49123 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -201,4 +201,41 @@ class Tests_Admin_includesTemplate extends WP_UnitTestCase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @ticket 42791
|
||||
*/
|
||||
public function test_wp_add_dashboard_widget() {
|
||||
global $wp_meta_boxes;
|
||||
|
||||
set_current_screen( 'dashboard' );
|
||||
|
||||
if ( ! function_exists( 'wp_add_dashboard_widget' ) ) {
|
||||
require_once ABSPATH . 'wp-admin/includes/dashboard.php';
|
||||
}
|
||||
|
||||
// Some hardcoded defaults for core widgets
|
||||
wp_add_dashboard_widget( 'dashboard_quick_press', 'Quick', '__return_false' );
|
||||
wp_add_dashboard_widget( 'dashboard_browser_nag', 'Nag', '__return_false' );
|
||||
|
||||
$this->assertArrayHasKey( 'dashboard_quick_press', $wp_meta_boxes['dashboard']['side']['core'] );
|
||||
$this->assertArrayHasKey( 'dashboard_browser_nag', $wp_meta_boxes['dashboard']['normal']['high'] );
|
||||
|
||||
// Location and priority defaults
|
||||
wp_add_dashboard_widget( 'dashboard1', 'Widget 1', '__return_false', null, null, 'foo' );
|
||||
wp_add_dashboard_widget( 'dashboard2', 'Widget 2', '__return_false', null, null, null, 'bar' );
|
||||
|
||||
$this->assertArrayHasKey( 'dashboard1', $wp_meta_boxes['dashboard']['foo']['core'] );
|
||||
$this->assertArrayHasKey( 'dashboard2', $wp_meta_boxes['dashboard']['normal']['bar'] );
|
||||
|
||||
// Cleanup
|
||||
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
|
||||
remove_meta_box( 'dashboard_browser_nag', 'dashboard', 'normal' );
|
||||
remove_meta_box( 'dashboard1', 'dashboard', 'foo' );
|
||||
|
||||
// This doesn't actually get removed due to the invalid priority
|
||||
remove_meta_box( 'dashboard2', 'dashboard', 'normal' );
|
||||
|
||||
set_current_screen( 'front' );
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user