Make WordPress Core

Opened 10 years ago

Closed 10 years ago

#25231 closed enhancement (fixed)

wp_ajax_ajax_tag_search should use get_terms instead of a custom query

Reported by: chouby's profile Chouby Owned by: nacin's profile nacin
Milestone: 3.7 Priority: normal
Severity: normal Version:
Component: Taxonomy Keywords: has-patch
Focuses: Cc:

Description

The goal is to take profit of all advantages of the get_terms function: cache, filters...

Attachments (1)

25231.patch (709 bytes) - added by Chouby 10 years ago.

Download all attachments as: .zip

Change History (5)

@Chouby
10 years ago

#1 @Chouby
10 years ago

  • Keywords has-patch added

#2 @SergeyBiryukov
10 years ago

  • Milestone changed from Awaiting Review to 3.7

#3 @nacin
10 years ago

Before: 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)"

After: SELECT t.term_id, tt.parent, tt.count, t.name FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON t.term_id = tt.term_id WHERE tt.taxonomy IN ('post_tag') AND t.name LIKE '%apple%' ORDER BY t.name ASC

name__like has two underscores. Also, this wouldn't have been possible without [25241]. I also like the ORDER BY, though it would probably be better to match based on LIKE '$name', then LIKE '$name%', then finally LIKE '%$name%'. This doesn't change functionality, though, so looks good.

#4 @nacin
10 years ago

  • Owner set to nacin
  • Resolution set to fixed
  • Status changed from new to closed

In 25452:

Use get_terms() in the ajax tag search.

props Chouby.
fixes #25231.

Note: See TracTickets for help on using tickets.