Ticket #14696: 14696.diff

File 14696.diff, 32.5 KB (added by ryan, 3 years ago)

Dump of what I'm playing with

Line 
1Index: wp-includes/vars.php
2===================================================================
3--- wp-includes/vars.php        (revision 15721)
4+++ wp-includes/vars.php        (working copy)
5@@ -15,7 +15,12 @@
6 // On which page are we ?
7 if ( is_admin() ) {
8        // wp-admin pages are checked more carefully
9-       preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
10+       if ( is_network_admin() )
11+               preg_match('#/wp-admin/network/?(.*?)$#i', $PHP_SELF, $self_matches);
12+       elseif ( is_user_admin() )
13+               preg_match('#/wp-admin/user/?(.*?)$#i', $PHP_SELF, $self_matches);
14+       else
15+               preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
16        $pagenow = $self_matches[1];
17        $pagenow = trim($pagenow, '/');
18        $pagenow = preg_replace('#\?.*?$#', '', $pagenow);
19Index: wp-includes/load.php
20===================================================================
21--- wp-includes/load.php        (revision 15721)
22+++ wp-includes/load.php        (working copy)
23@@ -621,6 +621,22 @@
24 }
25 
26 /**
27+ * Whether the current request is for a user admin screen /wp-admin/user/
28+ *
29+ * Does not inform on whether the user is an admin! Use capability checks to
30+ * tell if the user should be accessing a section or not.
31+ *
32+ * @since 3.1.0
33+ *
34+ * @return bool True if inside WordPress user administration pages.
35+ */
36+function is_user_admin() {
37+       if ( defined( 'WP_USER_ADMIN' ) )
38+               return WP_USER_ADMIN;
39+       return false;
40+}
41+
42+/**
43  * Whether Multisite support is enabled
44  *
45  * @since 3.0.0
46Index: wp-includes/link-template.php
47===================================================================
48--- wp-includes/link-template.php       (revision 15721)
49+++ wp-includes/link-template.php       (working copy)
50@@ -2130,6 +2130,25 @@
51 }
52 
53 /**
54+ * Retrieve the url to the admin area for the current user.
55+ *
56+ * @package WordPress
57+ * @since 3.0.0
58+ *
59+ * @param string $path Optional path relative to the admin url
60+ * @param string $scheme The scheme to use. Default is 'admin', which obeys force_ssl_admin() and is_ssl(). 'http' or 'https' can be passed to force those schemes.
61+ * @return string Admin url link with optional path appended
62+*/
63+function user_admin_url( $path = '', $scheme = 'admin' ) {
64+       $url = network_site_url('wp-admin/user/', $scheme);
65+
66+       if ( !empty($path) && is_string($path) && strpos($path, '..') === false )
67+               $url .= ltrim($path, '/');
68+
69+       return apply_filters('user_admin_url', $url, $path);
70+}
71+
72+/**
73  * Retrieve the url to the admin area for either the current blog or the network depending on context.
74  *
75  * @package WordPress
76@@ -2142,6 +2161,8 @@
77 function self_admin_url($path = '', $scheme = 'admin') {
78        if ( is_network_admin() )
79                return network_admin_url($path, $scheme);
80+       elseif ( is_user_admin() )
81+               return user_admin_url($path, $scheme);
82        else
83                return admin_url($path, $scheme);
84 }
85Index: wp-includes/capabilities.php
86===================================================================
87--- wp-includes/capabilities.php        (revision 15721)
88+++ wp-includes/capabilities.php        (working copy)
89@@ -737,6 +737,7 @@
90 
91                // Must have ALL requested caps
92                $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args );
93+               $capabilities['exist'] = true; // Everyone is allowed to exist
94                foreach ( (array) $caps as $cap ) {
95                        //echo "Checking cap $cap<br />";
96                        if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] )
97Index: wp-includes/pluggable.php
98===================================================================
99--- wp-includes/pluggable.php   (revision 15721)
100+++ wp-includes/pluggable.php   (working copy)
101@@ -81,7 +81,7 @@
102                return;
103 
104        if ( ! $user = wp_validate_auth_cookie() ) {
105-                if ( is_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
106+                if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) {
107                        wp_set_current_user(0);
108                        return false;
109                 }
110@@ -775,7 +775,12 @@
111                }
112        }
113 
114-       if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) {
115+       if ( is_user_admin() )
116+               $scheme = 'logged_in';
117+       else
118+               $scheme = apply_filters( 'auth_redirect_scheme', '' );
119+
120+       if ( $user_id = wp_validate_auth_cookie( '',  $scheme) ) {
121                do_action('auth_redirect', $user_id);
122 
123                // If the user wants ssl but the session is not ssl, redirect.
124Index: wp-includes/ms-functions.php
125===================================================================
126--- wp-includes/ms-functions.php        (revision 15721)
127+++ wp-includes/ms-functions.php        (working copy)
128@@ -72,13 +72,8 @@
129 function get_active_blog_for_user( $user_id ) {
130        global $wpdb;
131        $blogs = get_blogs_of_user( $user_id );
132-       if ( empty( $blogs ) ) {
133-               $details = get_dashboard_blog();
134-               add_user_to_blog( $details->blog_id, $user_id, 'subscriber' );
135-               update_user_meta( $user_id, 'primary_blog', $details->blog_id );
136-               wp_cache_delete( $user_id, 'users' );
137-               return $details;
138-       }
139+       if ( empty( $blogs ) )
140+               return null;
141 
142        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
143        $details = get_dashboard_blog();
144@@ -120,11 +115,7 @@
145                                }
146                        }
147                } else {
148-                       // Should never get here
149-                       $dashboard_blog = get_dashboard_blog();
150-                       add_user_to_blog( $dashboard_blog->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog
151-                       update_user_meta( $user_id, 'primary_blog', $dashboard_blog->blog_id );
152-                       return $dashboard_blog;
153+                       return null;
154                }
155                return $ret;
156        } else {
157Index: wp-admin/users.php
158===================================================================
159--- wp-admin/users.php  (revision 15721)
160+++ wp-admin/users.php  (working copy)
161@@ -18,6 +18,8 @@
162 $title = __('Users');
163 $parent_file = 'users.php';
164 
165+add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
166+
167 // contextual help - choose Help on the top right of admin panel to preview this.
168 add_contextual_help($current_screen,
169     '<p>' . __('This screen lists all the existing users for your site. Each user has one of five defined roles as set by the site admin: Site Administrator, Editor, Author, Contributor, or Subscriber. Users with roles other than Administrator will see fewer options when they are logged in, based on their role.') . '</p>' .
170Index: wp-admin/edit-comments.php
171===================================================================
172--- wp-admin/edit-comments.php  (revision 15721)
173+++ wp-admin/edit-comments.php  (working copy)
174@@ -105,6 +105,8 @@
175 else
176        $title = __('Comments');
177 
178+add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
179+
180 add_contextual_help( $current_screen, '<p>' . __('You can manage comments made on your site similar to the way you manage Posts and other content. This screen is customizable in the same ways as other management screens, and you can act on comments using the on-hover action links or the Bulk Actions.') . '</p>' .
181        '<p>' . __('A yellow row means the comment is waiting for you to moderate it.') . '</p>' .
182        '<p>' . __('In the Author column, in addition to the author&#8217;s name, email address, and blog URL, the commenter&#8217;s IP address is shown. Clicking on this link will show you all the comments made from this IP address.') . '</p>' .
183Index: wp-admin/includes/menu.php
184===================================================================
185--- wp-admin/includes/menu.php  (revision 15721)
186+++ wp-admin/includes/menu.php  (working copy)
187@@ -9,6 +9,8 @@
188 
189 if ( is_network_admin() )
190        do_action('_network_admin_menu');
191+elseif ( is_user_admin() )
192+       do_action('_user_admin_menu');
193 else
194        do_action('_admin_menu');
195 
196@@ -89,6 +91,8 @@
197 
198 if ( is_network_admin() )
199        do_action('network_admin_menu', '');
200+elseif ( is_user_admin() )
201+       do_action('user_admin_menu', '');
202 else
203        do_action('admin_menu', '');
204 
205Index: wp-admin/includes/default-list-tables.php
206===================================================================
207--- wp-admin/includes/default-list-tables.php   (revision 15721)
208+++ wp-admin/includes/default-list-tables.php   (working copy)
209@@ -2719,7 +2719,7 @@
210 
211        function WP_Sites_Table() {
212                parent::WP_List_Table( array(
213-                       'screen' => 'ms-sites',
214+                       'screen' => 'sites-network',
215                        'plural' => 'sites',
216                ) );
217        }
218@@ -2734,7 +2734,7 @@
219 
220                $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode'];
221 
222-               $per_page = $this->get_items_per_page( 'ms_sites_per_page' );
223+               $per_page = $this->get_items_per_page( 'sites_network_per_page' );
224 
225                $pagenum = $this->get_pagenum();
226 
227@@ -3007,7 +3007,7 @@
228 
229        function WP_MS_Users_Table() {
230                parent::WP_List_Table( array(
231-                       'screen' => 'ms-users',
232+                       'screen' => 'users-network',
233                ) );
234        }
235 
236@@ -3024,7 +3024,7 @@
237 
238                $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : '';
239 
240-               $users_per_page = $this->get_items_per_page( 'ms_users_per_page' );
241+               $users_per_page = $this->get_items_per_page( 'users_network_per_page' );
242 
243                $paged = $this->get_pagenum();
244 
245Index: wp-admin/includes/dashboard.php
246===================================================================
247--- wp-admin/includes/dashboard.php     (revision 15721)
248+++ wp-admin/includes/dashboard.php     (working copy)
249@@ -25,42 +25,47 @@
250        /* Register Widgets and Controls */
251 
252        // Right Now
253-       wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
254+       if ( is_blog_admin() && current_user_can('edit_posts') )
255+               wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
256 
257        // Recent Comments Widget
258-       if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
259-               $update = true;
260-               $widget_options['dashboard_recent_comments'] = array(
261-                       'items' => 5,
262-               );
263+       if ( is_blog_admin() && current_user_can('moderate_comments') ) {
264+               if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
265+                       $update = true;
266+                       $widget_options['dashboard_recent_comments'] = array(
267+                               'items' => 5,
268+                       );
269+               }
270+               $recent_comments_title = __( 'Recent Comments' );
271+               wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
272        }
273-       $recent_comments_title = __( 'Recent Comments' );
274-       wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
275 
276        // Incoming Links Widget
277-       if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
278-               $update = true;
279-               $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
280-               $widget_options['dashboard_incoming_links'] = array(
281-                       'home' => get_option('home'),
282-                       'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
283-                       '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') ) ),
284-                       'items' => $num_items,
285-                       'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
286-               );
287+       if ( is_blog_admin() && current_user_can('publish_posts') ) {
288+               if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) {
289+                       $update = true;
290+                       $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
291+                       $widget_options['dashboard_incoming_links'] = array(
292+                               'home' => get_option('home'),
293+                               'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ),
294+                               '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') ) ),
295+                               'items' => $num_items,
296+                               'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false
297+                       );
298+               }
299+               wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
300        }
301-       wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' );
302 
303        // WP Plugins Widget
304-       if ( current_user_can( 'install_plugins' ) )
305+       if ( is_blog_admin() && current_user_can( 'install_plugins' ) )
306                wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
307 
308        // QuickPress Widget
309-       if ( current_user_can('edit_posts') )
310+       if ( is_blog_admin() && current_user_can('edit_posts') )
311                wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
312 
313        // Recent Drafts
314-       if ( current_user_can('edit_posts') )
315+       if ( is_blog_admin() && current_user_can('edit_posts') )
316                wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
317 
318        // Primary feed (Dev Blog) Widget
319@@ -132,7 +137,10 @@
320                list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
321                $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
322        }
323-       $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
324+       if ( is_user_admin() )
325+               $side_widgets = array();
326+       else
327+               $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
328        $location = 'normal';
329        if ( in_array($widget_id, $side_widgets) )
330                $location = 'side';
331Index: wp-admin/includes/misc.php
332===================================================================
333--- wp-admin/includes/misc.php  (revision 15721)
334+++ wp-admin/includes/misc.php  (working copy)
335@@ -343,9 +343,9 @@
336 
337                switch ( $map_option ) {
338                        case 'edit_per_page':
339-                       case 'ms_sites_per_page':
340+                       case 'sites_network_per_page':
341                        case 'users_per_page':
342-                       case 'ms_users_per_page':
343+                       case 'users_network_per_page':
344                        case 'edit_comments_per_page':
345                        case 'upload_per_page':
346                        case 'edit_tags_per_page':
347Index: wp-admin/includes/template.php
348===================================================================
349--- wp-admin/includes/template.php      (revision 15721)
350+++ wp-admin/includes/template.php      (working copy)
351@@ -1390,6 +1390,9 @@
352        if ( is_string($screen) )
353                $screen = convert_to_screen($screen);
354 
355+       if ( $screen->is_user )
356+               return;
357+
358        if ( isset($screen->post_type) ) {
359                $post_type_object = get_post_type_object($screen->post_type);
360                if ( 'add' != $screen->action )
361@@ -1830,55 +1833,36 @@
362        return $return;
363 }
364 
365+function add_screen_option( $option, $args = array() ) {
366+       global $wp_current_screen_options;
367+
368+       if ( !isset($wp_current_screen_options) )
369+               $wp_current_screen_options = array();
370+
371+       $wp_current_screen_options[$option] = $args;
372+}
373+
374 function screen_options($screen) {
375+       global $wp_current_screen_options;
376+
377        if ( is_string($screen) )
378                $screen = convert_to_screen($screen);
379 
380-       switch ( $screen->base ) {
381-               case 'edit':
382-               case 'edit-pages':
383-                       $post_type = 'post';
384-                       if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array( 'show_ui' => true ) ) ) )
385-                               $post_type = $_GET['post_type'];
386-                       $post_type_object = get_post_type_object($post_type);
387-                       $per_page_label = $post_type_object->labels->name;
388-                       break;
389-               case 'ms-sites':
390-                       $per_page_label = _x( 'Sites', 'sites per page (screen options)' );
391-                       break;
392-               case 'users':
393-               case 'ms-users':
394-                       $per_page_label = _x( 'Users', 'users per page (screen options)' );
395-                       break;
396-               case 'edit-comments':
397-                       $per_page_label = _x( 'Comments', 'comments per page (screen options)' );
398-                       break;
399-               case 'upload':
400-                       $per_page_label = _x( 'Media items', 'items per page (screen options)' );
401-                       break;
402-               case 'edit-tags':
403-                       global $tax;
404-                       $per_page_label = $tax->labels->name;
405-                       break;
406-               case 'plugins':
407-                       $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' );
408-                       break;
409-               default:
410-                       return '';
411-       }
412+       if ( !isset($wp_current_screen_options['per_page']) )
413+               return '';
414 
415-       $option = str_replace( '-', '_', "{$screen->id}_per_page" );
416-       if ( 'edit_tags_per_page' == $option ) {
417-               if ( 'category' == $tax->name )
418-                       $option = 'categories_per_page';
419-               elseif ( 'post_tag' != $tax->name )
420-                       $option = 'edit_' . $tax->name . '_per_page';
421+       $per_page_label = $wp_current_screen_options['per_page']['label'];
422+
423+       if ( empty($wp_current_screen_options['per_page']['option']) ) {
424+               $option = str_replace( '-', '_', "{$screen->id}_per_page" );
425+       } else {
426+               $option = $wp_current_screen_options['per_page']['option'];
427        }
428 
429        $per_page = (int) get_user_option( $option );
430        if ( empty( $per_page ) || $per_page < 1 ) {
431-               if ( 'plugins' == $screen->id )
432-                       $per_page = 999;
433+               if ( isset($wp_current_screen_options['per_page']['default']) )
434+                       $per_page = $wp_current_screen_options['per_page']['default'];
435                else
436                        $per_page = 20;
437        }
438@@ -2060,6 +2044,15 @@
439        }
440 
441        $current_screen->is_network = is_network_admin() ? true : false;
442+       $current_screen->is_user = is_user_admin() ? true : false;
443+       
444+       if ( $current_screen->is_network ) {
445+               $current_screen->base .= '-network';
446+               $current_screen->id .= '-network';
447+       } elseif ( $current_screen->is_user ) {
448+               $current_screen->base .= '-user';
449+               $current_screen->id .= '-user';
450+       }
451 
452        $current_screen = apply_filters('current_screen', $current_screen);
453 }
454Index: wp-admin/includes/ms.php
455===================================================================
456--- wp-admin/includes/ms.php    (revision 15721)
457+++ wp-admin/includes/ms.php    (working copy)
458@@ -502,29 +502,14 @@
459        $c ++;
460 
461        $blog = get_active_blog_for_user( get_current_user_id() );
462-       $dashboard_blog = get_dashboard_blog();
463+
464        if ( is_object( $blog ) ) {
465                wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
466                exit;
467+       } else {
468+               wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case"
469        }
470 
471-       /*
472-          If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog,
473-          then update the primary_blog record to match the user's blog
474-        */
475-       $blogs = get_blogs_of_user( get_current_user_id() );
476-
477-       if ( !empty( $blogs ) ) {
478-               foreach( $blogs as $blogid => $blog ) {
479-                       if ( $blogid != $dashboard_blog->blog_id && get_user_meta( get_current_user_id() , 'primary_blog', true ) == $dashboard_blog->blog_id ) {
480-                               update_user_meta( get_current_user_id(), 'primary_blog', $blogid );
481-                               continue;
482-                       }
483-               }
484-               $blog = get_blog_details( get_user_meta( get_current_user_id(), 'primary_blog', true ) );
485-                       wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) );
486-               exit;
487-       }
488        wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
489 }
490 add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );
491Index: wp-admin/edit-tags.php
492===================================================================
493--- wp-admin/edit-tags.php      (revision 15721)
494+++ wp-admin/edit-tags.php      (working copy)
495@@ -22,6 +22,8 @@
496        $submenu_file = "edit-tags.php?taxonomy=$taxonomy";
497 }
498 
499+add_screen_option( 'per_page', array('label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page') );
500+
501 switch ( $wp_list_table->current_action() ) {
502 
503 case 'add-tag':
504Index: wp-admin/admin.php
505===================================================================
506--- wp-admin/admin.php  (revision 15721)
507+++ wp-admin/admin.php  (working copy)
508@@ -11,11 +11,16 @@
509  *
510  * @since unknown
511  */
512-if ( !defined('WP_ADMIN') )
513+if ( ! defined('WP_ADMIN') )
514        define('WP_ADMIN', TRUE);
515 
516-if ( !defined('WP_NETWORK_ADMIN') ) {
517+if ( ! defined('WP_NETWORK_ADMIN') )
518        define('WP_NETWORK_ADMIN', FALSE);
519+
520+if ( ! defined('WP_USER_ADMIN') )
521+       define('WP_USER_ADMIN', FALSE);
522+
523+if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) {
524        define('WP_BLOG_ADMIN', TRUE);
525 }
526 
527@@ -97,6 +102,8 @@
528 
529 if ( WP_NETWORK_ADMIN )
530        require(ABSPATH . 'wp-admin/network/menu.php');
531+elseif ( WP_USER_ADMIN )
532+       require(ABSPATH . 'wp-admin/user/menu.php');
533 else
534        require(ABSPATH . 'wp-admin/menu.php');
535 
536Index: wp-admin/index.php
537===================================================================
538--- wp-admin/index.php  (revision 15721)
539+++ wp-admin/index.php  (working copy)
540@@ -42,7 +42,7 @@
541        '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
542 );
543 
544-require_once('./admin-header.php');
545+include (ABSPATH . 'wp-admin/admin-header.php');
546 
547 $today = current_time('mysql', 1);
548 ?>
549Index: wp-admin/upload.php
550===================================================================
551--- wp-admin/upload.php (revision 15721)
552+++ wp-admin/upload.php (working copy)
553@@ -134,6 +134,8 @@
554 wp_enqueue_script( 'jquery-ui-draggable' );
555 wp_enqueue_script( 'media' );
556 
557+add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
558+
559 add_contextual_help( $current_screen,
560        '<p>' . __('All the files you&#8217;ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the <em>Screen Options</em> tab to customize the display of this screen.') . '</p>' .
561        '<p>' . __('You can narrow the list by file type/status using the text link filters at the top of the screen. You also can refine the list by date using the dropdown menu above the media table.') . '</p>' .
562Index: wp-admin/network/settings.php
563===================================================================
564--- wp-admin/network/settings.php       (revision 15721)
565+++ wp-admin/network/settings.php       (working copy)
566@@ -43,7 +43,7 @@
567 ?>
568 
569 <div class="wrap">
570-       <?php screen_icon(); ?>
571+       <?php screen_icon('options-general'); ?>
572        <h2><?php _e( 'Network Options' ) ?></h2>
573        <form method="post" action="edit.php?action=siteoptions">
574                <?php wp_nonce_field( 'siteoptions' ); ?>
575Index: wp-admin/network/users.php
576===================================================================
577--- wp-admin/network/users.php  (revision 15721)
578+++ wp-admin/network/users.php  (working copy)
579@@ -16,6 +16,8 @@
580 $title = __( 'Users' );
581 $parent_file = 'users.php';
582 
583+add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
584+
585 add_contextual_help($current_screen,
586        '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
587        '<p>' . __('Hover over any user on the list to make the edit links appear. The Edit link on the left will take you to his or her Edit User profile page; the Edit link on the right by any site name goes to an Edit Site screen for that site.') . '</p>' .
588Index: wp-admin/network/edit.php
589===================================================================
590--- wp-admin/network/edit.php   (revision 15721)
591+++ wp-admin/network/edit.php   (working copy)
592@@ -52,8 +52,8 @@
593                                                $user_dropdown = "<select name='blog[$val][{$key}]'>";
594                                                $user_list = '';
595                                                foreach ( $blog_users as $user ) {
596-                                                       if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) )
597-                                                               $user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>";
598+                                                       if ( $user->user_id != $val && !in_array( $user->id, $allusers ) )
599+                                                               $user_list .= "<option value='{$user->id}'>{$user->user_login}</option>";
600                                                }
601                                                if ( '' == $user_list )
602                                                        $user_list = $admin_out;
603@@ -687,11 +687,6 @@
604                else
605                        wp_new_user_notification( $user_id, $password );
606 
607-               if ( get_site_option( 'dashboard_blog' ) == false )
608-                       add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
609-               else
610-                       add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
611-
612                wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
613                exit();
614        break;
615Index: wp-admin/network/sites.php
616===================================================================
617--- wp-admin/network/sites.php  (revision 15721)
618+++ wp-admin/network/sites.php  (working copy)
619@@ -18,6 +18,8 @@
620 $title = __( 'Sites' );
621 $parent_file = 'sites.php';
622 
623+add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) );
624+
625 if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) {
626        add_contextual_help($current_screen,
627                '<p>' . __('This extensive list of options has five modules: Site Info, Site Options, allowing Site Themes for this given site, changing user roles and passwords for that site, adding a new user, and Miscellaneous Site Actions (upload size limits).') . '</p>' .
628@@ -109,7 +111,7 @@
629                require_once( '../admin-header.php' );
630                ?>
631                <div class="wrap">
632-               <?php screen_icon(); ?>
633+               <?php screen_icon('index'); ?>
634                <h2><?php _e( 'Edit Site' ); ?> - <a href="<?php echo esc_url( get_home_url( $id ) ); ?>"><?php echo esc_url( get_home_url( $id ) ); ?></a></h2>
635                <?php echo $msg; ?>
636                <form method="post" action="edit.php?action=updateblog">
637@@ -347,7 +349,7 @@
638                ?>
639 
640                <div class="wrap">
641-               <?php screen_icon(); ?>
642+               <?php screen_icon('index'); ?>
643                <h2><?php _e('Sites') ?>
644                <?php echo $msg; ?>
645                <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>
646Index: wp-admin/network/upgrade.php
647===================================================================
648--- wp-admin/network/upgrade.php        (revision 15721)
649+++ wp-admin/network/upgrade.php        (working copy)
650@@ -32,7 +32,7 @@
651        wp_die( __( 'You do not have permission to access this page.' ) );
652 
653 echo '<div class="wrap">';
654-screen_icon();
655+screen_icon('tools');
656 echo '<h2>' . __( 'Update Network' ) . '</h2>';
657 
658 $action = isset($_GET['action']) ? $_GET['action'] : 'show';
659Index: wp-admin/menu.php
660===================================================================
661--- wp-admin/menu.php   (revision 15721)
662+++ wp-admin/menu.php   (working copy)
663@@ -232,6 +232,6 @@
664        'themes' => 'appearance',
665        );
666 
667-require(ABSPATH . 'wp-admin/includes/menu.php');
668+require_once(ABSPATH . 'wp-admin/includes/menu.php');
669 
670 ?>
671Index: wp-admin/plugins.php
672===================================================================
673--- wp-admin/plugins.php        (revision 15721)
674+++ wp-admin/plugins.php        (working copy)
675@@ -290,6 +290,8 @@
676 wp_enqueue_script('plugin-install');
677 add_thickbox();
678 
679+add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999) );
680+
681 add_contextual_help($current_screen,
682        '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
683        '<p>' . sprintf(__('You can find additional plugins for your site by using the <a href="%1$s">Plugin Browser/Installer</a> functionality or by browsing the <a href="%2$s" target="_blank">WordPress Plugin Directory</a> directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your <code>/wp-content/plugins</code> directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '</p>' .
684Index: wp-admin/edit.php
685===================================================================
686--- wp-admin/edit.php   (revision 15721)
687+++ wp-admin/edit.php   (working copy)
688@@ -163,6 +163,8 @@
689        );
690 }
691 
692+add_screen_option( 'per_page', array('label' => $title, 'default' => 20) );
693+
694 require_once('./admin-header.php');
695 ?>
696 <div class="wrap">
697Index: wp-admin/index-extra.php
698===================================================================
699--- wp-admin/index-extra.php    (revision 15721)
700+++ wp-admin/index-extra.php    (working copy)
701@@ -10,7 +10,7 @@
702 require_once( './admin.php' );
703 
704 /** Load WordPress Administration Dashboard API */
705-require( './includes/dashboard.php' );
706+require(ABSPATH . 'wp-admin/includes/dashboard.php' );
707 
708 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
709 send_nosniff_header();
710Index: wp-admin/user-edit.php
711===================================================================
712--- wp-admin/user-edit.php      (revision 15721)
713+++ wp-admin/user-edit.php      (working copy)
714@@ -31,8 +31,12 @@
715        $submenu_file = 'users.php';
716 else
717        $submenu_file = 'profile.php';
718-$parent_file = 'users.php';
719 
720+if ( current_user_can('edit_users') && !is_user_admin() )
721+       $parent_file = 'users.php';
722+else
723+       $parent_file = 'profile.php';
724+
725 // contextual help - choose Help on the top right of admin panel to preview this.
726 add_contextual_help($current_screen,
727     '<p>' . __('Your profile contains information about you (your &#8220;account&#8221;) as well as some personal options related to using WordPress.') . '</p>' .
728Index: wp-admin/user/profile.php
729===================================================================
730--- wp-admin/user/profile.php   (revision 0)
731+++ wp-admin/user/profile.php   (revision 0)
732@@ -0,0 +1,5 @@
733+<?php
734+
735+require_once( './admin.php' );
736+
737+require( '../profile.php' );
738\ No newline at end of file
739
740Property changes on: wp-admin/user/profile.php
741___________________________________________________________________
742Added: svn:eol-style
743   + native
744
745Index: wp-admin/user/user-edit.php
746===================================================================
747--- wp-admin/user/user-edit.php (revision 0)
748+++ wp-admin/user/user-edit.php (revision 0)
749@@ -0,0 +1,5 @@
750+<?php
751+
752+require_once( './admin.php' );
753+
754+require( '../user-edit.php' );
755\ No newline at end of file
756
757Property changes on: wp-admin/user/user-edit.php
758___________________________________________________________________
759Added: svn:eol-style
760   + native
761
762Index: wp-admin/user/menu.php
763===================================================================
764--- wp-admin/user/menu.php      (revision 0)
765+++ wp-admin/user/menu.php      (revision 0)
766@@ -0,0 +1,18 @@
767+<?php
768+
769+/* translators: Network menu item */
770+$menu[0] = array(__('Dashboard'), 'exist', 'index.php', '', 'menu-top menu-top-first menu-icon-site', 'menu-site', 'div');
771+
772+$menu[4] = array( '', 'exist', 'separator1', '', 'wp-menu-separator' );
773+
774+$menu[70] = array( __('Profile'), 'exist', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' );
775+
776+$menu[99] = array( '', 'exist', 'separator-last', '', 'wp-menu-separator-last' );
777+
778+$_wp_real_parent_file['users.php'] = 'profile.php';
779+$compat = array();
780+$submenu = array();
781+
782+require_once(ABSPATH . 'wp-admin/includes/menu.php');
783+
784+?>
785\ No newline at end of file
786
787Property changes on: wp-admin/user/menu.php
788___________________________________________________________________
789Added: svn:eol-style
790   + native
791
792Index: wp-admin/user/index.php
793===================================================================
794--- wp-admin/user/index.php     (revision 0)
795+++ wp-admin/user/index.php     (revision 0)
796@@ -0,0 +1,5 @@
797+<?php
798+
799+require_once( './admin.php' );
800+
801+require( '../index.php' );
802
803Property changes on: wp-admin/user/index.php
804___________________________________________________________________
805Added: svn:eol-style
806   + native
807
808Index: wp-admin/user/admin.php
809===================================================================
810--- wp-admin/user/admin.php     (revision 0)
811+++ wp-admin/user/admin.php     (revision 0)
812@@ -0,0 +1,10 @@
813+<?php
814+
815+define('WP_USER_ADMIN', TRUE);
816+
817+require_once( dirname(dirname(__FILE__)) . '/admin.php');
818+
819+if ( ! is_main_site() )
820+       wp_redirect( user_admin_url() );
821+
822+?>
823
824Property changes on: wp-admin/user/admin.php
825___________________________________________________________________
826Added: svn:eol-style
827   + native
828
829Index: wp-admin/user/index-extra.php
830===================================================================
831--- wp-admin/user/index-extra.php       (revision 0)
832+++ wp-admin/user/index-extra.php       (revision 0)
833@@ -0,0 +1,5 @@
834+<?php
835+
836+require_once( './admin.php' );
837+
838+require( '../index-extra.php' );
839
840Property changes on: wp-admin/user/index-extra.php
841___________________________________________________________________
842Added: svn:eol-style
843   + native
844