Make WordPress Core

Ticket #11003: 11003.patch

File 11003.patch, 2.4 KB (added by hakre, 15 years ago)
  • wp-includes/taxonomy.php

    ### Eclipse Workspace Patch 1.0
    #P wordpress-trunk
     
    11911191 * The second argument is called, 'order' and has the default value of 'ASC'.
    11921192 * The only other value that will be acceptable is 'DESC'.
    11931193 *
    1194  * The final argument supported is called, 'fields' and has the default value of
     1194 * The third argument supported is called, 'fields' and has the default value of
    11951195 * 'all'. There are multiple other options that can be used instead. Supported
    1196  * values are as follows: 'all', 'ids', 'names', and finally
     1196 * values are as follows: 'all', 'ids', 'tt_ids', 'names', and finally
    11971197 * 'all_with_object_id'.
    1198  *
     1198 * 
    11991199 * The fields argument also decides what will be returned. If 'all' or
    12001200 * 'all_with_object_id' is choosen or the default kept intact, then all matching
    1201  * terms objects will be returned. If either 'ids' or 'names' is used, then an
    1202  * array of all matching term ids or term names will be returned respectively.
     1201 * terms objects will be returned. If either 'ids', 'tt_ids' or 'names' is used, then
     1202 * an array of all matching term ids, undocumented (tt_ids) or term names will be
     1203 * returned respectively.
     1204 *
     1205 * The fourth argument is called, 'select' and has the default value of 'all'.
     1206 * The other value that is supported is 'distinct', which will ensure no duplicate
     1207 * terms are returned (compare to SELECT ALL / SELECT DISTINCT in MySQL).
    12031208 *
    12041209 * @package WordPress
    12051210 * @subpackage Taxonomy
     
    12261231                $object_ids = array($object_ids);
    12271232        $object_ids = array_map('intval', $object_ids);
    12281233
    1229         $defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all');
     1234        $defaults = array('orderby' => 'name', 'order' => 'ASC', 'fields' => 'all', 'select' => 'all');
    12301235        $args = wp_parse_args( $args, $defaults );
    12311236
    12321237        $terms = array();
     
    12961301
    12971302        if ( ! $terms )
    12981303                $terms = array();
     1304               
     1305        if ( 'distinct' ==  $select ) {
     1306                if ( in_array( $fields, array('ids', 'names', 'tt_ids') ) ) {
     1307                        $terms = array_unique( $terms );
     1308                } else {
     1309                        $_terms = array();
     1310                        foreach( $terms as $key => $term )
     1311                                $_terms[$term->term_id] =& $terms[$key];                       
     1312                        $terms = $_terms;
     1313                }               
     1314        }
    12991315
    13001316        return apply_filters('wp_get_object_terms', $terms, $object_ids, $taxonomies, $args);
    13011317}