mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-12-06 12:51:58 +00:00
Autocomplete site names in Network Admin. More user completion areas. props Japh, DrewAPicture. see #19810.
git-svn-id: https://develop.svn.wordpress.org/trunk@20279 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -160,18 +160,26 @@ function wp_ajax_autocomplete_user() {
|
||||
|
||||
$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
|
||||
if ( isset( $_REQUEST['site_id'] ) )
|
||||
$id = absint( $_REQUEST['site_id'] );
|
||||
else
|
||||
$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(
|
||||
'blog_id' => false,
|
||||
'search' => '*' . $_REQUEST['term'] . '*',
|
||||
'exclude' => $this_blog_users,
|
||||
'include' => $include_blog_users,
|
||||
'exclude' => $exclude_blog_users,
|
||||
'search_columns' => array( 'user_login', 'user_nicename', 'user_email' ),
|
||||
) );
|
||||
|
||||
@@ -206,6 +214,35 @@ function wp_ajax_dashboard_widgets() {
|
||||
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.
|
||||
*/
|
||||
|
||||
@@ -416,6 +416,23 @@ function wp_network_dashboard_right_now() {
|
||||
if ( current_user_can('create_users') )
|
||||
$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_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">
|
||||
<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' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
<form name="searchform" action="<?php echo network_admin_url('sites.php'); ?>" method="get">
|
||||
<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' ) ); ?>
|
||||
</p>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user