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

git-svn-id: https://develop.svn.wordpress.org/trunk@15746 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2010-10-07 19:34:18 +00:00
parent 3950973583
commit 9ee8b20f30
42 changed files with 311 additions and 281 deletions

View File

@ -11,11 +11,16 @@
* *
* @since unknown * @since unknown
*/ */
if ( !defined('WP_ADMIN') ) if ( ! defined('WP_ADMIN') )
define('WP_ADMIN', TRUE); define('WP_ADMIN', TRUE);
if ( !defined('WP_NETWORK_ADMIN') ) { if ( ! defined('WP_NETWORK_ADMIN') )
define('WP_NETWORK_ADMIN', FALSE); 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); define('WP_BLOG_ADMIN', TRUE);
} }
@ -97,6 +102,8 @@ else
if ( WP_NETWORK_ADMIN ) if ( WP_NETWORK_ADMIN )
require(ABSPATH . 'wp-admin/network/menu.php'); require(ABSPATH . 'wp-admin/network/menu.php');
elseif ( WP_USER_ADMIN )
require(ABSPATH . 'wp-admin/user/menu.php');
else else
require(ABSPATH . 'wp-admin/menu.php'); require(ABSPATH . 'wp-admin/menu.php');

View File

@ -105,6 +105,8 @@ if ( $post_id )
else else
$title = __('Comments'); $title = __('Comments');
add_screen_option( 'per_page', array('label' => _x( 'Comments', 'comments per page (screen options)' )) );
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>' . 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>' .
'<p>' . __('A yellow row means the comment is waiting for you to moderate it.') . '</p>' . '<p>' . __('A yellow row means the comment is waiting for you to moderate it.') . '</p>' .
'<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>' . '<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>' .

View File

@ -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, 'advanced', $post);
do_action('do_meta_boxes', $post_type, 'side', $post); do_action('do_meta_boxes', $post_type, 'side', $post);
add_screen_option('layout_columns', array('max' => 2) );
if ( 'post' == $post_type ) { if ( 'post' == $post_type ) {
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<p>' . __('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.') . '</p>' . '<p>' . __('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.') . '</p>' .

View File

@ -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', 'advanced', $link);
do_action('do_meta_boxes', 'link', 'side', $link); do_action('do_meta_boxes', 'link', 'side', $link);
add_screen_option('layout_columns', array('max' => 2) );
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link&#8217;s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' . '<p>' . __( 'You can add or edit links on this screen by entering information in each of the boxes. Only the link&#8217;s web address and name (the text you want to display on your site as the link) are required fields.' ) . '</p>' .
'<p>' . __( '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&#8217;t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' . '<p>' . __( '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&#8217;t use in the Screen Options tab, or minimize boxes by clicking on the title bar of the box.' ) . '</p>' .

View File

@ -22,6 +22,8 @@ if ( 'post' != $post_type ) {
$submenu_file = "edit-tags.php?taxonomy=$taxonomy"; $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() ) { switch ( $wp_list_table->current_action() ) {
case 'add-tag': case 'add-tag':

View File

@ -163,6 +163,8 @@ if ( 'post' == $post_type ) {
); );
} }
add_screen_option( 'per_page', array('label' => $title, 'default' => 20) );
require_once('./admin-header.php'); require_once('./admin-header.php');
?> ?>
<div class="wrap"> <div class="wrap">

View File

@ -16,6 +16,7 @@
function wp_dashboard_setup() { function wp_dashboard_setup() {
global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks; global $wp_registered_widgets, $wp_registered_widget_controls, $wp_dashboard_control_callbacks;
$wp_dashboard_control_callbacks = array(); $wp_dashboard_control_callbacks = array();
$screen = get_current_screen();
$update = false; $update = false;
$widget_options = get_option( 'dashboard_widget_options' ); $widget_options = get_option( 'dashboard_widget_options' );
@ -25,9 +26,11 @@ function wp_dashboard_setup() {
/* Register Widgets and Controls */ /* Register Widgets and Controls */
// Right Now // Right Now
if ( is_blog_admin() && current_user_can('edit_posts') )
wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' ); wp_add_dashboard_widget( 'dashboard_right_now', __( 'Right Now' ), 'wp_dashboard_right_now' );
// Recent Comments Widget // Recent Comments Widget
if ( is_blog_admin() && current_user_can('moderate_comments') ) {
if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) { if ( !isset( $widget_options['dashboard_recent_comments'] ) || !isset( $widget_options['dashboard_recent_comments']['items'] ) ) {
$update = true; $update = true;
$widget_options['dashboard_recent_comments'] = array( $widget_options['dashboard_recent_comments'] = array(
@ -36,8 +39,10 @@ function wp_dashboard_setup() {
} }
$recent_comments_title = __( 'Recent Comments' ); $recent_comments_title = __( 'Recent Comments' );
wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' ); wp_add_dashboard_widget( 'dashboard_recent_comments', $recent_comments_title, 'wp_dashboard_recent_comments', 'wp_dashboard_recent_comments_control' );
}
// Incoming Links Widget // Incoming Links Widget
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') ) { 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; $update = true;
$num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10; $num_items = isset($widget_options['dashboard_incoming_links']['items']) ? $widget_options['dashboard_incoming_links']['items'] : 10;
@ -50,17 +55,18 @@ function wp_dashboard_setup() {
); );
} }
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 // 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' ); wp_add_dashboard_widget( 'dashboard_plugins', __( 'Plugins' ), 'wp_dashboard_plugins' );
// QuickPress Widget // 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' ); wp_add_dashboard_widget( 'dashboard_quick_press', __( 'QuickPress' ), 'wp_dashboard_quick_press' );
// Recent Drafts // 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' ); wp_add_dashboard_widget( 'dashboard_recent_drafts', __('Recent Drafts'), 'wp_dashboard_recent_drafts' );
// Primary feed (Dev Blog) Widget // Primary feed (Dev Blog) Widget
@ -115,28 +121,32 @@ function wp_dashboard_setup() {
if ( $update ) if ( $update )
update_option( 'dashboard_widget_options', $widget_options ); update_option( 'dashboard_widget_options', $widget_options );
do_action('do_meta_boxes', 'dashboard', 'normal', ''); do_action('do_meta_boxes', $screen->id, 'normal', '');
do_action('do_meta_boxes', 'dashboard', 'side', ''); do_action('do_meta_boxes', $screen->id, 'side', '');
} }
function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) { function wp_add_dashboard_widget( $widget_id, $widget_name, $callback, $control_callback = null ) {
$screen = get_current_screen();
global $wp_dashboard_control_callbacks; global $wp_dashboard_control_callbacks;
if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) { if ( $control_callback && current_user_can( 'edit_dashboard' ) && is_callable( $control_callback ) ) {
$wp_dashboard_control_callbacks[$widget_id] = $control_callback; $wp_dashboard_control_callbacks[$widget_id] = $control_callback;
if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) { if ( isset( $_GET['edit'] ) && $widget_id == $_GET['edit'] ) {
list($url) = explode( '#', add_query_arg( 'edit', false ), 2 ); list($url) = explode( '#', add_query_arg( 'edit', false ), 2 );
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>'; $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( $url ) . '">' . __( 'Cancel' ) . '</a></span>';
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; return;
} }
list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 ); list($url) = explode( '#', add_query_arg( 'edit', $widget_id ), 2 );
$widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>'; $widget_name .= ' <span class="postbox-title-action"><a href="' . esc_url( "$url#$widget_id" ) . '" class="edit-box open-box">' . __( 'Configure' ) . '</a></span>';
} }
if ( is_user_admin() )
$side_widgets = array();
else
$side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary'); $side_widgets = array('dashboard_quick_press', 'dashboard_recent_drafts', 'dashboard_primary', 'dashboard_secondary');
$location = 'normal'; $location = 'normal';
if ( in_array($widget_id, $side_widgets) ) if ( in_array($widget_id, $side_widgets) )
$location = 'side'; $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 ) { function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
@ -155,6 +165,8 @@ function _wp_dashboard_control_callback( $dashboard, $meta_box ) {
function wp_dashboard() { function wp_dashboard() {
global $screen_layout_columns; global $screen_layout_columns;
$screen = get_current_screen();
$hide2 = $hide3 = $hide4 = ''; $hide2 = $hide3 = $hide4 = '';
switch ( $screen_layout_columns ) { switch ( $screen_layout_columns ) {
case 4: case 4:
@ -176,16 +188,16 @@ function wp_dashboard() {
<div id="dashboard-widgets" class="metabox-holder"> <div id="dashboard-widgets" class="metabox-holder">
<?php <?php
echo "\t<div class='postbox-container' style='$width'>\n"; echo "\t<div class='postbox-container' style='$width'>\n";
do_meta_boxes( 'dashboard', 'normal', '' ); do_meta_boxes( $screen->id, 'normal', '' );
echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n"; echo "\t</div><div class='postbox-container' style='{$hide2}$width'>\n";
do_meta_boxes( 'dashboard', 'side', '' ); do_meta_boxes( $screen->id, 'side', '' );
echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n"; echo "\t</div><div class='postbox-container' style='{$hide3}$width'>\n";
do_meta_boxes( 'dashboard', 'column3', '' ); do_meta_boxes( $screen->id, 'column3', '' );
echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n"; echo "\t</div><div class='postbox-container' style='{$hide4}$width'>\n";
do_meta_boxes( 'dashboard', 'column4', '' ); do_meta_boxes( $screen->id, 'column4', '' );
?> ?>
</div></div> </div></div>

View File

@ -2719,7 +2719,7 @@ class WP_Sites_Table extends WP_List_Table {
function WP_Sites_Table() { function WP_Sites_Table() {
parent::WP_List_Table( array( parent::WP_List_Table( array(
'screen' => 'ms-sites', 'screen' => 'sites-network',
'plural' => 'sites', 'plural' => 'sites',
) ); ) );
} }
@ -2734,7 +2734,7 @@ class WP_Sites_Table extends WP_List_Table {
$mode = ( empty( $_REQUEST['mode'] ) ) ? 'list' : $_REQUEST['mode']; $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(); $pagenum = $this->get_pagenum();
@ -3007,7 +3007,7 @@ class WP_MS_Users_Table extends WP_List_Table {
function WP_MS_Users_Table() { function WP_MS_Users_Table() {
parent::WP_List_Table( array( 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'] : ''; $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(); $paged = $this->get_pagenum();

View File

@ -9,6 +9,8 @@
if ( is_network_admin() ) if ( is_network_admin() )
do_action('_network_admin_menu'); do_action('_network_admin_menu');
elseif ( is_user_admin() )
do_action('_user_admin_menu');
else else
do_action('_admin_menu'); do_action('_admin_menu');
@ -89,6 +91,8 @@ unset($id, $data, $subs, $first_sub, $old_parent, $new_parent);
if ( is_network_admin() ) if ( is_network_admin() )
do_action('network_admin_menu', ''); do_action('network_admin_menu', '');
elseif ( is_user_admin() )
do_action('user_admin_menu', '');
else else
do_action('admin_menu', ''); do_action('admin_menu', '');

View File

@ -343,9 +343,9 @@ function set_screen_options() {
switch ( $map_option ) { switch ( $map_option ) {
case 'edit_per_page': case 'edit_per_page':
case 'ms_sites_per_page': case 'sites_network_per_page':
case 'users_per_page': case 'users_per_page':
case 'ms_users_per_page': case 'users_network_per_page':
case 'edit_comments_per_page': case 'edit_comments_per_page':
case 'upload_per_page': case 'upload_per_page':
case 'edit_tags_per_page': case 'edit_tags_per_page':

View File

@ -502,29 +502,14 @@ function redirect_user_to_blog() {
$c ++; $c ++;
$blog = get_active_blog_for_user( get_current_user_id() ); $blog = get_active_blog_for_user( get_current_user_id() );
$dashboard_blog = get_dashboard_blog();
if ( is_object( $blog ) ) { if ( is_object( $blog ) ) {
wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case" wp_redirect( get_admin_url( $blog->blog_id, '?c=' . $c ) ); // redirect and count to 5, "just in case"
exit; 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.' ) ); wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
} }
add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 ); add_action( 'admin_page_access_denied', 'redirect_user_to_blog', 99 );

View File

@ -1390,6 +1390,9 @@ function favorite_actions( $screen = null ) {
if ( is_string($screen) ) if ( is_string($screen) )
$screen = convert_to_screen($screen); $screen = convert_to_screen($screen);
if ( $screen->is_user )
return;
if ( isset($screen->post_type) ) { if ( isset($screen->post_type) ) {
$post_type_object = get_post_type_object($screen->post_type); $post_type_object = get_post_type_object($screen->post_type);
if ( 'add' != $screen->action ) if ( 'add' != $screen->action )
@ -1635,7 +1638,7 @@ function convert_to_screen( $screen ) {
} }
function screen_meta($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) ) if ( is_string($screen) )
$screen = convert_to_screen($screen); $screen = convert_to_screen($screen);
@ -1669,7 +1672,10 @@ function screen_meta($screen) {
$show_screen = true; $show_screen = true;
break; break;
} }
if( ! empty( $settings ) ) if ( ! empty( $settings ) )
$show_screen = true;
if ( !empty($wp_current_screen_options) )
$show_screen = true; $show_screen = true;
?> ?>
@ -1796,29 +1802,30 @@ function plugins_search_help() {
} }
function screen_layout($screen) { function screen_layout($screen) {
global $screen_layout_columns; global $screen_layout_columns, $wp_current_screen_options;
if ( is_string($screen) ) if ( is_string($screen) )
$screen = convert_to_screen($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 if ( !isset($wp_current_screen_options['layout_columns']) ) {
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]) ) {
$screen_layout_columns = 0; $screen_layout_columns = 0;
return ''; return '';
} }
$screen_layout_columns = get_user_option("screen_layout_$screen->id"); $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; $screen_layout_columns = 2;
}
$i = 1; $i = 1;
$return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n"; $return = '<h5>' . __('Screen Layout') . "</h5>\n<div class='columns-prefs'>" . __('Number of Columns:') . "\n";
@ -1830,55 +1837,45 @@ function screen_layout($screen) {
return $return; 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) { function screen_options($screen) {
global $wp_current_screen_options;
if ( is_string($screen) ) if ( is_string($screen) )
$screen = convert_to_screen($screen); $screen = convert_to_screen($screen);
switch ( $screen->base ) { if ( !isset($wp_current_screen_options['per_page']) )
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 ''; return '';
}
$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" ); $option = str_replace( '-', '_', "{$screen->id}_per_page" );
if ( 'edit_tags_per_page' == $option ) { } else {
if ( 'category' == $tax->name ) $option = $wp_current_screen_options['per_page']['option'];
$option = 'categories_per_page';
elseif ( 'post_tag' != $tax->name )
$option = 'edit_' . $tax->name . '_per_page';
} }
$per_page = (int) get_user_option( $option ); $per_page = (int) get_user_option( $option );
if ( empty( $per_page ) || $per_page < 1 ) { if ( empty( $per_page ) || $per_page < 1 ) {
if ( 'plugins' == $screen->id ) if ( isset($wp_current_screen_options['per_page']['default']) )
$per_page = 999; $per_page = $wp_current_screen_options['per_page']['default'];
else else
$per_page = 20; $per_page = 20;
} }
@ -1997,6 +1994,22 @@ function compression_test() {
<?php <?php
} }
/**
* Get the current screen object
*
* @since 3.1.0
*
* @return object Current screen object
*/
function get_current_screen() {
global $current_screen;
if ( !isset($current_screen) )
return null;
return $current_screen;
}
/** /**
* Set the current screen object * Set the current screen object
* *
@ -2060,6 +2073,15 @@ function set_current_screen( $id = '' ) {
} }
$current_screen->is_network = is_network_admin() ? true : false; $current_screen->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); $current_screen = apply_filters('current_screen', $current_screen);
} }

View File

@ -10,7 +10,7 @@
require_once( './admin.php' ); require_once( './admin.php' );
/** Load WordPress Administration Dashboard API */ /** 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' ) ); @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
send_nosniff_header(); send_nosniff_header();

View File

@ -24,6 +24,11 @@ add_thickbox();
$title = __('Dashboard'); $title = __('Dashboard');
$parent_file = 'index.php'; $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, add_contextual_help($current_screen,
'<p>' . __('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.') . '</p>' . '<p>' . __('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.') . '</p>' .
@ -42,7 +47,7 @@ add_contextual_help($current_screen,
'<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>' '<p>' . __('<a href="http://wordpress.org/support/" target="_blank">Support Forums</a>') . '</p>'
); );
require_once('./admin-header.php'); include (ABSPATH . 'wp-admin/admin-header.php');
$today = current_time('mysql', 1); $today = current_time('mysql', 1);
?> ?>

View File

@ -42,7 +42,7 @@ jQuery(document).ready( function($) {
}; };
ajaxPopulateWidgets(); ajaxPopulateWidgets();
postboxes.add_postbox_toggles('dashboard', { pbshow: ajaxPopulateWidgets } ); postboxes.add_postbox_toggles(pagenow, { pbshow: ajaxPopulateWidgets } );
/* QuickPress */ /* QuickPress */
quickPressLoad = function() { quickPressLoad = function() {

View File

@ -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")})}}); 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")})}});

View File

@ -232,6 +232,6 @@ $compat = array(
'themes' => 'appearance', 'themes' => 'appearance',
); );
require(ABSPATH . 'wp-admin/includes/menu.php'); require_once(ABSPATH . 'wp-admin/includes/menu.php');
?> ?>

View File

@ -52,8 +52,8 @@ function confirm_delete_users( $users ) {
$user_dropdown = "<select name='blog[$val][{$key}]'>"; $user_dropdown = "<select name='blog[$val][{$key}]'>";
$user_list = ''; $user_list = '';
foreach ( $blog_users as $user ) { foreach ( $blog_users as $user ) {
if ( $user->user_id != $val && !in_array( $user->user_id, $allusers ) ) if ( $user->user_id != $val && !in_array( $user->id, $allusers ) )
$user_list .= "<option value='{$user->user_id}'>{$user->user_login}</option>"; $user_list .= "<option value='{$user->id}'>{$user->user_login}</option>";
} }
if ( '' == $user_list ) if ( '' == $user_list )
$user_list = $admin_out; $user_list = $admin_out;
@ -137,53 +137,8 @@ switch ( $_GET['action'] ) {
} else { } else {
update_site_option( 'banned_email_domains', '' ); update_site_option( 'banned_email_domains', '' );
} }
update_site_option( 'default_user_role', $_POST['default_user_role'] );
if ( trim( $_POST['dashboard_blog_orig'] ) == '' )
$_POST['dashboard_blog_orig'] = $current_site->blog_id;
if ( trim( $_POST['dashboard_blog'] ) == '' ) {
$_POST['dashboard_blog'] = $current_site->blog_id;
$dashboard_blog_id = $current_site->blog_id;
} elseif ( ! preg_match( '/(--|\.)/', $_POST['dashboard_blog'] ) && preg_match( '|^([a-zA-Z0-9-\.])+$|', $_POST['dashboard_blog'] ) ) {
$dashboard_blog = $_POST['dashboard_blog'];
$blog_details = get_blog_details( $dashboard_blog );
if ( false === $blog_details ) {
if ( is_numeric( $dashboard_blog ) )
wp_die( __( 'A dashboard site referenced by ID must already exist' ) );
if ( is_subdomain_install() ) {
$domain = $dashboard_blog . '.' . $current_site->domain;
$path = $current_site->path;
} else {
$domain = $current_site->domain;
$path = trailingslashit( $current_site->path . $dashboard_blog );
}
$wpdb->hide_errors();
$dashboard_blog_id = wpmu_create_blog( $domain, $path, __( 'My Dashboard' ), $current_user->id , array( 'public' => 0 ), $current_site->id );
$wpdb->show_errors();
} else {
$dashboard_blog_id = $blog_details->blog_id;
}
}
if ( is_wp_error( $dashboard_blog_id ) )
wp_die( __( 'Problem creating dashboard site: ' ) . $dashboard_blog_id->get_error_message() );
if ( $_POST['dashboard_blog_orig'] != $_POST['dashboard_blog'] ) {
$users = get_users_of_blog( get_site_option( 'dashboard_blog' ) );
$move_users = array();
foreach ( (array)$users as $user ) {
$user_meta_value = unserialize( $user->meta_value );
if ( is_array( $user_meta_value ) && array_pop( $var_by_ref = array_keys( $user_meta_value ) ) == 'subscriber' )
$move_users[] = $user->user_id;
}
if ( false == empty( $move_users ) ) {
foreach ( (array)$move_users as $user_id ) {
remove_user_from_blog($user_id, get_site_option( 'dashboard_blog' ) );
add_user_to_blog( $dashboard_blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
update_user_meta( $user_id, 'primary_blog', $dashboard_blog_id );
}
}
}
update_site_option( 'dashboard_blog', $dashboard_blog_id );
$options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'admin_notice_feed', 'global_terms_enabled' ); $options = array( 'registrationnotification', 'registration', 'add_new_users', 'menu_items', 'mu_media_buttons', 'upload_space_check_disabled', 'blog_upload_space', 'upload_filetypes', 'site_name', 'first_post', 'first_page', 'first_comment', 'first_comment_url', 'first_comment_author', 'welcome_email', 'welcome_user_email', 'fileupload_maxk', 'global_terms_enabled' );
$checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 ); $checked_options = array( 'mu_media_buttons' => array(), 'menu_items' => array(), 'registrationnotification' => 'no', 'upload_space_check_disabled' => 1, 'add_new_users' => 0 );
foreach ( $checked_options as $option_name => $option_unchecked_value ) { foreach ( $checked_options as $option_name => $option_unchecked_value ) {
if ( ! isset( $_POST[$option_name] ) ) if ( ! isset( $_POST[$option_name] ) )
@ -255,8 +210,7 @@ switch ( $_GET['action'] ) {
$id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id ); $id = wpmu_create_blog( $newdomain, $path, $title, $user_id , array( 'public' => 1 ), $current_site->id );
$wpdb->show_errors(); $wpdb->show_errors();
if ( !is_wp_error( $id ) ) { if ( !is_wp_error( $id ) ) {
$dashboard_blog = get_dashboard_blog(); if ( !is_super_admin( $user_id ) && !get_user_option( 'primary_blog', $user_id ) )
if ( !is_super_admin( $user_id ) && get_user_option( 'primary_blog', $user_id ) == $dashboard_blog->blog_id )
update_user_option( $user_id, 'primary_blog', $id, true ); update_user_option( $user_id, 'primary_blog', $id, true );
$content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) ); $content_mail = sprintf( __( "New site created by %1s\n\nAddress: http://%2s\nName: %3s"), $current_user->user_login , $newdomain . $path, stripslashes( $title ) );
wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' ); wp_mail( get_site_option('admin_email'), sprintf( __( '[%s] New Site Created' ), $current_site->site_name ), $content_mail, 'From: "Site Admin" <' . get_site_option( 'admin_email' ) . '>' );
@ -687,11 +641,6 @@ switch ( $_GET['action'] ) {
else else
wp_new_user_notification( $user_id, $password ); wp_new_user_notification( $user_id, $password );
if ( get_site_option( 'dashboard_blog' ) == false )
add_user_to_blog( $current_site->blog_id, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
else
add_user_to_blog( get_site_option( 'dashboard_blog' ), $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) ); wp_redirect( add_query_arg( array( 'updated' => 'true', 'action' => 'add' ), wp_get_referer() ) );
exit(); exit();
break; break;

View File

@ -43,7 +43,7 @@ if (isset($_GET['updated'])) {
?> ?>
<div class="wrap"> <div class="wrap">
<?php screen_icon(); ?> <?php screen_icon('options-general'); ?>
<h2><?php _e( 'Network Options' ) ?></h2> <h2><?php _e( 'Network Options' ) ?></h2>
<form method="post" action="edit.php?action=siteoptions"> <form method="post" action="edit.php?action=siteoptions">
<?php wp_nonce_field( 'siteoptions' ); ?> <?php wp_nonce_field( 'siteoptions' ); ?>
@ -67,44 +67,6 @@ if (isset($_GET['updated'])) {
</td> </td>
</tr> </tr>
</table> </table>
<h3><?php _e( 'Dashboard Settings' ); ?></h3>
<table class="form-table">
<tr valign="top">
<th scope="row"><label for="dashboard_blog"><?php _e( 'Dashboard Site' ) ?></label></th>
<td>
<?php
if ( $dashboard_blog = get_site_option( 'dashboard_blog' ) ) {
$details = get_blog_details( $dashboard_blog );
$blogname = untrailingslashit( sanitize_user( str_replace( '.', '', str_replace( $current_site->domain . $current_site->path, '', $details->domain . $details->path ) ) ) );
} else {
$blogname = '';
}?>
<input name="dashboard_blog_orig" type="hidden" id="dashboard_blog_orig" value="<?php echo esc_attr( $blogname ); ?>" />
<input name="dashboard_blog" type="text" id="dashboard_blog" value="<?php echo esc_attr( $blogname ); ?>" class="regular-text" />
<br />
<?php _e( 'Site path (&#8220;dashboard&#8221;, &#8220;control&#8221;, &#8220;manager&#8221;, etc.) or blog ID.<br />New users are added to this site as the user role defined below if they don&#8217;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.' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="default_user_role"><?php _e( 'Dashboard User Default Role' ) ?></label></th>
<td>
<select name="default_user_role" id="default_user_role"><?php
wp_dropdown_roles( get_site_option( 'default_user_role', 'subscriber' ) );
?>
</select>
<br />
<?php _e( 'The default role for new users on the Dashboard site. &#8220;Subscriber&#8221; or &#8220;Contributor&#8221; roles are recommended.' ); ?>
</td>
</tr>
<tr valign="top">
<th scope="row"><label for="admin_notice_feed"><?php _e( 'Admin Notice Feed' ) ?></label></th>
<td><input name="admin_notice_feed" class="large-text" type="text" id="admin_notice_feed" value="<?php echo esc_attr( get_site_option( 'admin_notice_feed' ) ) ?>" size="80" /><br />
<?php _e( 'Display the latest post from this RSS or Atom feed on all site dashboards. Leave blank to disable.' ); ?><br />
<?php if ( get_site_option( 'admin_notice_feed' ) != get_home_url( $current_site->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/' ) ) ?></td>
</tr>
</table>
<h3><?php _e( 'Registration Settings' ); ?></h3> <h3><?php _e( 'Registration Settings' ); ?></h3>
<table class="form-table"> <table class="form-table">
<tr valign="top"> <tr valign="top">

View File

@ -18,6 +18,8 @@ $wp_list_table->check_permissions();
$title = __( 'Sites' ); $title = __( 'Sites' );
$parent_file = 'sites.php'; $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'] ) { if ( isset( $_REQUEST['action'] ) && 'editblog' == $_REQUEST['action'] ) {
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<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>' . '<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>' .
@ -109,7 +111,7 @@ switch ( $action ) {
require_once( '../admin-header.php' ); require_once( '../admin-header.php' );
?> ?>
<div class="wrap"> <div class="wrap">
<?php screen_icon(); ?> <?php screen_icon('index'); ?>
<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> <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>
<?php echo $msg; ?> <?php echo $msg; ?>
<form method="post" action="edit.php?action=updateblog"> <form method="post" action="edit.php?action=updateblog">
@ -347,7 +349,7 @@ switch ( $action ) {
?> ?>
<div class="wrap"> <div class="wrap">
<?php screen_icon(); ?> <?php screen_icon('index'); ?>
<h2><?php _e('Sites') ?> <h2><?php _e('Sites') ?>
<?php echo $msg; ?> <?php echo $msg; ?>
<a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a> <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x( 'Add New', 'sites' ); ?></a>

View File

@ -32,7 +32,7 @@ if ( ! current_user_can( 'manage_network' ) )
wp_die( __( 'You do not have permission to access this page.' ) ); wp_die( __( 'You do not have permission to access this page.' ) );
echo '<div class="wrap">'; echo '<div class="wrap">';
screen_icon(); screen_icon('tools');
echo '<h2>' . __( 'Update Network' ) . '</h2>'; echo '<h2>' . __( 'Update Network' ) . '</h2>';
$action = isset($_GET['action']) ? $_GET['action'] : 'show'; $action = isset($_GET['action']) ? $_GET['action'] : 'show';

View File

@ -16,6 +16,8 @@ $wp_list_table->prepare_items();
$title = __( 'Users' ); $title = __( 'Users' );
$parent_file = 'users.php'; $parent_file = 'users.php';
add_screen_option( 'per_page', array('label' => _x( 'Users', 'users per page (screen options)' )) );
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' . '<p>' . __('This table shows all users across the network and the sites to which they are assigned.') . '</p>' .
'<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>' . '<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>' .

View File

@ -290,6 +290,8 @@ $wp_list_table->prepare_items();
wp_enqueue_script('plugin-install'); wp_enqueue_script('plugin-install');
add_thickbox(); add_thickbox();
add_screen_option( 'per_page', array('label' => _x( 'Plugins', 'plugins per page (screen options)' ), 'default' => 999) );
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' . '<p>' . __('Plugins extend and expand the functionality of WordPress. Once a plugin is installed, you may activate it or deactivate it here.') . '</p>' .
'<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>' . '<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>' .

View File

@ -134,6 +134,8 @@ wp_enqueue_script( 'wp-ajax-response' );
wp_enqueue_script( 'jquery-ui-draggable' ); wp_enqueue_script( 'jquery-ui-draggable' );
wp_enqueue_script( 'media' ); wp_enqueue_script( 'media' );
add_screen_option( 'per_page', array('label' => _x( 'Media items', 'items per page (screen options)' )) );
add_contextual_help( $current_screen, add_contextual_help( $current_screen,
'<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>' . '<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>' .
'<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>' . '<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>' .

View File

@ -31,7 +31,11 @@ if ( current_user_can('edit_users') && !IS_PROFILE_PAGE )
$submenu_file = 'users.php'; $submenu_file = 'users.php';
else else
$submenu_file = 'profile.php'; $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. // contextual help - choose Help on the top right of admin panel to preview this.
add_contextual_help($current_screen, add_contextual_help($current_screen,

10
wp-admin/user/admin.php Normal file
View File

@ -0,0 +1,10 @@
<?php
define('WP_USER_ADMIN', TRUE);
require_once( dirname(dirname(__FILE__)) . '/admin.php');
if ( ! is_main_site() )
wp_redirect( user_admin_url() );
?>

View File

@ -0,0 +1,5 @@
<?php
require_once( './admin.php' );
require( '../index-extra.php' );

5
wp-admin/user/index.php Normal file
View File

@ -0,0 +1,5 @@
<?php
require_once( './admin.php' );
require( '../index.php' );

17
wp-admin/user/menu.php Normal file
View File

@ -0,0 +1,17 @@
<?php
$menu[0] = array(__('Dashboard'), 'exist', 'index.php', '', 'menu-top menu-top-first menu-icon-dashboard', 'menu-dashboard', 'div');
$menu[4] = array( '', 'exist', 'separator1', '', 'wp-menu-separator' );
$menu[70] = array( __('Profile'), 'exist', 'profile.php', '', 'menu-top menu-icon-users', 'menu-users', 'div' );
$menu[99] = array( '', 'exist', 'separator-last', '', 'wp-menu-separator-last' );
$_wp_real_parent_file['users.php'] = 'profile.php';
$compat = array();
$submenu = array();
require_once(ABSPATH . 'wp-admin/includes/menu.php');
?>

View File

@ -0,0 +1,5 @@
<?php
require_once( './admin.php' );
require( '../profile.php' );

View File

@ -0,0 +1,5 @@
<?php
require_once( './admin.php' );
require( '../user-edit.php' );

View File

@ -18,6 +18,8 @@ $wp_list_table->check_permissions();
$title = __('Users'); $title = __('Users');
$parent_file = 'users.php'; $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. // contextual help - choose Help on the top right of admin panel to preview this.
add_contextual_help($current_screen, add_contextual_help($current_screen,
'<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>' . '<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>' .

View File

@ -110,14 +110,6 @@ function wp_admin_bar_my_blogs_menu() {
if ( !is_object( $wp_admin_bar ) ) if ( !is_object( $wp_admin_bar ) )
return false; 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. */ /* Add the 'My Dashboards' menu if the user has more than one blog. */
if ( count( $wp_admin_bar->user->blogs ) > 1 ) { 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 ) ); $wp_admin_bar->add_menu( array( 'id' => 'my-blogs', 'title' => __( 'My Blogs' ), 'href' => $wp_admin_bar->user->account_domain ) );

View File

@ -15,7 +15,7 @@ class WP_Admin_Bar {
$this->user->blogs = get_ordered_blogs_of_user( $current_user->id ); $this->user->blogs = get_ordered_blogs_of_user( $current_user->id );
if ( is_multisite() ) { if ( is_multisite() ) {
$this->user->active_blog = get_active_blog_for_user( $current_user->id ); $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; $this->user->account_domain = $this->user->domain;
} else { } else {
$this->user->active_blog = $this->user->blogs[$blog_id]; $this->user->active_blog = $this->user->blogs[$blog_id];

View File

@ -737,6 +737,7 @@ class WP_User {
// Must have ALL requested caps // Must have ALL requested caps
$capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args ); $capabilities = apply_filters( 'user_has_cap', $this->allcaps, $caps, $args );
$capabilities['exist'] = true; // Everyone is allowed to exist
foreach ( (array) $caps as $cap ) { foreach ( (array) $caps as $cap ) {
//echo "Checking cap $cap<br />"; //echo "Checking cap $cap<br />";
if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] ) if ( empty( $capabilities[$cap] ) || !$capabilities[$cap] )

View File

@ -447,7 +447,7 @@ function wp_load_core_site_options( $site_id = null ) {
if ( empty($site_id) ) if ( empty($site_id) )
$site_id = $wpdb->siteid; $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) . "'"; $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) ); $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) );

View File

@ -2129,6 +2129,25 @@ function network_admin_url( $path = '', $scheme = 'admin' ) {
return apply_filters('network_admin_url', $url, $path); 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. * 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') { function self_admin_url($path = '', $scheme = 'admin') {
if ( is_network_admin() ) if ( is_network_admin() )
return network_admin_url($path, $scheme); return network_admin_url($path, $scheme);
elseif ( is_user_admin() )
return user_admin_url($path, $scheme);
else else
return admin_url($path, $scheme); return admin_url($path, $scheme);
} }

View File

@ -620,6 +620,22 @@ function is_network_admin() {
return false; 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 * Whether Multisite support is enabled
* *

View File

@ -59,7 +59,6 @@ function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
* *
* @since MU 1.0 * @since MU 1.0
* @uses get_blogs_of_user() * @uses get_blogs_of_user()
* @uses get_dashboard_blog()
* @uses add_user_to_blog() * @uses add_user_to_blog()
* @uses update_user_meta() * @uses update_user_meta()
* @uses wp_cache_delete() * @uses wp_cache_delete()
@ -72,30 +71,29 @@ function get_admin_users_for_domain( $sitedomain = '', $path = '' ) {
function get_active_blog_for_user( $user_id ) { function get_active_blog_for_user( $user_id ) {
global $wpdb; global $wpdb;
$blogs = get_blogs_of_user( $user_id ); $blogs = get_blogs_of_user( $user_id );
if ( empty( $blogs ) ) { if ( empty( $blogs ) )
$details = get_dashboard_blog(); return null;
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $details->blog_id ); if ( !is_multisite() )
wp_cache_delete( $user_id, 'users' ); return $blogs[$wpdb->blogid];
return $details;
}
$primary_blog = get_user_meta( $user_id, 'primary_blog', true ); $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
$details = get_dashboard_blog(); $first_blog = current($blogs);
if ( $primary_blog ) { if ( $primary_blog ) {
if ( isset( $blogs[ $primary_blog ] ) == false ) { if ( ! isset( $blogs[ $primary_blog ] ) ) {
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $details->blog_id ); update_user_meta( $user_id, 'primary_blog', $first_blog->blog_id );
wp_cache_delete( $user_id, 'users' ); $primary = $first_blog;
} else { } else {
$details = get_blog_details( $primary_blog ); $primary = get_blog_details( $primary_blog );
} }
} else { } else {
add_user_to_blog( $details->blog_id, $user_id, 'subscriber' ); // Add subscriber permission for dashboard blog add_user_to_blog( $first_blog->blog_id, $user_id, 'subscriber' );
update_user_meta( $user_id, 'primary_blog', $details->blog_id ); 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. $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
$ret = false; $ret = false;
if ( is_array( $blogs ) && count( $blogs ) > 0 ) { 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 ); $details = get_blog_details( $blog_id );
if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) { if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
$ret = $blog; $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 ); 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 ); update_user_meta( $user_id, 'source_domain', $blog->domain );
$changed = true;
}
if ( $changed )
wp_cache_delete( $user_id, 'users' );
break; break;
} }
} }
} else { } else {
// Should never get here return null;
$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 $ret; return $ret;
} else { } 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); return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
wpmu_welcome_user_notification($user_id, $password, $meta); 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 ); add_new_user_to_blog( $user_id, $user_email, $meta );
do_action('wpmu_activate_user', $user_id, $password, $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' ) ); add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
update_option( 'blog_public', (int)$meta['public'] ); 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 ); update_user_meta( $user_id, 'primary_blog', $blog_id );
restore_current_blog(); 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); 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() { function get_dashboard_blog() {
if ( $blog = get_site_option( 'dashboard_blog' ) ) if ( $blog = get_site_option( 'dashboard_blog' ) )
return get_blog_details( $blog ); return get_blog_details( $blog );

View File

@ -81,7 +81,7 @@ function get_currentuserinfo() {
return; return;
if ( ! $user = wp_validate_auth_cookie() ) { 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); wp_set_current_user(0);
return false; 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); do_action('auth_redirect', $user_id);
// If the user wants ssl but the session is not ssl, redirect. // If the user wants ssl but the session is not ssl, redirect.

View File

@ -15,6 +15,11 @@
// On which page are we ? // On which page are we ?
if ( is_admin() ) { if ( is_admin() ) {
// wp-admin pages are checked more carefully // wp-admin pages are checked more carefully
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); preg_match('#/wp-admin/?(.*?)$#i', $PHP_SELF, $self_matches);
$pagenow = $self_matches[1]; $pagenow = $self_matches[1];
$pagenow = trim($pagenow, '/'); $pagenow = trim($pagenow, '/');

View File

@ -572,8 +572,13 @@ default:
</div></body></html> </div></body></html>
<?php exit; <?php exit;
} }
// If the user can't edit posts, send them to their profile.
if ( !$user->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'); $redirect_to = admin_url('profile.php');
wp_safe_redirect($redirect_to); wp_safe_redirect($redirect_to);
exit(); exit();