Make WordPress Core

Ticket #42791: 42791.2.diff

File 42791.2.diff, 2.5 KB (added by davidjlaietta, 7 years ago)
  • wp-admin/includes/dashboard.php

     
    136136 * Adds a new dashboard widget.
    137137 *
    138138 * @since 2.7.0
     139 * @since 4.9.5 added the location and priority arguments
    139140 *
    140141 * @global array $wp_dashboard_control_callbacks
    141142 *
     
    146147 * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null.
    147148 * @param array    $callback_args    Optional. Data that should be set as the $args property of the widget array
    148149 *                                   (which is the second parameter passed to your callback). Default null.
     150 * @param string   $context              Optional. The context within the screen where the boxes
     151 *                                   should display. Available contexts vary from screen to
     152 *                                   screen. Post edit screen contexts include 'normal', 'side',
     153 *                                   and 'advanced'. Comments screen contexts include 'normal'
     154 *                                   and 'side'. Menus meta boxes (accordion sections) all use
     155 *                                   the 'side' context. Default 'default'.
     156 * @param string   $priority         Optional. The priority within the context where the boxes
     157 *                                   should show ('high', 'low'). Default 'default'.
    149158 */
    150 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {
     159function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $location = 'default', $priority = 'default' ) {
    151160        $screen = get_current_screen();
    152161        global $wp_dashboard_control_callbacks;
    153162
     
    173182
    174183        $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
    175184
    176         $location = 'normal';
    177         if ( in_array( $widget_id, $side_widgets ) ) {
    178                 $location = 'side';
     185        if ( $location === 'default' ) {
     186                $location = 'normal';
     187                if ( in_array( $widget_id, $side_widgets ) ) {
     188                        $location = 'side';
     189                }
    179190        }
    180191
    181         $priority = 'core';
    182         if ( 'dashboard_browser_nag' === $widget_id ) {
    183                 $priority = 'high';
     192        if ( $priority === 'default' ) {
     193                $priority = 'core';
     194                if ( 'dashboard_browser_nag' === $widget_id ) {
     195                        $priority = 'high';
     196                }
    184197        }
    185198
    186199        add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );