diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 0f253703b4..63a31a138d 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -11,11 +11,16 @@ * * @since unknown */ -if ( !defined('WP_ADMIN') ) +if ( ! defined('WP_ADMIN') ) define('WP_ADMIN', TRUE); -if ( !defined('WP_NETWORK_ADMIN') ) { +if ( ! defined('WP_NETWORK_ADMIN') ) define('WP_NETWORK_ADMIN', FALSE); + +if ( ! defined('WP_USER_ADMIN') ) + define('WP_USER_ADMIN', FALSE); + +if ( ! WP_NETWORK_ADMIN && ! WP_USER_ADMIN ) { define('WP_BLOG_ADMIN', TRUE); } @@ -97,6 +102,8 @@ else if ( WP_NETWORK_ADMIN ) require(ABSPATH . 'wp-admin/network/menu.php'); +elseif ( WP_USER_ADMIN ) + require(ABSPATH . 'wp-admin/user/menu.php'); else require(ABSPATH . 'wp-admin/menu.php'); diff --git a/wp-admin/edit-comments.php b/wp-admin/edit-comments.php index 71d17c61dd..68abda1f32 100644 --- a/wp-admin/edit-comments.php +++ b/wp-admin/edit-comments.php @@ -105,6 +105,8 @@ if ( $post_id ) else $title = __('Comments'); +add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) ); + add_contextual_help( $current_screen, '

' . __('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.') . '

' . '

' . __('A yellow row means the comment is waiting for you to moderate it.') . '

' . '

' . __('In the Author column, in addition to the author’s name, email address, and blog URL, the commenter’s IP address is shown. Clicking on this link will show you all the comments made from this IP address.') . '

' . diff --git a/wp-admin/edit-form-advanced.php b/wp-admin/edit-form-advanced.php index aa0dcfc8a0..239c2ec590 100644 --- a/wp-admin/edit-form-advanced.php +++ b/wp-admin/edit-form-advanced.php @@ -163,6 +163,8 @@ do_action('do_meta_boxes', $post_type, 'normal', $post); do_action('do_meta_boxes', $post_type, 'advanced', $post); do_action('do_meta_boxes', $post_type, 'side', $post); +add_screen_option('layout_columns', array('max' => 2) ); + if ( 'post' == $post_type ) { add_contextual_help($current_screen, '

' . __('The title field and the big Post Editing Area are fixed in place, but you can reposition all the other boxes that allow you to add metadata to your post using drag and drop, and can minimize or expand them by clicking the title bar of the box. You can also hide any of the boxes by using the Screen Options tab, where you can also choose a 1- or 2-column layout for this screen.') . '

' . diff --git a/wp-admin/edit-link-form.php b/wp-admin/edit-link-form.php index 29e28623f4..f5bc0304ce 100644 --- a/wp-admin/edit-link-form.php +++ b/wp-admin/edit-link-form.php @@ -37,6 +37,8 @@ do_action('do_meta_boxes', 'link', 'normal', $link); do_action('do_meta_boxes', 'link', 'advanced', $link); do_action('do_meta_boxes', 'link', 'side', $link); +add_screen_option('layout_columns', array('max' => 2) ); + add_contextual_help($current_screen, '

' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link’s web address and name (the text you want to display on your site as the link) are required fields.' ) . '

' . '

' . __( 'The boxes for link name, web address, and description have fixed positions, while the others may be repositioned using drag and drop. You can also hide boxes you don’t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '

' . diff --git a/wp-admin/edit-tags.php b/wp-admin/edit-tags.php index e106efd019..1bed218539 100644 --- a/wp-admin/edit-tags.php +++ b/wp-admin/edit-tags.php @@ -22,6 +22,8 @@ if ( 'post' != $post_type ) { $submenu_file = "edit-tags.php?taxonomy=$taxonomy"; } +add_screen_option( 'per_page', array('label' => $title, 'default' => 20, 'option' => 'edit_' . $tax->name . '_per_page') ); + switch ( $wp_list_table->current_action() ) { case 'add-tag': diff --git a/wp-admin/edit.php b/wp-admin/edit.php index fb622fe76c..fdf92fa76c 100644 --- a/wp-admin/edit.php +++ b/wp-admin/edit.php @@ -163,6 +163,8 @@ if ( 'post' == $post_type ) { ); } +add_screen_option( 'per_page', array('label' => $title, 'default' => 20) ); + require_once('./admin-header.php'); ?>
diff --git a/wp-admin/includes/dashboard.php b/wp-admin/includes/dashboard.php index a53130c860..ccd143fc19 100644 --- a/wp-admin/includes/dashboard.php +++ b/wp-admin/includes/dashboard.php @@ -16,6 +16,7 @@ function wp_dashboard_setup() { global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; $wp_dashboard_control_callbacks = array(); + $screen = get_current_screen(); $update = false; $widget_options = get_option( 'dashboard_widget_options' ); @@ -25,42 +26,47 @@ function wp_dashboard_setup() { /* Register Widgets and Controls */ // Right Now - wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); + if ( is_blog_admin() && current_user_can('edit_posts') ) + wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); // Recent Comments Widget - if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { - $update = true; - $widget_options['dashboard_recent_comments'] = array( - 'items' => 5, - ); + if ( is_blog_admin() && current_user_can('moderate_comments') ) { + if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { + $update = true; + $widget_options['dashboard_recent_comments'] = array( + 'items' => 5, + ); + } + $recent_comments_title = __( 'Recent Comments' ); + wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); } - $recent_comments_title = __( 'Recent Comments' ); - wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); // Incoming Links Widget - if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { - $update = true; - $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; - $widget_options['dashboard_incoming_links'] = array( - 'home' => get_option('home'), - 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), - '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') ) ), - 'items' => $num_items, - 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false - ); + if ( is_blog_admin() && current_user_can('publish_posts') ) { + if ( !isset( $widget_options['dashboard_incoming_links'] ) || !isset( $widget_options['dashboard_incoming_links']['home'] ) || $widget_options['dashboard_incoming_links']['home'] != get_option('home') ) { + $update = true; + $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; + $widget_options['dashboard_incoming_links'] = array( + 'home' => get_option('home'), + 'link' => apply_filters( 'dashboard_incoming_links_link', 'http://blogsearch.google.com/blogsearch?scoring=d&partner=wordpress&q=link:' . trailingslashit( get_option('home') ) ), + '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') ) ), + 'items' => $num_items, + 'show_date' => isset($widget_options['dashboard_incoming_links']['show_date']) ? $widget_options['dashboard_incoming_links']['show_date'] : false + ); + } + wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' ); } - wp_add_dashboard_widget( 'dashboard_incoming_links', __( 'Incoming Links' ), 'wp_dashboard_incoming_links', 'wp_dashboard_incoming_links_control' ); // WP Plugins Widget - if ( current_user_can( 'install_plugins' ) ) + if ( is_blog_admin() && current_user_can( 'install_plugins' ) ) wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' ); // QuickPress Widget - if ( current_user_can('edit_posts') ) + if ( is_blog_admin() && current_user_can('edit_posts') ) wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' ); // Recent Drafts - if ( current_user_can('edit_posts') ) + if ( is_blog_admin() && current_user_can('edit_posts') ) wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' ); // Primary feed (Dev Blog) Widget @@ -115,28 +121,32 @@ function wp_dashboard_setup() { if ( $update ) update_option( 'dashboard_widget_options', $widget_options ); - do_action('do_meta_boxes', 'dashboard', 'normal', ''); - do_action('do_meta_boxes', 'dashboard', 'side', ''); + do_action('do_meta_boxes', $screen->id, 'normal', ''); + do_action('do_meta_boxes', $screen->id, 'side', ''); } function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) { + $screen = get_current_screen(); global $wp_dashboard_control_callbacks; if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { $wp_dashboard_control_callbacks[$widget_id] = $control_callback; if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); $widget_name .= ' ' . __( 'Cancel' ) . ''; - add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', 'dashboard', 'normal', 'core' ); + add_meta_box( $widget_id, $widget_name, '_wp_dashboard_control_callback', $screen->id, 'normal', 'core' ); return; } list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); $widget_name .= ' ' . __( 'Configure' ) . ''; } - $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); + if ( is_user_admin() ) + $side_widgets = array(); + else + $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); $location = 'normal'; if ( in_array($widget_id, $side_widgets) ) $location = 'side'; - add_meta_box( $widget_id, $widget_name , $callback, 'dashboard', $location, 'core' ); + add_meta_box( $widget_id, $widget_name , $callback, $screen->id, $location, 'core' ); } function _wp_dashboard_control_callback( $dashboard, $meta_box ) { @@ -155,6 +165,8 @@ function _wp_dashboard_control_callback( $dashboard, $meta_box ) { function wp_dashboard() { global $screen_layout_columns; + $screen = get_current_screen(); + $hide2 = $hide3 = $hide4 = ''; switch ( $screen_layout_columns ) { case 4: @@ -176,16 +188,16 @@ function wp_dashboard() {
\n"; - do_meta_boxes( 'dashboard', 'normal', '' ); + do_meta_boxes( $screen->id, 'normal', '' ); echo "\t
\n"; - do_meta_boxes( 'dashboard', 'side', '' ); + do_meta_boxes( $screen->id, 'side', '' ); echo "\t
\n"; - do_meta_boxes( 'dashboard', 'column3', '' ); + do_meta_boxes( $screen->id, 'column3', '' ); echo "\t
\n"; - do_meta_boxes( 'dashboard', 'column4', '' ); + do_meta_boxes( $screen->id, 'column4', '' ); ?>
diff --git a/wp-admin/includes/default-list-tables.php b/wp-admin/includes/default-list-tables.php index 844c108c15..76062db812 100644 --- a/wp-admin/includes/default-list-tables.php +++ b/wp-admin/includes/default-list-tables.php @@ -2719,7 +2719,7 @@ class WP_Sites_Table extends WP_List_Table { function WP_Sites_Table() { parent::WP_List_Table( array( - 'screen' => 'ms-sites', + 'screen' => 'sites-network', 'plural' => 'sites', ) ); } @@ -2734,7 +2734,7 @@ class WP_Sites_Table extends WP_List_Table { $mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; - $per_page = $this->get_items_per_page( 'ms_sites_per_page' ); + $per_page = $this->get_items_per_page( 'sites_network_per_page' ); $pagenum = $this->get_pagenum(); @@ -3007,7 +3007,7 @@ class WP_MS_Users_Table extends WP_List_Table { function WP_MS_Users_Table() { parent::WP_List_Table( array( - 'screen' => 'ms-users', + 'screen' => 'users-network', ) ); } @@ -3024,7 +3024,7 @@ class WP_MS_Users_Table extends WP_List_Table { $usersearch = isset( $_REQUEST['s'] ) ? $_REQUEST['s'] : ''; - $users_per_page = $this->get_items_per_page( 'ms_users_per_page' ); + $users_per_page = $this->get_items_per_page( 'users_network_per_page' ); $paged = $this->get_pagenum(); diff --git a/wp-admin/includes/menu.php b/wp-admin/includes/menu.php index 8222d1ae3e..84fc522734 100644 --- a/wp-admin/includes/menu.php +++ b/wp-admin/includes/menu.php @@ -9,6 +9,8 @@ if ( is_network_admin() ) do_action('_network_admin_menu'); +elseif ( is_user_admin() ) + do_action('_user_admin_menu'); else do_action('_admin_menu'); @@ -89,6 +91,8 @@ unset($id, $data, $subs, $first_sub, $old_parent, $new_parent); if ( is_network_admin() ) do_action('network_admin_menu', ''); +elseif ( is_user_admin() ) + do_action('user_admin_menu', ''); else do_action('admin_menu', ''); diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index dac85370ea..133ecdbe20 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -343,9 +343,9 @@ function set_screen_options() { switch ( $map_option ) { case 'edit_per_page': - case 'ms_sites_per_page': + case 'sites_network_per_page': case 'users_per_page': - case 'ms_users_per_page': + case 'users_network_per_page': case 'edit_comments_per_page': case 'upload_per_page': case 'edit_tags_per_page': diff --git a/wp-admin/includes/ms.php b/wp-admin/includes/ms.php index 742a3cabc5..777989c8ec 100644 --- a/wp-admin/includes/ms.php +++ b/wp-admin/includes/ms.php @@ -502,29 +502,14 @@ function redirect_user_to_blog() { $c ++; $blog = get_active_blog_for_user( get_current_user_id() ); - $dashboard_blog = get_dashboard_blog(); + if ( is_object( $blog ) ) { wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" exit; + } else { + wp_redirect( user_admin_url( '?c=' . $c ) ); // redirect and count to 5, "just in case" } - /* - If the user is a member of only 1 blog and the user's primary_blog isn't set to that blog, - then update the primary_blog record to match the user's blog - */ - $blogs = get_blogs_of_user( get_current_user_id() ); - - if ( !empty( $blogs ) ) { - foreach( $blogs as $blogid => $blog ) { - if ( $blogid != $dashboard_blog->blog_id && get_user_meta( get_current_user_id() , 'primary_blog', true ) == $dashboard_blog->blog_id ) { - update_user_meta( get_current_user_id(), 'primary_blog', $blogid ); - continue; - } - } - $blog = get_blog_details( get_user_meta( get_current_user_id(), 'primary_blog', true ) ); - wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); - exit; - } wp_die( __( 'You do not have sufficient permissions to access this page.' ) ); } add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 ); diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index c6ca29bf13..cd56356313 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1390,6 +1390,9 @@ function favorite_actions( $screen = null ) { if ( is_string($screen) ) $screen = convert_to_screen($screen); + if ( $screen->is_user ) + return; + if ( isset($screen->post_type) ) { $post_type_object = get_post_type_object($screen->post_type); if ( 'add' != $screen->action ) @@ -1635,7 +1638,7 @@ function convert_to_screen( $screen ) { } function screen_meta($screen) { - global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table; + global $wp_meta_boxes, $_wp_contextual_help, $wp_list_table, $wp_current_screen_options; if ( is_string($screen) ) $screen = convert_to_screen($screen); @@ -1669,7 +1672,10 @@ function screen_meta($screen) { $show_screen = true; break; } - if( ! empty( $settings ) ) + if ( ! empty( $settings ) ) + $show_screen = true; + + if ( !empty($wp_current_screen_options) ) $show_screen = true; ?> @@ -1796,29 +1802,30 @@ function plugins_search_help() { } function screen_layout($screen) { - global $screen_layout_columns; + global $screen_layout_columns, $wp_current_screen_options; if ( is_string($screen) ) $screen = convert_to_screen($screen); - $columns = array('dashboard' => 4, 'link' => 2); + // Back compat for plugins using the filter instead of add_screen_option() + $columns = apply_filters('screen_layout_columns', array(), $screen->id, $screen); + if ( !empty($columns) && isset($columns[$screen->id]) ) + add_screen_option('layout_columns', array('max' => $columns[$screen->id]) ); - // Add custom post types - foreach ( get_post_types( array('show_ui' => true) ) as $post_type ) - $columns[$post_type] = 2; - - $columns = apply_filters('screen_layout_columns', $columns, $screen->id, $screen); - - if ( !isset($columns[$screen->id]) ) { + if ( !isset($wp_current_screen_options['layout_columns']) ) { $screen_layout_columns = 0; return ''; - } + } $screen_layout_columns = get_user_option("screen_layout_$screen->id"); - $num = $columns[$screen->id]; + $num = $wp_current_screen_options['layout_columns']['max']; - if ( ! $screen_layout_columns ) + if ( ! $screen_layout_columns ) { + if ( isset($wp_current_screen_options['layout_columns']['default']) ) + $screen_layout_columns = $wp_current_screen_options['layout_columns']['default']; + else $screen_layout_columns = 2; + } $i = 1; $return = '
' . __('Screen Layout') . "
\n
" . __('Number of Columns:') . "\n"; @@ -1830,55 +1837,45 @@ function screen_layout($screen) { return $return; } +/** + * Register and configure an admin screen option + * + * @since 3.1.0 + * + * @param string $option An option name. + * @param mixed $args Option dependent arguments + * @return void + */ +function add_screen_option( $option, $args = array() ) { + global $wp_current_screen_options; + + if ( !isset($wp_current_screen_options) ) + $wp_current_screen_options = array(); + + $wp_current_screen_options[$option] = $args; +} + function screen_options($screen) { + global $wp_current_screen_options; + if ( is_string($screen) ) $screen = convert_to_screen($screen); - switch ( $screen->base ) { - case 'edit': - case 'edit-pages': - $post_type = 'post'; - if ( isset($_GET['post_type']) && in_array( $_GET['post_type'], get_post_types( array( 'show_ui' => true ) ) ) ) - $post_type = $_GET['post_type']; - $post_type_object = get_post_type_object($post_type); - $per_page_label = $post_type_object->labels->name; - break; - case 'ms-sites': - $per_page_label = _x( 'Sites', 'sites per page (screen options)' ); - break; - case 'users': - case 'ms-users': - $per_page_label = _x( 'Users', 'users per page (screen options)' ); - break; - case 'edit-comments': - $per_page_label = _x( 'Comments', 'comments per page (screen options)' ); - break; - case 'upload': - $per_page_label = _x( 'Media items', 'items per page (screen options)' ); - break; - case 'edit-tags': - global $tax; - $per_page_label = $tax->labels->name; - break; - case 'plugins': - $per_page_label = _x( 'Plugins', 'plugins per page (screen options)' ); - break; - default: - return ''; - } + if ( !isset($wp_current_screen_options['per_page']) ) + return ''; - $option = str_replace( '-', '_', "{$screen->id}_per_page" ); - if ( 'edit_tags_per_page' == $option ) { - if ( 'category' == $tax->name ) - $option = 'categories_per_page'; - elseif ( 'post_tag' != $tax->name ) - $option = 'edit_' . $tax->name . '_per_page'; + $per_page_label = $wp_current_screen_options['per_page']['label']; + + if ( empty($wp_current_screen_options['per_page']['option']) ) { + $option = str_replace( '-', '_', "{$screen->id}_per_page" ); + } else { + $option = $wp_current_screen_options['per_page']['option']; } $per_page = (int) get_user_option( $option ); if ( empty( $per_page ) || $per_page < 1 ) { - if ( 'plugins' == $screen->id ) - $per_page = 999; + if ( isset($wp_current_screen_options['per_page']['default']) ) + $per_page = $wp_current_screen_options['per_page']['default']; else $per_page = 20; } @@ -1997,6 +1994,22 @@ function compression_test() { is_network = is_network_admin() ? true : false; + $current_screen->is_user = is_user_admin() ? true : false; + + if ( $current_screen->is_network ) { + $current_screen->base .= '-network'; + $current_screen->id .= '-network'; + } elseif ( $current_screen->is_user ) { + $current_screen->base .= '-user'; + $current_screen->id .= '-user'; + } $current_screen = apply_filters('current_screen', $current_screen); } diff --git a/wp-admin/index-extra.php b/wp-admin/index-extra.php index 22df0d67dc..efa2526c55 100644 --- a/wp-admin/index-extra.php +++ b/wp-admin/index-extra.php @@ -10,7 +10,7 @@ require_once( './admin.php' ); /** Load WordPress Administration Dashboard API */ -require( './includes/dashboard.php' ); +require(ABSPATH . 'wp-admin/includes/dashboard.php' ); @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) ); send_nosniff_header(); diff --git a/wp-admin/index.php b/wp-admin/index.php index 789835c99c..572cca8415 100644 --- a/wp-admin/index.php +++ b/wp-admin/index.php @@ -24,6 +24,11 @@ add_thickbox(); $title = __('Dashboard'); $parent_file = 'index.php'; +if ( is_user_admin() ) + add_screen_option('layout_columns', array('max' => 4, 'default' => 1) ); +else + add_screen_option('layout_columns', array('max' => 4, 'default' => 2) ); + add_contextual_help($current_screen, '

' . __('Welcome to your WordPress Dashboard! You will find helpful tips in the Help tab of each screen to assist you as you get to know the application.') . '

' . @@ -42,7 +47,7 @@ add_contextual_help($current_screen, '

' . __('Support Forums') . '

' ); -require_once('./admin-header.php'); +include (ABSPATH . 'wp-admin/admin-header.php'); $today = current_time('mysql', 1); ?> diff --git a/wp-admin/js/dashboard.dev.js b/wp-admin/js/dashboard.dev.js index 4969113ccc..a305467629 100644 --- a/wp-admin/js/dashboard.dev.js +++ b/wp-admin/js/dashboard.dev.js @@ -42,7 +42,7 @@ jQuery(document).ready( function($) { }; ajaxPopulateWidgets(); - postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } ); + postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } ); /* QuickPress */ quickPressLoad = function() { diff --git a/wp-admin/js/dashboard.js b/wp-admin/js/dashboard.js index f391e1342e..4450ab3a8e 100644 --- a/wp-admin/js/dashboard.js +++ b/wp-admin/js/dashboard.js @@ -1 +1 @@ -var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins","dashboard_quick_press"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load("index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_plugins"==g&&a.isFunction(tb_init)){tb_init("#dashboard_plugins a.thickbox")}if("dashboard_quick_press"==g&&a.isFunction(tb_init)){tb_init("#dashboard_quick_press a.thickbox");quickPressLoad()}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles("dashboard",{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").next("p").remove();a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})}}); \ No newline at end of file +var ajaxWidgets,ajaxPopulateWidgets,quickPressLoad;jQuery(document).ready(function(a){ajaxWidgets=["dashboard_incoming_links","dashboard_primary","dashboard_secondary","dashboard_plugins","dashboard_quick_press"];ajaxPopulateWidgets=function(b){show=function(g,c){var f,d=a("#"+g+" div.inside:visible").find(".widget-loading");if(d.length){f=d.parent();setTimeout(function(){f.load("index-extra.php?jax="+g,"",function(){f.hide().slideDown("normal",function(){a(this).css("display","");if("dashboard_plugins"==g&&a.isFunction(tb_init)){tb_init("#dashboard_plugins a.thickbox")}if("dashboard_quick_press"==g&&a.isFunction(tb_init)){tb_init("#dashboard_quick_press a.thickbox");quickPressLoad()}})})},c*500)}};if(b){b=b.toString();if(a.inArray(b,ajaxWidgets)!=-1){show(b,0)}}else{a.each(ajaxWidgets,function(c){show(this,c)})}};ajaxPopulateWidgets();postboxes.add_postbox_toggles(pagenow,{pbshow:ajaxPopulateWidgets});quickPressLoad=function(){var b=a("#quickpost-action"),c;c=a("#quick-press").submit(function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","visible");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","disabled");if("post"==b.val()){b.val("post-quickpress-publish")}a("#dashboard_quick_press div.inside").load(c.attr("action"),c.serializeArray(),function(){a("#dashboard_quick_press #publishing-action img.waiting").css("visibility","hidden");a('#quick-press .submit input[type="submit"], #quick-press .submit input[type="reset"]').attr("disabled","");a("#dashboard_quick_press ul").next("p").remove();a("#dashboard_quick_press ul").find("li").each(function(){a("#dashboard_recent_drafts ul").prepend(this)}).end().remove();tb_init("a.thickbox");quickPressLoad()});return false});a("#publish").click(function(){b.val("post-quickpress-publish")})}}); \ No newline at end of file diff --git a/wp-admin/menu.php b/wp-admin/menu.php index 192fa14bb3..7d92deca95 100644 --- a/wp-admin/menu.php +++ b/wp-admin/menu.php @@ -232,6 +232,6 @@ $compat = array( 'themes' => 'appearance', ); -require(ABSPATH . 'wp-admin/includes/menu.php'); +require_once(ABSPATH . 'wp-admin/includes/menu.php'); ?> diff --git a/wp-admin/network/edit.php b/wp-admin/network/edit.php index a5e065cc1f..e041aff1a7 100644 --- a/wp-admin/network/edit.php +++ b/wp-admin/network/edit.php @@ -52,8 +52,8 @@ function confirm_delete_users( $users ) { $user_dropdown = " - -
- New users are added to this site as the user role defined below if they don’t have a site. Leave blank for the main site. Users with the Subscriber role on the old site will be moved to the new site if changed. The new site will be created if it does not exist.' ); ?> - - - - - - -
- - - - - -
-
- - id, 'feed/' ) ) - echo __( 'A good one to use would be the feed from your main site: ' ) . esc_url( get_home_url( $current_site->id, 'feed/' ) ) ?> - -

diff --git a/wp-admin/network/sites.php b/wp-admin/network/sites.php index 004fb89b28..85abd151fd 100644 --- a/wp-admin/network/sites.php +++ b/wp-admin/network/sites.php @@ -18,6 +18,8 @@ $wp_list_table->check_permissions(); $title = __( 'Sites' ); $parent_file = 'sites.php'; +add_screen_option( 'per_page', array('label' => _x( 'Sites', 'sites per page (screen options)' )) ); + if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) { add_contextual_help($current_screen, '

' . __('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).') . '

' . @@ -109,7 +111,7 @@ switch ( $action ) { require_once( '../admin-header.php' ); ?>
- +

-

@@ -347,7 +349,7 @@ switch ( $action ) { ?>
- +

diff --git a/wp-admin/network/upgrade.php b/wp-admin/network/upgrade.php index 9ea1e6b783..a56ba2579d 100644 --- a/wp-admin/network/upgrade.php +++ b/wp-admin/network/upgrade.php @@ -32,7 +32,7 @@ if ( ! current_user_can( 'manage_network' ) ) wp_die( __( 'You do not have permission to access this page.' ) ); echo '
'; -screen_icon(); +screen_icon('tools'); echo '

' . __( 'Update Network' ) . '

'; $action = isset($_GET['action']) ? $_GET['action'] : 'show'; diff --git a/wp-admin/network/users.php b/wp-admin/network/users.php index c925ae0842..74e505fff2 100644 --- a/wp-admin/network/users.php +++ b/wp-admin/network/users.php @@ -16,6 +16,8 @@ $wp_list_table->prepare_items(); $title = __( 'Users' ); $parent_file = 'users.php'; +add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); + add_contextual_help($current_screen, '

' . __('This table shows all users across the network and the sites to which they are assigned.') . '

' . '

' . __('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.') . '

' . diff --git a/wp-admin/plugins.php b/wp-admin/plugins.php index 03bd4d50a0..85d506a78b 100644 --- a/wp-admin/plugins.php +++ b/wp-admin/plugins.php @@ -290,6 +290,8 @@ $wp_list_table->prepare_items(); wp_enqueue_script('plugin-install'); add_thickbox(); +add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999) ); + add_contextual_help($current_screen, '

' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '

' . '

' . sprintf(__('You can find additional plugins for your site by using the Plugin Browser/Installer functionality or by browsing the WordPress Plugin Directory directly and installing new plugins manually. To manually install a plugin you generally just need to upload the plugin file into your /wp-content/plugins directory. Once a plugin has been installed, you can activate it here.'), 'plugin-install.php', 'http://wordpress.org/extend/plugins/') . '

' . diff --git a/wp-admin/upload.php b/wp-admin/upload.php index 4d864eb9a2..66b9f6f16b 100644 --- a/wp-admin/upload.php +++ b/wp-admin/upload.php @@ -134,6 +134,8 @@ wp_enqueue_script( 'wp-ajax-response' ); wp_enqueue_script( 'jquery-ui-draggable' ); wp_enqueue_script( 'media' ); +add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) ); + add_contextual_help( $current_screen, '

' . __('All the files you’ve uploaded are listed in the Media Library, with the most recent uploads listed first. You can use the Screen Options tab to customize the display of this screen.') . '

' . '

' . __('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.') . '

' . diff --git a/wp-admin/user-edit.php b/wp-admin/user-edit.php index 7f0de03e0d..c108039805 100644 --- a/wp-admin/user-edit.php +++ b/wp-admin/user-edit.php @@ -31,7 +31,11 @@ if ( current_user_can('edit_users') && !IS_PROFILE_PAGE ) $submenu_file = 'users.php'; else $submenu_file = 'profile.php'; -$parent_file = 'users.php'; + +if ( current_user_can('edit_users') && !is_user_admin() ) + $parent_file = 'users.php'; +else + $parent_file = 'profile.php'; // contextual help - choose Help on the top right of admin panel to preview this. add_contextual_help($current_screen, diff --git a/wp-admin/user/admin.php b/wp-admin/user/admin.php new file mode 100644 index 0000000000..7d9b11583b --- /dev/null +++ b/wp-admin/user/admin.php @@ -0,0 +1,10 @@ + diff --git a/wp-admin/user/index-extra.php b/wp-admin/user/index-extra.php new file mode 100644 index 0000000000..d778541bcb --- /dev/null +++ b/wp-admin/user/index-extra.php @@ -0,0 +1,5 @@ + \ No newline at end of file diff --git a/wp-admin/user/profile.php b/wp-admin/user/profile.php new file mode 100644 index 0000000000..98f5db702d --- /dev/null +++ b/wp-admin/user/profile.php @@ -0,0 +1,5 @@ +check_permissions(); $title = __('Users'); $parent_file = 'users.php'; +add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) ); + // contextual help - choose Help on the top right of admin panel to preview this. add_contextual_help($current_screen, '

' . __('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.') . '

' . diff --git a/wp-includes/admin-bar.php b/wp-includes/admin-bar.php index eb57d1713d..3a05c89294 100644 --- a/wp-includes/admin-bar.php +++ b/wp-includes/admin-bar.php @@ -110,14 +110,6 @@ function wp_admin_bar_my_blogs_menu() { if ( !is_object( $wp_admin_bar ) ) return false; - /* Remove the global dashboard */ - if ( is_multisite() ) { - foreach ( (array) $wp_admin_bar->user->blogs as $key => $blog ) { - if ( get_dashboard_blog() == $blog->domain ) - unset( $wp_admin_bar->user->blogs[$key] ); - } - } - /* Add the 'My Dashboards' menu if the user has more than one blog. */ if ( count( $wp_admin_bar->user->blogs ) > 1 ) { $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Blogs' ), 'href' => $wp_admin_bar->user->account_domain ) ); diff --git a/wp-includes/admin-bar/admin-bar-class.php b/wp-includes/admin-bar/admin-bar-class.php index 91e30dd5fd..5b9774b228 100644 --- a/wp-includes/admin-bar/admin-bar-class.php +++ b/wp-includes/admin-bar/admin-bar-class.php @@ -15,7 +15,7 @@ class WP_Admin_Bar { $this->user->blogs = get_ordered_blogs_of_user( $current_user->id ); if ( is_multisite() ) { $this->user->active_blog = get_active_blog_for_user( $current_user->id ); - $this->user->domain = ( $this->user->active_blog == 'username only' ) ? get_dashboard_blog() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); + $this->user->domain = empty( $this->user->active_blog ) ? user_admin_url() : trailingslashit( get_home_url( $this->user->active_blog->blog_id ) ); $this->user->account_domain = $this->user->domain; } else { $this->user->active_blog = $this->user->blogs[$blog_id]; diff --git a/wp-includes/capabilities.php b/wp-includes/capabilities.php index 385899412f..959fae5440 100644 --- a/wp-includes/capabilities.php +++ b/wp-includes/capabilities.php @@ -737,6 +737,7 @@ class WP_User { // Must have ALL requested caps $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args ); + $capabilities['exist'] = true; // Everyone is allowed to exist foreach ( (array) $caps as $cap ) { //echo "Checking cap $cap
"; if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] ) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 0d458ef980..db5e2e8630 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -447,7 +447,7 @@ function wp_load_core_site_options( $site_id = null ) { if ( empty($site_id) ) $site_id = $wpdb->siteid; - $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'dashboard_blog', 'can_compress_scripts', 'global_terms_enabled' ); + $core_options = array('site_name', 'siteurl', 'active_sitewide_plugins', '_site_transient_timeout_theme_roots', '_site_transient_theme_roots', 'site_admins', 'can_compress_scripts', 'global_terms_enabled' ); $core_options_in = "'" . implode("', '", $core_options) . "'"; $options = $wpdb->get_results( $wpdb->prepare("SELECT meta_key, meta_value FROM $wpdb->sitemeta WHERE meta_key IN ($core_options_in) AND site_id = %d", $site_id) ); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 44eb5a87c7..768fe63123 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -2129,6 +2129,25 @@ function network_admin_url( $path = '', $scheme = 'admin' ) { return apply_filters('network_admin_url', $url, $path); } +/** + * Retrieve the url to the admin area for the current user. + * + * @package WordPress + * @since 3.0.0 + * + * @param string $path Optional path relative to the admin url + * @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. + * @return string Admin url link with optional path appended +*/ +function user_admin_url( $path = '', $scheme = 'admin' ) { + $url = network_site_url('wp-admin/user/', $scheme); + + if ( !empty($path) && is_string($path) && strpos($path, '..') === false ) + $url .= ltrim($path, '/'); + + return apply_filters('user_admin_url', $url, $path); +} + /** * Retrieve the url to the admin area for either the current blog or the network depending on context. * @@ -2142,6 +2161,8 @@ function network_admin_url( $path = '', $scheme = 'admin' ) { function self_admin_url($path = '', $scheme = 'admin') { if ( is_network_admin() ) return network_admin_url($path, $scheme); + elseif ( is_user_admin() ) + return user_admin_url($path, $scheme); else return admin_url($path, $scheme); } diff --git a/wp-includes/load.php b/wp-includes/load.php index c4fdc476c0..37fa7d0840 100644 --- a/wp-includes/load.php +++ b/wp-includes/load.php @@ -620,6 +620,22 @@ function is_network_admin() { return false; } +/** + * Whether the current request is for a user admin screen /wp-admin/user/ + * + * Does not inform on whether the user is an admin! Use capability checks to + * tell if the user should be accessing a section or not. + * + * @since 3.1.0 + * + * @return bool True if inside WordPress user administration pages. + */ +function is_user_admin() { + if ( defined( 'WP_USER_ADMIN' ) ) + return WP_USER_ADMIN; + return false; +} + /** * Whether Multisite support is enabled * diff --git a/wp-includes/ms-functions.php b/wp-includes/ms-functions.php index 1468621d3a..b3ada31139 100644 --- a/wp-includes/ms-functions.php +++ b/wp-includes/ms-functions.php @@ -59,7 +59,6 @@ function get_admin_users_for_domain( $sitedomain = '', $path = '' ) { * * @since MU 1.0 * @uses get_blogs_of_user() - * @uses get_dashboard_blog() * @uses add_user_to_blog() * @uses update_user_meta() * @uses wp_cache_delete() @@ -72,30 +71,29 @@ function get_admin_users_for_domain( $sitedomain = '', $path = '' ) { function get_active_blog_for_user( $user_id ) { global $wpdb; $blogs = get_blogs_of_user( $user_id ); - if ( empty( $blogs ) ) { - $details = get_dashboard_blog(); - add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); - update_user_meta( $user_id, 'primary_blog', $details->blog_id ); - wp_cache_delete( $user_id, 'users' ); - return $details; - } + if ( empty( $blogs ) ) + return null; + + if ( !is_multisite() ) + return $blogs[$wpdb->blogid]; $primary_blog = get_user_meta( $user_id, 'primary_blog', true ); - $details = get_dashboard_blog(); + $first_blog = current($blogs); if ( $primary_blog ) { - if ( isset( $blogs[ $primary_blog ] ) == false ) { - add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); - update_user_meta( $user_id, 'primary_blog', $details->blog_id ); - wp_cache_delete( $user_id, 'users' ); + if ( ! isset( $blogs[ $primary_blog ] ) ) { + add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' ); + update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id ); + $primary = $first_blog; } else { - $details = get_blog_details( $primary_blog ); + $primary = get_blog_details( $primary_blog ); } } else { - add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog - update_user_meta( $user_id, 'primary_blog', $details->blog_id ); + add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' ); + update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id ); + $primary = $first_blog; } - if ( ( is_object( $details ) == false ) || ( is_object( $details ) && $details->archived == 1 || $details->spam == 1 || $details->deleted == 1 ) ) { + if ( ( ! is_object( $primary ) ) || ( is_object( $primary ) && $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) { $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs. $ret = false; if ( is_array( $blogs ) && count( $blogs ) > 0 ) { @@ -105,30 +103,19 @@ function get_active_blog_for_user( $user_id ) { $details = get_blog_details( $blog_id ); if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { $ret = $blog; - $changed = false; - if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) { + if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id ) update_user_meta( $user_id, 'primary_blog', $blog_id ); - $changed = true; - } - if ( !get_user_meta($user_id , 'source_domain', true) ) { + if ( !get_user_meta($user_id , 'source_domain', true) ) update_user_meta( $user_id, 'source_domain', $blog->domain ); - $changed = true; - } - if ( $changed ) - wp_cache_delete( $user_id, 'users' ); break; } } } else { - // Should never get here - $dashboard_blog = get_dashboard_blog(); - add_user_to_blog( $dashboard_blog->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog - update_user_meta( $user_id, 'primary_blog', $dashboard_blog->blog_id ); - return $dashboard_blog; + return null; } return $ret; } else { - return $details; + return $primary; } } @@ -840,12 +827,6 @@ function wpmu_activate_signup($key) { return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup); wpmu_welcome_user_notification($user_id, $password, $meta); - $user_site = get_site_option( 'dashboard_blog', $current_site->blog_id ); - - if ( $user_site == false ) - add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); - else - add_user_to_blog( $user_site, $user_id, get_site_option( 'default_user_role', 'subscriber' ) ); add_new_user_to_blog( $user_id, $user_email, $meta ); do_action('wpmu_activate_user', $user_id, $password, $meta); @@ -926,7 +907,7 @@ function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id add_option( 'WPLANG', get_site_option( 'WPLANG' ) ); update_option( 'blog_public', (int)$meta['public'] ); - if ( !is_super_admin() && get_user_meta( $user_id, 'primary_blog', true ) == get_site_option( 'dashboard_blog', 1 ) ) + if ( !is_super_admin() && ! get_user_meta( $user_id, 'primary_blog', true ) ) update_user_meta( $user_id, 'primary_blog', $blog_id ); restore_current_blog(); @@ -1460,19 +1441,6 @@ function update_blog_public( $old_value, $value ) { } add_action('update_option_blog_public', 'update_blog_public', 10, 2); -/* Redirect all hits to "dashboard" blog to wp-admin/ Dashboard. */ -function redirect_mu_dashboard() { - global $current_site, $current_blog; - - $dashboard_blog = get_dashboard_blog(); - if ( $current_blog->blog_id == $dashboard_blog->blog_id && $dashboard_blog->blog_id != $current_site->blog_id ) { - $protocol = ( is_ssl() ? 'https://' : 'http://' ); - wp_redirect( $protocol . $dashboard_blog->domain . trailingslashit( $dashboard_blog->path ) . 'wp-admin/' ); - die(); - } -} -add_action( 'template_redirect', 'redirect_mu_dashboard' ); - function get_dashboard_blog() { if ( $blog = get_site_option( 'dashboard_blog' ) ) return get_blog_details( $blog ); diff --git a/wp-includes/pluggable.php b/wp-includes/pluggable.php index ba13617835..d444adc5b5 100644 --- a/wp-includes/pluggable.php +++ b/wp-includes/pluggable.php @@ -81,7 +81,7 @@ function get_currentuserinfo() { return; if ( ! $user = wp_validate_auth_cookie() ) { - if ( is_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { + if ( is_blog_admin() || is_network_admin() || empty($_COOKIE[LOGGED_IN_COOKIE]) || !$user = wp_validate_auth_cookie($_COOKIE[LOGGED_IN_COOKIE], 'logged_in') ) { wp_set_current_user(0); return false; } @@ -775,7 +775,12 @@ function auth_redirect() { } } - if ( $user_id = wp_validate_auth_cookie( '', apply_filters( 'auth_redirect_scheme', '' ) ) ) { + if ( is_user_admin() ) + $scheme = 'logged_in'; + else + $scheme = apply_filters( 'auth_redirect_scheme', '' ); + + if ( $user_id = wp_validate_auth_cookie( '', $scheme) ) { do_action('auth_redirect', $user_id); // If the user wants ssl but the session is not ssl, redirect. diff --git a/wp-includes/vars.php b/wp-includes/vars.php index 7a62c892ad..67d8d70d48 100644 --- a/wp-includes/vars.php +++ b/wp-includes/vars.php @@ -15,7 +15,12 @@ // On which page are we ? if ( is_admin() ) { // wp-admin pages are checked more carefully - preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); + if ( is_network_admin() ) + preg_match('#/wp-admin/network/?(.*?)$#i', $PHP_SELF, $self_matches); + elseif ( is_user_admin() ) + preg_match('#/wp-admin/user/?(.*?)$#i', $PHP_SELF, $self_matches); + else + preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches); $pagenow = $self_matches[1]; $pagenow = trim($pagenow, '/'); $pagenow = preg_replace('#\?.*?$#', '', $pagenow); diff --git a/wp-login.php b/wp-login.php index 7d8efe8f00..08d95c87c3 100644 --- a/wp-login.php +++ b/wp-login.php @@ -572,8 +572,13 @@ default:
has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) + + // If the user doesn't belong to a blog, send them to user admin. If the user can't edit posts, send them to their profile. + if ( is_multisite() && !get_active_blog_for_user($user->id) ) + $redirect_to = user_admin_url(); + elseif ( !is_multisite() && !$user->has_cap('read') ) + $redirect_to = user_admin_url(); + elseif ( !$user->has_cap('edit_posts') && ( empty( $redirect_to ) || $redirect_to == 'wp-admin/' || $redirect_to == admin_url() ) ) $redirect_to = admin_url('profile.php'); wp_safe_redirect($redirect_to); exit();