WordPress.org

Make WordPress Core

Ticket #13580: 13580.diff

File 13580.diff, 1.1 KB (added by brianlayman, 7 years ago)

Updated patch to reflect 13580.2.diff 's inclusion in 3.1. This patch should apply to 3.2's dev/trunk code.

  • admin-ajax.php

     
    9393                $s = $s[count( $s ) - 1];
    9494        }
    9595        $s = trim( $s );
    96         if ( strlen( $s ) < 2 )
    97                 die; // require 2 chars for matching
     96        if ( strlen( $s ) < apply_filters( 'ats_min_chars', 2) )
     97                die; // require 'ats_min_chars' chars for matching (default 2)
    9898
    99         $results = $wpdb->get_col( $wpdb->prepare( "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ) );
     99        $sql = "SELECT t.name FROM $wpdb->term_taxonomy AS tt INNER JOIN $wpdb->terms AS t ON tt.term_id = t.term_id WHERE tt.taxonomy = %s AND t.name LIKE (%s)", $taxonomy, '%' . like_escape( $s ) . '%' ;
     100        $ats_min_count = (int)apply_filters('ats_min_count', 0);
     101        if ($ats_min_count) $sql .= " and tt.count > " . $ats_min_count;
     102        $results = $wpdb->get_col($wpdb->prepare($sql));
    100103
    101104        echo join( $results, "\n" );
    102105        die;