Make WordPress Core

Changeset 21003


Ignore:
Timestamp:
06/05/2012 06:51:33 PM (12 years ago)
Author:
nacin
Message:

Remove user/site suggestions (autocompletion) from search inputs, as the UX isn't proper.

  • Removes all instances of site-search, so away it goes. Sidesteps a number of bugs with site-search.
  • Renames user-search to user-suggest, which means it better describes the current behavior (autocompletion) while allowing for future behavior (instant search).
  • Ties user suggestions to a single .wp-suggest-user class.

with help from markjaquith, helenyhou, wonderboymusic.
fixes #20835.

Location:
trunk
Files:
2 deleted
9 edited
2 moved

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r20857 r21003  
    3939$core_actions_get = array(
    4040    'fetch-list', 'ajax-tag-search', 'wp-compression-test', 'imgedit-preview', 'oembed-cache',
    41     'autocomplete-user', 'autocomplete-site', 'dashboard-widgets',
     41    'autocomplete-user', 'dashboard-widgets',
    4242);
    4343
  • trunk/wp-admin/includes/ajax-actions.php

    r20913 r21003  
    211211    }
    212212    wp_die();
    213 }
    214 
    215 function wp_ajax_autocomplete_site() {
    216     if ( ! is_multisite() || ! current_user_can( 'manage_sites' ) || wp_is_large_network( 'sites' ) )
    217         wp_die( -1 );
    218 
    219     $return = array();
    220 
    221     global $wpdb;
    222     $like_escaped_term = '%' . like_escape( stripslashes( $_REQUEST['term'] ) ) . '%';
    223     $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 );
    224 
    225     if ( empty( $sites ) )
    226         wp_die( -1 );
    227 
    228     foreach ( (array) $sites as $details ) {
    229         $blogname = get_blog_option( $details['blog_id'], 'blogname' );
    230         $return[] = array(
    231             'label' => sprintf( '%1$s (%2$s)', $blogname, $details['domain'] . $details['path'] ),
    232             'value' => $details['domain']
    233         );
    234     }
    235 
    236     wp_die( json_encode( $return ) );
    237213}
    238214
  • trunk/wp-admin/includes/dashboard.php

    r20984 r21003  
    415415        $actions['create-user'] = '<a href="' . network_admin_url('user-new.php') . '">' . __( 'Create a New User' ) . '</a>';
    416416
    417     if ( ! wp_is_large_network( 'users' ) )
    418         wp_enqueue_script( 'user-search' );
    419 
    420     if ( ! wp_is_large_network( 'sites' ) )
    421         wp_enqueue_script( 'site-search' );
    422 
    423417    $c_users = get_user_count();
    424418    $c_blogs = get_blog_count();
     
    443437    <?php do_action( 'wpmuadminresult', '' ); ?>
    444438
    445     <form name="searchform" action="<?php echo network_admin_url('users.php'); ?>" method="get">
     439    <form action="<?php echo network_admin_url('users.php'); ?>" method="get">
    446440        <p>
    447             <input type="search" name="s" value="" size="30" id="all-user-search-input" />
     441            <input type="search" name="s" value="" size="30" autocomplete="off" />
    448442            <?php submit_button( __( 'Search Users' ), 'button', 'submit', false, array( 'id' => 'submit_users' ) ); ?>
    449443        </p>
    450444    </form>
    451445
    452     <form name="searchform" action="<?php echo network_admin_url('sites.php'); ?>" method="get">
     446    <form action="<?php echo network_admin_url('sites.php'); ?>" method="get">
    453447        <p>
    454             <input type="search" name="s" value="" size="30" id="site-search-input" />
     448            <input type="search" name="s" value="" size="30" autocomplete="off" />
    455449            <?php submit_button( __( 'Search Sites' ), 'button', 'submit', false, array( 'id' => 'submit_sites' ) ); ?>
    456450        </p>
  • trunk/wp-admin/js/user-suggest.dev.js

    r20992 r21003  
    1 jQuery( function($) {
    2     var id = typeof( current_site_id ) != 'undefined' ? '&site_id=' + current_site_id : '',
    3         isRTL = !! ( 'undefined' != typeof isRtl && isRtl ),
    4         position = isRTL ? { my: 'right top', at: 'right bottom', offset: '0, -1' } : { offset: '0, -1' },
    5         open = function(e, ui) {
    6             $(this).addClass('open');
    7         },
    8         close = function(e, ui) {
    9             $(this).removeClass('open');
    10         };
    11 
    12     $( '#adduser-email, #newuser' ).autocomplete({
    13         source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id,
    14         delay:     500,
    15         minLength: 2,
    16         position:  position,
    17         open:      open,
    18         close:     close
     1(function($) {
     2    var id = 'undefined' !== typeof current_site_id ? '&site_id=' + current_site_id : '';
     3    $(document).ready( function() {
     4        $( '.wp-suggest-user' ).autocomplete({
     5            source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id,
     6            delay:     500,
     7            minLength: 2,
     8            position:  ( 'undefined' !== typeof isRtl && isRtl ) ? { my: 'right top', at: 'right bottom', offset: '0, -1' } : { offset: '0, -1' },
     9            open:      function() { $(this).addClass('open'); },
     10            close:     function() { $(this).removeClass('open'); }
     11        });
    1912    });
    20 
    21     $( '#user-search-input' ).autocomplete({
    22         source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=search' + id,
    23         delay:     500,
    24         minLength: 2,
    25         position:  position,
    26         open:      open,
    27         close:     close
    28     });
    29 
    30     $( '#all-user-search-input' ).autocomplete({
    31         source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=search-all' + id,
    32         delay:     500,
    33         minLength: 2,
    34         position:  position,
    35         open:      open,
    36         close:     close
    37     });
    38 });
     13})(jQuery);
  • trunk/wp-admin/network/site-users.php

    r20713 r21003  
    173173
    174174if ( ! wp_is_large_network( 'users' ) && apply_filters( 'show_network_site_users_add_existing_form', true ) )
    175     wp_enqueue_script( 'user-search' );
     175    wp_enqueue_script( 'user-suggest' );
    176176
    177177require('../admin-header.php'); ?>
     
    268268        <tr>
    269269            <th scope="row"><?php _e( 'Username' ); ?></th>
    270             <td><input type="text" class="regular-text" name="newuser" id="newuser" /></td>
     270            <td><input type="text" class="regular-text wp-suggest-user" name="newuser" id="newuser" /></td>
    271271        </tr>
    272272        <tr>
  • trunk/wp-admin/network/sites.php

    r20713 r21003  
    283283$wp_list_table->prepare_items();
    284284
    285 if ( ! wp_is_large_network( 'sites' ) )
    286     wp_enqueue_script( 'site-search' );
    287 
    288285require_once( '../admin-header.php' );
    289286?>
  • trunk/wp-admin/network/users.php

    r20993 r21003  
    246246);
    247247
    248 if ( ! wp_is_large_network( 'users' ) )
    249     wp_enqueue_script( 'user-search' );
    250 
    251248require_once( '../admin-header.php' );
    252249
  • trunk/wp-admin/user-new.php

    r20631 r21003  
    181181    && ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) )
    182182) {
    183     wp_enqueue_script( 'user-search' );
     183    wp_enqueue_script( 'user-suggest' );
    184184}
    185185
     
    270270    <tr class="form-field form-required">
    271271        <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th>
    272         <td><input name="email" type="text" id="adduser-email" value="" /></td>
     272        <td><input name="email" type="text" id="adduser-email" class="wp-suggest-user" value="" /></td>
    273273    </tr>
    274274    <tr class="form-field">
  • trunk/wp-admin/users.php

    r20631 r21003  
    340340    }
    341341
    342     if ( is_multisite() && current_user_can( 'promote_users' ) && ! wp_is_large_network( 'users' )
    343         && ( is_super_admin() || apply_filters( 'autocomplete_users_for_site_admins', false ) )
    344     ) {
    345         wp_enqueue_script( 'user-search' );
    346     }
    347 
    348342    include('./admin-header.php');
    349343
  • trunk/wp-includes/script-loader.php

    r20960 r21003  
    268268    $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 );
    269269
    270     $scripts->add( 'user-search', "/wp-admin/js/user-search$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
    271 
    272     $scripts->add( 'site-search', "/wp-admin/js/site-search$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
     270    $scripts->add( 'user-suggest', "/wp-admin/js/user-suggest$suffix.js", array( 'jquery-ui-autocomplete' ), false, 1 );
    273271
    274272    $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 );
Note: See TracChangeset for help on using the changeset viewer.