Make WordPress Core


Ignore:
Timestamp:
09/21/2012 10:52:54 PM (12 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/link-template.php

    r21937 r21948  
    107107        return get_page_link($post->ID, $leavename, $sample);
    108108    elseif ( $post->post_type == 'attachment' )
    109         return get_attachment_link($post->ID);
     109        return get_attachment_link( $post->ID, $leavename );
    110110    elseif ( in_array($post->post_type, get_post_types( array('_builtin' => false) ) ) )
    111111        return get_post_permalink($post->ID, $leavename, $sample);
     
    293293 *
    294294 * @param mixed $post Optional. Post ID or object.
    295  * @return string
    296  */
    297 function get_attachment_link( $post = null ) {
     295 * @param bool $leavename Optional. Leave name.
     296 * @return string
     297 */
     298function get_attachment_link( $post = null, $leavename = false ) {
    298299    global $wp_rewrite;
    299300
     
    315316
    316317        if ( strpos($parentlink, '?') === false )
    317             $link = user_trailingslashit( trailingslashit($parentlink) . $name );
     318            $link = user_trailingslashit( trailingslashit($parentlink) . '%postname%' );
     319
     320        if ( ! $leavename )
     321            $link = str_replace( '%postname%', $name, $link );
    318322    }
    319323
Note: See TracChangeset for help on using the changeset viewer.