Make WordPress Core

Ticket #25348: 25348.diff

File 25348.diff, 3.4 KB (added by helen, 11 years ago)
  • src/wp-admin/includes/ajax-actions.php

     
    198198
    199199        // Check the type of request
    200200        if ( isset( $_REQUEST['autocomplete_type'] ) )
    201                 $type = $_REQUEST['autocomplete_type'];
     201                $type = sanitize_key( $_REQUEST['autocomplete_type'] );
    202202        else
    203203                $type = 'add';
    204204
     205        // Check the desired field for value
     206        if ( isset( $_REQUEST['autocomplete_value'] ) )
     207                $value_field = sanitize_key( $_REQUEST['autocomplete_value'] );
     208        else
     209                $value_field = 'user_login';
     210
    205211        // Exclude current users of this blog
    206212        if ( isset( $_REQUEST['site_id'] ) )
    207213                $id = absint( $_REQUEST['site_id'] );
     
    223229                $return[] = array(
    224230                        /* translators: 1: user_login, 2: user_email */
    225231                        'label' => sprintf( __( '%1$s (%2$s)' ), $user->user_login, $user->user_email ),
    226                         'value' => $user->user_login,
     232                        'value' => $user->$value_field,
    227233                );
    228234        }
    229235
  • src/wp-admin/js/user-suggest.js

     
    88                        position.my = 'right top';
    99                        position.at = 'right bottom';
    1010                }
    11                 $( '.wp-suggest-user' ).autocomplete({
    12                         source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=add' + id,
    13                         delay:     500,
    14                         minLength: 2,
    15                         position:  position,
    16                         open: function() {
    17                                 $( this ).addClass( 'open' );
    18                         },
    19                         close: function() {
    20                                 $( this ).removeClass( 'open' );
    21                         }
     11                $( '.wp-suggest-user' ).each( function( i ){
     12                        var $this = $( this ),
     13                                autocompleteType = ( typeof $this.data( 'autocompleteType' ) !== 'undefined' ) ? $this.data( 'autocompleteType' ) : 'add',
     14                                autocompleteValue = ( typeof $this.data( 'autocompleteValue' ) !== 'undefined' ) ? $this.data( 'autocompleteValue' ) : 'user_login'
     15
     16                        $this.autocomplete({
     17                                source:    ajaxurl + '?action=autocomplete-user&autocomplete_type=' + autocompleteType + '&autocomplete_value=' + autocompleteValue + id,
     18                                delay:     500,
     19                                minLength: 2,
     20                                position:  position,
     21                                open: function() {
     22                                        $( this ).addClass( 'open' );
     23                                },
     24                                close: function() {
     25                                        $( this ).removeClass( 'open' );
     26                                }
     27                        });
    2228                });
    2329        });
    2430})( jQuery );
     31 No newline at end of file
  • src/wp-admin/network/site-new.php

     
    106106$title = __('Add New Site');
    107107$parent_file = 'sites.php';
    108108
     109wp_enqueue_script( 'user-suggest' );
     110
    109111require( ABSPATH . 'wp-admin/admin-header.php' );
    110112
    111113?>
     
    138140                </tr>
    139141                <tr class="form-field form-required">
    140142                        <th scope="row"><?php _e( 'Admin Email' ) ?></th>
    141                         <td><input name="blog[email]" type="text" class="regular-text" title="<?php esc_attr_e( 'Email' ) ?>"/></td>
     143                        <td><input name="blog[email]" type="text" class="regular-text wp-suggest-user" data-autocomplete-type="search" data-autocomplete-value="user_email" title="<?php esc_attr_e( 'Email' ) ?>"/></td>
    142144                </tr>
    143145                <tr class="form-field">
    144146                        <td colspan="2"><?php _e( 'A new user will be created if the above email address is not in the database.' ) ?><br /><?php _e( 'The username and password will be mailed to this email address.' ) ?></td>