Autocomplete site names in Network Admin. More user completion areas. props Japh, DrewAPicture. see #19810.
git-svn-id: http://svn.automattic.com/wordpress/trunk@20279 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
6213bdfa52
commit
2a8c7bbc7a
|
@ -36,7 +36,7 @@ do_action( 'admin_init' );
|
||||||
|
|
||||||
$core_actions_get = array(
|
$core_actions_get = array(
|
||||||
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
|
'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
|
||||||
'autocomplete-user', 'dashboard-widgets',
|
'autocomplete-user', 'autocomplete-site', 'dashboard-widgets',
|
||||||
);
|
);
|
||||||
|
|
||||||
$core_actions_post = array(
|
$core_actions_post = array(
|
||||||
|
|
|
@ -900,6 +900,7 @@ ul#add-to-blog-users {
|
||||||
|
|
||||||
.ui-autocomplete li a.ui-state-hover {
|
.ui-autocomplete li a.ui-state-hover {
|
||||||
background-color: #f0f0b8;
|
background-color: #f0f0b8;
|
||||||
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------------------
|
/*------------------------------------------------------------------------------
|
||||||
|
|
|
@ -160,18 +160,26 @@ function wp_ajax_autocomplete_user() {
|
||||||
|
|
||||||
$return = array();
|
$return = array();
|
||||||
|
|
||||||
|
// Check the type of request
|
||||||
|
if ( isset( $_REQUEST['autocomplete_type'] ) )
|
||||||
|
$type = $_REQUEST['autocomplete_type'];
|
||||||
|
else
|
||||||
|
$type = 'add';
|
||||||
|
|
||||||
// Exclude current users of this blog
|
// Exclude current users of this blog
|
||||||
if ( isset( $_REQUEST['site_id'] ) )
|
if ( isset( $_REQUEST['site_id'] ) )
|
||||||
$id = absint( $_REQUEST['site_id'] );
|
$id = absint( $_REQUEST['site_id'] );
|
||||||
else
|
else
|
||||||
$id = get_current_blog_id();
|
$id = get_current_blog_id();
|
||||||
|
|
||||||
$this_blog_users = get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) );
|
$include_blog_users = ( $type == 'search' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
|
||||||
|
$exclude_blog_users = ( $type == 'add' ? get_users( array( 'blog_id' => $id, 'fields' => 'ID' ) ) : array() );
|
||||||
|
|
||||||
$users = get_users( array(
|
$users = get_users( array(
|
||||||
'blog_id' => false,
|
'blog_id' => false,
|
||||||
'search' => '*' . $_REQUEST['term'] . '*',
|
'search' => '*' . $_REQUEST['term'] . '*',
|
||||||
'exclude' => $this_blog_users,
|
'include' => $include_blog_users,
|
||||||
|
'exclude' => $exclude_blog_users,
|
||||||
'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
|
'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
|
||||||
) );
|
) );
|
||||||
|
|
||||||
|
@ -206,6 +214,35 @@ function wp_ajax_dashboard_widgets() {
|
||||||
wp_die();
|
wp_die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function wp_ajax_autocomplete_site() {
|
||||||
|
if ( ! is_multisite()
|
||||||
|
|| ! current_user_can( 'manage_sites' )
|
||||||
|
|| wp_is_large_network( 'sites' )
|
||||||
|
|| ! is_super_admin()
|
||||||
|
) {
|
||||||
|
wp_die( -1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
$return = array();
|
||||||
|
|
||||||
|
global $wpdb;
|
||||||
|
$like_escaped_term = '%' . like_escape( stripslashes( $_REQUEST['term'] ) ) . '%';
|
||||||
|
$sites = $wpdb->get_results( $wpdb->prepare( "SELECT blog_id, domain, path FROM $wpdb->blogs WHERE ( domain LIKE %s OR path LIKE %s ) AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $like_escaped_term, $like_escaped_term ), ARRAY_A );
|
||||||
|
|
||||||
|
if ( empty( $sites ) )
|
||||||
|
wp_die( -1 );
|
||||||
|
|
||||||
|
foreach ( (array) $sites as $details ) {
|
||||||
|
$blogname = get_blog_option( $details['blog_id'], 'blogname' );
|
||||||
|
$return[] = array(
|
||||||
|
'label' => sprintf( '%1$s (%2$s)', $blogname, $details['domain'] . $details['path'] ),
|
||||||
|
'value' => $details['domain']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
wp_die( json_encode( $return ) );
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajax helper.
|
* Ajax helper.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -416,6 +416,23 @@ function wp_network_dashboard_right_now() {
|
||||||
if ( current_user_can('create_users') )
|
if ( current_user_can('create_users') )
|
||||||
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
|
$actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
|
||||||
|
|
||||||
|
if ( is_multisite()
|
||||||
|
&& current_user_can( 'promote_users' )
|
||||||
|
&& ! wp_is_large_network( 'users' )
|
||||||
|
&& is_super_admin()
|
||||||
|
&& is_network_admin()
|
||||||
|
) {
|
||||||
|
wp_enqueue_script( 'user-search' );
|
||||||
|
}
|
||||||
|
if ( is_multisite()
|
||||||
|
&& current_user_can( 'manage_sites' )
|
||||||
|
&& ! wp_is_large_network( 'sites' )
|
||||||
|
&& is_super_admin()
|
||||||
|
&& is_network_admin()
|
||||||
|
) {
|
||||||
|
wp_enqueue_script( 'site-search' );
|
||||||
|
}
|
||||||
|
|
||||||
$c_users = get_user_count();
|
$c_users = get_user_count();
|
||||||
$c_blogs = get_blog_count();
|
$c_blogs = get_blog_count();
|
||||||
|
|
||||||
|
@ -440,14 +457,14 @@ function wp_network_dashboard_right_now() {
|
||||||
|
|
||||||
<form name="searchform" action="<?php echo network_admin_url('users.php'); ?>" method="get">
|
<form name="searchform" action="<?php echo network_admin_url('users.php'); ?>" method="get">
|
||||||
<p>
|
<p>
|
||||||
<input type="search" name="s" value="" size="17" />
|
<input type="search" name="s" value="" size="17" id="all-user-search-input" />
|
||||||
<?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
|
<?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form name="searchform" action="<?php echo network_admin_url('sites.php'); ?>" method="get">
|
<form name="searchform" action="<?php echo network_admin_url('sites.php'); ?>" method="get">
|
||||||
<p>
|
<p>
|
||||||
<input type="search" name="s" value="" size="17" />
|
<input type="search" name="s" value="" size="17" id="site-search-input" />
|
||||||
<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
|
<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -88,7 +88,7 @@ get_current_screen()->set_help_sidebar(
|
||||||
'<p>' . __( '<a href="http://codex.wordpress.org/Dashboard_Screen" target="_blank">Documentation on Dashboard</a>' ) . '</p>' .
|
'<p>' . __( '<a href="http://codex.wordpress.org/Dashboard_Screen" target="_blank">Documentation on Dashboard</a>' ) . '</p>' .
|
||||||
'<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>'
|
||||||
);
|
);
|
||||||
|
|
||||||
include (ABSPATH . 'wp-admin/admin-header.php');
|
include (ABSPATH . 'wp-admin/admin-header.php');
|
||||||
|
|
||||||
$today = current_time('mysql', 1);
|
$today = current_time('mysql', 1);
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
jQuery( function($) {
|
||||||
|
$( '#site-search-input' ).autocomplete({
|
||||||
|
source: ajaxurl + '?action=autocomplete-site',
|
||||||
|
delay: 500,
|
||||||
|
minLength: 2
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
jQuery(function($){$("#site-search-input").autocomplete({source:ajaxurl+"?action=autocomplete-site",delay:500,minLength:2})});
|
|
@ -2,8 +2,20 @@ jQuery( function($) {
|
||||||
var id = typeof( current_site_id ) != 'undefined' ? '&site_id=' + current_site_id : '';
|
var id = typeof( current_site_id ) != 'undefined' ? '&site_id=' + current_site_id : '';
|
||||||
|
|
||||||
$( '#adduser-email, #newuser' ).autocomplete({
|
$( '#adduser-email, #newuser' ).autocomplete({
|
||||||
source: ajaxurl + '?action=autocomplete-user' + id,
|
source: ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id,
|
||||||
delay: 500,
|
delay: 500,
|
||||||
minLength: 2
|
minLength: 2
|
||||||
});
|
});
|
||||||
});
|
|
||||||
|
$( '#user-search-input' ).autocomplete({
|
||||||
|
source: ajaxurl + '?action=autocomplete-user&autocomplete_type=search' + id,
|
||||||
|
delay: 500,
|
||||||
|
minLength: 2
|
||||||
|
});
|
||||||
|
|
||||||
|
$( '#all-user-search-input' ).autocomplete({
|
||||||
|
source: ajaxurl + '?action=autocomplete-user&autocomplete_type=search-all' + id,
|
||||||
|
delay: 500,
|
||||||
|
minLength: 2
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
jQuery(function(a){var b=typeof(current_site_id)!="undefined"?"&site_id="+current_site_id:"";a("#adduser-email, #newuser").autocomplete({source:ajaxurl+"?action=autocomplete-user"+b,delay:500,minLength:2})});
|
jQuery(function($){var id=typeof(current_site_id)!="undefined"?"&site_id="+current_site_id:"";$("#adduser-email, #newuser").autocomplete({source:ajaxurl+"?action=autocomplete-user&autocomplete_type=add"+id,delay:500,minLength:2});$("#user-search-input").autocomplete({source:ajaxurl+"?action=autocomplete-user&autocomplete_type=search"+id,delay:500,minLength:2});$("#all-user-search-input").autocomplete({source:ajaxurl+"?action=autocomplete-user&autocomplete_type=search-all"+id,delay:500,minLength:2})});
|
|
@ -171,7 +171,7 @@ $title = sprintf( __('Edit Site: %s'), $site_url_no_http );
|
||||||
$parent_file = 'sites.php';
|
$parent_file = 'sites.php';
|
||||||
$submenu_file = 'sites.php';
|
$submenu_file = 'sites.php';
|
||||||
|
|
||||||
if ( current_user_can( 'promote_users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) && !wp_is_large_network( 'users' ) )
|
if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) )
|
||||||
wp_enqueue_script( 'user-search' );
|
wp_enqueue_script( 'user-search' );
|
||||||
|
|
||||||
require('../admin-header.php'); ?>
|
require('../admin-header.php'); ?>
|
||||||
|
|
|
@ -282,6 +282,9 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
|
||||||
|
|
||||||
$wp_list_table->prepare_items();
|
$wp_list_table->prepare_items();
|
||||||
|
|
||||||
|
if ( ! wp_is_large_network( 'sites' ) )
|
||||||
|
wp_enqueue_script( 'site-search' );
|
||||||
|
|
||||||
require_once( '../admin-header.php' );
|
require_once( '../admin-header.php' );
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -245,6 +245,14 @@ get_current_screen()->set_help_sidebar(
|
||||||
'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
|
'<p>' . __('<a href="http://wordpress.org/support/forum/multisite/" target="_blank">Support Forums</a>') . '</p>'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if ( is_multisite()
|
||||||
|
&& current_user_can( 'promote_users' )
|
||||||
|
&& ! wp_is_large_network( 'users' )
|
||||||
|
&& is_super_admin()
|
||||||
|
) {
|
||||||
|
wp_enqueue_script( 'user-search' );
|
||||||
|
}
|
||||||
|
|
||||||
require_once( '../admin-header.php' );
|
require_once( '../admin-header.php' );
|
||||||
|
|
||||||
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
|
if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) {
|
||||||
|
@ -288,7 +296,7 @@ if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty(
|
||||||
<?php $wp_list_table->views(); ?>
|
<?php $wp_list_table->views(); ?>
|
||||||
|
|
||||||
<form action="" method="get" class="search-form">
|
<form action="" method="get" class="search-form">
|
||||||
<?php $wp_list_table->search_box( __( 'Search Users' ), 'user' ); ?>
|
<?php $wp_list_table->search_box( __( 'Search Users' ), 'all-user' ); ?>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<form id="form-user-list" action='users.php?action=allusers' method='post'>
|
<form id="form-user-list" action='users.php?action=allusers' method='post'>
|
||||||
|
|
|
@ -338,6 +338,15 @@ default:
|
||||||
wp_redirect( add_query_arg( 'paged', $total_pages ) );
|
wp_redirect( add_query_arg( 'paged', $total_pages ) );
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( is_multisite()
|
||||||
|
&& current_user_can( 'promote_users' )
|
||||||
|
&& ! wp_is_large_network( 'users' )
|
||||||
|
&& ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) )
|
||||||
|
) {
|
||||||
|
wp_enqueue_script( 'user-search' );
|
||||||
|
}
|
||||||
|
|
||||||
include('./admin-header.php');
|
include('./admin-header.php');
|
||||||
|
|
||||||
$messages = array();
|
$messages = array();
|
||||||
|
|
|
@ -268,6 +268,8 @@ function wp_default_scripts( &$scripts ) {
|
||||||
|
|
||||||
$scripts->add( 'user-search', "/wp-admin/js/user-search$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
|
$scripts->add( 'user-search', "/wp-admin/js/user-search$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
|
||||||
|
|
||||||
|
$scripts->add( 'site-search', "/wp-admin/js/site-search$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
|
||||||
|
|
||||||
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
|
$scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
|
||||||
|
|
||||||
$scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 );
|
$scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 );
|
||||||
|
|
Loading…
Reference in New Issue