Changeset 15746 for trunk/wp-admin/includes/dashboard.php
- Timestamp:
- 10/07/2010 07:34:18 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/dashboard.php
r15718 r15746 17 17 global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; 18 18 $wp_dashboard_control_callbacks = array(); 19 $screen = get_current_screen(); 19 20 20 21 $update = false; … … 26 27 27 28 // 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' ); 29 31 30 32 // 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 } 39 43 40 44 // 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 } 53 59 54 60 // WP Plugins Widget 55 if ( current_user_can( 'install_plugins' ) )61 if ( is_blog_admin() && current_user_can( 'install_plugins' ) ) 56 62 wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' ); 57 63 58 64 // QuickPress Widget 59 if ( current_user_can('edit_posts') )65 if ( is_blog_admin() && current_user_can('edit_posts') ) 60 66 wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' ); 61 67 62 68 // Recent Drafts 63 if ( current_user_can('edit_posts') )69 if ( is_blog_admin() && current_user_can('edit_posts') ) 64 70 wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); 65 71 … … 116 122 update_option( 'dashboard_widget_options', $widget_options ); 117 123 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', ''); 120 126 } 121 127 122 128 function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) { 129 $screen = get_current_screen(); 123 130 global $wp_dashboard_control_callbacks; 124 131 if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { … … 127 134 list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); 128 135 $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' ); 130 137 return; 131 138 } … … 133 140 $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; 134 141 } 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'); 136 146 $location = 'normal'; 137 147 if ( in_array($widget_id, $side_widgets) ) 138 148 $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' ); 140 150 } 141 151 … … 155 165 function wp_dashboard() { 156 166 global $screen_layout_columns; 167 168 $screen = get_current_screen(); 157 169 158 170 $hide2 = $hide3 = $hide4 = ''; … … 177 189 <?php 178 190 echo "\t<div class='postbox-container' style='$width'>\n"; 179 do_meta_boxes( 'dashboard', 'normal', '' );191 do_meta_boxes( $screen->id, 'normal', '' ); 180 192 181 193 echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n"; 182 do_meta_boxes( 'dashboard', 'side', '' );194 do_meta_boxes( $screen->id, 'side', '' ); 183 195 184 196 echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n"; 185 do_meta_boxes( 'dashboard', 'column3', '' );197 do_meta_boxes( $screen->id, 'column3', '' ); 186 198 187 199 echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n"; 188 do_meta_boxes( 'dashboard', 'column4', '' );200 do_meta_boxes( $screen->id, 'column4', '' ); 189 201 ?> 190 202 </div></div>
Note: See TracChangeset
for help on using the changeset viewer.