Make WordPress Core


Ignore:
Timestamp:
08/20/2016 05:34:13 PM (7 years ago)
Author:
boonebgorges
Message:

Allow attachment taxonomies to be fetched as objects.

By adding the $output parameter to get_attachment_taxonomies(), the
function signature matches that of get_object_taxonomies(). The change
also allows for more consistent behavior when passing output=objects
to get_object_taxonomies() for the 'attachment' object type, since
the $output parameter is now passed through the function stack.

Props codemovement.pk.
See #37368.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/media.php

    r38086 r38292  
    26952695 *
    26962696 * @since 2.5.0
     2697 * @since 4.7.0 Introduced the `$output` parameter.
    26972698 *
    26982699 * @param int|array|object $attachment Attachment ID, data array, or data object.
     2700 * @param string           $output     Output type. 'names' to return an array of taxonomy names,
     2701 *                                     or 'objects' to return an array of taxonomy objects.
     2702 *                                     Default is 'names'.
    26992703 * @return array Empty array on failure. List of taxonomies on success.
    27002704 */
    2701 function get_attachment_taxonomies( $attachment ) {
     2705function get_attachment_taxonomies( $attachment, $output = 'names' ) {
    27022706    if ( is_int( $attachment ) ) {
    27032707        $attachment = get_post( $attachment );
     
    27242728
    27252729    $taxonomies = array();
    2726     foreach ( $objects as $object )
    2727         if ( $taxes = get_object_taxonomies($object) )
    2728             $taxonomies = array_merge($taxonomies, $taxes);
     2730    foreach ( $objects as $object ) {
     2731        if ( $taxes = get_object_taxonomies( $object, $output ) ) {
     2732            $taxonomies = array_merge( $taxonomies, $taxes );
     2733        }
     2734    }
    27292735
    27302736    return array_unique($taxonomies);
Note: See TracChangeset for help on using the changeset viewer.