[wp-trac] [WordPress Trac] #19094: Add wp_get_object_terms filters.
WordPress Trac
wp-trac at lists.automattic.com
Tue Nov 1 00:14:50 UTC 2011
#19094: Add wp_get_object_terms filters.
-------------------------+-----------------------------
Reporter: Zatsugami | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future Release
Component: Taxonomy | Version: 3.2.1
Severity: normal | Resolution:
Keywords: needs-patch |
-------------------------+-----------------------------
Comment (by Zatsugami):
Ok, I've done it myself. It should work.
Basically copy-paste of posts_clauses.
Hmm, it may be a stupid question, but can I apply this to be a patch?
If so, how?
{{{
$pieces = array( 'select', 'join', 'where', 'orderby', 'order' );
// Setting up initial $query pieces, some are already present
$select = $select_this;
$join = "INNER JOIN $wpdb->term_taxonomy AS tt ON tt.term_id = t.term_id
INNER JOIN $wpdb->term_relationships AS tr ON tr.term_taxonomy_id =
tt.term_taxonomy_id";
$where = "WHERE tt.taxonomy IN ($taxonomies) AND tr.object_id IN
($object_ids)";
// We applay filters
$select = apply_filters( 'object_terms_select', $select );
$join = apply_filters( 'object_terms_join', $join );
$where = apply_filters( 'object_terms_where', $where );
$orderby = apply_filters( 'object_terms_orderby', $orderby);
$order = apply_filters( 'object_terms_order', $order);
// Filter all clauses at once, for convenience
$clauses = (array) apply_filters( 'object_terms_clauses', compact( $pieces
) );
foreach ( $pieces as $piece )
$$piece = isset( $clauses[ $piece ] ) ? $clauses[ $piece ] : '';
$query = "SELECT $select FROM $wpdb->terms AS t $join $where $orderby
$order";
$query = apply_filters('object_terms_query', $query);
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/19094#comment:2>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list