Make WordPress Core


Ignore:
Timestamp:
10/07/2010 07:34:18 PM (15 years ago)
Author:
ryan
Message:

First pass of user admin. Network admin and screen cleanups. see #14696

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/dashboard.php

    r15718 r15746  
    1717    global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
    1818    $wp_dashboard_control_callbacks = array();
     19    $screen = get_current_screen();
    1920
    2021    $update = false;
     
    2627
    2728    // Right Now
    28     wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
     29    if ( is_blog_admin() && current_user_can('edit_posts') )
     30        wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
    2931
    3032    // Recent Comments Widget
    31     if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
    32         $update = true;
    33         $widget_options['dashboard_recent_comments'] = array(
    34             'items' => 5,
    35         );
    36     }
    37     $recent_comments_title = __( 'Recent Comments' );
    38     wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
     33    if ( is_blog_admin() && current_user_can('moderate_comments') ) {
     34        if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
     35            $update = true;
     36            $widget_options['dashboard_recent_comments'] = array(
     37                'items' => 5,
     38            );
     39        }
     40        $recent_comments_title = __( 'Recent Comments' );
     41        wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
     42    }
    3943
    4044    // Incoming Links Widget
    41     if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
    42         $update = true;
    43         $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
    44         $widget_options['dashboard_incoming_links'] = array(
    45             'home' => get_option('home'),
    46             'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
    47             'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
    48             'items' => $num_items,
    49             'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
    50         );
    51     }
    52     wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
     45    if ( is_blog_admin() && current_user_can('publish_posts') ) {
     46        if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
     47            $update = true;
     48            $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
     49            $widget_options['dashboard_incoming_links'] = array(
     50                'home' => get_option('home'),
     51                'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
     52                'url' => isset($widget_options['dashboard_incoming_links']['url']) ? apply_filters( 'dashboard_incoming_links_feed', $widget_options['dashboard_incoming_links']['url'] ) : apply_filters( 'dashboard_incoming_links_feed', 'http://blogsearch.google.com/blogsearch_feeds?scoring=d&ie=utf-8&num=' . $num_items . '&output=rss&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
     53                'items' => $num_items,
     54                'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
     55            );
     56        }
     57        wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
     58    }
    5359
    5460    // WP Plugins Widget
    55     if ( current_user_can( 'install_plugins' ) )
     61    if ( is_blog_admin() && current_user_can( 'install_plugins' ) )
    5662        wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
    5763
    5864    // QuickPress Widget
    59     if ( current_user_can('edit_posts') )
     65    if ( is_blog_admin() && current_user_can('edit_posts') )
    6066        wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
    6167
    6268    // Recent Drafts
    63     if ( current_user_can('edit_posts') )
     69    if ( is_blog_admin() && current_user_can('edit_posts') )
    6470        wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
    6571
     
    116122        update_option( 'dashboard_widget_options', $widget_options );
    117123
    118     do_action('do_meta_boxes', 'dashboard', 'normal', '');
    119     do_action('do_meta_boxes', 'dashboard', 'side', '');
     124    do_action('do_meta_boxes', $screen->id, 'normal', '');
     125    do_action('do_meta_boxes', $screen->id, 'side', '');
    120126}
    121127
    122128function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
     129    $screen = get_current_screen();
    123130    global $wp_dashboard_control_callbacks;
    124131    if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
     
    127134            list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
    128135            $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' );
     136            add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', $screen->id, 'normal', 'core' );
    130137            return;
    131138        }
     
    133140        $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
    134141    }
    135     $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
     142    if ( is_user_admin() )
     143        $side_widgets = array();
     144    else
     145        $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
    136146    $location = 'normal';
    137147    if ( in_array($widget_id, $side_widgets) )
    138148        $location = 'side';
    139     add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' );
     149    add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' );
    140150}
    141151
     
    155165function wp_dashboard() {
    156166    global $screen_layout_columns;
     167
     168    $screen = get_current_screen();
    157169
    158170    $hide2 = $hide3 = $hide4 = '';
     
    177189<?php
    178190    echo "\t<div class='postbox-container' style='$width'>\n";
    179     do_meta_boxes( 'dashboard', 'normal', '' );
     191    do_meta_boxes( $screen->id, 'normal', '' );
    180192
    181193    echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";
    182     do_meta_boxes( 'dashboard', 'side', '' );
     194    do_meta_boxes( $screen->id, 'side', '' );
    183195
    184196    echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n";
    185     do_meta_boxes( 'dashboard', 'column3', '' );
     197    do_meta_boxes( $screen->id, 'column3', '' );
    186198
    187199    echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n";
    188     do_meta_boxes( 'dashboard', 'column4', '' );
     200    do_meta_boxes( $screen->id, 'column4', '' );
    189201?>
    190202</div></div>
Note: See TracChangeset for help on using the changeset viewer.