Make WordPress Core


Ignore:
Timestamp:
09/21/2012 10:52:54 PM (13 years ago)
Author:
nacin
Message:

Use the regular post type UI for editing single media items (attachments).

  • Attachments now go through post.php, edit_post(), the like, and have show_ui set to true.
  • Taxonomies attached to the media library now appear in the admin menu (if show_ui).
  • Editing, cropping, uploading, etc. is still very rough, but mostly functional.

API-wise:

  • New function: get_taxonomies_for_attachments(). Like get_taxonomies(), for taxonomies specifically registered against attachments.
  • Brings taxonomy support from the posts list table to the media list table. Expect them to converge soon.
  • wp_insert_attachment() now handles taxonomies like wp_insert_post(). Also expect them to converge soon.
  • New edit_form_after_title hook.

props helenyhou, ocean90. see #21391.

File:
1 edited

Legend:

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

    r21909 r21948  
    987987
    988988/**
     989 * Return all of the taxonomy names that are registered for attachments.
     990 *
     991 * Handles mime-type-specific taxonomies such as attachment:image and attachment:video.
     992 *
     993 * @since 3.5.0
     994 * @see get_attachment_taxonomies()
     995 * @uses get_taxonomies()
     996 *
     997 * @param string $output The type of output to return, either taxonomy 'names' or 'objects'. 'names' is the default.
     998 * @return array The names of all taxonomy of $object_type.
     999 */
     1000function get_taxonomies_for_attachments( $output = 'names' ) {
     1001    $taxonomies = array();
     1002    foreach ( get_taxonomies( array(), 'objects' ) as $taxonomy ) {
     1003        foreach ( $taxonomy->object_type as $object_type ) {
     1004            if ( 'attachment' == $object_type || 0 === strpos( $object_type, 'attachment:' ) ) {
     1005                if ( 'names' == $output )
     1006                    $taxonomies[] = $taxonomy->name;
     1007                else
     1008                    $taxonomies[ $taxonomy->name ] = $taxonomy;
     1009                break;
     1010            }
     1011        }
     1012    }
     1013
     1014    return $taxonomies;
     1015}
     1016
     1017/**
    9891018 * Check if the installed version of GD supports particular image type
    9901019 *
Note: See TracChangeset for help on using the changeset viewer.