Ticket #19810: 19810.5.patch

File 19810.5.patch, 4.9 KB (added by markjaquith, 16 months ago)

Remove multi-user-add. Fix throbber-that-never-dies on empty result set.

  • wp-includes/script-loader.php

     
    260260 
    261261        $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 ); 
    262262 
     263        $scripts->add( 'user-new', "/wp-admin/js/user-new$suffix.js", array( 'jquery', 'jquery-ui-autocomplete' ), '20120125', 1 ); 
     264 
    263265        $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); 
    264266 
    265267        $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 ); 
  • wp-admin/admin-ajax.php

     
    3434 
    3535do_action( 'admin_init' ); 
    3636 
    37 $core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'compression-test', 'imgedit-preview', 'oembed_cache' ); 
     37$core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'compression-test', 'imgedit-preview', 'oembed_cache', 'autocomplete-user' ); 
    3838 
    3939$core_actions_post = array( 
    4040        'oembed_cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link', 
  • wp-admin/includes/ajax-actions.php

     
    146146        wp_die( $return ); 
    147147} 
    148148 
     149function wp_ajax_autocomplete_user() { 
     150        $return = array(); 
     151 
     152        // Exclude current users of this blog 
     153        $this_blog_users = new WP_User_Query( array( 
     154                'blog_id' => get_current_blog_id() 
     155        ) ); 
     156         
     157        $tbu_ids = array(); 
     158        if ( !empty( $this_blog_users->results ) ) { 
     159                foreach( $this_blog_users->results as $this_blog_user ) { 
     160                        $tbu_ids[] = $this_blog_user->ID; 
     161                } 
     162        } 
     163 
     164        $users = new WP_User_Query( array( 
     165                'blog_id' => false, 
     166                'search'  => '*' . $_REQUEST['term'] . '*', 
     167                'exclude' => $tbu_ids 
     168        ) ); 
     169         
     170        if ( !empty( $users->results ) ) { 
     171                foreach ( $users->results as $user ) { 
     172                        $return[] = array( 
     173                                'label' => $user->user_login . ' (' . $user->user_email . ')', 
     174                                'value' => $user->user_login, 
     175                        ); 
     176                } 
     177        } 
     178         
     179        die( json_encode( $return ) ); 
     180} 
     181 
    149182/* 
    150183 * Ajax helper. 
    151184 */ 
  • wp-admin/js/user-new.dev.js

     
     1(function($){    
     2        var ainput = $('#adduser-email'); 
     3 
     4        $(document).ready(function() { 
     5                                 
     6                var options = { 
     7                        source: ajaxurl + '?action=autocomplete-user', 
     8                        appendTo: 'form#adduser', 
     9                        select: function( event, ui ){ $(ainput).val( ui.item.value ); }, 
     10                        delay: 500, // milliseconds 
     11                        minLength: 2, // Don't want to match a crazy number of items. 
     12                }; 
     13 
     14                a = $(ainput).autocomplete(options); 
     15        }); 
     16 
     17})(jQuery); 
  • wp-admin/css/wp-admin.dev.css

     
    892892        margin: 0; 
    893893} 
    894894 
     895#wpcontent input[type="text"].ui-autocomplete-loading { 
     896        background: transparent url('../images/loading.gif') no-repeat right center; 
     897        visibility: visible; 
     898} 
    895899 
     900ul#add-to-blog-users { 
     901        margin: 0 0 0 14px; 
     902} 
     903 
     904form#adduser ul.ui-autocomplete { 
     905        padding: 0; 
     906        margin: 0; 
     907        list-style: none; 
     908        position: absolute; 
     909        z-index: 10000; 
     910        border-width: 1px; 
     911        border-style: solid; 
     912 
     913        background-color: #ffffff; 
     914        border-color: gray; 
     915} 
     916 
     917form#adduser .ui-widget-content {  
     918        background: #ececec; 
     919} 
     920 
     921form#adduser .ui-widget-content li {  
     922        padding: 2px 5px; 
     923        white-space: nowrap; 
     924        text-align: left; 
     925        color: #101010; 
     926} 
     927 
     928form#adduser .ui-widget-content li a { 
     929        display: block; 
     930        height: 100%; 
     931        padding: 2px 5px; 
     932        color: #333; 
     933} 
     934 
     935form#adduser .ui-widget-content li a.ui-state-hover { 
     936        background-color: #f0f0b8; 
     937} 
     938 
     939form#adduser a.remove { 
     940        margin: 6px 0pt 0pt -12px; 
     941        cursor: pointer; 
     942        width: 10px; 
     943        height: 10px; 
     944        display: block; 
     945        float: left; 
     946        text-indent: -9999px; 
     947        overflow: hidden; 
     948        position: absolute; 
     949        background: transparent url(../images/xit.gif) no-repeat; 
     950} 
     951 
     952form#adduser a.remove:hover { 
     953        background: transparent url(../images/xit.gif) no-repeat -10px 0; 
     954} 
     955 
     956 
    896957/*------------------------------------------------------------------------------ 
    897958  3.0 - Actions 
    898959------------------------------------------------------------------------------*/ 
  • wp-admin/user-new.php

     
    178178 
    179179wp_enqueue_script('wp-ajax-response'); 
    180180wp_enqueue_script('user-profile'); 
     181wp_enqueue_script('user-new'); 
     182wp_enqueue_script('jquery-ui-autocomplete'); 
    181183 
    182184require_once ('admin-header.php'); 
    183185