Make WordPress Core

Ticket #14785: 14785.diff

File 14785.diff, 2.0 KB (added by duck_, 14 years ago)
  • wp-admin/includes/dashboard.php

     
    121121
    122122function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
    123123        global $wp_dashboard_control_callbacks;
     124
    124125        if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
    125126                $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
    126127                if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
    127128                        list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
    128129                        $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
    129                         add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' );
    130                         return;
     130                        $callback = '_wp_dashboard_control_callback';
     131                } else {
     132                        list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
     133                        $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
    131134                }
    132                 list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
    133                 $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
    134135        }
     136
    135137        $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
    136138        $location = 'normal';
    137139        if ( in_array($widget_id, $side_widgets) )
     
    143145        echo '<form action="" method="post" class="dashboard-widget-control-form">';
    144146        wp_dashboard_trigger_widget_control( $meta_box['id'] );
    145147        echo '<p class="submit"><input type="hidden" name="widget_id" value="' . esc_attr($meta_box['id']) . '" /><input type="submit" value="' . esc_attr__( 'Submit' ) . '" /></p>';
    146 
    147148        echo '</form>';
    148149}
    149150