Make WordPress Core

Changeset 16166


Ignore:
Timestamp:
11/03/2010 06:28:02 PM (14 years ago)
Author:
ryan
Message:

Drop Sites search action dropdown. Determine the search action from the search string. see #15170

Location:
trunk/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-ms-sites-list-table.php

    r16161 r16166  
    4646        $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' ";
    4747
    48         if ( isset( $_REQUEST['searchaction'] ) ) {
    49             if ( 'name' == $_REQUEST['searchaction'] ) {
    50                 if ( is_subdomain_install() ) {
    51                     $like_s = str_replace( '.' . $current_site->domain, '', $like_s );
    52                     $like_s .= '.' . $current_site->domain;
    53                     $query .= " AND {$wpdb->blogs}.domain LIKE '$like_s' ";
    54                 } else {
    55                     if ( $like_s != trim('/', $current_site->path) )
    56                         $like_s = $current_site->path .= $like_s . '/';
    57                     $query .= " AND {$wpdb->blogs}.path LIKE '$like_s' ";
    58                 }
    59             } elseif ( 'id' == $_REQUEST['searchaction'] ) {
    60                 $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' ";
    61             } elseif ( 'ip' == $_REQUEST['searchaction'] ) {
    62                 $query = "SELECT *
    63                     FROM {$wpdb->blogs}, {$wpdb->registration_log}
    64                     WHERE site_id = '{$wpdb->siteid}'
    65                     AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
    66                     AND {$wpdb->registration_log}.IP LIKE ( '%{$like_s}%' )";
     48        if ( empty($s) ) {
     49            // Nothing to do.
     50        } elseif ( false !== strpos($s, '.') ) {
     51            // IP address
     52            $query = "SELECT *
     53                FROM {$wpdb->blogs}, {$wpdb->registration_log}
     54                WHERE site_id = '{$wpdb->siteid}'
     55                AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id
     56                AND {$wpdb->registration_log}.IP LIKE ( '{$like_s}%' )";
     57        } else {
     58            if ( is_subdomain_install() ) {
     59                $blog_s = str_replace( '.' . $current_site->domain, '', $like_s );
     60                $blog_s .= '.' . $current_site->domain;
     61                $query .= " AND ( {$wpdb->blogs}.domain LIKE '$blog_s' ";
     62            } else {
     63                if ( $like_s != trim('/', $current_site->path) )
     64                    $blog_s = $current_site->path .= $like_s . '/';
     65                else
     66                    $blog_s = $like_s;
     67                $query .= " AND  ( {$wpdb->blogs}.path LIKE '$blog_s' ";
    6768            }
     69
     70            if ( is_numeric($s) )
     71                $query .= " OR {$wpdb->blogs}.blog_id = '{$like_s}' ";
     72
     73            $query .= ' )';
    6874        }
    6975
  • trunk/wp-admin/network/sites.php

    r16128 r16166  
    100100<input type="hidden" name="action" value="blogs" />
    101101<input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" />
    102 <?php submit_button( __( 'Search Site by' ), 'button', 'submit', false ); ?>
    103 <select name="searchaction">
    104     <option value="name" selected="selected"><?php _e( 'Name' ); ?></option>
    105     <option value="id"><?php _e( 'ID' ); ?></option>
    106     <option value="ip"><?php _e( 'IP address' ); ?></option>
    107 </select>
     102<?php submit_button( __( 'Search Sites' ), 'button', 'submit', false ); ?>
    108103</p>
    109104</form>
Note: See TracChangeset for help on using the changeset viewer.