Make WordPress Core

Ticket #42791: 42791.4.diff

File 42791.4.diff, 2.5 KB (added by soulseekah, 7 years ago)

Enforce default priority and location when null is supplied

  • src/wp-admin/includes/dashboard.php

    diff --git src/wp-admin/includes/dashboard.php src/wp-admin/includes/dashboard.php
    index 7701967..f5ecc33 100644
    function wp_dashboard_setup() { 
    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 *
    function wp_dashboard_setup() { 
    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 'normal'.
     156 * @param string   $priority         Optional. The priority within the context where the boxes
     157 *                                   should show ('high', 'low'). Default 'core'.
    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 = 'normal', $priority = 'core' ) {
    151160        $screen = get_current_screen();
    152161        global $wp_dashboard_control_callbacks;
    153162
    function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_ 
    173182
    174183        $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' );
    175184
    176         $location = 'normal';
    177185        if ( in_array( $widget_id, $side_widgets ) ) {
    178186                $location = 'side';
    179187        }
    180188
    181         $priority = 'core';
    182189        if ( 'dashboard_browser_nag' === $widget_id ) {
    183190                $priority = 'high';
    184191        }
    185192
     193        if ( is_null( $location ) ) {
     194                $location = 'normal';
     195        }
     196
     197        if ( is_null( $priority ) ) {
     198                $priority = 'core';
     199        }
     200
    186201        add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );
    187202}
    188203