Ticket #42791: 42791.2.diff
File 42791.2.diff, 2.5 KB (added by , 7 years ago) |
---|
-
wp-admin/includes/dashboard.php
136 136 * Adds a new dashboard widget. 137 137 * 138 138 * @since 2.7.0 139 * @since 4.9.5 added the location and priority arguments 139 140 * 140 141 * @global array $wp_dashboard_control_callbacks 141 142 * … … 146 147 * @param callable $control_callback Optional. Function that outputs controls for the widget. Default null. 147 148 * @param array $callback_args Optional. Data that should be set as the $args property of the widget array 148 149 * (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'. 149 158 */ 150 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null ) {159 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null, $callback_args = null, $location = 'default', $priority = 'default' ) { 151 160 $screen = get_current_screen(); 152 161 global $wp_dashboard_control_callbacks; 153 162 … … 173 182 174 183 $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); 175 184 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 } 179 190 } 180 191 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 } 184 197 } 185 198 186 199 add_meta_box( $widget_id, $widget_name, $callback, $screen, $location, $priority, $callback_args );