WordPress.org

Make WordPress Core

Changeset 13821


Ignore:
Timestamp:
03/26/2010 02:00:17 PM (8 years ago)
Author:
nacin
Message:

Correct inline docs and parameter names for get_objects_in_term() to reflect that it uses term ids, not term slugs. fixes #11835

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/taxonomy.php

    r13802 r13821  
    352352 * @uses wp_parse_args() Creates an array from string $args.
    353353 *
    354  * @param string|array $terms String of term or array of string values of terms that will be used
     354 * @param int|array $term_ids Term id or array of term ids of terms that will be used
    355355 * @param string|array $taxonomies String of taxonomy name or Array of string values of taxonomy names
    356356 * @param array|string $args Change the order of the object_ids, either ASC or DESC
     
    358358 *  the array can be empty meaning that there are no $object_ids found or it will return the $object_ids found.
    359359 */
    360 function get_objects_in_term( $terms, $taxonomies, $args = array() ) {
     360function get_objects_in_term( $term_ids, $taxonomies, $args = array() ) {
    361361    global $wpdb;
    362362
    363     if ( !is_array( $terms) )
    364         $terms = array($terms);
    365 
    366     if ( !is_array($taxonomies) )
    367         $taxonomies = array($taxonomies);
     363    if ( ! is_array( $term_ids ) )
     364        $term_ids = array( $term_ids );
     365
     366    if ( ! is_array( $taxonomies ) )
     367        $taxonomies = array( $taxonomies );
    368368
    369369    foreach ( (array) $taxonomies as $taxonomy ) {
    370         if ( ! is_taxonomy($taxonomy) )
    371             return new WP_Error('invalid_taxonomy', __('Invalid Taxonomy'));
    372     }
    373 
    374     $defaults = array('order' => 'ASC');
     370        if ( ! is_taxonomy( $taxonomy ) )
     371            return new WP_Error( 'invalid_taxonomy', __( 'Invalid Taxonomy' ) );
     372    }
     373
     374    $defaults = array( 'order' => 'ASC' );
    375375    $args = wp_parse_args( $args, $defaults );
    376     extract($args, EXTR_SKIP);
    377 
    378     $order = ( 'desc' == strtolower($order) ) ? 'DESC' : 'ASC';
    379 
    380     $terms = array_map('intval', $terms);
    381 
    382     $taxonomies = "'" . implode("', '", $taxonomies) . "'";
    383     $terms = "'" . implode("', '", $terms) . "'";
    384 
    385     $object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($terms) ORDER BY tr.object_id $order");
     376    extract( $args, EXTR_SKIP );
     377
     378    $order = ( 'desc' == strtolower( $order ) ) ? 'DESC' : 'ASC';
     379
     380    $term_ids = array_map('intval', $term_ids );
     381
     382    $taxonomies = "'" . implode( "', '", $taxonomies ) . "'";
     383    $term_ids = "'" . implode( "', '", $term_ids ) . "'";
     384
     385    $object_ids = $wpdb->get_col("SELECT tr.object_id FROM $wpdb->term_relationships AS tr INNER JOIN $wpdb->term_taxonomy AS tt ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ($taxonomies) AND tt.term_id IN ($term_ids) ORDER BY tr.object_id $order");
    386386
    387387    if ( ! $object_ids )
Note: See TracChangeset for help on using the changeset viewer.