diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index 7ed08b8119..b36ef18dce 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -15,7 +15,7 @@ * * @global array $wp_registered_widgets * @global array $wp_registered_widget_controls - * @global array $wp_dashboard_control_callbacks + * @global callable[] $wp_dashboard_control_callbacks */ function wp_dashboard_setup() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; @@ -157,8 +157,9 @@ function wp_dashboard_setup() { * Adds a new dashboard widget. * * @since 2.7.0 + * @since 5.6.0 The `$context` and `$priority` parameters were added. * - * @global array $wp_dashboard_control_callbacks + * @global callable[] $wp_dashboard_control_callbacks * * @param string $widget_id Widget ID (used in the 'id' attribute for the widget). * @param string $widget_name Title of the widget. @@ -167,8 +168,12 @@ function wp_dashboard_setup() { * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null. * @param array $callback_args Optional. Data that should be set as the $args property of the widget array * (which is the second parameter passed to your callback). Default null. + * @param string $context Optional. The context within the screen where the box should display. + * Accepts 'normal', 'side', 'column3', or 'column4'. Default 'normal'. + * @param string $priority Optional. The priority within the context where the box should show. + * Accepts 'high', 'core', 'default', or 'low'. Default 'core'. */ -function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) { +function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $context = 'normal', $priority = 'core' ) { $screen = get_current_screen(); global $wp_dashboard_control_callbacks; @@ -194,19 +199,24 @@ function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); - $location = 'normal'; if ( in_array( $widget_id, $side_widgets, true ) ) { - $location = 'side'; + $context = 'side'; } $high_priority_widgets = array( 'dashboard_browser_nag', 'dashboard_php_nag' ); - $priority = 'core'; if ( in_array( $widget_id, $high_priority_widgets, true ) ) { $priority = 'high'; } - add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args ); + if ( empty( $context ) ) { + $context = 'normal'; + } + if ( empty( $priority ) ) { + $priority = 'core'; + } + + add_meta_box( $widget_id, $widget_name, $callback, $screen, $context, $priority, $callback_args ); } /** @@ -1139,7 +1149,7 @@ function wp_dashboard_cached_rss_widget( $widget_id, $callback, $check_urls = ar * * @since 2.5.0 * - * @global array $wp_dashboard_control_callbacks + * @global callable[] $wp_dashboard_control_callbacks * * @param int $widget_control_id Registered Widget ID. */ diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index d27a7d6f79..aa27e6a527 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1014,14 +1014,14 @@ function wp_import_upload_form( $action ) { * add_submenu_page() to create a new screen (and hence screen_id), * make sure your menu slug conforms to the limits of sanitize_key() * otherwise the 'screen' menu may not correctly render on your page. - * @param string $context Optional. The context within the screen where the boxes + * @param string $context Optional. The context within the screen where the box * should display. Available contexts vary from screen to * screen. Post edit screen contexts include 'normal', 'side', * and 'advanced'. Comments screen contexts include 'normal' * and 'side'. Menus meta boxes (accordion sections) all use * the 'side' context. Global default is 'advanced'. - * @param string $priority Optional. The priority within the context where the boxes - * should show ('high', 'low'). Default 'default'. + * @param string $priority Optional. The priority within the context where the box should show. + * Accepts 'high', 'core', 'default', or 'low'. Default 'default'. * @param array $callback_args Optional. Data that should be set as the $args property * of the box array (which is the second parameter passed * to your callback). Default null. diff --git a/wp-includes/version.php b/wp-includes/version.php index 1bc667e8db..64ba566500 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.6-alpha-49122'; +$wp_version = '5.6-alpha-49123'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.